Skip to content

Fix all node-side type errors and make typecheck:node a blocking gate#204

Merged
willwashburn merged 1 commit into
mainfrom
audit/typecheck-node-blocking
Jun 10, 2026
Merged

Fix all node-side type errors and make typecheck:node a blocking gate#204
willwashburn merged 1 commit into
mainfrom
audit/typecheck-node-blocking

Conversation

@willwashburn

Copy link
Copy Markdown
Member

What this does

Burns down the ~95 pre-existing tsconfig.node.json type errors documented in #196 and flips the CI typecheck:node step from continue-on-error to a blocking gate (and updates the now-stale comment). typecheck:web was already clean.

All fixes are type-only except where a type error revealed a genuine runtime bug (see below). Real types are preferred over as casts — zero new any, and the net cast count went down (removed (event as Record<string, unknown>), removed the addProject literal's implicit need for a cast).

Real bugs found

Bug File Detail
normalizeRelayWorkspace undefined at runtime store.ts The function was called by setRelayWorkspace / setRelayWorkspaceRecord but never defined — the definition was dropped in the #7 wave-scaffolding merge while the call sites survived (TS2304: Cannot find name). At runtime those code paths threw ReferenceError: normalizeRelayWorkspace is not defined. Restored the function (and its isRecord helper) from git history.
reconcile-stalled alerts mislabeled as auth stalls integrations.ts The mount health observer handled auth-required, then fell through and emitted a mount-auth-stall event for everything else — including reconcile-stalled alerts, which carry no pendingWriteback/message fields. That produced a malformed event with undefined values. Added a narrow if (alert.type !== 'auth-stall') return so reconcile stalls are no longer mislabeled.

The TS2367 "impossible comparison" errors in integration-event-bridge.ts (writeback.succeeded, file.deleted, relayfile.changed.summary) were each investigated: they are correct runtime checks defeated by an overly-narrow SDK type, not logic bugs — the live change stream delivers the underlying filesystem event type and the bridge synthesizes relayfile.changed.summary rollups. Fixed at the type level (below), not by deleting the checks.

Error families and how each was fixed

Count File Fix
10 store.ts Restored normalizeRelayWorkspace/isRecord (real bug); widened the persisted Project/StoreData types to include the wave-additive fields (cloudAgent, cloudAgentWorkspaceMode, proactiveAgents, relayWorkspace) that the zod schema already round-trips via .passthrough(). Type-only widening — no runtime change. Set relayWorkspaceId on the addProject literal to match the schema default.
15 / 11 cloud-agent.ts / proactive-agent.ts Resolved entirely by the Project type widening above — fixed once at the type definition, not per call site.
22 integration-event-bridge.ts Aliased the SDK import (ChangeEvent as SdkChangeEvent) and defined a module-internal widened ChangeEvent (broad type union + relaxed expand) reflecting what actually flows through the bridge; added an asRecord() accessor replacing the isRecord(x) ? x : {} patterns (fixes the {}-property and conversion errors); fixed the .ts dynamic import with the existing @ts-expect-error convention; fixed the auth possibly-null + token-provider return type by initializing let auth from the narrowed initialAuth.
6 broker.ts event.reason/event.lastError now read via the existing brokerEventString accessor; added typeof guards for RelayMessageTarget's loose { kind: string; [k]: unknown } catch-all union member (truthy/non-empty behavior preserved).
1 index.ts app.dock?.setIcon(...).
2 integrations.ts reconcile-stall narrowing (real bug).
13 / 7 / 3 / 3 / 2 / 1 test files Fixed mock parameter/return typings: annotated vi.fn() defaults that inferred never[]/undefined/Promise<never>, typed mock params so mock.calls tuples have the right arity, supplied MountLauncherStart.readyTimeoutMs, fixed the delete optionality and a new Promise<unknown> + definite-assignment for a closure-captured resolver.

Verification (run locally)

  • npm run typecheckboth clean (web + node, 0 errors).
  • npm run test:allgreen: node:test 115/115, vitest 20 files, 287 passed + 1 expected-fail (288).
  • npm run buildpasses (esbuild build unaffected; tsconfig changes are typecheck-only).

Scope

Did not touch src/main/git.ts, tests/playwright/, or eslint configs (owned by parallel branches). src/shared/schemas/project.ts is unchanged — the wave-field widening lives in store.ts so the shared schema stays generic and renderer-agnostic.

🤖 Generated with Claude Code

Burns down the ~95 pre-existing `tsconfig.node.json` type errors and flips the
CI `typecheck:node` step from continue-on-error to blocking.

Fixes are type-only except where an error exposed a genuine runtime bug
(restored normalizeRelayWorkspace, reconcile-stall mislabeling). Prefer real
types over casts; zero new `any` (net cast count went down).

Real bugs found:
- store.ts: normalizeRelayWorkspace was called by setRelayWorkspace/
  setRelayWorkspaceRecord but never defined (lost in the #7 wave-scaffolding
  merge). At runtime those paths threw ReferenceError. Restored the function
  and its isRecord helper from git history.
- integrations.ts: the mount health observer fell through and emitted a
  mount-auth-stall event with undefined pendingWriteback/message for
  reconcile-stalled alerts (which carry neither field). Narrowed to auth-stall.

Schema/type families:
- store.ts/cloud-agent.ts/proactive-agent.ts: widened the persisted Project /
  StoreData types to include the wave-additive fields (cloudAgent,
  cloudAgentWorkspaceMode, proactiveAgents, relayWorkspace) that the schema
  already round-trips via .passthrough(). Type-only widening, no runtime change.
- integration-event-bridge.ts: the @relayfile SDK narrows ChangeEvent['type']
  to one literal, but the live stream delivers filesystem event types and the
  bridge synthesizes summary events. Aliased the SDK import and defined a
  module-internal widened ChangeEvent; added an asRecord() accessor to replace
  the `isRecord(x) ? x : {}` patterns. The TS2367 "impossible" comparisons were
  investigated and are correct runtime checks defeated by the narrow SDK type.
- broker.ts: read reason/lastError via the existing brokerEventString accessor;
  added typeof guards for RelayMessageTarget's loose catch-all union member.
- index.ts: guarded app.dock?.setIcon.
- test files: fixed mock parameter/return typings (never[]/undefined inference).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codeant-ai

codeant-ai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Your free trial PR review limit of 300 PRs has been reached. Please upgrade your plan to continue using CodeAnt AI.

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@willwashburn, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 34 minutes and 4 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 53509e23-818b-4bbc-a5a9-dc2a13cc9b03

📥 Commits

Reviewing files that changed from the base of the PR and between 831a56b and 981eecd.

📒 Files selected for processing (13)
  • .github/workflows/ci.yml
  • src/main/auth.test.ts
  • src/main/broker.test.ts
  • src/main/broker.ts
  • src/main/cloud-agent.test.ts
  • src/main/git.test.ts
  • src/main/index.ts
  • src/main/integration-event-bridge.ts
  • src/main/integration-mounts.test.ts
  • src/main/integrations.test.ts
  • src/main/integrations.ts
  • src/main/relayfile-mount-launcher.test.ts
  • src/main/store.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch audit/typecheck-node-blocking

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request focuses on improving TypeScript type safety, resolving compiler warnings, and restoring missing utility functions across several files. Key changes include narrowing and widening types where appropriate (such as introducing a module-internal ChangeEvent and widening the Project type to support persisted fields), adding safe navigation operators, implementing the asRecord helper to simplify dynamic field access, and restoring the normalizeRelayWorkspace utility in store.ts. Additionally, test mocks have been updated with explicit parameter and return types. No review comments were provided, so there is no feedback to address.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@willwashburn willwashburn merged commit c20aff9 into main Jun 10, 2026
5 checks passed
@willwashburn willwashburn deleted the audit/typecheck-node-blocking branch June 10, 2026 13:43
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