Skip to content

feat(agent,workbench): add inline quote annotations and unify review/side quotes - #7504

Merged
M4n5ter merged 2 commits into
mainfrom
feat/quote-annotations
Dec 1, 2026
Merged

M4n5ter merged 2 commits into
mainfrom
feat/quote-annotations

Conversation

@M4n5ter

@M4n5ter M4n5ter commented Dec 1, 2026

Copy link
Copy Markdown
Member

Summary

Adds inline annotation support to Maka by extending QuoteRef with an optional QuoteNote instead of introducing a parallel annotation track, and unifies the two existing parallel "excerpt + comment" flows (Side Question gathered passages and Diff/File ReviewNote) onto the same model.

Key changes

  • Contract, prompt & history projection (maka-agent-facts, maka-agent-ports, maka-agent-native, plugin-sdk)
    • Added QuoteNote newtype (rejects blank strings while preserving non-blank content verbatim) and optional QuoteRef.note (skip_serializing_if = "Option::is_none").
    • Plain quotes continue rendering byte-identically as <quoted_excerpt> (preserving prompt cache); annotated quotes render as <annotated_excerpt> with escaped <excerpt> and <user_comment>.
    • Shared the 28 KiB JSON-encoded projection budget across up to 16 quotes so notes remain untruncated under normal lengths while staying bounded under worst-case escaping.
    • Empty-body queue previews prefer quote.note over excerpt text; journal draft persistence, retract, steer aggregation, and send snapshots carry notes automatically.
    • Added pre-upgrade cold-migration readback and post-upgrade annotated agent.send coverage in products/maka/cli/tests/upgrade_compat.rs.
  • NSH settled selection signal (third-party/nsh)
    • Exposed dragging: bool on TextSelectionEvent / TextViewSelectionEvent across nsh-core, nsh-base, nsh-platform-macos, nsh-platform-windows, and nsh-testing, firing a settled update when drag selection ends.
  • Workbench annotation UX & unification (maka-workbench, agent-composer, agent-conversations, workspace-files)
    • Added floating SelectionToolbar (Quote / Comment / Ask beside) anchored to settled selection pageBounds on macOS/Windows (with mouse-down handoff protection and scroll dismissal), plus Comment on selection… in the context menu on all platforms.
    • Upgraded DraftQuotes with collapsible per-quote multiline note editors (plain quotes stay compact; Enter returns focus to composer, Shift+Enter inserts newline, Cmd/Ctrl+Enter sends directly even with empty composer body), bounded scroll (maxHeight: 220), and live TextViewMark highlight/underline linkage on the source message.
    • Rendered quote notes in history bubbles, optimistic pending turns, and queued message previews (with iOS shell read-only display sync in ChatQuotes.tsx / ChatScreen.tsx).
    • Unified Side Question passage gathering (dropped parallel gatheredPassages / SideQuoteTray; copies from draft quotes without clearing main draft and enforces the 16-quote cap) and Diff/File ReviewNote (delivers structured QuoteRef + note with dedented excerpts, falling back to formatted markdown text only when a batch exceeds 16 notes).
    • Updated all 12 workbench locale files.

Scope notes

  • Linux floating selection toolbar: nsh-platform-linux does not yet emit selection bounds/pageBounds; Linux users annotate via the context menu (Comment on selection…) until Linux selection bounds are implemented.
  • iOS shell: Displays sent and draft quote notes read-only; inline note editing on iOS is left for a follow-up.

Verification

Automated checks

  • node --test products/maka/workbench/tests/send-receipt.test.mjs products/maka/workbench/tests/conversation-resources.test.mjs — 27/27 passed (upsert/restore union cap, distinct multi-note dedup, floating selection mouse-down hold & scroll dismissal, review note dedent & >16 batch fallback).
  • cargo test --locked -p maka-workbench --lib -- fullscreen_composer_ — 2/2 passed (including headless inline annotation typing and quote-only send without composer body).
  • cargo test --locked -p maka-agent-facts -p maka-app-client -p maka-agent-native --lib -- quote — all passed (XML rendering, blank note rejection, restart persistence, shared projection budget).
  • cargo test --locked -p maka-cli --test upgrade_compat — passed (upgrade_compat_capsule_roundtrip).
  • node scripts/ci.mjs run contracts, check i18n, check licenses, check migrations — all passed.
  • rustfmt --edition 2024 --check on all modified .rs files and biome check on all 51 modified JS/TS/JSON files — clean.
  • Not run locally: Windows/Linux native builds and full workspace test matrix (covered by CI).

