Skip to content

feat(editor): question answers — history, progress chip, Questions panel, Send answers (PR 2) - #1638

Merged
backnotprop merged 3 commits into
mainfrom
feat/question-blocks-editor
Sep 29, 2026
Merged

backnotprop merged 3 commits into
mainfrom
feat/question-blocks-editor

Conversation

@backnotprop

Copy link
Copy Markdown
Owner

PR 2 (editor) of the approved question/answer components feature (.product/approved/qa-components/: SPEC §8 PR 2, owner decisions in approval.md). Builds on #1637. No publish, no release; ui 0.48.0 / core 0.25.8 are still unpublished, so the additive changes ride those versions.

What this adds

  1. Undo/redo for answers. Each answer change records in the existing annotation history (kind: 'annotation' add/edit/delete). Typing in free text, "Other…" or a note folds into one entry per burst (1 s idle) through a new useUndoHistory.replaceLast(expected, next). Picks, skips and Accept recommended are one entry each. packages/editor/hooks/useQuestionAnswers.ts.
  2. ann-question-* treated like ann-checkbox-*. annotationOwnsHighlight and repaintHighlights exclude answer rows (no highlight sync on undo, no false "no longer match the text" toast after Edit Mode). applyEditedDocument re-points answers by question key, not by quote (questionAnswerRemapper); a reworded prompt gives blockId ''.
  3. Header "N/M answered" chip (QuestionProgressChip) beside the decision control, plan review and annotate. N counts answered + settled. A click scrolls to and focuses the next open question after the last one it jumped to, wrapping; with nothing open it steps through skipped ones.
  4. Questions section in the annotations panel (QuestionsPanelSection, AnnotationPanel questionRows / onSelectQuestion), above a Comments heading, per the mock: progress bar, one row per question with its answer or "Not answered yet", Open / ✓ / Skipped. A row click scrolls to the card. Answer rows no longer list as Comment cards. A host that passes no questionRows gets the old panel.
  5. Orphaned answers (prompt edited or block removed) list with the existing Unanchored chip and a "Remove answer" link, and still export.
  6. Plan review "Send answers". When the only feedback is answers (no comment, attachment, direct edit or saved-file change), the primary reads Send answers (header and compact row). It posts /api/deny with a framing paragraph under the title ("The reviewer answered the questions in your plan and asked for no other changes. Update the plan so each answered question becomes a decision … Then resubmit.") plus an additive answersOnly: true body flag that today's servers ignore. The feedback-loss copy names answers: "Your 3 answers will be lost." The annotate decision control needs no change (answers are annotations → Send Feedback); verified.
  7. PR 1 review fixes:
    • Settled [x] + note only: counted as answered, exported as Answer: REST (already settled in the document) + the note.
    • Multi-line notes export as a Note: blockquote; one-line notes are unchanged.
    • Double-clicking a word in an option never picks: the second click is cancelled and the first click's pick is taken back (the history entry is dropped too).
    • Pinpoint mode: a click on option text pins without picking; a click on the radio/checkbox/text box answers without pinning (usePinpoint).
    • The free-text, Other and note fields are annotation-exclude, so text-search restore never lands in typed text.
    • One status rule in core, questionStatus, shared by card, rows and chip.

Documents without questions: questionRows is not passed, the chip does not render, the feedback label and loss copy are unchanged (tested), and the export is untouched. Toolbar untouched.

Evidence

  • New/extended tests: core (settled+note, multi-line note, questionStatus), questionDecision.test.ts (answers-only rule, framing placement, loss copy, Edit Mode remap), questionAnswers.test.ts (rows, progress, next-open), DOM: useQuestionAnswers.test.tsx (burst = 1 entry, pause = 2, picks separate, double-click leaves no pick and no entry), usePinpoint.question.test.tsx, AnnotationPanel.questions.test.tsx, highlighter restore vs typed text. Mutation-checked: the double-click, pinpoint and annotation-exclude tests fail with their fix removed. New DOM files added to test.yml.
  • bun test: 0 fail (6820 tests). CI DOM list: 1349 pass. bun run typecheck passes (incl. strict-consumer).
  • Built with bun run --cwd apps/review build && bun run build:hook. check:manifest passes after regenerating the guides.show CSS pin (the stylesheet gained the chip/panel classes; deploy guides.show before a release).
  • Headless Chromium (--use-mock-keychain --password-store=basic), real plan hook (claude-code origin) and annotate, dark and light, 26/26 checks:
    • chip starts 1/5 (settled counts), jumps Q1 → Q2; in annotate jumps Q1 → Q3 after answering
    • double-click on option text: no pick
    • typed a sentence, Mod+Z removed it in one step, Mod+Shift+Z restored it; a second Mod+Z undid Accept recommended
    • panel: 5 rows, no answer comment cards; row click focused its card
    • Send answers posted deny with framing + Answers section, no "pieces of feedback" line
    • Approve → "Your 3 answers will be lost."
    • Edit Mode (inserted a paragraph): statuses and the multi-line note kept, no "no longer match" toast, primary back to Send Feedback, export carries Direct Edits + Answers with the settled+note line
    • annotate Send Feedback carried the Answers section

