Repository navigation
fix(sidebar): close an agent's row sheet when its row or PC goes away - #1751
Merged
Merged
Conversation
Keep the existing identity-based live token details, and retire the menu when its row disappears or its PC disconnects. Cover token updates, deletion, hide rules, disconnect, reconnect, and row return through the real React components. Refs #1349
Retire menus only when their row disappears or the PC reaches disconnected or error. Keep connecting and reconnecting sheets mounted, with token visibility following the live row and current values restored after recovery. Add transient recovery regressions and retain terminal disconnect and removed-row coverage. Refs #1349
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 2 minutes. View limit details
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. Comment |
Owner
Author
|
Merge pass: reviewed instead of a CodeRabbit review (rate-limited). A gate reviewer on a different model from the author's reported:
|
devswha
added a commit
that referenced
this pull request
Oct 28, 2026
…ers never get their operands (#2139) Closes #1349 (item 4, the last one open: items 1, 2, 3 and 5 were fixed by #1402 and #1751). The lower item about bidi and control characters in token values is now #2133. ## Change **The PC roster and the rows' event no longer carry the operands of herdr's token hide rules, nor the values those rules hide.** The `herdr-sidebar` machine event used to carry the user's `[ui.sidebar.agents]` rules as written. So a rule such as `equals = "<literal>", hide = true` reached every browser, watch-only devices included, even when no pane reported that literal, and each browser applied the rules itself. The server now applies them: - **Values out of rosters:** `withoutHiddenTokens` (`server/herdr-sidebar.ts`) leaves out of every roster a browser gets each token value that the rows hide at every place they name it. That covers the SSE `machines` events and both `GET /api/machines` variants. The server picks a row's token specs with the browser's own function (`paneTokenSpecs`, extracted from `paneTokenValues`), and a row's agent and tokens the way `src/lib/sidebarAgents.ts` and `AgentSidebar` do. A value the user chose to hide is therefore in no roster the browser draws the agent rows from, whatever rows it holds when one lands: after a reconnect, through a poll that beats the stream, or while the page loads, when the browser has no rows yet and draws every token. - **Operands stay on the server, and the decision fails closed:** the `herdr-sidebar` event carries the rows with no operands. Each place that has hide rules lists the reported values it draws as plain `{ equals: <value> }` rules and ends with `{ contains: "", hide: true }`, so any value the server has not decided is hidden there. A decision out of step with a roster, for example a reconnect after herdr's rows changed while the browser kept an older roster, or a poll that beats the stream, can only hide a drawn value for a moment, never show a hidden one. A token named twice still draws at the place herdr draws it. Places without hide rules carry no rules. - **Order on the stream:** the decision goes in the same write as, and just before, the roster it belongs to, and it also covers the roster the browser still holds. When herdr's rows change, the roster is sent again under the new rows. Reported values are copied when emitted, because `MachineManager` replaces its machines' snapshots in place. The wire shape is unchanged; older browsers draw the same. DESIGN.md says so, and `changelog.d/sidebar-token-hide-operands.md` covers it. ## Known limits (reviewed, not blocking) - **Scope:** this covers the PC roster (`GET /api/machines`, both variants, and the machine events' `machines`) and the `herdr-sidebar` event. Other browser-bound snapshots still carry herdr's tokens as reported, as on main: the relayed remote `snapshot` inside `machine-message` events on the same stream, `GET /api/session` and its `/api/machines/:id/session` proxy, and the `/ws` `snapshot` frame (local and relayed). The sidebar does not draw tokens from those, but their JSON holds hidden values. Tracked in #2160, which this lane takes as the next PR. - A value newly drawn at a place with hide rules, delivered by a poll before the stream's decision, is hidden there until that decision lands (fail closed). - A place with hide rules lists every distinct value it draws, so thousands of them make the browser's linear matcher quadratic. - A malformed snapshot shape would throw in the manager's emit loop. The server trusts these shapes elsewhere already. ## Validation - `bun run check fast`: green on the final head. - `server/herdr-sidebar.test.ts` adds three tests: - **Browser-model stream test:** a browser that holds the rows and roster it was last told, checked after every frame. It covers a first poll before any rows, the stream, a poll that lands before the stream's queued roster, a reconnect after the value changed, a config change, and a reconnect after the rows changed while the browser kept an older roster. It fails with each earlier head's `server/machine-api.ts`, including cd4ff86 (the merge pass's two cases), and on main. - **`withoutHiddenTokens` unit test:** each row's own agent, agent-record tokens, a token named twice, blank and non-string values, no change to the manager's machines, and drawn values equal to the raw config's. - **`decidedRowTokens` equivalence test.** - `shared/pane-tokens.test.ts`, `src/components/AgentSidebar.test.tsx`, `server/pane-tokens.contract.test.ts` and `scripts/sidebar-tokens-demo-regression.ts` pass. - Live check: a real server (`createServer`, port 0) on the isolated `ovis-test` herdr session, with a temp `HERDR_CONFIG_PATH`, read by `curl -N` on `/api/machines/events` and `curl` on `GET /api/machines` while a pane reported `5h 95%` and then a hidden `off · paused`. The hidden value appeared 0 times in the stream and 0 times in GET, the operand 0 times, and `starts_with` 0 times; shown values arrived as before. - Reviews: omo-native-code-reviewer passed on a5f03b2. Codex Sol 6.1 Fast xhigh rounds found two MEDIUMs (fixed in 28f882e and cd4ff86). The merge pass then reproduced two more MEDIUMs on cd4ff86 (reconnect, and a poll landing before the decision), fixed in e3dc853 by keeping hidden values out of rosters. Codex then found a reconnect after a config change (fixed in 1ebb8dc, fail-closed decision) and re-reviewed 1ebb8dc before this push.
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.
Change
Item 2 of #1349. The phone row sheet already reads a row's plugin tokens live, but an open sheet whose row had gone away (the pane closed or a hide rule now applies) or whose PC disconnected stayed open, showing the details it opened with.
src/components/AgentSidebar.tsxnow closes and clears the sheet when its row is no longer in the roster or its PC isdisconnectedor inerror(a disabled PC reportsdisconnected). While the PC isconnectingorreconnectingthe sheet stays open, so a brief reconnect does not close it. No visual change.Item 1 (long values pushing the sheet's actions out of view) was already fixed on main by #1402, and
scripts/sidebar-tokens-demo-regression.tscovers it. Items 3 and 4 stay open (item 3 is fixed on main too; item 4 needsserver/herdr-sidebar.ts, which another open PR holds).Refs #1349
Validation
src/components/AgentSidebar.test.tsx: removed-row, disconnected-PC and connected -> reconnecting -> connected cases; 9 pass (the close cases fail on main).bun scripts/sidebar-tokens-demo-regression.ts: all four scenarios pass; in a browser the sheet closes on disconnect at phone and desktop widths, light and dark.bun run check fast: pass.