Skip to content

Fix main process typecheck coverage and IPC registration#56

Merged
ZYKJShadow merged 4 commits into
masterfrom
codex/fix-main-typecheck-errors
Apr 25, 2026
Merged

Fix main process typecheck coverage and IPC registration#56
ZYKJShadow merged 4 commits into
masterfrom
codex/fix-main-typecheck-errors

Conversation

@ZYKJShadow
Copy link
Copy Markdown
Owner

Summary

  • Split main-process IPC registration into namespace-specific handler modules and added IPC smoke coverage for handler registration and execution.
  • Expanded TypeScript coverage to include main-src and fixed the resulting main-process type errors.
  • Added missing team settings and task status typing, fixed team orchestrator narrowing, and aligned Electron, plugin, Feishu, Anthropic, MCP, browser, SFTP, and provider identity typings with current APIs.
  • Updated tests to avoid native Electron ABI coupling and to account for the IPC smoke test runtime.

Investigation Notes

  • teamTaskQueue blocked is an active task status, not a stale enum.
  • enableSimpleGoalShortCircuit and taskSchedulingStrategy are active team settings and now have defaults.
  • Legacy persisted ShellSettings.mcp.servers is accepted and merged into mcpServers.

Verification

  • npm run typecheck
  • npm run build
  • npm test
  • npx vitest run main-src/ipc/registerSmoke.test.ts

Cut main-src/ipc/register.ts from 4236 lines to 1980 (-53%) by extracting
~75 IPC handlers into focused modules and lifting the chat pipeline out
of the dispatcher.

New modules:
- agentRuntime.ts: cross-handler helpers (senderWorkspaceRoot,
  workspaceRootsEqual, parseAppWindowSurface, broadcastPluginsChanged)
- chatRuntime.ts: runChatStream + 6 shared state Maps (abortByThread,
  agentRevertSnapshotsByThread, toolApprovalWaiters, mistakeLimitWaiters,
  preflightAbortByThread, threadTitleGenerationVersion) and helpers
  (recordTurnTokenUsageStats, persistAssistantStreamError,
  queueThreadTitleGeneration, resolveManagedAgentLoopOptions,
  activeUsageStatsDir, appendSystemBlock)
- handlers/{app,workspace,fs,shell,git,browser,mcp,plugins,settings,
  terminalExec}Handlers.ts: one file per IPC namespace

Behaviour is unchanged: handlers were moved verbatim and rewired through
register.ts:registerIpc(). Also clears 67 newly-unused imports left
behind in register.ts.

Fix + regression test for ReferenceError shipped in ref/app:
- register.ts referenced workspaceRootsEqual without importing it after
  the helper moved to agentRuntime.ts. esbuild does not catch free
  identifiers and main-src is outside tsconfig.json `include`, so the
  bug only surfaced when threads:listAgentSidebar fired in production.
- Add main-src/ipc/registerSmoke.test.ts: mocks `electron`, loads every
  register*Handlers() module plus registerIpc(), then invokes every
  captured handler body. Any ReferenceError from a missing import now
  fails CI (verified by temporarily reverting the fix - the test caught
  it). 16 new test cases, 561/562 total pass.
Resolve TypeScript errors after including main-src in typecheck.

Add missing team settings and task status typing, fix team orchestrator narrowing, update Electron dialog overload calls, and align plugin, Feishu, Anthropic, MCP, browser, and SFTP code with current SDK types.

Keep tests isolated from native Electron ABI bindings and extend the IPC smoke timeout to match its actual runtime.
@ZYKJShadow ZYKJShadow merged commit 01edaba into master Apr 25, 2026
1 check passed
@ZYKJShadow ZYKJShadow deleted the codex/fix-main-typecheck-errors branch April 25, 2026 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant