Move runtime sessions and saved company profiles out of App() into hooks - #478
Merged
lamemustafa merged 3 commits intoSep 17, 2026
Merged
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
The smallest state cluster in App(): runtimeSessions and runtimeError, refreshRuntime and cancelTallyRequest. No reset hub clears it and no source-text test asserts on it. The bodies move verbatim into src/tally-runtime-sessions.ts; App() destructures the same four names. Adds behaviour tests for the hook (refresh success/failure, the already-finished cancel message and the refresh that follows, a failed cancel) and puts them in pnpm test. Each was mutation-checked. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Five states, the load-version ref and refreshPersistedCompanyProfiles move verbatim into src/persisted-company-profiles.ts. The one line that wrote App's company list becomes a call to mergeProfiles, which App supplies as a stable callback around its own mergeTallyCompanies, so company identity merging stays in the pinned main.tsx. No reset hub clears this state. ux1-shell and tally-setup-safety read the useState, ref, stale-load guard and error handling out of main.tsx; they now read the hook module, assert main.tsx imports it, and check the slice anchors exist before slicing. Adds four behaviour tests (merge and counts; an older success or failure settling after a newer load writes nothing; a failure keeps counts and clears on the next load), each guard mutation-checked. Pending before push: pin src/persisted-company-profiles.ts. It decides which load may write App's company list, so a broken guard could merge a stale page over newer company records. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
It decides which saved-profile load may write App's company list; the reason is recorded beside MAX_SURFACE_FILES (251 -> 252). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
lamemustafa
force-pushed
the
tapish-claude/persisted-company-profiles-hook
branch
from
September 17, 2026 04:02
fa5fcd6 to
8520845
Compare
lamemustafa
deleted the
tapish-claude/persisted-company-profiles-hook
branch
September 17, 2026 04:14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Steps 2 and 3 of the order in
docs/frontend-module-conventions.md(#470): the twoApp()state clusters that no reset hub touches become hooks.main.tsxgoes from 2,290 to 2,241 lines.App()useTallyRuntimeSessionsruntimeSessions,runtimeError,refreshRuntime,cancelTallyRequestsrc/tally-runtime-sessions.tsusePersistedCompanyProfilesrefreshPersistedCompanyProfiles,PersistedCompanyProfilePagesrc/persisted-company-profiles.tsThe bodies move verbatim, with one exception. The line that wrote App's company list,
setCompanies((current) => mergeTallyCompanies(page.profiles, current)), becomesmergeProfiles(page.profiles). App passes a stableReact.useCallbackaround that exact expression, so company identity merging stays in the pinnedmain.tsx. The hook'suseCallbackdependency changes from[]to[mergeProfiles], andmergeProfilesnever changes identity.Checklist (from
docs/frontend-module-conventions.md)tally-runtime-sessions.tsstays unpinned: session display and request cancellation attribute nothing to a book.persisted-company-profiles.tsis pinned, with its reason besideMAX_SURFACE_FILES. It decides which saved-profile load may merge into App's company list, and a broken stale-load guard could put an older page's identity fields back on a company the switcher and drawer select.--pins-changed: 5 digests plus 1 added pin, none removed.ux1-shell.test.mjsasserted the hook'suseState, ref and stale-load guard inmain.tsx. It now reads them from the hook module and asserts thatmain.tsximports it.tally-setup-safety.test.mjsslicedmain.tsxbetween two anchors, one of which moved. It now slices the hook module and asserts both anchors exist first, so a missing anchor fails instead of slicing the wrong region.doesNotMatch(profileLoad, /setCompanyError\(/)now holds trivially, because the hook has no access tosetCompanyError.pnpm test, and every guard mutation-checked (each mutation fails at least one test):scripts/tally-runtime-sessions.test.tsx, 4 tests. Mutations: removing the "already completed" message, dropping the refresh after a cancel, and not clearing the error on a successful refresh.scripts/persisted-company-profiles.test.tsx, 4 tests. Mutations: removing the success-path stale guard, the error-path stale guard, thefinallyguard, and the error clear at load start.tsc --noEmitOK,pnpm buildOK;corepack pnpm testnode 250/250, vitest 121/121 (10 files), Playwright 10/10;cargo test -p bridge-tally-compatibility --lib24/24 (privateCARGO_TARGET_DIR). Seal check without the binary: 267 pins, 0 digest mismatches, matrix → manifest OK, pins added{src/persisted-company-profiles.ts}, removed none.Queue
Joins the tail of the shared merge queue; CI runs pushed early are cancelled until it's near the head.
🤖 Generated with Claude Code
Rebased onto
1a9dc1f4(#483), 266 → 267 pins, resealed with--pins-changed(privateCARGO_TARGET_DIR). Seal re-verified,tscOK, node 250/250, compat lib 24/24.