@plannotator/ui 0.46.1 → 0.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HANDOFF.md +114 -3
- package/README.md +41 -2
- package/components/AISettingsTab.tsx +6 -0
- package/components/AgentsTab.tsx +11 -1
- package/components/AnnotationPanel.tsx +44 -3
- package/components/BlockRenderer.tsx +55 -1
- package/components/CompletionOverlay.tsx +23 -1
- package/components/MarkdownEditor.tsx +9 -0
- package/components/ModelSourceHint.tsx +49 -0
- package/components/PRPlatformIcon.tsx +22 -0
- package/components/QuestionProgressChip.tsx +66 -0
- package/components/QuestionsPanelSection.tsx +121 -0
- package/components/Settings.tsx +25 -1
- package/components/Viewer.tsx +169 -6
- package/components/ai/AIProviderBar.tsx +11 -3
- package/components/blocks/QuestionBlock.tsx +591 -0
- package/config/settings.ts +17 -0
- package/hooks/useAgentSettings.ts +8 -1
- package/hooks/useAnnotationHighlighter.ts +4 -0
- package/hooks/useCodeAnnotationDraft.ts +24 -7
- package/hooks/useModelCatalogs.ts +28 -11
- package/hooks/usePinpoint.ts +10 -0
- package/hooks/useScrollKeyRouting.ts +157 -0
- package/hooks/useUndoHistory.ts +17 -0
- package/hooks/useVimDocumentFocus.ts +2 -1
- package/package.json +4 -4
- package/styles.css +1 -1
- package/types.ts +3 -0
- package/utils/aiProvider.ts +4 -0
- package/utils/autoUpdateNotice.ts +59 -0
- package/utils/decisionSpec.ts +36 -2
- package/utils/parser.ts +125 -563
- package/utils/questionAnswers.ts +227 -0
package/HANDOFF.md
CHANGED
|
@@ -189,10 +189,12 @@ We deliberately did **not** restructure the exports map in this PR (move-don't-r
|
|
|
189
189
|
| `theme` / `styles.css` | Theme tokens + precompiled stylesheet. **Prefer `styles.css`.** The raw `theme` export still `@import`s KaTeX (re-acquiring the fonts `styles.css` deliberately excludes, as separate lazy files) and contains Tailwind v4 `@theme` at-rules, so it's inert without Tailwind processing. |
|
|
190
190
|
| `types` | `Annotation`, `Block`, `AnnotationType`, etc. |
|
|
191
191
|
| `utils/parser` (`parseMarkdownToBlocks`, `exportAnnotations`) | Pure — no backend. |
|
|
192
|
+
| `utils/questionAnswers` (`upsertQuestionAnswerAnnotation`, `collectQuestionAnswers`, `resolveQuestionAnswers`, `questionAnswerToAnnotation`, `buildQuestionPanelRows`, `questionProgress`, `nextOpenQuestionKey`, `focusQuestionCard`) | Pure (except `focusQuestionCard`, which scrolls and focuses a card in the DOM). Applies `Viewer`'s `onAnswerQuestion` to your annotation list and derives the panel rows and progress (0.48.0; see "Questions in documents"). |
|
|
193
|
+
| `components/QuestionProgressChip`, `components/QuestionsPanelSection` | The header "N/M answered" chip and the panel's Questions section (0.48.0). `AnnotationPanel` renders the section itself when you pass `questionRows`. |
|
|
192
194
|
| `components/BlockRenderer` + the block components it renders (`TableBlock`, `HtmlBlock`, `Callout`, `MermaidBlock`, `MathBlock`, …) | Pure rendering. |
|
|
193
195
|
| `components/InlineMarkdown` | Code-file hover previews route through the `docPreviewFetcher` seam. Wiki-link rendering takes the sync `resolveLinkedDoc` prop (live labels + deleted-doc treatment; see "Wiki-link seams (0.27.0)"). |
|
|
194
196
|
| `components/Viewer` | The full annotatable document. Required props: `markdown` and `taterMode` (pass `false`). **Pass `disableCodePathValidation` unless you implement `/api/doc/exists`** — code-path validation is a prop-level opt-out, not a `configure` seam. `annotationHeader={{ onInputMethodChange, onModeChange, hideQuickLabel? }}` opts into one Viewer-owned, in-flow header containing the compact annotation controls and existing document actions. It reserves its measured responsive height, preserves all document badges, and follows `stickyActions` as one unit; omit it for the legacy action bar. Compact mode contains no help link. `hideQuickLabel` still requires the host to clamp restored mode state away from `'quickLabel'`. A host-owned scroll element must be supplied through `ScrollViewportProvider` (`hooks/useScrollViewport`) so stuck chrome and anchor clearance use the real scroller. |
|
|
195
|
-
| `components/MarkdownEditor` | Theme-bridging wrapper over `@plannotator/markdown-editor`. Takes CM6 extensions via the `extensions` prop (captured ONCE per `documentId` — see "Wiki-link seams (0.27.0)") and re-exports `wikiLinks`, `embedPicker`, `embedSlashItem`, `planEmbedInsert`, and their public types. |
|
|
197
|
+
| `components/MarkdownEditor` | Theme-bridging wrapper over `@plannotator/markdown-editor`. Takes CM6 extensions via the `extensions` prop (captured ONCE per `documentId` — see "Wiki-link seams (0.27.0)") and re-exports `wikiLinks`, `linkWidgets`, `refreshLinkWidgets` (0.47.0), `embedPicker`, `embedSlashItem`, `planEmbedInsert`, and their public types. |
|
|
196
198
|
| `components/MarkdownDiff` | Theme-bridging wrapper over `@plannotator/markdown-editor`'s frozen two-revision diff. Same shim pattern as `components/MarkdownEditor` (ThemeProvider bridge, `extensions` passthrough, grid card chrome); never editable. See "Frozen markdown diff (0.28.0)". |
|
|
197
199
|
| `components/CommentPopover` | Anchor capture + comment entry. Ask-AI UI renders only if you pass `onAskAI`. |
|
|
198
200
|
| `components/AnnotationPanel` | Renders from your annotation state; no fetches of its own. |
|
|
@@ -1511,11 +1513,11 @@ Behaviour changes a host may notice:
|
|
|
1511
1513
|
- `useAgentSettings(catalogs?)` takes the catalogs and returns EFFECTIVE (resolved) model/effort values; called without catalogs it returns the saved values unchanged, as before.
|
|
1512
1514
|
- `AIProviderModel` is now an alias of `CatalogModel` (adds optional `resolvedId`, `fastMode`); `resolveAIModelForProvider` uses the shared resolver, so a stale pinned id keeps its model family instead of snapping to the provider default.
|
|
1513
1515
|
|
|
1514
|
-
## Forge-aware `#123` / `@user` links (
|
|
1516
|
+
## Forge-aware `#123` / `@user` links (additive; #1596; published in core 0.25.6 / ui 0.46.x)
|
|
1515
1517
|
|
|
1516
1518
|
Bare `#123` and `@user` in a document used to link to github.com whenever `githubRepo` held a slash, so GitLab and GitHub Enterprise repos got links to the wrong forge. `InlineMarkdown` (and every block component that forwards `githubRepo`: `BlockRenderer`, `RenderedMarkdown`, `TableBlock`, `TablePopout`, `AlertBlock`, `Callout`, `proseBody`) gains an optional `repoHost?: string` beside it; `Viewer` passes `repoInfo.host`. The rule is the new `@plannotator/core/forge-refs` subpath (`forgeRefLinks`, `classifyForgeHost`, `normalizeForgeHost`). The host is normalized first: lowercased, port dropped, `www.github.com` / `ssh.github.com` / SSH aliases starting `github.com-` folded to `github.com` and `altssh.gitlab.com` to `gitlab.com`; a host that is not a plausible DNS name (no dot, brackets, `@`, a dotless SSH alias) counts as absent. Then a github host (`github.com`, `github.*`) links to `https://<host>/<path>/issues/N`, a gitlab host (`gitlab.com`, `gitlab.*`, `*.gitlab.*`) to `https://<host>/<path>/-/issues/N`, users to `https://<host>/<user>`, and any other host renders the ref as an unlinked span. **A host that passes no `repoHost` (or an implausible one) keeps the old github.com links**, so nothing changes until it opts in. Because ui imports a new core subpath and `@plannotator/ui` pins `@plannotator/core` EXACTLY (currently `"0.25.6"`), the core version bump and ui's pin must move together in the same release: bump core, set ui's `@plannotator/core` dependency to that same version, `bun install`, then publish `core` first and `ui` second. A ui built against this code on the old core pin would import a `forge-refs` subpath the pinned core does not ship.
|
|
1517
1519
|
|
|
1518
|
-
## Guided Review generation in core (core 0.25.6,
|
|
1520
|
+
## Guided Review generation in core (core 0.25.6, published, additive)
|
|
1519
1521
|
|
|
1520
1522
|
Core-only; `@plannotator/ui` imports none of it, so ui's exact `0.25.6` pin is unchanged. The pure half of Guided Review generation moved verbatim from the private `@plannotator/server` (`packages/server/guide/guide-review.ts`, which re-exports every name) so a host such as Workspaces generates guides with Plannotator's exact prompt and holds the output to the same coverage rule. All three subpaths are browser-safe and zero-dependency:
|
|
1521
1523
|
|
|
@@ -1525,8 +1527,117 @@ Core-only; `@plannotator/ui` imports none of it, so ui's exact `0.25.6` pin is u
|
|
|
1525
1527
|
|
|
1526
1528
|
The guide chain's engine plumbing (Claude/Codex/marker commands, output parsing, `composeGuideMethodology`, sessions) stays in the server. It ships in core 0.25.6 alongside what that unpublished version already carries; ui needs no change for it.
|
|
1527
1529
|
|
|
1530
|
+
## Host link widgets (0.47.0, core 0.25.7)
|
|
1531
|
+
|
|
1532
|
+
Additive. `components/MarkdownEditor` re-exports the engine's new link seam beside `wikiLinks`: `linkWidgets(...specs: LinkWidgetSpec[]): Extension`, `refreshLinkWidgets: StateEffectType<null>`, and the types `LinkWidgetSpec` (`{ match(link: LinkWidgetLink): WidgetType | null }`) and `LinkWidgetLink` (`{ url; text; title?; from; to }`). They are the engine's own objects (identity pinned by `MarkdownEditor.linkWidgets.test.tsx`); hosts import them from `@plannotator/ui/components/MarkdownEditor`, never from `@plannotator/atomic-editor`.
|
|
1533
|
+
|
|
1534
|
+
- **What it does.** For a single-line `[text](url)` link the inline preview would draw with its syntax hidden, the engine asks each registered spec in order; the first non-null widget replaces the whole link range (no link mark, no hidden `[` / `](url)` replaces, no open-in-new-tab icon beside it). `null` keeps the engine's link. Revealed links, multi-line links, reference / autolinks / wiki links, links inside tables and links wrapping an image are never offered. A spec that throws is logged once and skipped.
|
|
1535
|
+
- **The reveal rule stays the engine's.** Caret inside, overlapping selection, focus, the pointer-press freeze and `MarkdownDiff` changed ranges decide when the raw bytes show, exactly as for a normal link, so a widget comes and goes when the hidden syntax would. The source text is never changed.
|
|
1536
|
+
- **`match` runs on every rebuild** (selection, focus, document change): synchronous, no side effects, and implement `eq` on the widget so an unchanged widget keeps its DOM. Do not `preventDefault` on `mousedown` in the widget: it blocks a drag selection that starts on it.
|
|
1537
|
+
- **Refreshing.** When a spec's answer changes without a document edit (a record arrives after mount), dispatch `view.dispatch({ effects: refreshLinkWidgets.of(null) })`. It changes no text, adds no history entry and sends nothing through collab bindings; during a held pointer press the rebuild waits for the release.
|
|
1538
|
+
- **Composition.** `linkWidgets(spec)` goes in the same stable `extensions` array as `wikiLinks`, captured once per `documentId`. Several `linkWidgets(...)` extensions concatenate in extension order.
|
|
1539
|
+
|
|
1540
|
+
**Dependency note:** 0.47.0 requires `@plannotator/atomic-editor ^0.9.0` (adds the seam) and `@plannotator/markdown-editor ^0.5.0` (widens its engine peer to `^0.8.0 || ^0.9.0`). A host that pins either exactly (e.g. through package-manager overrides) must move both pins with the ui bump. Plannotator's own apps pass no `linkWidgets`, so their editor is unchanged.
|
|
1541
|
+
|
|
1542
|
+
Also new in 0.47.0 (all additive, all no-op for a host that passes nothing):
|
|
1543
|
+
|
|
1544
|
+
- **`useCodeAnnotationDraft` `persistViewedFiles?: boolean`** (default `true`, #1632). `false` leaves viewed-file state out of the draft: autosave omits `viewedFiles` / `autoViewSuppressed`, an empty-annotations session with only viewed files counts as empty, the restore banner ignores viewed counts, and `restoreDraft()` returns empty viewed lists. For hosts that persist review progress on their own (Plannotator's review app now does, server-side).
|
|
1545
|
+
- **Model source hint** (#1616). New module `components/ModelSourceHint` (`ModelSourceHint`, `modelSourceHint`, `modelSourceToolForProvider`, types `ModelSourceTool` / `ModelSourceInfo`): a muted line under a Claude/Codex model picker ("From your installed Codex 0.155.1", or the built-in-list variant). `ModelCatalog` (`hooks/useModelCatalogs`) and `AIProviderConfig` (`utils/aiProvider`) gain optional `modelsSource` and `toolVersion`, read from `/api/ai/capabilities`; the hint renders only when the server sends `toolVersion`, so a host whose backend omits it sees no change. `AgentsTab`, `AISettingsTab` and `AIProviderBar` render it.
|
|
1546
|
+
- **Guided Review Codex default** (#1616): `PREFERRED_GUIDE_CODEX_MODEL` (`'gpt-6-luna'`) from `hooks/useAgentSettings`; an unset guide Codex pick resolves to it when the catalog offers it, else to Codex's own default. Never written to the cookie.
|
|
1547
|
+
- **Agent job warnings** (#1627): `AgentsTab` shows `AgentJobInfo.warning` under a job row when present.
|
|
1548
|
+
- **Request changes on PR reviews** (#1611): `buildDecisionSpec`'s platform input takes optional `requestChangesSupported`. Absent keeps the previous copy; `false` says request-changes posts as a comment; `true` with `selfAuthored` mutes Request changes and adds a live `Comment…` row.
|
|
1549
|
+
|
|
1550
|
+
### `@plannotator/core` 0.25.7
|
|
1551
|
+
|
|
1552
|
+
Required by ui 0.47.0 (`components/ModelSourceHint` and `hooks/useModelCatalogs` import the new `ModelsSource` type). Changes since the published 0.25.6, all additive:
|
|
1553
|
+
|
|
1554
|
+
- `@plannotator/core/model-catalog`: new `ModelsSource` type (`'fallback' | 'discovered'`) and `cliVersionFrom(text, toolLine?)` (reads a CLI's version out of `claude --version` or the codex app-server `userAgent`). `CODEX_FALLBACK_MODELS` refreshed to what codex 0.155.1 reports (GPT-6 Sol / Astra / Luna, GPT-5.6 Sol / Terra / Luna, GPT-5.5; efforts up to `max` / `ultra`). `claudeCatalogFromSdk` names a model from `displayName` when the SDK `description` is only a tagline (no ` · `), which Claude Code 2.1.282+ emits (#1615).
|
|
1555
|
+
- `@plannotator/core/agent-jobs`: optional `AgentJobInfo.warning` (#1627).
|
|
1556
|
+
- `@plannotator/core/agents`: the `mistral-vibe` origin in `AGENT_CONFIG` (#1480, merged just after 0.25.6 was published).
|
|
1557
|
+
- `@plannotator/core/review-prompt`: workspace review context lines now tell the model the inline diff is the complete combined changeset and to read files by folder-prefixed path, instead of suggesting `git -C` (#1629). Prompt text only.
|
|
1558
|
+
|
|
1559
|
+
Minor rather than patch because of the new exports (`cliVersionFrom`, `ModelsSource`).
|
|
1560
|
+
|
|
1561
|
+
## Questions in documents (0.48.0, core 0.25.8)
|
|
1562
|
+
|
|
1563
|
+
Additive. An agent can ask the reviewer questions inside a markdown document with a `:::question` directive, and the reviewer answers in place. The approved design is the "Card" variant: an eyebrow ("Question 2 of 4", "· pick any" on multi), a status tag (Open / ✓ Answered / Skipped / ✓ Settled), the prompt, its context, the choices, and a footer with Add note · Skip · a right-aligned **Accept recommended**.
|
|
1564
|
+
|
|
1565
|
+
```markdown
|
|
1566
|
+
:::question
|
|
1567
|
+
Where should losing conflict versions be kept?
|
|
1568
|
+
|
|
1569
|
+
Last-write-wins silently drops the loser unless we keep it somewhere.
|
|
1570
|
+
|
|
1571
|
+
- [ ] Local only, purged after 30 days — cheap, no server change
|
|
1572
|
+
- [ ] Server-side per user — survives reinstall, needs a retention policy
|
|
1573
|
+
|
|
1574
|
+
Recommended: Local only, purged after 30 days
|
|
1575
|
+
:::
|
|
1576
|
+
```
|
|
1577
|
+
|
|
1578
|
+
**`@plannotator/core/question-block` (new subpath, pure):**
|
|
1579
|
+
|
|
1580
|
+
- `parseQuestionBlock(directiveKind, body)` returns a `ParsedQuestion` or **null** when the block is not a question (no prompt, wrong kind, over `MAX_QUESTION_BODY_CHARS`). It never throws. It is tolerant: tight or spaced markdown, `-`/`*`/`+`/`1.` markers, plain bullets as choices when there are no task-list items, indented continuation lines, `Recommended:` / `**Recommended:**` / `Recommendation:` / `➡️` / `->` / `=>` / `→`, a `label — reason` recommendation, and a `,` / `;` / `and` list on multi questions. `- [x]` means **settled** (already decided), not recommended.
|
|
1581
|
+
- `indexQuestionBlocks(blocks)` numbers the document's question blocks, gives the prompt's document line, and de-duplicates keys (`-2`, `-3`…). It takes a structural block shape, so it works on your own block list.
|
|
1582
|
+
- `questionKey(kind, prompt)` = `q-` + an 8-hex FNV-1a hash of the kind and the normalized prompt. It is stable across versions while the prompt is unchanged. A reworded prompt is a new question.
|
|
1583
|
+
- `QuestionAnswer` (`{ v: 1, key, kind, prompt, selected: labels[], other?, text?, note?, skipped?, sourceLine? }`), `parseQuestionAnswer` (fail-closed: wrong types return null, strings are truncated to the caps), `isQuestionAnswered`, `isQuestionAnswerEmpty`, `recommendedQuestionAnswer`, `buildQuestionAnswerAnnotation` (structural record, `type: 'COMMENT'`).
|
|
1584
|
+
- `formatQuestionAnswersSection(items, answers, { headingLevel })`, `questionExportItems(index)`, `formatQuestionAnswerLines`, `formatQuestionAnswerText`.
|
|
1585
|
+
- `QUESTION_AUTHORING_GUIDE`: the syntax reference as one markdown string. Put it in your own agent prompts. Plannotator's `plannotator` skill carries the same text byte for byte (a test keeps them equal).
|
|
1586
|
+
|
|
1587
|
+
**`@plannotator/ui`:**
|
|
1588
|
+
|
|
1589
|
+
- `Annotation.questionAnswer?: QuestionAnswer`. An answer is ONE annotation, id `ann-question-<key>`, `blockId` = the question block, `originalText` = the prompt, `text` = a one-line answer (`Answer: Local only — note: …`), offsets 0. A consumer that does not know the field still reads it as a comment. Your annotation store and `draftTransport` carry it as opaque JSON. Nothing new to persist.
|
|
1590
|
+
- `Viewer` `onAnswerQuestion?(blockId, answer | null, key)`: the only new prop. The Viewer derives every card's state from its `annotations` prop (matched by key, so an answer follows its question across re-parses). On a change it calls the handler with the next answer, or `null` when the answer became empty. Apply it with `upsertQuestionAnswerAnnotation(annotations, blockId, answer, key)` (`utils/questionAnswers`; replaces in place and keeps `createdA`, appends when new, removes on null/empty). With no handler, or `readOnly`, the cards render disabled and still show stored answers.
|
|
1591
|
+
- `BlockRenderer` takes optional `question` / `questionTotal` / `questionAnswer` / `onAnswerQuestion`. Without them (plan diff, `RenderedMarkdown`) a question block is parsed alone and renders read-only and unnumbered.
|
|
1592
|
+
- `components/blocks/QuestionBlock` is exported for a host that renders blocks itself.
|
|
1593
|
+
- The highlighter skips rows carrying `questionAnswer` (neither painted nor attempted nor unanchored), the same rule `diagramAnchor` rows follow.
|
|
1594
|
+
- Exporters: `exportAnnotations` prints `## Answers to your questions` right after the title (before reference images and the numbered feedback): `N of M questions answered.`, one `### Q<n>. <prompt> (line L)` entry per answered, skipped or noted question (`Answer: X (your recommendation)`, a bullet list for several picks, a blockquote for free text, `Skipped`, `Note: …`), an `### Unanswered` list, and answers whose question is no longer in the document. Answers are not counted in "I've reviewed this plan and have N pieces of feedback". Questions the agent settled with `[x]` and the reviewer left alone are neither counted nor listed as unanswered. `exportLinkedDocAnnotations` prints the same section per document one level deeper; `exportAnnotationEntry` prints one answer. A row whose `questionAnswer` fails validation exports as an ordinary comment. A document with questions but no answers and no feedback still exports `No changes detected.`
|
|
1595
|
+
- Interaction: native `<input type=radio|checkbox>` inside a `<label>`. A click on a row picks only when the pointer moved less than 4 px (10 px touch) and no text is selected, so a drag across option text is an annotation, never a pick. The eyebrow, tags and footer are `annotation-exclude` / `select-none` / `data-pinpoint-ignore`; the prompt, context and choice text are not. "Other…" is always offered. There are no required questions and no new keyboard shortcuts.
|
|
1596
|
+
- Fallback: an unparseable block renders through the existing directive `Callout`; a ui older than 0.48.0 renders every `:::question` that way (the prompt and the task list as text).
|
|
1597
|
+
|
|
1598
|
+
**Progress, the panel and history (also 0.48.0, the editor PR):**
|
|
1599
|
+
|
|
1600
|
+
- `AnnotationPanel` `questionRows?` + `onSelectQuestion?`: pass `buildQuestionPanelRows(blocks, annotations)` and the panel renders a **Questions** section (progress, one row per question with its answer or "Not answered yet" and an Open / answered / Skipped state) above a **Comments** heading, and stops listing answer rows as comment cards. A row whose question is no longer in the document shows the Unanchored chip and a "Remove answer" link that calls your `onDelete(annotationId)`; it still exports. Without `questionRows` the panel is unchanged (answers list as comment cards, as in the first 0.48.0 cut).
|
|
1601
|
+
- `QuestionProgressChip` (`done`, `total`, `hasOpen`, `onJump`): the header "N/M answered" chip. `questionProgress(rows)` counts answered and settled questions; `nextOpenQuestionKey(rows, afterKey)` walks the open ones in document order and wraps; `focusQuestionCard(key)` scrolls the card to the centre and focuses its first control.
|
|
1602
|
+
- Core: `questionStatus(question, answer)` is the one status rule (answered / skipped / settled / open) the card, the rows and the chip share. The export counts a settled `[x]` question the reviewer only added a note to as answered, printing its settled choice with the note, and a multi-line note keeps its line breaks as a blockquote.
|
|
1603
|
+
- Card fixes: a double-click on a word in an option selects the word and takes back the pick its first click made; in pinpoint input mode a click on option text pins the text and does not pick the option (a click on the radio itself answers and does not pin); the free-text, "Other…" and note fields are `annotation-exclude`, so a text-search restore never lands inside typed text.
|
|
1604
|
+
- History: `useUndoHistory` gains `replaceLast(expected, next)` (fold into the newest entry while it is still the one you recorded). Plannotator records one entry per answer change and folds a typing burst into one; a host with its own history can do the same.
|
|
1605
|
+
|
|
1606
|
+
**No `configurePlannotatorUI` seam** is involved. Plannotator's server does not change.
|
|
1607
|
+
|
|
1608
|
+
**guides.show:** the viewer JS is unchanged, but the shared stylesheet gained the card's utility classes, so `guide-viewer-manifest.ts` pins a new CSS hash. Deploy guides.show before a release that ships this manifest.
|
|
1609
|
+
|
|
1610
|
+
## Question host seams (ui 0.49.0, core 0.25.9)
|
|
1611
|
+
|
|
1612
|
+
Additive. What a host that keeps question answers ITSELF needs (Workspaces stores answers beside the document as structured records, not as Plannotator annotations, and turns some answers into project decisions). Plannotator passes none of the new props: its cards render exactly as in 0.48.0, except that a block carrying a `Decision:` line now shows it (below).
|
|
1613
|
+
|
|
1614
|
+
**`@plannotator/core/question-block`:**
|
|
1615
|
+
|
|
1616
|
+
- **Decision lines.** A `Decision:` line after the prompt, at the start of a line (no indentation), is read once per block and kept out of `context`:
|
|
1617
|
+
- `Decision: when answered` (case-insensitive, trailing period allowed) sets `ParsedQuestion.decisionOnAnswer: true`: the asker flags that the answer should become a recorded decision.
|
|
1618
|
+
- `Decision: [statement](url)` (exactly one markdown link, absolute `http:`/`https:` only) sets `ParsedQuestion.decision: { statement, url }` (`QuestionDecisionLink`): the decision exists. When both lines are present the link wins and `decisionOnAnswer` is absent.
|
|
1619
|
+
- Any other `Decision:` value (a relative or `javascript:` link, prose around the link, a second flag line) stays context prose. A `Decision:` line BEFORE the prompt is the prompt, as before. Neither form changes `questionKey`, so adding, removing or replacing the line never orphans an answer.
|
|
1620
|
+
- An older Plannotator shows both lines as one line of context, which still reads correctly.
|
|
1621
|
+
- **`findQuestionBlocks(markdown, { frontmatter? })`** returns `QuestionBlockLocation[]`: `{ key, directiveKind, startLine, endLine, text }` per parseable question block in document order. Lines are 1-based lines of the original text (frontmatter counted); `endLine` is the closing `:::`, or the last line when the block is never closed (it then runs to the end, as it renders); `text` is the exact source of those lines. Keys are de-duplicated exactly like `indexQuestionBlocks` (`-2`, `-3`… for repeated prompts; one shared helper), so **always address a block by the returned key**. For a server that has to find or verify a question without the UI parser.
|
|
1622
|
+
- **`@plannotator/core/markdown-structure`** (new subpath): the block splitter's structural rules, moved out of `@plannotator/ui/utils/parser` so `findQuestionBlocks` and `parseMarkdownToBlocks` share one copy: `splitFrontmatter`, `resolveReferenceLinks`, `markProtectedLines`, `htmlBlockEndAt` / `findHtmlBlockEnd` / `HTML_BLOCK_TAGS`, `codeFenceCloseIndex`, `scanDisplayMath`, `DIRECTIVE_OPEN_RE` / `directiveCloseIndex`. `utils/parser` still exports `HTML_BLOCK_TAGS`, `resolveReferenceLinks` and `extractFrontmatter`, unchanged. A parity test (`packages/ui/utils/questionBlockParity.test.ts`) runs both over fenced, nested, quoted, HTML, math, frontmatter, reference-link, CRLF and unclosed cases and asserts the same keys and lines.
|
|
1623
|
+
|
|
1624
|
+
**`@plannotator/ui` (`Viewer`, forwarded through `BlockRenderer` to `QuestionBlock`):**
|
|
1625
|
+
|
|
1626
|
+
- **`questionAnswers?: ReadonlyMap<string, QuestionAnswer> | Record<string, QuestionAnswer>`**, keyed by the de-duplicated question key. When given, the cards read their answers from it and NEVER from `annotations` (an empty map means "no answers"); entries that fail `parseQuestionAnswer` are dropped. Absent: the annotation path, unchanged. The pure resolver is `resolveQuestionAnswers(annotations, hostAnswers?)` in `utils/questionAnswers`.
|
|
1627
|
+
- **`onSaveQuestionAnswer?(key, answer | null) => void | Promise<unknown>`**: explicit save mode, taking precedence over `onAnswerQuestion`. Edits stay a draft inside the card; while the draft differs from the host's answer the footer shows **Save answer** and **Cancel**, and **Skip is not offered** (skip is a live-mode draft state that a save never writes). Save calls the handler once with the key and the answer (null when the draft is empty); return a promise to keep the draft on screen until it settles, and a rejection keeps the draft for a retry (report the error yourself). Cancel returns to the host's `answer`. Ignored under `readOnly`.
|
|
1628
|
+
- **`saveQuestionAnswerLabel?: string | ((question: ParsedQuestion) => string)`**: the Save button's label in explicit save mode (e.g. "Save and record decision" for a flagged question). Default "Save answer". The card never picks a label from `decisionOnAnswer` itself: the host does the recording, so only the host may claim it.
|
|
1629
|
+
- **`renderQuestionFooter?(question: IndexedQuestion, answer: QuestionAnswer | undefined) => ReactNode`**: host actions at the right end of a card's footer (e.g. "Mark as decision"), given the SAVED answer, never the draft. Rendered in read-only cards too (return null for nothing). To make that work, read-only cards now disable each input instead of the whole `<fieldset>` (a disabled fieldset disables every button inside it); the fieldset carries `aria-disabled` instead.
|
|
1630
|
+
- **Decision display.** A flagged question shows a "Records a decision" tag in the eyebrow and a row under the prompt reading "Answering this records a decision"; a linked one shows a "Decision" tag and a row with the statement as a link to the URL (new tab, `noopener noreferrer`). The card carries `data-question-decision="on-answer" | "recorded"` and the row `data-question-decision-row`. The banner's "Don't record a decision" toggle and the guest/no-project variants in the Workspaces frames are host UI: put them in the footer slot.
|
|
1631
|
+
|
|
1632
|
+
**guides.show:** the viewer JS is unchanged, but the shared stylesheet gained the decision row's utility classes, so `guide-viewer-manifest.ts` pins a new CSS hash. Deploy guides.show before a release that ships this manifest.
|
|
1633
|
+
|
|
1634
|
+
Not here (dropped with the owner's Q2 answer): record lines inside the block (`Other:`, `Answer:`, `Note:`, `Answered:`) and a `writeQuestionAnswer` byte rewriter.
|
|
1635
|
+
|
|
1528
1636
|
## Publishing & versioning
|
|
1529
1637
|
|
|
1638
|
+
- **core 0.25.9 / ui 0.49.0 (question host seams): both change. Publish `core` first**: ui imports the new `@plannotator/core/markdown-structure` subpath and the new `findQuestionBlocks` / decision fields, so a ui on a published core 0.25.8 fails to compile in a consumer. See "Question host seams (ui 0.49.0, core 0.25.9)".
|
|
1639
|
+
- **core 0.25.8 / ui 0.48.0 (questions in documents): both change. Publish `core` 0.25.8 first, then `ui` 0.48.0**, which pins core `0.25.8` exactly and imports the new `@plannotator/core/question-block` subpath. Core is a patch bump because its change is additive and pre-1.0 caret ranges would not accept a minor. See "Questions in documents (0.48.0, core 0.25.8)".
|
|
1640
|
+
- **core 0.25.7 / ui 0.47.0 (host link widgets + model source hint + `persistViewedFiles`): both packages change, and both need unpublished upstream packages first.** Order: `@plannotator/atomic-editor` 0.9.0, then `@plannotator/markdown-editor` 0.5.0, then `bun install` here to refresh `bun.lock`, then publish `core` 0.25.7, then `ui` 0.47.0. ui pins core `0.25.7` exactly, `@plannotator/atomic-editor` `^0.9.0` and `@plannotator/markdown-editor` `^0.5.0`. See "Host link widgets (0.47.0, core 0.25.7)".
|
|
1530
1641
|
- **ui 0.46.1 (fix, ui only, core pin unchanged at `0.25.6`):** `useVimSelection` (mounted by every `Viewer`) now only clears a page selection whose anchor or focus lies inside the viewer's own container; with vim off it used to clear the WHOLE page's selection on every mount and `contentVersion` change, so a selection in another host panel vanished whenever the document behind it loaded or changed.
|
|
1531
1642
|
- **ui 0.45.0 (annotation card header slot + mentions on the card's edit box): `@plannotator/ui` only — `@plannotator/core` is UNCHANGED at `0.25.5`, so this publishes alone** (core 0.25.5 must already be published). Purely additive over 0.44.0, both props on `AnnotationPanel`: `renderCardHeader` (the header-row twin of `renderCardFooter`, wrapper `[data-annotation-card-header]`, renders under `readOnly`, open-document cards only in the All-files view) and `mentionSource` (the 0.43.0 type, applied to the card's EDIT box, saving `onEdit(id, { text, mentions })` only when a source was supplied and a pick survived). Nothing is removed, no new supported imports (`components/MentionAutocomplete` is internal glue), no export-, share- or archive-visible change, and Plannotator passes neither — `packages/editor` and `packages/review-editor` have zero source diff, and the panel is byte-identical to 0.44.0. Known difference from `CommentPopover`: no chips in the card's edit box (follow-up named in the section). See "Annotation card header slot and mentions on the edit box (0.45.0)".
|
|
1532
1643
|
- **ui 0.44.0 (mention token chips in the composer): `@plannotator/ui` only — `@plannotator/core` is UNCHANGED at `0.25.5`, so this publishes alone** (core 0.25.5 must already be published). Purely additive over 0.43.2: the `@Label` tokens a `mentionSource` composer inserted render as chips in the composer's existing highlight overlay, `MentionSource.tokenClassName?` lets a host restyle them (under the metric rule), `useMentionAutocomplete` also returns the surviving `mentions`, and `utils/composerTokens` joins the supported-import list. Nothing is removed, no export-, share- or archive-visible change, and Plannotator passes none of it — with neither `mentionSource` nor `skillReferences` the composer is byte-identical to 0.43.2. See "Mention token chips in the composer (0.44.0)".
|
package/README.md
CHANGED
|
@@ -75,9 +75,16 @@ Plannotator's own entries import the eager math and identity modules (`math-eage
|
|
|
75
75
|
<MarkdownEditor markdown={md} documentId={docId} editorHandleRef={ref} extensions={editorExtensions} />
|
|
76
76
|
```
|
|
77
77
|
- **`embedPicker(config)` and `embedSlashItem()` are re-exported from the same surface.** Compose the static item into `slashCommands({ items: [...] })` and pass the picker beside it in the stable `extensions` array. `getTargets`, `buildInsertLine`, optional `uploadTarget`, and optional `getNotice` stay live through callbacks. Optional `labels` (`upload`, `empty`, `noMatch(query)`) reword the three rows that say "HTML"; absent keys keep the built-in text. The host owns embed grammar and upload error UI; the package owns filtering, async anchor mapping, single-flight upload state, and paragraph-safe insertion through the re-exported `planEmbedInsert()`.
|
|
78
|
+
- **`linkWidgets(...specs)` and `refreshLinkWidgets` are re-exported from the same surface** (since 0.47.0, engine `@plannotator/atomic-editor` ^0.9.0), with the types `LinkWidgetSpec` and `LinkWidgetLink`. A spec's `match(link)` gets `{ url, text, title?, from, to }` for a single-line `[text](url)` link whose syntax the engine would hide, and returns a CM6 `WidgetType` to draw in the link's place (first non-null spec wins) or `null` for the engine's normal link. The reveal rule (caret, focus, pointer-press freeze, diff ranges) stays the engine's, so the widget comes and goes exactly when the hidden syntax would; `match` is never asked about table-cell links or links wrapping an image. `match` runs on every rebuild: keep it synchronous and side-effect free and implement `eq` on the widget. When the answer changes without a document edit (data arrived after mount), dispatch `view.dispatch({ effects: refreshLinkWidgets.of(null) })`; it changes no text and adds no history entry.
|
|
79
|
+
```tsx
|
|
80
|
+
import { linkWidgets, refreshLinkWidgets, type LinkWidgetSpec } from "@plannotator/ui/components/MarkdownEditor";
|
|
81
|
+
|
|
82
|
+
const spec: LinkWidgetSpec = { match: (link) => (isMine(link.url) ? new MyChip(link) : null) };
|
|
83
|
+
const editorExtensions = [linkWidgets(spec)]; // stable reference!
|
|
84
|
+
```
|
|
78
85
|
- **The viewer resolves wiki-links synchronously.** `InlineMarkdown` takes `resolveLinkedDoc?: (target) => { label?; status?: 'active' | 'deleted' } | null` — called with the raw stored target (opaque ids like `doc_01XYZ`, no `.md` normalization). Return a `label` to display live titles (stored label is the fallback, target the last resort); return `status: 'deleted'` for a muted non-link ("Document deleted") instead of a live link. Absent or `null` → rendering is unchanged. Sync-only by design: back it with an in-memory cache.
|
|
79
86
|
|
|
80
|
-
|
|
87
|
+
Wiki links require `@plannotator/markdown-editor ^0.3.2` and `@plannotator/atomic-editor ^0.7.0` (see HANDOFF.md § "Wiki-link seams (0.27.0)"); link widgets require `@plannotator/markdown-editor ^0.5.0` and `@plannotator/atomic-editor ^0.9.0`, which is what 0.47.0 declares (see HANDOFF.md § "Host link widgets (0.47.0)").
|
|
81
88
|
|
|
82
89
|
### Frozen markdown diff (`MarkdownDiff`)
|
|
83
90
|
|
|
@@ -206,6 +213,14 @@ common case) applies inside the header too and pulls the action cluster out of
|
|
|
206
213
|
its row. Scope such rules away from the header, e.g.
|
|
207
214
|
`[data-viewer-document-header] [data-sticky-actions] { margin-top: 0; margin-right: 0; }`.
|
|
208
215
|
|
|
216
|
+
With `stickyActions` on, the legacy bar's `[data-sticky-actions]` cluster is no
|
|
217
|
+
longer the sticky element or a float: it pins inside a zero-height
|
|
218
|
+
`[data-sticky-actions-lane]`, beside a static float that reserves the title's
|
|
219
|
+
wrap space. Both copy the cluster's measured size and margins, so margin
|
|
220
|
+
overrides on `[data-sticky-actions]` still apply. Do not give the cluster
|
|
221
|
+
`position: sticky` and a float together: Firefox narrows float-avoiding blocks
|
|
222
|
+
such as table and code wrappers around a sticky float's stuck position.
|
|
223
|
+
|
|
209
224
|
The config is intentionally typed rather than a React-node slot. Viewer reuses
|
|
210
225
|
its existing `mode`, `inputMethod`, and `taterMode`; the config supplies only
|
|
211
226
|
the state-change callbacks and optional `hideQuickLabel`. Compact toolstrips
|
|
@@ -344,6 +359,30 @@ The engine that lets a browser-integrated agent (Chrome/Edge WebMCP, `document.m
|
|
|
344
359
|
|
|
345
360
|
The one additive data-model change that rides with it: `Annotation.inReplyTo` (threaded replies; the panel indents them under the parent, the export nests them, share links drop them).
|
|
346
361
|
|
|
362
|
+
### Questions in documents (`:::question`; 0.48.0, core 0.25.8)
|
|
363
|
+
|
|
364
|
+
An agent writes `:::question` (pick one), `:::question-multi` (pick any) or `:::question-text` (free text) blocks in a markdown document; `Viewer` renders each as an answer card (`components/blocks/QuestionBlock`) with native radios / checkboxes, an always-present "Other…", Add note · Skip · Accept recommended. Question and choice text stay selectable and annotatable; a drag across option text never picks it.
|
|
365
|
+
|
|
366
|
+
- **Grammar, key, answer shape, export section, authoring guide:** `@plannotator/core/question-block` (`parseQuestionBlock`, `indexQuestionBlocks`, `questionKey`, `QuestionAnswer`, `parseQuestionAnswer`, `formatQuestionAnswersSection`, `QUESTION_AUTHORING_GUIDE` — the syntax reference to put in your own agent prompts).
|
|
367
|
+
- **Storage is an annotation.** An answer is one row with `Annotation.questionAnswer` (id `ann-question-<key>`). The Viewer draws answers from its existing `annotations` prop, so your annotation persistence and `draftTransport` carry them unchanged.
|
|
368
|
+
- **One new optional prop:** `Viewer` `onAnswerQuestion?(blockId, answer | null, key)`. Apply it with `upsertQuestionAnswerAnnotation(annotations, blockId, answer, key)` from `utils/questionAnswers` and store the result. Without the prop (or under `readOnly`) the cards render read-only, still showing stored answers.
|
|
369
|
+
- **Export:** `exportAnnotations` / `exportLinkedDocAnnotations` / `exportAnnotationEntry` print answers in an "Answers to your questions" section before the numbered feedback, with no host action.
|
|
370
|
+
- An unparseable block (no prompt) renders as the ordinary directive callout; a ui older than 0.48.0 renders every `:::question` that way.
|
|
371
|
+
- **Progress and panel (optional):** pass `questionRows={buildQuestionPanelRows(blocks, annotations)}` to `AnnotationPanel` for the Questions section (answers then leave the comment timeline), and mount `QuestionProgressChip` with `questionProgress(rows)` / `nextOpenQuestionKey(rows)` / `focusQuestionCard(key)` for the "N/M answered" chip.
|
|
372
|
+
|
|
373
|
+
See HANDOFF.md § "Questions in documents (0.48.0, core 0.25.8)".
|
|
374
|
+
|
|
375
|
+
**A host that keeps answers itself (ui 0.49.0, core 0.25.9).** All optional on `Viewer`; Plannotator passes none of them:
|
|
376
|
+
|
|
377
|
+
- `questionAnswers` (Map or object keyed by the de-duplicated question key): the cards read answers from here instead of from `annotations`.
|
|
378
|
+
- `onSaveQuestionAnswer(key, answer | null)`: explicit save mode. Edits stay a draft in the card, which shows Save answer and Cancel (no Skip); return a promise to hold the draft until the save settles.
|
|
379
|
+
- `saveQuestionAnswerLabel` (string, or `(question) => string`): the Save button's label in explicit save mode. Default "Save answer"; never derived from `Decision: when answered`, since only the host knows whether its save records a decision.
|
|
380
|
+
- `renderQuestionFooter(question, savedAnswer)`: host actions at the right of the card's footer (e.g. "Mark as decision"), live in read-only cards too.
|
|
381
|
+
- Core reads a `Decision: when answered` line after the prompt as `ParsedQuestion.decisionOnAnswer` and a `Decision: [statement](https://…)` line as `ParsedQuestion.decision`; the card shows either. Neither changes the key.
|
|
382
|
+
- `findQuestionBlocks(markdown)` (core) locates each question block by key, line range and exact text, without the UI parser; it shares the block splitter's rules through the new `@plannotator/core/markdown-structure` subpath, so it agrees with what renders.
|
|
383
|
+
|
|
384
|
+
See HANDOFF.md § "Question host seams (ui 0.49.0, core 0.25.9)".
|
|
385
|
+
|
|
347
386
|
## Consuming it (e.g. from Workspaces)
|
|
348
387
|
|
|
349
388
|
```bash
|
|
@@ -367,7 +406,7 @@ npm install @plannotator/ui @plannotator/core
|
|
|
367
406
|
- `@plannotator/core` — pure utils + types, zero deps, browser-safe (CI enforces no `node:` imports). Published.
|
|
368
407
|
- `@plannotator/ui` — React components/hooks + theme + `configure()`. Depends on an exact published `@plannotator/core` version. Published.
|
|
369
408
|
- `@plannotator/shared`, `@plannotator/ai` — stay private to the monorepo; `shared` re-exports `core`'s modules via shims so Plannotator's internals are untouched.
|
|
370
|
-
- Currently `@plannotator/ui` 0.
|
|
409
|
+
- Currently `@plannotator/ui` 0.48.0 depends exactly on `@plannotator/core` 0.25.8. `core` is bumped only when something under `packages/core` changes, so `ui` can advance alone. Keep the published core version exact in `packages/ui/package.json`; do not use a `workspace:` protocol there, because a directly published manifest must remain installable outside this monorepo. Bun still links the matching local workspace during development. When both packages change, publish `core` first, then build and publish the UI tarball. See HANDOFF.md "Publishing & versioning" for the verification command.
|
|
371
410
|
|
|
372
411
|
## The one rule
|
|
373
412
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
2
|
import { getProviderMeta } from './ProviderIcons';
|
|
3
|
+
import { ModelSourceHint, modelSourceToolForProvider } from './ModelSourceHint';
|
|
3
4
|
import {
|
|
4
5
|
getAIProviderSettings,
|
|
5
6
|
resolveAIProviderSelection,
|
|
@@ -121,6 +122,11 @@ export const AISettingsTab: React.FC<AISettingsTabProps> = ({
|
|
|
121
122
|
))}
|
|
122
123
|
</select>
|
|
123
124
|
</label>
|
|
125
|
+
<ModelSourceHint
|
|
126
|
+
tool={modelSourceToolForProvider(p.name)}
|
|
127
|
+
info={p}
|
|
128
|
+
className="mt-1.5 text-[10px] text-muted-foreground/60"
|
|
129
|
+
/>
|
|
124
130
|
</div>
|
|
125
131
|
)}
|
|
126
132
|
|
package/components/AgentsTab.tsx
CHANGED
|
@@ -23,6 +23,7 @@ import { useAgentSettings } from '../hooks/useAgentSettings';
|
|
|
23
23
|
import type { AgentEngine, AgentMode, ReviewEngine } from '../hooks/useAgentSettings';
|
|
24
24
|
import type { AgentLaunchParams } from '../hooks/useAgentJobs';
|
|
25
25
|
import { ConfigRow, SegmentedPicker, Toggle, SelectMenu } from './AgentControls';
|
|
26
|
+
import { ModelSourceHint } from './ModelSourceHint';
|
|
26
27
|
import {
|
|
27
28
|
CLAUDE_FALLBACK_MODELS,
|
|
28
29
|
CODEX_FALLBACK_MODELS,
|
|
@@ -429,6 +430,12 @@ function JobCard({
|
|
|
429
430
|
</button>
|
|
430
431
|
)}
|
|
431
432
|
|
|
433
|
+
{job.warning && (
|
|
434
|
+
<p role="status" data-agent-job-warning className="mt-1.5 ml-4 text-[10px] leading-snug text-warning">
|
|
435
|
+
{job.warning}
|
|
436
|
+
</p>
|
|
437
|
+
)}
|
|
438
|
+
|
|
432
439
|
{/* Error details — fallback for when the dockview detail panel is not available */}
|
|
433
440
|
{!onViewDetails && job.status === 'failed' && job.error && expanded && (
|
|
434
441
|
<div className="mt-2 rounded bg-destructive/5 border border-destructive/20 p-2">
|
|
@@ -1015,7 +1022,10 @@ export const AgentsTab: React.FC<AgentsTabProps> = ({
|
|
|
1015
1022
|
) => (
|
|
1016
1023
|
<ConfigRow label="Model" stacked>
|
|
1017
1024
|
{catalogs[engine].settled ? (
|
|
1018
|
-
|
|
1025
|
+
<>
|
|
1026
|
+
<SelectMenu value={value} options={modelSelectOptions(catalogs[engine].models, value)} onChange={onChange} />
|
|
1027
|
+
<ModelSourceHint tool={engine} info={catalogs[engine]} className="text-[10px] text-muted-foreground/50" />
|
|
1028
|
+
</>
|
|
1019
1029
|
) : (
|
|
1020
1030
|
renderStaticChoice('Loading models…', <Loader2 className="animate-spin text-muted-foreground" size={11} />)
|
|
1021
1031
|
)}
|
|
@@ -13,6 +13,8 @@ import { cn } from '../lib/utils';
|
|
|
13
13
|
import { resolveReplyParents, resolveThreadRootTimestamps } from '@plannotator/core/annotation-threads';
|
|
14
14
|
import { ROOT_DOCUMENT_GROUP_KEY } from '../utils/annotationScope';
|
|
15
15
|
import type { AnnotationScope, AnnotationDocumentGroup } from '../utils/annotationScope';
|
|
16
|
+
import type { QuestionPanelRow } from '../utils/questionAnswers';
|
|
17
|
+
import { QuestionsPanelSection } from './QuestionsPanelSection';
|
|
16
18
|
|
|
17
19
|
// Card type-word colors. Deletion uses `destructive` (reliably red on every
|
|
18
20
|
// theme, matching the in-document .deletion highlight). Comment uses the
|
|
@@ -177,6 +179,16 @@ interface PanelProps {
|
|
|
177
179
|
onDeleteInDocument?: (path: string, id: string) => void;
|
|
178
180
|
/** Edit an annotation in its owning document's store. */
|
|
179
181
|
onEditInDocument?: (path: string, id: string, updates: Partial<Annotation>) => void;
|
|
182
|
+
/**
|
|
183
|
+
* `:::question` rows for the open document (`buildQuestionPanelRows`).
|
|
184
|
+
* Supplied, a Questions section renders above a Comments section and the
|
|
185
|
+
* answer annotations (rows carrying `questionAnswer`) leave the comment
|
|
186
|
+
* timeline; a row whose question is gone offers Remove through `onDelete`.
|
|
187
|
+
* Absent, the panel is unchanged and answers list as comment cards.
|
|
188
|
+
*/
|
|
189
|
+
questionRows?: readonly QuestionPanelRow[];
|
|
190
|
+
/** A Questions row was clicked (the host scrolls to the card). */
|
|
191
|
+
onSelectQuestion?: (row: QuestionPanelRow) => void;
|
|
180
192
|
}
|
|
181
193
|
|
|
182
194
|
export const AnnotationPanel: React.FC<PanelProps> = ({
|
|
@@ -212,13 +224,20 @@ export const AnnotationPanel: React.FC<PanelProps> = ({
|
|
|
212
224
|
onSelectInDocument,
|
|
213
225
|
onDeleteInDocument,
|
|
214
226
|
onEditInDocument,
|
|
227
|
+
questionRows,
|
|
228
|
+
onSelectQuestion,
|
|
215
229
|
}) => {
|
|
216
230
|
const isMobile = useIsMobile();
|
|
217
231
|
const embedded = presentation === 'embedded';
|
|
218
232
|
const mobilePanel = isMobile && !embedded;
|
|
219
233
|
const [copiedText, setCopiedText] = useState(false);
|
|
220
234
|
const listRef = useRef<HTMLDivElement>(null);
|
|
221
|
-
|
|
235
|
+
// With a Questions section, answers are listed there, not as comments.
|
|
236
|
+
const showQuestions = questionRows !== undefined && questionRows.length > 0;
|
|
237
|
+
const timelineAnnotations = questionRows !== undefined
|
|
238
|
+
? annotations.filter((a) => a.questionAnswer == null)
|
|
239
|
+
: annotations;
|
|
240
|
+
const sortedAnnotations = [...timelineAnnotations].sort((a, b) => a.createdA - b.createdA);
|
|
222
241
|
const sortedCodeAnnotations = [...codeAnnotations].sort((a, b) => a.createdAt - b.createdAt);
|
|
223
242
|
// Replies (`inReplyTo`) thread under their parent: each reply is lifted to
|
|
224
243
|
// sit right after its parent (and the parent's earlier replies) at the
|
|
@@ -237,6 +256,7 @@ export const AnnotationPanel: React.FC<PanelProps> = ({
|
|
|
237
256
|
return a.ts - b.ts;
|
|
238
257
|
});
|
|
239
258
|
const totalCount = annotations.length + codeAnnotations.length + (editorAnnotations?.length ?? 0);
|
|
259
|
+
const timelineCount = timelineAnnotations.length + codeAnnotations.length + (editorAnnotations?.length ?? 0);
|
|
240
260
|
|
|
241
261
|
// --- Cross-file scope (opt-in: a host that passes neither prop is unchanged) ---
|
|
242
262
|
const scopeEnabled = annotationScope !== undefined && onAnnotationScopeChange !== undefined;
|
|
@@ -383,11 +403,28 @@ export const AnnotationPanel: React.FC<PanelProps> = ({
|
|
|
383
403
|
{directEdits?.map((item) => (
|
|
384
404
|
<DirectEditsCard key={item.id} {...item} onDiscard={readOnly ? undefined : item.onDiscard} />
|
|
385
405
|
))}
|
|
406
|
+
{showQuestions && (
|
|
407
|
+
<>
|
|
408
|
+
<QuestionsPanelSection
|
|
409
|
+
rows={questionRows!}
|
|
410
|
+
onSelect={onSelectQuestion}
|
|
411
|
+
onRemoveOrphan={readOnly ? undefined : (row) => { if (row.annotationId) onDelete(row.annotationId); }}
|
|
412
|
+
/>
|
|
413
|
+
<div className="mx-0.5 mt-1 flex items-center gap-2 text-[11px] font-semibold uppercase tracking-[0.07em] text-muted-foreground">
|
|
414
|
+
<span className="flex-1">Comments</span>
|
|
415
|
+
<span className="tabular-nums">{showGroups ? groupedTotal : timelineCount}</span>
|
|
416
|
+
</div>
|
|
417
|
+
</>
|
|
418
|
+
)}
|
|
386
419
|
{showGroups ? (
|
|
387
420
|
<>
|
|
388
421
|
{groups.map((group) => {
|
|
389
422
|
const collapsed = collapsedGroups.has(group.path);
|
|
390
|
-
|
|
423
|
+
// The open document's answers are in the Questions section.
|
|
424
|
+
const groupAnnotations = group.isCurrent && questionRows !== undefined
|
|
425
|
+
? group.annotations.filter((a) => a.questionAnswer == null)
|
|
426
|
+
: group.annotations;
|
|
427
|
+
const sorted = [...groupAnnotations].sort((a, b) => a.createdA - b.createdA);
|
|
391
428
|
const threaded = threadReplies(sorted);
|
|
392
429
|
return (
|
|
393
430
|
<section key={group.path} data-annotation-group={group.path}>
|
|
@@ -509,7 +546,11 @@ export const AnnotationPanel: React.FC<PanelProps> = ({
|
|
|
509
546
|
</button>
|
|
510
547
|
)}
|
|
511
548
|
</>
|
|
512
|
-
) :
|
|
549
|
+
) : timelineCount === 0 && showQuestions ? (
|
|
550
|
+
<p className="px-1 py-2.5 text-[12.5px] text-muted-foreground">
|
|
551
|
+
Select text in the document to comment. Question and option text is selectable too.
|
|
552
|
+
</p>
|
|
553
|
+
) : timelineCount === 0 ? (
|
|
513
554
|
(!directEdits || directEdits.length === 0) && (
|
|
514
555
|
<div className="flex flex-col items-center justify-center px-4 py-16 text-center">
|
|
515
556
|
<p className="text-xs text-muted-foreground/60">
|
|
@@ -8,6 +8,20 @@ import { Callout } from "./blocks/Callout";
|
|
|
8
8
|
import { AlertBlock } from "./blocks/AlertBlock";
|
|
9
9
|
import { TableBlock } from "./blocks/TableBlock";
|
|
10
10
|
import { MathBlock } from "./blocks/MathBlock";
|
|
11
|
+
import { QuestionBlock, type QuestionBlockProps } from "./blocks/QuestionBlock";
|
|
12
|
+
import {
|
|
13
|
+
indexQuestionBlocks,
|
|
14
|
+
isQuestionDirectiveKind,
|
|
15
|
+
type IndexedQuestion,
|
|
16
|
+
type QuestionAnswer,
|
|
17
|
+
} from "@plannotator/core/question-block";
|
|
18
|
+
|
|
19
|
+
/** A question block rendered outside a Viewer's document index (plan diff,
|
|
20
|
+
* other markdown surfaces): parsed alone, unnumbered. */
|
|
21
|
+
const standaloneQuestion = (block: Block): IndexedQuestion | undefined => {
|
|
22
|
+
const [indexed] = indexQuestionBlocks([block]);
|
|
23
|
+
return indexed ? { ...indexed, number: 0 } : undefined;
|
|
24
|
+
};
|
|
11
25
|
|
|
12
26
|
export const BlockRenderer: React.FC<{
|
|
13
27
|
block: Block;
|
|
@@ -22,7 +36,22 @@ export const BlockRenderer: React.FC<{
|
|
|
22
36
|
repoHost?: string;
|
|
23
37
|
headingAnchorId?: string;
|
|
24
38
|
onNavigateAnchor?: (hash: string) => void;
|
|
25
|
-
|
|
39
|
+
/** `:::question` blocks: this block's entry in the document's question
|
|
40
|
+
* index (numbering, key, prompt line) and the document's question count.
|
|
41
|
+
* Absent, a question block is parsed on its own and shows no "N of M". */
|
|
42
|
+
question?: IndexedQuestion;
|
|
43
|
+
questionTotal?: number;
|
|
44
|
+
/** The answer to draw (from the annotation carrying `questionAnswer`). */
|
|
45
|
+
questionAnswer?: QuestionAnswer;
|
|
46
|
+
/** Absent: question blocks render read-only. */
|
|
47
|
+
onAnswerQuestion?: (blockId: string, answer: QuestionAnswer | null, key: string) => void;
|
|
48
|
+
/** Explicit save mode for question cards (see `QuestionBlock`). */
|
|
49
|
+
onSaveQuestionAnswer?: QuestionBlockProps['onSaveAnswer'];
|
|
50
|
+
/** Label of the explicit-save-mode Save button (see `QuestionBlock`). */
|
|
51
|
+
saveQuestionAnswerLabel?: QuestionBlockProps['saveLabel'];
|
|
52
|
+
/** Host actions in a question card's footer (see `QuestionBlock`). */
|
|
53
|
+
renderQuestionFooter?: QuestionBlockProps['renderFooter'];
|
|
54
|
+
}> = ({ block, onOpenLinkedDoc, onOpenCodeFile, imageBaseDir, onImageClick, onToggleCheckbox, checkboxOverrides, orderedIndex, githubRepo, repoHost, headingAnchorId, onNavigateAnchor, question, questionTotal, questionAnswer, onAnswerQuestion, onSaveQuestionAnswer, saveQuestionAnswerLabel, renderQuestionFooter }) => {
|
|
26
55
|
switch (block.type) {
|
|
27
56
|
case 'heading': {
|
|
28
57
|
const Tag = `h${block.level || 1}` as React.ElementType;
|
|
@@ -135,6 +164,31 @@ export const BlockRenderer: React.FC<{
|
|
|
135
164
|
|
|
136
165
|
case 'directive': {
|
|
137
166
|
const kind = block.directiveKind || 'note';
|
|
167
|
+
if (isQuestionDirectiveKind(kind)) {
|
|
168
|
+
// An unparseable question (no prompt) falls through to the callout.
|
|
169
|
+
const indexed = question ?? standaloneQuestion(block);
|
|
170
|
+
if (indexed) {
|
|
171
|
+
return (
|
|
172
|
+
<QuestionBlock
|
|
173
|
+
blockId={block.id}
|
|
174
|
+
indexed={indexed}
|
|
175
|
+
total={questionTotal ?? 0}
|
|
176
|
+
answer={questionAnswer}
|
|
177
|
+
onAnswer={onAnswerQuestion}
|
|
178
|
+
onSaveAnswer={onSaveQuestionAnswer}
|
|
179
|
+
saveLabel={saveQuestionAnswerLabel}
|
|
180
|
+
renderFooter={renderQuestionFooter}
|
|
181
|
+
onOpenLinkedDoc={onOpenLinkedDoc}
|
|
182
|
+
onOpenCodeFile={onOpenCodeFile}
|
|
183
|
+
imageBaseDir={imageBaseDir}
|
|
184
|
+
onImageClick={onImageClick}
|
|
185
|
+
githubRepo={githubRepo}
|
|
186
|
+
repoHost={repoHost}
|
|
187
|
+
onNavigateAnchor={onNavigateAnchor}
|
|
188
|
+
/>
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
138
192
|
return (
|
|
139
193
|
<Callout
|
|
140
194
|
blockId={block.id}
|
|
@@ -29,9 +29,15 @@ interface CompletionOverlayProps {
|
|
|
29
29
|
title: string;
|
|
30
30
|
subtitle: string;
|
|
31
31
|
agentLabel: string;
|
|
32
|
+
/**
|
|
33
|
+
* Optional destinations shown under the subtitle as ordinary links (opened
|
|
34
|
+
* in a new tab by a real click, so no popup blocker applies) — e.g. the PR
|
|
35
|
+
* a platform review was just posted to. Omitted or empty renders nothing.
|
|
36
|
+
*/
|
|
37
|
+
links?: ReadonlyArray<{ href: string; label: string }>;
|
|
32
38
|
}
|
|
33
39
|
|
|
34
|
-
export function CompletionOverlay({ submitted, title, subtitle, agentLabel }: CompletionOverlayProps) {
|
|
40
|
+
export function CompletionOverlay({ submitted, title, subtitle, agentLabel, links }: CompletionOverlayProps) {
|
|
35
41
|
const { state, enableAndStart } = useAutoClose(!!submitted);
|
|
36
42
|
|
|
37
43
|
if (!submitted) return null;
|
|
@@ -52,6 +58,22 @@ export function CompletionOverlay({ submitted, title, subtitle, agentLabel }: Co
|
|
|
52
58
|
<div className="space-y-2">
|
|
53
59
|
<h2 className="text-xl font-semibold text-foreground">{title}</h2>
|
|
54
60
|
<p className="text-muted-foreground">{subtitle}</p>
|
|
61
|
+
{links && links.length > 0 && (
|
|
62
|
+
<div className="flex flex-col items-center gap-1 pt-1">
|
|
63
|
+
{links.map((link) => (
|
|
64
|
+
<a
|
|
65
|
+
key={link.href}
|
|
66
|
+
href={link.href}
|
|
67
|
+
target="_blank"
|
|
68
|
+
rel="noopener noreferrer"
|
|
69
|
+
data-completion-link
|
|
70
|
+
className="text-sm font-medium text-primary underline-offset-4 hover:underline break-all"
|
|
71
|
+
>
|
|
72
|
+
{link.label}
|
|
73
|
+
</a>
|
|
74
|
+
))}
|
|
75
|
+
</div>
|
|
76
|
+
)}
|
|
55
77
|
</div>
|
|
56
78
|
|
|
57
79
|
<div className="pt-4 border-t border-border space-y-2">
|
|
@@ -34,6 +34,15 @@ export type { SlashCommandItem, SlashCommandsConfig } from '@plannotator/atomic-
|
|
|
34
34
|
export { selectionToolbar } from '@plannotator/atomic-editor';
|
|
35
35
|
export type { SelectionToolbarConfig, InlineFormat } from '@plannotator/atomic-editor';
|
|
36
36
|
|
|
37
|
+
/* Host link widgets (engine ≥0.9.0), re-exported for the same reason as
|
|
38
|
+
wikiLinks. linkWidgets(...specs) lets a host swap an inline markdown link
|
|
39
|
+
for its own WidgetType when a spec's match(link) returns one (null keeps
|
|
40
|
+
the engine's normal link rendering). Compose it through the `extensions`
|
|
41
|
+
prop; dispatch refreshLinkWidgets.of(null) on the view to re-run every
|
|
42
|
+
spec's match after host state the specs read has changed. */
|
|
43
|
+
export { linkWidgets, refreshLinkWidgets } from '@plannotator/atomic-editor';
|
|
44
|
+
export type { LinkWidgetSpec, LinkWidgetLink } from '@plannotator/atomic-editor';
|
|
45
|
+
|
|
37
46
|
/* Host-configured embed media authoring. The picker is per editor mount so its
|
|
38
47
|
callbacks can close over live route state; nothing enters configurePlannotatorUI.
|
|
39
48
|
The package owns paragraph-safe splicing while the host owns embed grammar. */
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { ModelsSource } from '@plannotator/core/model-catalog';
|
|
3
|
+
|
|
4
|
+
/** The tools whose model lists are discovered from the installed CLI. */
|
|
5
|
+
export type ModelSourceTool = 'claude' | 'codex';
|
|
6
|
+
|
|
7
|
+
export interface ModelSourceInfo {
|
|
8
|
+
modelsSource?: ModelsSource;
|
|
9
|
+
toolVersion?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const TOOL_NAME: Record<ModelSourceTool, string> = {
|
|
13
|
+
claude: 'Claude Code',
|
|
14
|
+
codex: 'Codex',
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/** The hint tool for an Ask AI provider type (`claude-agent-sdk`, `codex-sdk`); null for the rest. */
|
|
18
|
+
export function modelSourceToolForProvider(providerType: string | null | undefined): ModelSourceTool | null {
|
|
19
|
+
if (providerType === 'claude-agent-sdk') return 'claude';
|
|
20
|
+
if (providerType === 'codex-sdk') return 'codex';
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Where the model list under a picker came from. Only when the server reports
|
|
26
|
+
* the tool's version: a host that does not send it gets no hint.
|
|
27
|
+
*/
|
|
28
|
+
export function modelSourceHint(tool: ModelSourceTool | null | undefined, info: ModelSourceInfo | null | undefined): string | null {
|
|
29
|
+
if (!tool || !info?.toolVersion) return null;
|
|
30
|
+
const name = TOOL_NAME[tool];
|
|
31
|
+
if (info.modelsSource === 'discovered') return `From your installed ${name} ${info.toolVersion}`;
|
|
32
|
+
if (info.modelsSource === 'fallback') return `Using the built-in list — update or sign in to ${name} to see its latest models`;
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** A muted line under a model picker; renders nothing when there is no hint. */
|
|
37
|
+
export const ModelSourceHint: React.FC<{
|
|
38
|
+
tool: ModelSourceTool | null | undefined;
|
|
39
|
+
info: ModelSourceInfo | null | undefined;
|
|
40
|
+
className?: string;
|
|
41
|
+
}> = ({ tool, info, className }) => {
|
|
42
|
+
const text = modelSourceHint(tool, info);
|
|
43
|
+
if (!text) return null;
|
|
44
|
+
return (
|
|
45
|
+
<p data-model-source-hint={info?.modelsSource} className={className}>
|
|
46
|
+
{text}
|
|
47
|
+
</p>
|
|
48
|
+
);
|
|
49
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { GitHubIcon } from "./GitHubIcon";
|
|
3
|
+
import { GitLabIcon } from "./GitLabIcon";
|
|
4
|
+
|
|
5
|
+
/** Bitbucket bucket mark (simple-icons, CC0). Uses currentColor. */
|
|
6
|
+
export const BitbucketIcon: React.FC<{ className?: string }> = ({ className }) => (
|
|
7
|
+
<svg
|
|
8
|
+
className={className}
|
|
9
|
+
viewBox="0 0 24 24"
|
|
10
|
+
fill="currentColor"
|
|
11
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
12
|
+
>
|
|
13
|
+
<path d="M.778 1.213a.768.768 0 00-.768.892l3.263 19.81c.084.5.515.868 1.022.873H19.95a.772.772 0 00.77-.646l3.27-20.03a.768.768 0 00-.768-.891zM14.52 15.53H9.522L8.17 8.466h7.561z" />
|
|
14
|
+
</svg>
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
/** The mark of the platform a PR/MR lives on. Unknown platforms get GitHub's. */
|
|
18
|
+
export const PRPlatformIcon: React.FC<{ platform: string; className?: string }> = ({ platform, className }) => {
|
|
19
|
+
if (platform === "gitlab") return <GitLabIcon className={className} />;
|
|
20
|
+
if (platform === "bitbucket") return <BitbucketIcon className={className} />;
|
|
21
|
+
return <GitHubIcon className={className} />;
|
|
22
|
+
};
|