Repository navigation
refactor(server): move the status wiring into createStatusHub - #1338
Conversation
Step 2 of splitting createServer's core by state ownership. The status services, snapshots, the status frame handlers, the collector and the pollers' start move into createStatusHub in server/core/status.ts. They were two pieces in index.ts with only function declarations between them, so the hub body is the two pieces in their original order. createServer calls the hub once where the first piece began, so construction order does not change. The closure values the body reads are passed under their old names, so the body is unchanged apart from the bridge token, which stays in index.ts. Co-authored-by: Cursor <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Summary
Merge Risk: ⚪ Minimal · up to
|
The branch is ready for the board to push and open the PR. With the login fixed, `gh` can now read both issues. Neither has comments and no open PR covers this, so the fix didn't change. While re-checking, I found `main` had moved by one commit (#1338), which conflicted with my branch on one import line in `server/index.ts`. #1338 had trimmed that import and I had added `ProjectFavicon` to it, so I kept `main`'s version and added `ProjectFavicon` back. That's in merge commit 9c9f8bd, after the fix commit b635eb3, which closes #1333 and #1334. After the merge, typecheck and build pass, and so do the favicon, access, proxy and conventions tests on the isolated herdr session. `bun run check fast` ends the same way as before: two unit test files fail, `scripts/install-star.test.ts` and `server/portal.test.ts`. The #1338 commit on `main` reports the same two failures on this Mac. I didn't push or open the PR myself, because my task rules leave that to the board. The closing note is updated with the merge. **Also noticed** - `src/components/Sidebar.tsx` / `server/workspace-routes.ts`: `/api/worktree/list` logs one 404 per non-git workspace on each page load (herdr refuses it with `not_git_worktree`). - `scripts/install-star.test.ts`: fails on a Mac with a display, on `main` too. - `server/portal.test.ts`: fails during the full unit run and passes on its own, so it may be flaky. Task: HWU-1 (herdr-web-ui/1) Co-authored-by: Claude Opus 5.5 <[email protected]>
Change
Step 2 of splitting the stateful core of
server/index.tsby state ownership. The status wiring moves intocreateStatusHubinserver/core/status.ts. No behavior changes.index.tsloses 288 lines.settling, visit counting, the machine manager, the status frame handlers, the collector and the pollers'start.createServercalls it once, where the status code began, and receives the names the rest of the server still uses (clientSnapshot,broadcastAll,countVisit,push,omo,gjc,claudeAgents,plans,machines,logPushError,collector,waitTimer).options,devices,clients,present,pending,drainPending,holdPendingPane,usage,usageLogin) are passed in under their old names.Scope:
broadcast, which writes to one pane's attached clients, and the bridge token stay inindex.ts. Pending delivery, attachments and the WebSocket handler move in later steps.Why this is safe
functiondeclarations between them, so nothing ran between the pieces. The hub body is the two pieces in their original order, and the call sits where the first piece began. Services are built, handlers bound, the collector opened and the pollers started in the same order as before, all beforeBun.serve.mainbyte for byte apart from the one bridge token line. A script rebuilt both pieces frommainand diffed them.pendingContextrefers toclientSnapshotandomobefore the call site, as it did before. It only runs from a socket frame or a drain, aftercreateServerreturns.drainPending, which is queued-input code, so this PR waits for a real CodeRabbit review perAGENTS.md.Validation
bun run check integration:collector,claude-session,omo-detached,omo,gjc,machines-refresh,pending-input,submitanddevice-accesscontract tests pass. Insideapi.contract, "pushes pane-status and pane-exited for a pane nobody is attached to" and the Notifications are sent to all clients even if a client is active and in-focus #751 in-use alert test pass. The only failures are three tests that also fail on an untouchedmainon this Mac (api.contractpane files search,hermes.contractstore selection,output.contractattach-time queries).bun run check fast: typecheck and build are ok, and 4,361 unit tests pass. The only failures are the knowninstall-starandportaltiming failures on this Mac. The convention tests pass.Made with Cursor