8000 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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions packages/deck/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,24 @@ MC_BRIEFS_AGENT=
# uses a session called "agents"; INSTALL.md records that as a known limitation.
MC_TMUX_SESSION=

# Optional: the Deepgram API key that turns voice dictation on. Unset = the mic
# reports "no key" and everything else works exactly as before. The key is held
# by the voice proxy and is never sent downstream to a browser.
DEEPGRAM_API_KEY=

# Optional: comma-separated speech-recognition keyterms, boosting the words
# dictation is most likely to get wrong. THIS IS WHERE YOUR AGENTS' NAMES GO.
# Unset = a built-in default naming the DEMO roster. That default exists so the
# bundled demo dictates sensibly out of the box and is not meant to survive
# contact with a real fleet: a name that is not in this list comes out as
# whatever ordinary English word sounds nearest, mid-sentence, silently.
# Set it to your own roster plus any product terms you say often:
# DEEPGRAM_KEYTERMS=Quill,Scribe,Atlas,Inkie
# It is a rerank, not a guarantee. For a name with a very close everyday
# neighbour, DEEPGRAM_REPLACEMENTS (comma-separated find:replacement pairs) is
# the deterministic layer on top - see server/voice-proxy.mjs.
DEEPGRAM_KEYTERMS=

# Sandbox mode: when set to a non-empty value, the server REFUSES any root that
# resolves to ~/.the-vault or below, so a sandbox configuration can never be
# pointed at a live agent silo. test/setup.ts sets it automatically, and a dev
Expand Down
26 changes: 19 additions & 7 deletions packages/deck/app/components/ActionCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,21 @@ interface ActionCardProps {
/**
* Thread C: when set, card mutation forms POST to this path (the owning
* agent's thread action, e.g. "/threads/scribe") instead of the current
* route, and the additive Supersede affordance is revealed. The dedicated
* Cards tab passes this; the thread view omits it, so its UI is unchanged.
* route, and the additive Supersede affordance is revealed. The Cards tab
* passes the same route it always did (a cross-route hand-off); the thread
* view passes its own route too, so Supersede shows inline on unresolved
* cards there as well.
*/
postAction?: string;
/**
* The dated stamp format, independent of postAction. Defaults to
* Boolean(postAction) so the Cards tab keeps its dated stamps without
* callers having to say so explicitly - but the thread view sets this to
* false explicitly, because postAction there means "reveal Supersede", not
* "also switch this card's timestamp format away from the bare clock time
* every other bubble in the thread uses".
*/
withDate?: boolean;
}

