Repository navigation
fix(sidebar): keep plugin token follow-ups from #1341 in step with the rows - #1402
Conversation
…e rows The phone sheet scrolls long token values instead of pushing its actions out, an open sheet reads its row at each render, a recovery resets the display_agent baseline to the resynced snapshot, and a token named twice in herdr's rows shows at the first place that does not hide it. Refs #1349.
|
@coderabbitai review |
|
CodeRabbit did not review ba0ea26 (its review allowance ran out; |
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing: 10
✨ Finishing Touches
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 |
|
|
Tip For best results, initiate chat on the files or code changes. @devswha Thanks for clarifying. You are interacting with an AI system. |
…#1751) ## 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.tsx` now closes and clears the sheet when its row is no longer in the roster or its PC is `disconnected` or in `error` (a disabled PC reports `disconnected`). While the PC is `connecting` or `reconnecting` the 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.ts` covers it. Items 3 and 4 stay open (item 3 is fixed on main too; item 4 needs `server/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.
…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.
Refs #1349 (items 1, 2, 3 and 5; item 4, hide-rule operands on the machine events, touches what watch-only browsers receive and goes in its own PR).
Change
Follow-ups to #1341 (plugin pane tokens in the sidebar, not released yet, so no changelog fragment:
changelog.d/sidebar-plugin-tokens.mdstill describes the feature)..row-sheet-detailis capped at a third of the screen and scrolls. Before, 32 long tokens filled the sheet: the title scrolled off the top and Pin agent sat under Cancel, out of reach. This follows the iOS action sheet (and the Claude and Codex apps' long-press sheets): a long message scrolls, the actions stay put.AgentSidebarkept a copy of the title, place and tokens taken when the menu opened. The menu now keeps only which row and anchor, and reads what it says from the row at each render, so a changed value, a hide rule that now applies or a PC going away shows in the open sheet too.display_agent) after a recovery is measured against what clients show. The collector's dedupe baseline was seeded only for panes it had never seen, so after a lost subscription the baseline stayed at the line heard before the loss. A change back to that line then looked like no change, and the sidebar waited for the next roster poll. On a resync, which already tells clients to read the panes again, the baseline now takes the snapshot's line, except for panes an event has spoken for since the snapshot was asked.server/herdr-sidebar.tskept only the first place of a token, so a token hidden by its first place's rule showed nowhere, though herdr tests each place on its own (src/ui/sidebar/tokens.rsmaps every row entry independently). The parser now keeps each place, andpaneTokenValuessays a token once, at the first place whose rules leave it shown. Theherdr-sidebarmachine event may now list a name more than once; an older browser reading it keeps the first place, as before.Validation
bun run check fast: workflow syntax, generated types and themes, typecheck, build, unit tests (4504 pass, 0 fail, 8 skip).shared/pane-tokens.test.ts(a token named twice),server/herdr-sidebar.test.ts(each place kept, updated from "each once"),server/collector.test.ts(an event after a recovery). The collector case times out against main'sserver/collector.tsand passes with this change.scripts/sidebar-tokens-demo-regression.ts(demo fixture, no live session) gained two phone checks: the open sheet's detail follows a changed value, and with 32 long tokens the sheet's title, Pin agent and Cancel are on screen and hit-testable while the detail scrolls. All four desktop and phone passes are green. Both checks failed on main when reproduced by hand before the fix (Pin agent covered by Cancel; sheet kept40% 12m · 5h 95%after the row changed).