Repository navigation
Card affordance parity in thread view, per-thread panel memory, custom-answer hardening - #7
Merged
Merged
Conversation
isCustomAnswer returned true on a bare `answered: custom`, with no check that any custom-answer text came with it. Moving off the letter "C" made the option-key collision unlikely, not impossible: the parser accepts any non-empty string as an option key, so a card author can key a real option `custom`, and a tap on it recorded exactly the marker a written answer records. That tap then rendered as a written answer with no text to show, which is the same "no option chosen at all" record the letter sentinel used to produce. Requiring the text FIRST is what makes "cannot collide with an option key" true by construction rather than by convention. It is not a heuristic: the thread route's schema enforces a non-empty trimmed string and applyCustomAnswer writes it as the custom-answer: sibling, so a written answer always has text and a tap never does. Both legacy and current markers still read correctly, and nothing on disk is rewritten. Tests: two new cases fail on the old reader - a tap on an option keyed with the sentinel's own spelling, and the bare marker with no text. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
DecisionCard and ActionCard gate the Dismiss and Supersede affordances behind an optional postAction prop. The Cards tab passed it, the thread view did not, so the same card component rendered inline in an agent's thread was missing buttons the Cards tab had. The omission was deliberate and commented as such, but there is no reason for it: closing a stale decision from the thread you are already reading is the obvious place to want it, and every server intent it needs (dismissDecision/supersedeDecision/supersedeAction) was already handled by the thread route itself. The route now passes its own path. postAction was doing a second, unrelated job: it also selected the dated timestamp format. Passing it from the thread view would therefore have switched every card's stamp to "22 Jul, 14:40" while the message bubbles around it kept the bare clock time. Split that out into an explicit withDate prop defaulting to Boolean(postAction), so the Cards tab is byte-identical without changing its call, and the thread view pins it false. Tests: both card suites gain a case for the shape the thread route really renders now (postAction set AND withDate false). Without it, re-coupling the two would leave the suite green while every card in the thread silently grew a date. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The review panel (?doc=) and the Files panel (?files=1) keep their open
state ENTIRELY in the thread route's URL search params. Search params are
scoped to the exact current URL, so leaving a thread and coming back
always rendered both closed, even when the user had been reading
something specific a moment earlier.
usePersistedPanelState mirrors those two params into sessionStorage,
keyed by agent, and restores them on re-entry. It works through the
search params, so ReviewPanel, FilesPanel and the route's own layout gate
are untouched.
Scope, all deliberate:
- Per thread. A doc open on one agent does not follow you to another.
- sessionStorage, not localStorage: this is "where was I a minute ago"
UI state, not a durable record. A fresh browser session starts clean.
- The URL always wins. A deep link opens exactly what it names.
- An explicit close clears that thread's entry, so a panel the user
deliberately shut is never resurrected.
Two things the naive version got wrong, both pinned by tests:
The restore must carry the URL hash. setSearchParams navigates to a bare
"?<search>" string, which resolves to an EMPTY hash, and on
/threads/<agent>#<decisionId> that destroys the scroll target - the
anchor effect returns early on an empty hash and cannot recover it. So
any thread with remembered panel state silently stopped scrolling to its
linked card. navigate({search, hash}) instead.
The restore must not race the ?reply= strip. Both effects
replace-navigate off a render-time searchParams snapshot and fire in the
same flush, so neither sees the other's pending edit and the later one
wins outright. The settled URL was `reply=<id>&doc=<path>`: this hook
wrote the SPENT seed back, where the strip's consume-once ref means it is
never removed again. The route passes a `hold` while the param is still
present, making the two writes sequential.
Client-only and SSR-safe: storage is touched from effects, never at
module top level, and every access is guarded (blocked storage can throw
on the property itself). Persistence is a convenience, never a gate.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
DEFAULT_KEYTERMS in server/voice-relay.ts names the DEMO roster, on purpose: it is there so the bundled demo dictates sensibly out of the box, and its own comment says nothing in it needs to be the names your agents actually use. DEEPGRAM_KEYTERMS is the supported way to say those names, read by the voice proxy and comma-separated like VOICE_ALLOWED_ORIGINS. It was not in .env.example, which is the file a deployer actually reads, so the failure mode on a real fleet was invisible: an agent name that is not a keyterm comes back as whatever ordinary English word sounds nearest, mid-sentence, with nothing to indicate a knob was missed. Documented alongside DEEPGRAM_API_KEY, in the same shape as the other "point this at YOUR fleet" entries already in the file. No behaviour change. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
simon-inkie
added a commit
that referenced
this pull request
Aug 18, 2026
…m-answer hardening (#7) * fix(cards): require the custom-answer text, not just the marker isCustomAnswer returned true on a bare `answered: custom`, with no check that any custom-answer text came with it. Moving off the letter "C" made the option-key collision unlikely, not impossible: the parser accepts any non-empty string as an option key, so a card author can key a real option `custom`, and a tap on it recorded exactly the marker a written answer records. That tap then rendered as a written answer with no text to show, which is the same "no option chosen at all" record the letter sentinel used to produce. Requiring the text FIRST is what makes "cannot collide with an option key" true by construction rather than by convention. It is not a heuristic: the thread route's schema enforces a non-empty trimmed string and applyCustomAnswer writes it as the custom-answer: sibling, so a written answer always has text and a tap never does. Both legacy and current markers still read correctly, and nothing on disk is rewritten. Tests: two new cases fail on the old reader - a tap on an option keyed with the sentinel's own spelling, and the bare marker with no text. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * fix(cards): show Dismiss/Supersede on cards rendered in thread view DecisionCard and ActionCard gate the Dismiss and Supersede affordances behind an optional postAction prop. The Cards tab passed it, the thread view did not, so the same card component rendered inline in an agent's thread was missing buttons the Cards tab had. The omission was deliberate and commented as such, but there is no reason for it: closing a stale decision from the thread you are already reading is the obvious place to want it, and every server intent it needs (dismissDecision/supersedeDecision/supersedeAction) was already handled by the thread route itself. The route now passes its own path. postAction was doing a second, unrelated job: it also selected the dated timestamp format. Passing it from the thread view would therefore have switched every card's stamp to "22 Jul, 14:40" while the message bubbles around it kept the bare clock time. Split that out into an explicit withDate prop defaulting to Boolean(postAction), so the Cards tab is byte-identical without changing its call, and the thread view pins it false. Tests: both card suites gain a case for the shape the thread route really renders now (postAction set AND withDate false). Without it, re-coupling the two would leave the suite green while every card in the thread silently grew a date. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * feat(threads): remember each thread's open side panels The review panel (?doc=) and the Files panel (?files=1) keep their open state ENTIRELY in the thread route's URL search params. Search params are scoped to the exact current URL, so leaving a thread and coming back always rendered both closed, even when the user had been reading something specific a moment earlier. usePersistedPanelState mirrors those two params into sessionStorage, keyed by agent, and restores them on re-entry. It works through the search params, so ReviewPanel, FilesPanel and the route's own layout gate are untouched. Scope, all deliberate: - Per thread. A doc open on one agent does not follow you to another. - sessionStorage, not localStorage: this is "where was I a minute ago" UI state, not a durable record. A fresh browser session starts clean. - The URL always wins. A deep link opens exactly what it names. - An explicit close clears that thread's entry, so a panel the user deliberately shut is never resurrected. Two things the naive version got wrong, both pinned by tests: The restore must carry the URL hash. setSearchParams navigates to a bare "?<search>" string, which resolves to an EMPTY hash, and on /threads/<agent>#<decisionId> that destroys the scroll target - the anchor effect returns early on an empty hash and cannot recover it. So any thread with remembered panel state silently stopped scrolling to its linked card. navigate({search, hash}) instead. The restore must not race the ?reply= strip. Both effects replace-navigate off a render-time searchParams snapshot and fire in the same flush, so neither sees the other's pending edit and the later one wins outright. The settled URL was `reply=<id>&doc=<path>`: this hook wrote the SPENT seed back, where the strip's consume-once ref means it is never removed again. The route passes a `hold` while the param is still present, making the two writes sequential. Client-only and SSR-safe: storage is touched from effects, never at module top level, and every access is guarded (blocked storage can throw on the property itself). Persistence is a convenience, never a gate. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * docs(env): document the speech-recognition keyterm override DEFAULT_KEYTERMS in server/voice-relay.ts names the DEMO roster, on purpose: it is there so the bundled demo dictates sensibly out of the box, and its own comment says nothing in it needs to be the names your agents actually use. DEEPGRAM_KEYTERMS is the supported way to say those names, read by the voice proxy and comma-separated like VOICE_ALLOWED_ORIGINS. It was not in .env.example, which is the file a deployer actually reads, so the failure mode on a real fleet was invisible: an agent name that is not a keyterm comes back as whatever ordinary English word sounds nearest, mid-sentence, with nothing to indicate a knob was missed. Documented alongside DEEPGRAM_API_KEY, in the same shape as the other "point this at YOUR fleet" entries already in the file. No behaviour change. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> --------- Co-authored-by: Simon <simon@inkie.ink> Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
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.
Four small, independent gaps, each with its own commit. Nothing here is a
refactor: every change is either a behaviour the Cards tab already had and
the thread view did not, or a guard that was weaker than its own comment
claimed.
1.
isCustomAnswerrequired only the marker, not the textisCustomAnswerreturned true on a bareanswered: custom. Moving thesentinel off the letter
Cmade the option-key collision unlikely, notimpossible: the parser accepts any non-empty string as an option key, so a
card author can key a real option
custom, and a tap on it recorded exactlythe marker a written answer records. That tap then rendered as a written
answer with no text to show, which is the same "no option chosen at all"
record the letter sentinel used to produce.
The fix requires the
custom-answertext FIRST. That is not a heuristic:the thread route's schema enforces a non-empty trimmed string and
applyCustomAnswerwrites it as the sibling field, so a written answeralways has text and a tap never does. This is what makes "cannot collide
with an option key" true by construction rather than by convention. Legacy
and current markers both still read correctly; nothing on disk is rewritten.
Two new tests fail on the old reader.
2. Dismiss/Supersede inline in thread view, and the stamp decoupled
DecisionCard/ActionCardgate Dismiss and Supersede behindpostAction.The Cards tab passed it, the thread view did not, so the same component
rendered inline in a thread was missing buttons the Cards tab had. Every
server intent it needs was already handled by the thread route itself, so
the route now passes its own path.
postActionwas quietly doing a second job: selecting the dated timestampformat. Passing it from the thread view would have switched every card's
stamp to
22 Jul, 14:40while the bubbles around it kept the bare clocktime. That is now an explicit
withDateprop defaulting toBoolean(postAction), so the Cards tab is byte-identical without changingits call, and the thread view pins it false.
Both card suites gain a case for the shape the route really renders now
(
postActionset ANDwithDatefalse). Without it, re-coupling the twowould leave the suite green while every card in the thread silently grew a
date.
3. Per-thread side-panel memory
The review panel (
?doc=) and Files panel (?files=1) keep their open stateentirely in the thread route's search params, so leaving a thread and coming
back always rendered both closed.
usePersistedPanelStatemirrors those twoparams into sessionStorage keyed by agent and restores them on re-entry,
working through the search params so the panels themselves are untouched.
Scope is deliberately narrow: per thread, sessionStorage not localStorage,
the URL always wins, and an explicit close clears the entry so a panel the
user shut is never resurrected.
Two things the naive version gets wrong, both pinned by tests:
setSearchParamsnavigates to abare
?<search>string, which resolves to an EMPTY hash. On/threads/<agent>#<id>that destroys the scroll target, and the anchoreffect returns early on an empty hash and cannot recover it.
?reply=strip. Both effectsreplace-navigate off a render-time snapshot in the same flush, so the
later one wins outright and the settled URL was
reply=<id>&doc=<path>—the spent seed written back, where the strip's consume-once ref means it
is never removed again. The route passes a
holdwhile the param is stillpresent.
Client-only and SSR-safe; blocked storage is caught, since persistence is a
convenience and never a gate.
4.
DEEPGRAM_KEYTERMSwas undocumentedDEFAULT_KEYTERMSnames the demo roster on purpose — its own comment saysnothing in it needs to be the names your agents actually use, and
DEEPGRAM_KEYTERMSis the supported override. But that variable was absentfrom
.env.example, the file a deployer actually reads, so the failure modeon a real fleet was invisible: an agent name that is not a keyterm comes
back as whatever ordinary English word sounds nearest, mid-sentence, with
nothing to indicate a knob was missed. Documented alongside
DEEPGRAM_API_KEY, in the same shape as the other "point this at YOURfleet" entries already in the file. No behaviour change.
Verification
pnpm test— 90 files, 1866 passed, 11 skipped (+47 over baseline).Note:
test/skeleton.test.tshas one 5s-timeout flake under heavy machineload that reproduces identically on untouched
main; it passes inisolation and with
--testTimeout=30000.pnpm typecheck— cleanpnpm check:boundaries— no violations (487 modules)check:leaks,--self-test,--messages— clean for every commit here.The two pre-existing
--messagesfindings are onmain's own HEAD and onan unrelated branch, neither reachable from these commits.