Skip to content

refactor(server): move the status wiring into createStatusHub - #1338

Merged
devswha merged 1 commit into
mainfrom
chore/core-status
Oct 18, 2026
Merged

devswha merged 1 commit into
mainfrom
chore/core-status

Conversation

@devswha

@devswha devswha commented Oct 18, 2026 •

Copy link
Copy Markdown
Owner

Change

Step 2 of splitting the stateful core of server/index.ts by state ownership. The status wiring moves into createStatusHub in server/core/status.ts. No behavior changes. index.ts loses 288 lines.

  • The hub owns push, completions, OmO, GJC, background waits, Claude subagents, plans, settling, visit counting, the machine manager, the status frame handlers, the collector and the pollers' start.
  • createServer calls 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).
  • The closure values the body reads (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 in index.ts. Pending delivery, attachments and the WebSocket handler move in later steps.

Why this is safe

  • The status code was two pieces with only function declarations 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 before Bun.serve.
  • The hub body matches main byte for byte apart from the one bridge token line. A script rebuilt both pieces from main and diffed them.
  • pendingContext refers to clientSnapshot and omo before the call site, as it did before. It only runs from a socket frame or a drain, after createServer returns.
  • Status changes wake pending delivery through drainPending, which is queued-input code, so this PR waits for a real CodeRabbit review per AGENTS.md.

Validation

  • bun run check integration: collector, claude-session, omo-detached, omo, gjc, machines-refresh, pending-input, submit and device-access contract tests pass. Inside api.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 untouched main on this Mac (api.contract pane files search, hermes.contract store selection, output.contract attach-time queries).
  • bun run check fast: typecheck and build are ok, and 4,361 unit tests pass. The only failures are the known install-star and portal timing failures on this Mac. The convention tests pass.

Made with Cursor

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]>
@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: devswha/herdr-web-ui/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9b663ab5-edd7-426c-8766-1724207917cf
📥 Commits

Reviewing files that changed from the base of the PR and between c577e6f and 176f640.

📒 Files selected for processing: 2
  • server/core/status.ts
  • server/index.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

📝 Summary

Summary by CodeRabbit

  • Improvements
    • Status updates now bring together task completions, background activity, and plan summaries when available.
    • Push alerts and status notifications are handled alongside updates to pending inputs.
    • When a pane ends, associated status is cleared, pending messages are held with an explanatory fault, and an exit notification is sent.

createStatusHub now composes status tracking and related services. server/index.ts initializes the hub instead of constructing and managing those status services locally.

Changes: Status hub

Layer / File(s) Summary
Compose status tracking and callbacks
server/core/status.ts
createStatusHub combines provider-specific tracking, completion persistence, plans, push, telemetry, machine and bridge updates, and collector event handling.
Initialize the status hub
server/index.ts
The server replaces its local status setup and broadcasting with a createStatusHub call, then uses the returned services and callbacks.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Refactor

Suggested reviewers: haeminway1

Merge Risk: ⚪ Minimal · up to 176f6

This change moves the status wiring into a dedicated hub without changing behavior. The hub uses the same live server state, the same push-error logging and the same callbacks as before, and the bridge token still lives outside it. No merge-blocking risk was found.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 46.15% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly and concisely describes the main change: moving server status wiring into createStatusHub.
Description check Passed The description includes the change, scope, safety rationale, and detailed validation results. It follows the required Change and Validation sections.
  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@devswha
devswha merged commit 466eae2 into main Oct 18, 2026
17 checks passed
@devswha
devswha deleted the chore/core-status branch October 18, 2026 10:42
devswha added a commit that referenced this pull request Oct 18, 2026
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]>
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