Live macOS desktop verification

Verified on an isolated desktop build against a local mock model server:

  1. Settled drag selection floating toolbar (引用 / 批注 / 旁问)
    Floating selection toolbar on settled drag selection

  2. Multi-passage inline annotations in composer draft tray with live TextViewMark highlight/underline on source message
    Multiple annotated quotes in draft tray with source TextViewMark highlights

  3. Sent annotated turn rendered in history (with <annotated_excerpt> XML verified at mock model endpoint)
    Sent message history rendering excerpts and user comments

  4. Diff ReviewNote unified into structured QuoteRef + note in composer tray
    Diff line review note delivered as structured quote annotation

AI use

Select exactly one:

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: Maka (design research, implementation, automated & live macOS verification, and code review). Commits carry the Generated-by: Maka trailer.

Checklist

  • Tests cover the change and fail without it
  • Format, typecheck and the affected suites pass locally

Does this PR entail a breaking change or persisted-data migration?

  • Yes — describe user/data impact, in-place migration, and upgrade_compat.rs coverage under Summary above
  • No (strictly additive optional note field with #[serde(default, skip_serializing_if = "Option::is_none")]; cold-migration readback & live send verified in upgrade_compat.rs)

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

…side quotes\n\nExtend QuoteRef with an optional QuoteNote so users can select one or\nmore passages from assistant replies or diffs, attach per-passage\ncomments, and send them directly or alongside composer text.\n\n- Backend & contracts: add QuoteNote newtype and optional QuoteRef.note;\n render plain quotes identically (<quoted_excerpt>) to preserve prompt\n cache while rendering annotated quotes as <annotated_excerpt>; share\n the 28 KiB history projection budget across excerpts and notes; prefer\n quote notes in empty-body queue previews; cover cold-migration and\n live annotated sends in upgrade_compat.rs.\n- NSH selection signal: expose dragging on TextSelectionEvent across\n nsh-core, nsh-base, macOS/Windows selectable views, and headless tests\n so floating UI appears only after drag selection settles.\n- Workbench annotations & unification: add floating SelectionToolbar\n (Quote / Comment / Ask beside) on macOS/Windows plus context-menu\n entry everywhere, collapsible inline note editing in DraftQuotes with\n bounded scroll and live TextViewMark linkage, history/pending note\n rendering, and iOS read-only display. Unify SideQuestion gathered\n passages and Diff/File ReviewNote onto QuoteRef + note (with >16\n batch text fallback).\n\nGenerated-by: Maka
@github-actions github-actions Bot added the effort/XL Under 2500 readable lines label Dec 1, 2026
…cted note edits\n\nAddress re-review findings:\n- Collapse floating toolbar visibility in messageSelection into a single\n signal + phase so native live -> justCleared -> pressHeld transitions\n never emit an intermediate null that unmounts the hit-tested button.\n- Return acceptance boolean from ComposerSession.setQuoteNote so\n DraftQuotes reverts the controlled <Input> immediately when a note\n edit is rejected (e.g. restore union cap).\n- Gate DraftQuotes' Ask beside action on canAskSideWithQuotes so empty\n sessions without a fork anchor hide the button instead of exposing a\n no-op.\n\nGenerated-by: Maka

@jackwener jackwener left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Keep saved drafts readable after rolling back

Saving a draft with an annotated quote writes the new note property into the journal's existing quotes column. If the user rolls back to the previous build and reopens that conversation, its strict QuoteRef decoder rejects the field. The journal propagates the error for the whole draft, so the existing text and attachments never reach the composer and the editor stays disabled. Journal write · Previous draft loader

I exercised the Rust quote types from both commits. Both read plain quotes. The new type round-tripped an annotated quote, and the previous type rejected the serialized list with unknown field note. This verifies the decoding step. A full desktop rollback remains to be tested.

Please keep the draft readable by the rollback build and preserve the annotation for a subsequent upgrade. A regression should save a draft containing text, an attachment, and an annotated quote, then check that the previous build can reopen the draft and that the newer build can recover the annotation.


Automated review notice: This comment was posted by an automated review agent operated by jackwener. It is not an independent human review and does not replace one.

@jackwener jackwener left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved at the author's direction. The required GitHub check and 27 local tests passed. The earlier review records the draft decoding behavior when rolling back to the previous build.


Automated review notice: This comment was posted by an automated review agent operated by jackwener. It is not an independent human review and does not replace one.

@M4n5ter
M4n5ter merged commit b7fb5b5 into main Dec 1, 2026
1 check passed
@M4n5ter
M4n5ter deleted the feat/quote-annotations branch December 1, 2026 15:11
jay23606 added a commit to jay23606/maka that referenced this pull request Dec 1, 2026
…side quotes (apache#7504)

* feat(agent,workbench): add inline quote annotations and unify review/side quotes\n\nExtend QuoteRef with an optional QuoteNote so users can select one or\nmore passages from assistant replies or diffs, attach per-passage\ncomments, and send them directly or alongside composer text.\n\n- Backend & contracts: add QuoteNote newtype and optional QuoteRef.note;\n  render plain quotes identically (<quoted_excerpt>) to preserve prompt\n  cache while rendering annotated quotes as <annotated_excerpt>; share\n  the 28 KiB history projection budget across excerpts and notes; prefer\n  quote notes in empty-body queue previews; cover cold-migration and\n  live annotated sends in upgrade_compat.rs.\n- NSH selection signal: expose dragging on TextSelectionEvent across\n  nsh-core, nsh-base, macOS/Windows selectable views, and headless tests\n  so floating UI appears only after drag selection settles.\n- Workbench annotations & unification: add floating SelectionToolbar\n  (Quote / Comment / Ask beside) on macOS/Windows plus context-menu\n  entry everywhere, collapsible inline note editing in DraftQuotes with\n  bounded scroll and live TextViewMark linkage, history/pending note\n  rendering, and iOS read-only display. Unify SideQuestion gathered\n  passages and Diff/File ReviewNote onto QuoteRef + note (with >16\n  batch text fallback).\n\nGenerated-by: Maka

* fix(workbench): make floating selection handover atomic and sync rejected note edits\n\nAddress re-review findings:\n- Collapse floating toolbar visibility in messageSelection into a single\n  signal + phase so native live -> justCleared -> pressHeld transitions\n  never emit an intermediate null that unmounts the hit-tested button.\n- Return acceptance boolean from ComposerSession.setQuoteNote so\n  DraftQuotes reverts the controlled <Input> immediately when a note\n  edit is rejected (e.g. restore union cap).\n- Gate DraftQuotes' Ask beside action on canAskSideWithQuotes so empty\n  sessions without a fork anchor hide the button instead of exposing a\n  no-op.\n\nGenerated-by: Maka
M4n5ter pushed a commit that referenced this pull request Dec 3, 2026
…ations (#7531)

Carry forward the CI repairs on Jack's branch and clean up follow-up regressions:\n\n- Fix the missing ACP ModelChoice.provider_id test fixture and format markdown-toc.test.mjs with Biome.\n- Update stale test expectations for NSH drag-lift selection events, desktop Google Gemini -> Antigravity connection flow, folded Bot turn layout settlement, archived Read page newlines, iOS Room recovery New Chat locator, and Agent replay/stack sizing.\n- Retain plaintext reasoning normalization policy on reused Responses wire prefixes via a shared wire::install helper.\n- Restore light-theme iOS pressed glass action contrast (#D9E8F2, 4.57:1) and narrow HostListNotices offline state from a single snapshot.\n- Keep macOS popup autofocus pending until first-frame show and resolve AppKit field editor ownership in keymap::editing.\n- Isolate Markdown TOC native list scroll state per turn inside TocHeadingList (covering docked, compact-pinned, and section lists) and drop the obsolete syncedTurn reuse branch.\n- Decode saved eval batch CellRecord outcomes via serde_json::Value so arbitrary_precision feature unification preserves numeric fields inside tagged enums.\n- Restore the resident-pressure model.has_wire_prefix() assertion in Agent driver wire prefix reuse tests.\n\nRefs #7443, #7488, #7395, #7499, #7503, #7504, #7505, #7456, #7515.\n\nCo-authored-by: jackwener <jakevingoo@gmail.com>\nCo-authored-by: M4n5ter <m4n5terrr@gmail.com>\nGenerated-by: Claude Code (Claude Opus 5.5)\nGenerated-by: Maka (OpenAI)\nGenerated-by: OpenAI Codex\nGenerated-by: Maka (Gemini 4 Neon)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/XL Under 2500 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants