Skip to content

test(shift-manager): fix main — snapshot test's workforce fake lacks watchRoster - #4793

Merged
jhoffner merged 3 commits into
mainfrom
fix/shift-coordinator-as-of-refresh
Nov 5, 2026
Merged

jhoffner merged 3 commits into
mainfrom
fix/shift-coordinator-as-of-refresh

Conversation

@jhoffner

@jhoffner jhoffner commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes red main CI: Test (1/3) failing in packages/shift-manager/test/snapshot-subscribe.test.tsx (lines 282 and 292). Failing run: 42077021692, head 335b8462e.

Cause

A semantic merge conflict between two PRs that were each green on their own:

  • 243a14a15 (FIX-2409) put snapshot-subscribe.test.tsx on main. Its fake for useWorkforce had only roster().
  • 79b03fcc2 (FIX-2412, "live roster read") moved useRoster (src/lib/roster.ts) from workforce.roster() to workforce.watchRoster(...). It updated the workforce fakes on its own branch, but this test wasn't on that branch yet.
  • 335b8462e (merge of PR FIX-2412: the roster follows hires, forks, edits and fires in every app #4747) brought FIX-2412 onto main. Git found no textual conflict.

After that merge, the Sidebar's roster effect threw TypeError: workforce.watchRoster is not a function. There's no error boundary, so React 19 unmounted the whole root. That's why the failure showed an empty <div />: the subscription was closed (expected [] to have a length of 1) and shift-coordinator-as-of-refresh was gone.

4e3d10175 (FIX-2403 starter lines) is not the cause. The error is raised from roster.ts's joinWatch.

Change

Gives the test's workforce fake the same watchRoster that connection.test.tsx already uses: one empty read, a no-op stop. No assertions change and no source changes.

Verification

  • Reproduced on origin/main (162792f3e) with Node 24: 2 failed, watchRoster is not a function in stderr.
  • With the fix: snapshot-subscribe.test.tsx passes 11/11.
  • In this sandbox, other shift-manager test files fail locally for environment reasons: unbuilt dist-client, local sockets refused, a tmp-path realpath mismatch. They passed on the failing CI run and this diff doesn't touch them. CI on this PR is the real check.

🤖 Generated with Claude Code

…ter (fix main)

Main's CI went red at 335b846 (PR #4747). That merge brought in
79b03fc (FIX-2412), which moved useRoster from workforce.roster() to
workforce.watchRoster(...) and updated the workforce fakes on its branch.
243a14a (FIX-2409) had meanwhile landed snapshot-subscribe.test.tsx on
main with a fake carrying only roster(). The two merged with no textual
conflict; the Sidebar's roster effect then threw "watchRoster is not a
function", React unmounted the root, and the as-of line and its refresh
link were gone.

Give the fake the same watchRoster connection.test.tsx uses. No assertion
changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

3 Skipped Deployments
Project Deployment Actions Updated
flow-state-dev-docs Ignored Ignored Nov 5, 2026 7:22pm UTC
flow-state-dev-ui Ignored Ignored Preview Nov 5, 2026 7:22pm UTC
flow-state-dev-build-site Skipped Skipped Nov 5, 2026 7:22pm UTC

Request Review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-05T19:15:01.455960Z ff26e0a Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@jhoffner

jhoffner commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

jhoffner commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator Author

Second look + architecture review

Verdict: the approach is right. Merge it as is. It's the smallest fix for a red main: a test-only change, no assertion changes, no source changes. I looked for a leaner or better shape and didn't find one.

Alternatives considered

  • Error boundary around the Sidebar/root. It would stop one failing effect from unmounting the whole tree, which is why the failure showed an empty <div />. That's a product change and out of scope for a CI fix. If it's worth doing, it's a separate issue.
  • Defensive workforce.watchRoster?.() in roster.ts. Don't. It would bend production code around a stale fake.

Architecture note (optional follow-up, not for this PR)
The same watchRoster fake is now hand-copied in four shift-manager test files:

  • connection.test.tsx:36 (the same one-empty-read form this PR adds)
  • worker-settings-screen.test.tsx:45
  • roster-screen.test.tsx:29
  • coordinator-view.test.tsx:34

This PR is the second time a missing watchRoster has broken a test. That's the same drift that caused the semantic merge conflict. A shared fakeWorkforce({ roster }) helper in packages/shift-manager/test/ would fix it, because a future change to the useWorkforce surface would then have one place to update. It would also remove the copied long inline type signature. Keep it out of this PR: the fix is red-main urgent, and the helper touches four other files. I'd file it as a small follow-up.

Minor

  • The inline comment refers to FIX-2412. Fine in a test comment, but BP-006 says to keep tracking labels out of code and tests. Consider dropping the ID and keeping the "roster watch useRoster follows" wording.

No blocking findings.


Generated by Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: ff26e0a13e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…t (BP-006)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jhoffner

jhoffner commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks for the review.

  • Minor (BP-006): done in f7cfd367c. I took FIX-2412 out of the test comment and kept the "roster watch useRoster follows" wording. The test still passes 11/11.
  • Shared fakeWorkforce helper: agreed, I'm leaving it out of this PR. It touches four more test files, and this one should stay the small fix for red main. I'm proposing it as a separate follow-up.
  • Error boundary / defensive watchRoster?.(): agreed on both. No change here.

Generated by Claude Code

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Snob

joinWatch only stores the function watchRoster returns and calls it when the last view leaves. This screen's inventory is empty, so Talk never mounts and roster() never runs. withRoster draws no workers while the watch has not reported, the same workers as the empty delivery.

Drop the comment (it restates the next line and names FIX-2412), roster(), and the typed Promise.resolve([]) delivery. The stub is watchRoster: () => () => {}.

Against main that is the whole fix: one line in place of roster. POC: #4794 — snapshot-subscribe.test.tsx 11/11, and a call log on the longer fake recorded watch twice and roster never. Fold that subtraction into this PR. Close the POC unmerged after this lands. The shared workforce helper stays the follow-up this PR already split off.

View PR

Open in Web View Automation 

Sent by Cursor Automation: Code Snob

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

/simplify review

Problem: After FIX-2412, useRoster calls workforce.watchRoster(). The snapshot-subscribe suite mounts <App /> with a workforce fake that only implemented roster(), so the test blew up at runtime (watchRoster is not a function) and main broke.

Verdict: This is the right-sized fix. Extending the existing useWorkforce mock—not introducing a second strategy like vi.mock("../src/lib/roster")—matches every other App-level screen test in this package and keeps the real useRoster → joinWatch → watchRoster wiring under test. A shared emptyWorkforceClient() helper would only dedupe one other copy today (connection.test.tsx); extracting it here would add indirection without paying for itself yet.

Alternatives considered (and why not here):

  • Mock useRoster directly — no precedent in shift-manager/test/; would hide workforce-client regressions and fork conventions.
  • Richer stub (roster-screen / coordinator-view style) — over-scoped; this file cares about FIX-2409 subscription refresh, not roster UX.
  • Third-party package — N/A; this is test-local fake data.

Optional nits (non-blocking): The new inline comment names FIX-2412 and useRoster; connection.test.tsx uses the shorter // The roster watch, reporting one read. Aligning wording would reduce ticket noise in the mock body (BP-006 spirit) without changing behavior.

Follow-ups (separate PR if a third copy appears): shared test/workforce-stubs.ts with roster + empty one-shot watchRoster; optional Pick<WorkforceClient, "roster" | "watchRoster"> so the next missing method fails at compile time.

Verification: pnpm --filter @flow-state-dev/shift-manager test — 78 files, 703 passed (includes snapshot-subscribe.test.tsx).

Approving — nothing here over-engineers the fix.

Open in Web View Automation 

Sent by Cursor Automation: Review For Best Approach

… reaches

The snapshot test mounts App with an empty inventory, so Talk never mounts
and roster() is never called; a call log on the longer fake recorded the
watch twice and roster never. A watch that never reports draws the same as
one empty read. The fake is now the one method useRoster calls.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jhoffner

jhoffner commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator Author

Code Snob review: applied in bc7a58d5b.

I checked the claim before folding it in. A call log on the longer fake recorded watchRoster twice and roster never: the inventory is empty, so Talk (and useStarterLines) never mounts. With watchRoster: () => () => {}:

  • snapshot-subscribe.test.tsx passed 11/11 on three runs
  • typecheck is clean

The PR is now a one-line change against main: roster is replaced by the one method useRoster calls. The commit message records the call-log result so the smaller fake isn't mistaken for a looser test.

Once this lands, POC #4794 can be closed unmerged. I haven't touched it. The shared workforce helper stays a separate follow-up.

Generated by Claude Code

@jhoffner
jhoffner added this pull request to the merge queue Nov 5, 2026
Merged via the queue into main with commit d13b904 Nov 5, 2026
19 checks passed
@jhoffner
jhoffner deleted the fix/shift-coordinator-as-of-refresh branch November 5, 2026 21: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.

2 participants