/**
Expand All @@ -61,7 +72,7 @@ interface ActionCardProps {
* When the action is already done, renders a "Done <time>" success badge with
* the tick disabled (card stays visible as historical record, CARD-06).
*/
export function ActionCard({ block, now, onOpenDoc, postAction }: ActionCardProps) {
export function ActionCard({ block, now, onOpenDoc, postAction, withDate = Boolean(postAction) }: ActionCardProps) {
const fetcher = useFetcher();
const busy = fetcher.state !== "idle";
const actionCard = block.actionCard;
Expand Down Expand Up @@ -165,7 +176,7 @@ export function ActionCard({ block, now, onOpenDoc, postAction }: ActionCardProp
Superseded {supersededDisplay ?? "just now"}
</Badge>
)}
<Timestamp iso={block.header.timestamp} now={now} withDate={Boolean(postAction)} />
<Timestamp iso={block.header.timestamp} now={now} withDate={withDate} />
<ChevronDown
className={cn("h-4 w-4 shrink-0 text-muted-foreground transition-transform", expanded && "rotate-180")}
aria-hidden="true"
Expand Down Expand Up @@ -311,7 +322,7 @@ export function ActionCard({ block, now, onOpenDoc, postAction }: ActionCardProp
hue (Alex live feedback, TASK-453) - same treatment as the receipt. */}
<div className="flex items-center justify-between border-b border-accent/20 bg-accent/10 px-4 py-2">
<span className="label-mono text-accent">Action</span>
<Timestamp iso={block.header.timestamp} now={now} withDate={Boolean(postAction)} />
<Timestamp iso={block.header.timestamp} now={now} withDate={withDate} />
</div>

<div className="p-4">
Expand Down Expand Up @@ -398,8 +409,9 @@ export function ActionCard({ block, now, onOpenDoc, postAction }: ActionCardProp
>
<X className="h-5 w-5" aria-hidden="true" />
</Button>
{/* Thread C: Supersede button - additive, only on the Cards tab
(postAction set). Marks the action replaced by a newer one. */}
{/* Thread C: Supersede button - additive, shown on unresolved
cards wherever postAction is set (Cards tab and thread view).
Marks the action replaced by a newer one. */}
{postAction ? (
<Button
type="button"
Expand Down
24 changes: 17 additions & 7 deletions packages/deck/app/components/DecisionCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,20 @@ interface DecisionCardProps {
* Thread C: when set, card mutation forms POST to this path (the owning
* agent's thread action, e.g. "/threads/scribe") instead of the current
* route, and the additive Dismiss + Supersede affordances are revealed. The
* dedicated Cards tab passes this; the thread view omits it, so its UI is
* unchanged (answer options + write-own only, exactly as today).
* Cards tab passes the same route it always did (a cross-route hand-off);
* the thread view passes its own route too, so Dismiss + Supersede show
* inline on unresolved cards there as well.
*/
postAction?: string;
/**
* The dated stamp format, independent of postAction. Defaults to
* Boolean(postAction) so the Cards tab keeps its dated stamps without
* callers having to say so explicitly - but the thread view sets this to
* false explicitly, because postAction there means "reveal Dismiss and
* Supersede", not "also switch this card's timestamp format away from the
* bare clock time every other bubble in the thread uses".
*/
withDate?: boolean;
}

/**
Expand All @@ -77,7 +87,7 @@ interface DecisionCardProps {
* The PUSHBACK_RESOLUTION const distinguishes a pushed-back badge from an
* answered badge so the UI can show different copy for each state.
*/
export function DecisionCard({ block, now, onWriteOwn, draftCustomAnswer, onOpenDoc, postAction }: DecisionCardProps) {
export function DecisionCard({ block, now, onWriteOwn, draftCustomAnswer, onOpenDoc, postAction, withDate = Boolean(postAction) }: DecisionCardProps) {
const fetcher = useFetcher();
const busy = fetcher.state !== "idle";
const card = block.card;
Expand Down Expand Up @@ -173,7 +183,7 @@ export function DecisionCard({ block, now, onWriteOwn, draftCustomAnswer, onOpen
Superseded
</Badge>
)}
<Timestamp iso={block.header.timestamp} now={now} withDate={Boolean(postAction)} />
<Timestamp iso={block.header.timestamp} now={now} withDate={withDate} />
<ChevronDown
className={cn("h-4 w-4 shrink-0 text-muted-foreground transition-transform", expanded && "rotate-180")}
aria-hidden="true"
Expand Down Expand Up @@ -284,7 +294,7 @@ export function DecisionCard({ block, now, onWriteOwn, draftCustomAnswer, onOpen
{/* Card header row - teal banner so a "needs you" card reads as a physical card */}
<div className="flex items-center justify-between border-b border-primary/20 bg-primary/10 px-4 py-2">
<span className="label-mono text-primary">Decision</span>
<Timestamp iso={block.header.timestamp} now={now} withDate={Boolean(postAction)} />
<Timestamp iso={block.header.timestamp} now={now} withDate={withDate} />
</div>

<div className="p-4">
Expand Down Expand Up @@ -368,8 +378,8 @@ export function DecisionCard({ block, now, onWriteOwn, draftCustomAnswer, onOpen
<span className="label-mono text-xs">OR write something...</span>
</Button>

{/* Thread C: Dismiss + Supersede - additive, only on the Cards tab
(postAction set), so the thread view keeps its answer-only UI.
{/* Thread C: Dismiss + Supersede - additive, shown on unresolved
cards wherever postAction is set (Cards tab and thread view).
Close a stale decision without round-tripping the agent. */}
{postAction ? (
<div className="mt-1 flex items-center gap-2">
Expand Down
37 changes: 27 additions & 10 deletions packages/deck/app/lib/blocks/answer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ export const PUSHBACK_REPLY_MARKER = "push-back: true";
* the record showed no option chosen at all. "answered: pushback" already
* proved a non-letter resolution is the established shape here, and the parser
* accepts any non-empty string, so nothing schema-side moves.
*
* A non-letter sentinel cannot collide with A/B/C by CONVENTION, and
* convention is not a guarantee: the parser accepts ANY non-empty string as an
* option key, so nothing stops a card author writing `key: custom`. The
* guarantee lives in isCustomAnswer below, which requires the custom-answer
* TEXT to be present and not merely the marker.
*/
export const CUSTOM_ANSWER_RESOLUTION = "custom";

Expand All @@ -81,22 +87,33 @@ const LEGACY_CUSTOM_ANSWER_RESOLUTION = "C";
/**
* Does this card's answered state mean "the user wrote their own answer"?
*
* Both forms count, because the fix changed the value written from here on and
* did NOT migrate what is already on disk:
* - "answered: custom" - written since the collision fix.
* - "answered: C" WITH a custom-answer: value - the legacy form. The custom
* text is the evidence: a real tap on option C never writes that field, so
* keying on its presence rather than on the letter distinguishes the two
* cases that the old sentinel had merged.
* Requires BOTH a marker (the current sentinel, or the legacy letter for
* records already on disk) AND the custom-answer text. Both halves are
* load-bearing:
*
* - the text alone is not enough, or a normal tap on a card carrying
* leftover custom-answer text would read as a written answer;
* - the marker alone is not enough, which is what keeps out both a genuine
* tap on option C and a tap on an option someone keyed `custom`.
*/
export function isCustomAnswer(card: {
answered?: string;
customAnswer?: string;
}): boolean {
if (card.answered === CUSTOM_ANSWER_RESOLUTION) return true;
// A WRITTEN ANSWER ALWAYS HAS TEXT. The thread route's schema enforces
// `text: z.string().trim().min(1)` and applyCustomAnswer writes that text as
// the custom-answer: sibling, so this is not a heuristic. Requiring it FIRST
// is what makes "cannot collide with an option key" true by construction
// rather than by convention: a card author CAN key an option `custom`, and a
// tap on that option carries no sibling, so it is correctly not a written
// answer.
if (card.customAnswer === undefined) return false;
// Either marker, given the text is there. The legacy letter is accepted only
// for records already on disk; a genuine tap on option C has no sibling and
// was excluded above.
return (
card.answered === LEGACY_CUSTOM_ANSWER_RESOLUTION &&
card.customAnswer !== undefined
card.answered === CUSTOM_ANSWER_RESOLUTION ||
card.answered === LEGACY_CUSTOM_ANSWER_RESOLUTION
);
}

Expand Down
Loading
Loading
0