FFFF Card affordance parity in thread view, per-thread panel memory, custom-answer hardening by simon-inkie · Pull Request #7 · simon-inkie/inkie-deck · GitHub
[go: up one dir, main page]

Skip to content

Card affordance parity in thread view, per-thread panel memory, custom-answer hardening - #7

Merged
simon-inkie merged 4 commits into
mainfrom
card-parity-and-panel-state
Aug 18, 2026
Merged

simon-inkie merged 4 commits into
mainfrom
card-parity-and-panel-state

Conversation

@simon-inkie
Copy link
Copy Markdown
Owner

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. isCustomAnswer required only the marker, not the text

isCustomAnswer returned true on a bare answered: custom. Moving the
sentinel 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.

The fix requires the custom-answer text FIRST. That is not a heuristic:
the thread route's schema enforces a non-empty trimmed string and
applyCustomAnswer writes it as the sibling field, so a written answer
always 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/ActionCard gate Dismiss and Supersede behind postAction.
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.

postAction was quietly doing a second job: selecting the dated timestamp
format. Passing it from the thread view would have switched every card's
stamp to 22 Jul, 14:40 while the bubbles around it kept the bare clock
time. That is now 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.

Both card suites gain a case for the shape the 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.

3. Per-thread side-panel memory

The review panel (?doc=) and Files panel (?files=1) keep their open state
entirely in the thread route's search params, so leaving a thread and coming
back always rendered both closed. usePersistedPanelState mirrors those two
params 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:

  • The restore must carry the URL hash. setSearchParams navigates to a
    bare ?<search> string, which resolves to an EMPTY hash. On
    /threads/<agent>#<id> that destroys the scroll target, and the anchor
    effect returns early on an empty hash and cannot recover it.
  • The restore must not race the ?reply= strip. Both effects
    replace-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 hold while the param is still
    present.

Client-only and SSR-safe; blocked storage is caught, since persistence is a
convenience and never a gate.

4. DEEPGRAM_KEYTERMS was undocumented

DEFAULT_KEYTERMS names the demo roster on purpose — its own comment says
nothing in it needs to be the names your agents actually use, and
DEEPGRAM_KEYTERMS is the supported override. But that variable was absent
from .env.example, 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.

Verification

  • pnpm test — 90 files, 1866 passed, 11 skipped (+47 over baseline).
    Note: test/skeleton.test.ts has one 5s-timeout flake under heavy machine
    load that reproduces identically on untouched main; it passes in
    isolation and with --testTimeout=30000.
  • pnpm typecheck — clean
  • pnpm check:boundaries — no violations (487 modules)
  • check:leaks, --self-test, --messages — clean for every commit here.
    The two pre-existing --messages findings are on main's own HEAD and on
    an unrelated branch, neither reachable from these commits.

Simon and others added 4 commits August 17, 2026 22:34
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
simon-inkie merged commit f9f30e0 into main Aug 18, 2026
1 of 4 checks passed
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>
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

0