Send answers body the agent received (after the server's deny prompt):

# Plan Feedback

The reviewer answered the questions in your plan and asked for no other changes. Update the plan so each answered question becomes a decision: remove its `:::question` block and write the decision into the prose, or keep the block with the chosen choice marked `- [x]`. Keep any question listed under "Unanswered" as it is. Then resubmit the plan.

## Answers to your questions

3 of 4 questions answered. 1 already settled in the document was left as is.

### Q1. Where should losing conflict versions be kept? (line 10)
Answer: Server-side per user

### Q3. Which sync indicators ship in v1? (line 33)
Answer (your recommendation):
- Per-document synced / pending / failed dot
- Global offline banner

### Q5. Describe the manual test you'd run before calling offline sync shippable. (line 54)
Answer:
> Two phones, one offline, same doc.

### Unanswered
- Q2. Should sync run while the app is in the background? (line 24)

Screenshots

Hosted on assets/qa-components-pr2; delete that branch after review.

Dark Light

Send answers header:

Claude Code approve warning:

After Edit Mode:

Deviations to review

  • Agent wording for Send answers is client-side. The deny still goes through the server's "YOUR PLAN WAS NOT APPROVED" prompt; the answers framing is a paragraph in the feedback body. The real plan.answered prompt (both runtimes) is PR 3 per SPEC §8; the answersOnly flag is there for it.
  • Plan review has no caret menu, so there is no "Approve with answers" / "Approve, discard n answers…" item from the SPEC table. The existing Approve button is that path; on Claude Code it raises the existing warning (approval decision 1).
  • The chip counts settled questions as done (1/5 on arrival) and treats skipped ones as not open.
  • A pick followed by note typing is two history entries (typing only folds into typing).
  • Answers-only detection counts answers in the open document only; answers in other linked documents keep "Send Feedback".
  • Double-click fix is a revert of the first click's pick (the first click cannot be told apart from a single click when it lands).

What PR 3 needs

  • plan.answered prompt key (Bun + Pi, OpenCode), selected by the answersOnly flag; then drop or keep the client framing paragraph.
  • SKILL.md section from QUESTION_AUTHORING_GUIDE + freshness test, PFM paragraph, feedback-archive questionAnswer, read-only WebMCP questions.

…anel, Send answers (PR 2)

- Answers record in the annotation undo history; typing folds into one entry
  per burst (useUndoHistory.replaceLast), a double-click revert drops its entry.
- ann-question-* rows never own a highlight; Edit Mode remaps answers by
  question key (a reworded prompt orphans the answer, still exported).
- Header N/M answered chip jumps to the next open question.
- AnnotationPanel Questions section (questionRows) above Comments; orphaned
  answers show Unanchored + Remove answer.
- Plan review: Send answers when answers are the only feedback, deny with an
  answers framing paragraph (+ additive answersOnly flag); the Claude Code
  approve warning names answers.
- Core: questionStatus; settled [x] + note counts as answered by the settled
  choice; multi-line notes keep line breaks.
- Card: double-click a word never picks; pinpoint on option text pins without
  picking; typed fields are annotation-exclude.
- guides.show manifest CSS pin regenerated.
…editor

# Conflicts:
#	packages/core/guide-viewer-manifest.ts
… them correctly

With no open question left, the chip always jumped to the first skipped
question instead of stepping through them, and its title read 'All
questions answered' while skipped questions remained.
@backnotprop
backnotprop merged commit 62efe8f into main Sep 29, 2026
28 checks passed
@backnotprop
backnotprop deleted the feat/question-blocks-editor branch September 29, 2026 22:25
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