Skip to content

ui: host-controlled decision toggle and status tag on question cards - #1744

Merged
backnotprop merged 3 commits into
mainfrom
feat/ui-question-decision-toggle
Oct 7, 2026
Merged

backnotprop merged 3 commits into
mainfrom
feat/ui-question-decision-toggle

Conversation

@backnotprop

Copy link
Copy Markdown
Owner

Why

Workspaces (and the upcoming Plannotator Inbox) need two things on question cards that @plannotator/ui could not do yet:

  1. Let the reviewer switch a Decision: when answered question's decision recording off and on from the card itself.
  2. Draw their own status tag instead of the card's Open / Answered / Settled / Skipped tag.

Both are optional props, cut for ui 0.52.0. Plannotator's own app passes none of them and renders exactly as before.

Props

QuestionBlock (packages/ui/components/blocks/QuestionBlock.tsx):

  • decisionRecording?: boolean (default true)
  • onToggleDecisionRecording?: (key: string, next: boolean) => void
  • statusTag?: 'card' | 'none' (default 'card')

Viewer (forwarded through BlockRenderer the same way renderQuestionFooter is):

  • questionDecisionRecording?: (question: IndexedQuestion) => boolean | undefined
  • onToggleQuestionDecisionRecording?: (key: string, next: boolean) => void
  • questionStatusTag?: 'card' | 'none'

BlockRenderer takes questionDecisionRecording?: boolean, onToggleQuestionDecisionRecording and questionStatusTag.

Behavior

These props affect only a Decision: when answered question (decisionOnAnswer) whose decision is not recorded yet:

  • With the handler, the "◇ Records a decision" tag is a <button type="button" aria-pressed> with data-question-decision-toggle. It works from the keyboard and shows a focus ring. A ring is used, not an outline, because the dotted outline is what draws the off state. A click calls onToggleDecisionRecording(question.key, !on). The card keeps no state of its own: the host stores the value and passes it back.
  • On looks exactly as it does today.
  • Off shows the same words, dimmed, with a dotted outline (an inline style). The "Answering this records a decision" row (data-question-decision-row) is removed, not dimmed.
  • decisionRecording: false without a handler is honored. The card shows a static dimmed tag and hides the row, for a state the reviewer may not change.
  • Read-only cards never get the toggle. Viewer drops the handler under readOnly, and a card with no answer handler shows a static tag in its current state.
  • A recorded decision (Decision: [statement](url)) and a question with no decision line are never affected.
  • Attributes: data-question-decision keeps its current values (on-answer / recorded). A separate data-question-decision-recording="on" | "off" is added only when the host passes decisionRecording or the handler.
  • statusTag: 'none' hides Open / Answered / Settled / Skipped. The decision tags stay, and data-question-status still holds the status.

No stylesheet change: the toggle uses utility classes the package already ships. The guides.show viewer manifest stays in sync (check:manifest passes), so no guides.show deploy is needed.

Plannotator unchanged

With none of the props, the rendered markup (interactive and read-only) is byte-identical to main. I checked this with renderToStaticMarkup over decision-on-answer, recorded-decision and plain questions, rendered with the main and branch components.

Tests

packages/ui/components/blocks/QuestionBlock.decisionToggle.test.tsx is DOM-gated and has been added to the DOM_TESTS=1 step in test.yml. It covers:

  • the toggle is an aria-pressed button that calls the handler with the key and the next state
  • off hides the row and dims the tag
  • a recorded or plain question gets no toggle
  • a read-only card shows a static span
  • decisionRecording: false without a handler
  • with no props: sentinel checks (plain span, no new attribute, the row still shows)
  • statusTag: 'none' hides the status tag and keeps the decision tag
  • Viewer threading, including readOnly

With the component change reverted, 5 of the 8 tests fail.

Verified:

  • QuestionBlock tests: 30 pass
  • bun test packages/ui: 0 fail
  • 20 Viewer and question DOM files with --isolate: 139 pass
  • DOM allowlist guard: passes
  • bun run typecheck: passes
  • guides.show build:viewer + check:manifest: in sync
  • apps/review build && build:hook: both build

smoke:package fails on main for an unrelated reason: the UI imports @plannotator/core/server-session, which is not in the published core 0.25.11. The core 0.25.12 bump in #1743 fixes it. This PR does not touch core or imports.

No version bumps.

backnotprop and others added 3 commits October 6, 2026 21:37
QuestionBlock gains decisionRecording / onToggleDecisionRecording (the
"Records a decision" tag becomes an aria-pressed toggle; off dims it with
a dotted outline and hides the decision row) and statusTag ('none' hides
the card's own status tag). Threaded through BlockRenderer and Viewer as
questionDecisionRecording(question), onToggleQuestionDecisionRecording and
questionStatusTag. Plannotator passes none; markup unchanged.

Co-Authored-By: Claude <noreply@anthropic.com>
60% opacity on primary text put the off "Records a decision" tag at
2.92:1 in the default light theme and under 3:1 in most bundled themes.
The theme's muted-foreground is the token every palette tunes for
secondary text (8.9:1 / 7.4:1 in the default light / dark theme), so the
dimmed tag stays legible while still reading as off.
@backnotprop
backnotprop merged commit 75595b6 into main Oct 7, 2026
28 checks passed
@backnotprop
backnotprop deleted the feat/ui-question-decision-toggle branch October 7, 2026 05:00
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