refactor: decompose monoliths across runtime, server, desktop, and tests 4 months ago
Authored
mweinbach 5/21/2026, 10:15:57 PM Split oversized modules identified in the code quality review so each layer
stays under maintainable size boundaries while preserving behavior.
- Codex app-server runtime into src/runtime/codexAppServer/ with a unified
notification router; shared telemetry and record parsing utilities
- Google native interactions into src/runtime/googleNative/
- Turn execution into steerCoordinator, userMessageAttachments, and
runUserMessageTurn; slim TurnExecutionManager to a thin delegate
- Session title generation into src/server/title/; projection helpers extracted
- Desktop ChatView, Sidebar, Canvas, and preview flows into focused modules
- Mega test files split with shared fixtures; remove stale CODEX_AUDIT_REPORT
Co-authored-by: Cursor <cursoragent@cursor.com> Parent5df4838
110 files changed
CODEX_AUDIT_REPORT.md +0 −363 apps/desktop/src/app/store.actions.ts +2 −0 apps/desktop/src/app/store.actions/preview.ts +39 −0 apps/desktop/src/app/store.actions/thread.ts +2 −50 apps/desktop/src/app/store.feedMapping.ts +1 −4 apps/desktop/src/app/store.helpers.ts +13 −0 apps/desktop/src/app/store.helpers/oneOffWorkspaceRecord.ts +60 −0 apps/desktop/src/app/toolFeedState.ts
+5
−0
apps/desktop/src/lib/canvasMarkdown.ts +207 −0
apps/desktop/src/ui/Canvas.tsx +37 −363
apps/desktop/src/ui/ChatView.tsx +98 −1607
apps/desktop/src/ui/PptxPreview.tsx +3 −8
apps/desktop/src/ui/Sidebar.tsx +33 −672
apps/desktop/src/ui/SlidePreview.tsx +3 −8
apps/desktop/src/ui/SpreadsheetPreview.tsx +8 −13
apps/desktop/src/ui/canvas/CanvasElectronTitlebar.tsx +43 −0
apps/desktop/src/ui/canvas/CanvasFilePreviewLayout.tsx +71 −0
apps/desktop/src/ui/chat/CancelSubagentsDialog.tsx +39 −0
apps/desktop/src/ui/chat/ChatComposer.tsx +201 −0
apps/desktop/src/ui/chat/ChatFeed.tsx +130 −0
apps/desktop/src/ui/chat/ChatThreadHeader.tsx +65 −0
apps/desktop/src/ui/chat/ChatViewContext.tsx +15 −0
apps/desktop/src/ui/chat/ComposerModelSelector.tsx +184 −0
apps/desktop/src/ui/chat/DraftThreadModelSelector.tsx +29 −0
apps/desktop/src/ui/chat/FeedRow.tsx +216 −0
apps/desktop/src/ui/chat/NewChatLanding.tsx +476 −0
apps/desktop/src/ui/chat/ThreadModelIndicator.tsx +33 −0
apps/desktop/src/ui/chat/activityGroups.ts +1 −4
apps/desktop/src/ui/chat/chatLogic.ts +253 −0
apps/desktop/src/ui/chat/feedMessageParsing.ts +63 −0
apps/desktop/src/ui/chat/newChatLandingModel.ts +16 −0
apps/desktop/src/ui/chat/overflowCitationContext.ts +46 −0
apps/desktop/src/ui/sidebar/SidebarOneOffChatItem.tsx +124 −0
apps/desktop/src/ui/sidebar/SidebarSectionFrame.tsx +65 −0
apps/desktop/src/ui/sidebar/SidebarWorkspaceItem.tsx +394 −0
apps/desktop/src/ui/sidebar/useSidebarPersistence.ts +105 −0
src/agent.ts +3 −15
src/managedSofficeRuntime.ts +23 −0
src/observability/modelCallSpan.ts +198 −0
src/providers/codexAppServerAuth.ts +1 −1
src/providers/codexAppServerClient.ts +1 −1
src/runtime/codexAppServer/clientLifecycle.ts +72 −0
src/runtime/codexAppServer/config.ts +319 −0
src/runtime/codexAppServer/index.ts +1 −0
src/runtime/codexAppServer/notifications.ts +382 −0
src/runtime/codexAppServer/runTurn.ts +308 −0
src/runtime/codexAppServer/serverRequests.ts +191 −0
src/runtime/codexAppServer/turnInput.ts +92 −0
src/runtime/codexAppServer/types.ts +149 −0
src/runtime/codexAppServerRuntime.ts +1 −1528
src/runtime/googleNative/buildRequest.ts +63 −0
src/runtime/googleNative/client.ts +28 −0
src/runtime/googleNative/errors.ts +91 −0
src/runtime/googleNative/index.ts +15 −0
src/runtime/googleNative/interactionsToModel.ts +206 −0
src/runtime/googleNative/internal.ts +40 −0
src/runtime/googleNative/messageToInput.ts +376 −0
src/runtime/googleNative/nativeTools.ts +311 −0
src/runtime/googleNative/runStep.ts +252 −0
src/runtime/googleNative/stream/mapToStreamParts.ts +212 −0
src/runtime/googleNative/stream/normalize.ts +48 −0
src/runtime/googleNative/stream/processEvent.ts +318 −0
src/runtime/googleNative/stream/types.ts +39 −0
src/runtime/googleNative/toolsAndBuiltIns.ts +39 −0
src/runtime/googleNative/types.ts +56 −0
src/runtime/googleNativeInteractions.ts +9 −1984
src/runtime/openaiResponsesRuntime.ts +1 −1
src/runtime/piRuntime.ts +17 −94
src/runtime/piRuntimeOptions.ts +16 −25
src/runtime/types.ts +7 −0
src/server/jsonrpc/threadReadProjector.ts +3 −6
src/server/projection/conversationProjection.ts +37 −271
src/server/projection/conversationProjectionDiagnostics.ts +136 −0
src/server/projection/conversationProjectionToolKeys.ts +42 −0
src/server/projection/conversationProjectionTypes.ts +78 −0
src/server/runtime/ServerRuntime.ts +10 −10
src/server/session/TurnExecutionManager.ts +48 −1518
src/server/session/turnExecution/attachmentGuidancePolicy.ts +70 −0
src/server/session/turnExecution/continuationPolicy.ts +61 −0
src/server/session/turnExecution/partialTurnError.ts +38 −0
src/server/session/turnExecution/runUserMessageTurn.ts +685 −0
src/server/session/turnExecution/steerCoordinator.ts +238 −0
src/server/session/turnExecution/turnResponseParsing.ts +130 −0
src/server/session/turnExecution/turnUsageAggregator.ts +112 −0
src/server/session/turnExecution/userMessageAttachments.ts +471 −0
src/server/sessionTitleService.ts +9 −612
src/server/title/appleFoundationTitle.ts +310 −0
src/server/title/heuristicTitle.ts +22 −0
src/server/title/index.ts +123 −0
src/server/title/remoteModelTitle.ts +95 −0
src/server/title/shared.ts +139 −0
src/shared/projectedItems.ts +7 −6
src/shared/projectionPolicy.ts +10 −0
src/shared/recordParsing.ts +29 −0
test/fixtures/codexAppServerMock.ts +534 −0
test/jsonrpc.projectors.test.ts +8 −1513
test/jsonrpc/projectors/assistant-dedupe.test.ts +94 −0
test/jsonrpc/projectors/assistant-segments.test.ts +206 −0
test/jsonrpc/projectors/fixtures.ts +61 −0
test/jsonrpc/projectors/gemini-raw.test.ts +342 −0
test/jsonrpc/projectors/pi-matrix.test.ts +174 −0
test/jsonrpc/projectors/reasoning-stream.test.ts +293 −0
test/jsonrpc/projectors/steer.test.ts +85 −0
test/jsonrpc/projectors/thread-read.test.ts +170 −0
test/jsonrpc/projectors/tool-reuse.test.ts +138 −0
test/runtime.codex-app-server.test.ts +11 −957
test/runtime.google-interactions.test.ts +1 −1835
test/runtime/codex-app-server/helpers.ts +77 −0
test/runtime/codex-app-server/turn.test.ts +379 −0
test/runtime/google-native-interactions.unit.test.ts +1891 −0