@nxxxsooo/opencode-annotate 0.11.1 → 0.13.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/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.13.0 — auto-sizing reference comments
4
+
5
+ - Add an optional whole-reference comment to `/ref`, kept separate from quoted history.
6
+ - Grow and shrink the comment field with its content, wrap long lines, and scroll within
7
+ a terminal-aware height limit. Multiline paste and Chinese text retain their line breaks.
8
+ - Use **Shift+Enter** for a new line, **Enter** to continue to confirmation, and **Esc** to
9
+ cancel. References still queue for the next prompt without starting a model turn.
10
+
11
+ ## 0.12.0 — Safari companion and compact review toolbar
12
+
13
+ - Add a Safari Web Extension companion built from the shared browser sources, with a
14
+ separate panel window, local notes, restorable rounds and **Copy notes**. Safari has no
15
+ direct OpenCode session delivery; Chrome keeps its existing delivery behavior.
16
+ - Add reproducible Safari build/install scripts and explicit browser selection. Safari
17
+ distribution is source/build support, not a prebuilt signed or notarized application.
18
+ - Keep the selection toolbar compact with four actions: approve, comment, **Done**
19
+ (Enter: the requested work is finished) and **Get** (`g`: understood). Done/Get save
20
+ anchored feedback; Esc only dismisses. `w`, `d` and `y` remain available by keyboard.
21
+ - Add opt-in, locally supplied PNG toolbar artwork using Kitty graphics. Images fit one
22
+ text row, keep action-colored bold shortcuts, and clear with the toolbar. No artwork is
23
+ included; unconfigured terminals keep Unicode icons.
24
+ - Make successful explicit copying clearer: **Copied to clipboard (N chars)**.
25
+
3
26
  ## 0.11.1 — comment cursor movement
4
27
 
5
28
  - Up/Down move the comment and edit cursor across wrapped rows, so long single-paragraph
package/README.md CHANGED
@@ -82,7 +82,10 @@ commands, but cannot register the agent tools.
82
82
 
83
83
  ## Reference another conversation
84
84
 
85
- Run `/ref` or `/ref <title words>`, select the source, then choose **Attach reference**.
85
+ Run `/ref` or `/ref <title words>`, select the source, add an optional comment, then choose
86
+ **Attach reference**. The comment field grows as you type or paste, wraps long lines, and
87
+ scrolls at a screen-aware height limit. **Shift+Enter** adds a line, **Enter** continues to
88
+ confirmation, and **Esc** cancels without attaching anything.
86
89
  The confirmation names both conversations and shows whether the text is an excerpt.
87
90
  The source is attached to the session where you invoked `/ref`, even if you switch tabs.
88
91
  It is queued as historical context with `resume: false`: an idle assistant stays idle
@@ -162,7 +165,45 @@ Launchers must honor an existing `PLANNOTATOR_TUI_CONFIG`.
162
165
 
163
166
  ## Browser review (optional)
164
167
 
165
- Requirements: macOS and Chrome 116+, plus Node 22+ for the native host.
168
+ Requirements: macOS and Chrome 116+ or Safari 18+, plus Node 22+ for the Chrome native host.
169
+
170
+ ### Safari (copy-only)
171
+
172
+ Build the shared browser sources into a Safari Web Extension app with Xcode installed:
173
+
174
+ ```sh
175
+ ANNOTATE_SIGN_IDENTITY="Apple Development: Your Name (TEAMID)" \
176
+ ANNOTATE_DEVELOPMENT_TEAM="TEAMID" npm run build:safari
177
+ npm run install:safari
178
+ ```
179
+
180
+ The installer replaces `/Applications/annotate.app` and refreshes its registration.
181
+ Open that app once, then enable Annotate in Safari > Settings > Extensions. Without
182
+ signing environment variables the build uses an ad-hoc signature, which Safari may
183
+ refuse to register. Allow access to the pages you want to review.
184
+
185
+ Click the Annotate toolbar button, or use Option+Shift+A where Safari supports the
186
+ extension command, to open its standalone panel. Select text or pick an element,
187
+ write notes, then **Copy notes** to paste the round into any agent. Notes and drafts
188
+ stay local; copying closes the round and **Restore last round** recovers it.
189
+
190
+ Safari requires an App-Sandboxed app extension, so it cannot start the Node bridge or
191
+ read the session registry. It has no direct session delivery or session chooser;
192
+ Chrome retains both. Safari also has no docked side panel: its separate window stays
193
+ bound to the reviewed browser window and keeps polling while you work on the page.
194
+
195
+ Set the plugin option `"browser": "Safari"` so `/annotate-web <url-or-html-file>` opens
196
+ the page in Safari. The only public values are `"Chrome"` (default) and `"Safari"`;
197
+ Chrome maps to the macOS app Google Chrome. AGY supports the same choice with
198
+ `agy-annotate web <url> --browser Safari`. Restart the client after changing the option.
199
+ `/annotate-web` keeps its existing pairing lifecycle; Safari ignores that pairing
200
+ and copies notes instead. `/annotate` remains the text/TUI command.
201
+
202
+ After updates, run `npm run build:safari` with the signing variables again, then
203
+ `npm run install:safari`. Reopen the app and re-enable the extension if needed. An
204
+ unpacked Chrome reload does not update the installed Safari app.
205
+
206
+ ### Chrome (direct delivery)
166
207
 
167
208
  1. Clone this repository and load its `browser/` directory as an unpacked extension in
168
209
  `chrome://extensions`. Allow file URL access if reviewing local HTML.
@@ -264,9 +305,11 @@ The manifest version alone cannot identify edits to an unpacked extension.
264
305
  3. Press `c` to comment, `w` for **what?**, `a` for “looks good,” or `d` to request deletion.
265
306
  **what?** marks a passage you don't understand with a short `what?` note
266
307
  ([what? notes](#what-notes)). Without a selection, `c` comments on the current block.
267
- Enter saves a comment.
268
- Selecting never touches the clipboard; press `y` (or click **copy**) to copy the
269
- selected source, and the selection stays for annotating.
308
+ Enter saves a comment. With a selection waiting, Enter records **Done** (the requested
309
+ work is finished), and `g` records **Get** (understood). Esc dismisses without a note.
310
+ The compact toolbar shows approve, comment, Done and Get; `w`, `d` and `y` are keyboard-only.
311
+ Selecting never touches the clipboard; press `y` to copy the selected source and keep
312
+ the selection for annotating.
270
313
  4. Press **`q`** to send your notes and return to OpenCode.
271
314
 
272
315
  **`Ctrl+S`** does the same mid-comment, saving the comment first. The header's **Send N back (q)**
@@ -275,6 +318,10 @@ button does the same as `q`.
275
318
  following any `[keys]` rebinding, and the clipboard copy and Review menu (resend, finish, archive) are hidden
276
319
  because OpenCode owns delivery.
277
320
 
321
+ For real PNG toolbar artwork in a verified Kitty-graphics terminal, see the
322
+ [local image-toolbar configuration](tui/README.md#local-image-toolbar-trial).
323
+ Artwork is user-supplied and not included; unconfigured terminals keep Unicode icons.
324
+
278
325
  ### Chinese and other input methods
279
326
 
280
327
  An input method holds plain letters while it composes, so review keys such as `e`, `q`
@@ -463,7 +510,7 @@ See [release instructions](docs/releasing.md) and [changelog](CHANGELOG.md).
463
510
  - `/annotate-pick`:从最近的回复和运行中的进度说明里选一条批注。
464
511
  - `/annotate-selection`:先在会话里拖选文字,再批注包含这段文字的消息。
465
512
  - `/annotate-last`:固定批注最新一条完整回复,忽略附带参数。
466
- - `/ref`:选择并引用同项目的历史会话;`/ref --all 关键词` 跨项目搜索;`/ref ses_…` 直接指定。确认后附加上下文,不启动空闲助手。
513
+ - `/ref`:选择并引用同项目的历史会话,可附留言;留言框随内容自动增高、换行,超长时滚动。Shift+Enter 换行,Enter 进入确认,Esc 取消。`/ref --all 关键词` 跨项目搜索;`/ref ses_…` 直接指定。确认后附加上下文,不启动空闲助手。
467
514
  - `/annotate-web`:配对 Chrome;空白首页会先创建空会话,无需先发提示词。`/annotate-web 页面.html`、`/annotate-web https://…` 批注网页;`/annotate-web off` 撤销配对。
468
515
  - 选中文字 → `c` 写批注 → Enter 保存 → `q` 发送并返回。
469
516
  - 写批注中途按 `Ctrl+S`,一步保存、返回并发送(中文输入法开着也有效);`Ctrl+C` 返回后由 OpenCode 询问。
package/agy/cli.mjs CHANGED
@@ -12,6 +12,7 @@ import { enqueueAnnotations, listPendingBatches, defaultInboxRoot } from "./inbo
12
12
  import { startAgyDaemon } from "./daemon.mjs"
13
13
  import { listTargets, registryRoot } from "../bridge/receiver.mjs"
14
14
  import { browserTarget } from "../targets.mjs"
15
+ import { openInBrowser } from "../scripts/browser-target.mjs"
15
16
  import { prepareTheme } from "../theme.mjs"
16
17
  import { createInputSource } from "../input-source.mjs"
17
18
  import { resolveTuiBinary } from "../tui/binary.mjs"
@@ -47,6 +48,7 @@ Commands:
47
48
  Options:
48
49
  --session <id> Explicit AGY conversation ID (defaults to cwd-matched active session)
49
50
  --binary <path> Override the bundled Annotate TUI executable
51
+ --browser <name> Browser review: Chrome (default) or Safari (copy only)
50
52
  `)
51
53
  }
52
54
 
@@ -116,14 +118,14 @@ async function cmdWeb(targetArg, options) {
116
118
  }
117
119
 
118
120
  console.log(`✓ Session paired for browser review: "${session.title}" (${session.conversationId.slice(0, 8)})`)
119
- console.log(` Open Chrome extension "Annotate" and choose this session.`)
121
+ console.log(` Open the "Annotate" extension and choose this session (Safari copies notes locally).`)
120
122
 
121
123
  if (targetArg && targetArg.trim()) {
122
124
  const target = await browserTarget(targetArg, session.directory)
123
125
  if (target?.url) {
124
- console.log(` Opening Chrome target: ${target.url}`)
126
+ console.log(` Opening target: ${target.url}`)
125
127
  if (process.platform === "darwin") {
126
- await execute("open", ["-a", "Google Chrome", target.url])
128
+ await openInBrowser(target.url, options)
127
129
  }
128
130
  }
129
131
  }
@@ -323,6 +325,8 @@ async function main() {
323
325
  options.binary = args[++i]
324
326
  } else if (args[i] === "--interactive-tty") {
325
327
  options.interactiveTty = true
328
+ } else if (args[i] === "--browser") {
329
+ options.browser = args[++i]
326
330
  } else if (!args[i].startsWith("-") && !posArg) {
327
331
  posArg = args[i]
328
332
  }
@@ -52,6 +52,7 @@
52
52
  }, { capture: true })
53
53
  on(document, "keydown", event => { if (picking && event.key === "Escape") setPicking(false) })
54
54
  const onMessage = (message, _sender, respond) => {
55
+ if (message.action === "annotate-ping") { respond({ ok: true }); return }
55
56
  if (message.action === "pick") { setPicking(!picking); respond({ ok: true, picking }) }
56
57
  if (message.action === "markers") { markers = message.notes || []; draw(); respond({ ok: true }) }
57
58
  if (message.action === "locate") respond({ states: message.anchors.map(locate) })
@@ -0,0 +1,54 @@
1
+ // Shared engine differences. Safari uses an independent, copy-only panel window;
2
+ // only Chrome reaches the local native messaging bridge.
3
+ export function extensionScheme() {
4
+ try { return new URL(chrome.runtime.getURL("/")).protocol.replace(/:$/, "") } catch { return "" }
5
+ }
6
+ export const isSafari = () => extensionScheme() === "safari-web-extension"
7
+ export const isChrome = () => extensionScheme() === "chrome-extension"
8
+
9
+ // Safari extension UUIDs can differ in case between APIs.
10
+ export function sameExtensionURL(url) {
11
+ if (!url) return false
12
+ try {
13
+ const candidate = new URL(url), own = new URL(chrome.runtime.getURL("/"))
14
+ return candidate.protocol === own.protocol && candidate.host.toLowerCase() === own.host.toLowerCase()
15
+ } catch { return false }
16
+ }
17
+ export function panelWindowID() {
18
+ if (typeof location === "undefined") return undefined
19
+ const raw = new URLSearchParams(location.search).get("window")
20
+ if (raw === null) return undefined
21
+ const id = Number(raw)
22
+ return Number.isInteger(id) && id >= 0 ? id : undefined
23
+ }
24
+ export async function openPanel(tab) {
25
+ if (!isSafari()) return chrome.sidePanel.open({ tabId: tab.id })
26
+ const url = new URL(chrome.runtime.getURL("panel.html"))
27
+ url.searchParams.set("window", String(tab.windowId))
28
+ try { return await chrome.windows.create({ url: url.href, type: "popup", width: 420, height: 860 }) }
29
+ catch (error) { throw new Error(`Could not open the Safari annotation window: ${error.message}`) }
30
+ }
31
+ // Bind the Safari popup to the reviewed browser window, not its own focused window.
32
+ export async function resolveTargetTab(message) {
33
+ const windowID = message?.windowID
34
+ if (Number.isInteger(windowID) && windowID >= 0) {
35
+ const [tab] = await chrome.tabs.query({ active: true, windowId: windowID })
36
+ if (!tab) throw new Error("No active page")
37
+ return tab
38
+ }
39
+ const [tab] = await chrome.tabs.query({ active: true, lastFocusedWindow: true })
40
+ if (!tab) throw new Error("No active page")
41
+ return tab
42
+ }
43
+ export function panelPolling() {
44
+ return isSafari() || document.visibilityState === "visible"
45
+ }
46
+ // Safari requires an App-Sandboxed extension, which cannot reach the Node bridge.
47
+ export function sessionDelivery() {
48
+ return !isSafari()
49
+ }
50
+ export function reconnectHint() {
51
+ return isSafari()
52
+ ? "This page reloaded. Click the Annotate toolbar button once to reconnect it; your notes are kept."
53
+ : "This page reloaded. Click the Annotate icon (Alt+Shift+A) once to reconnect it; your notes are kept."
54
+ }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "OpenCode Annotate",
4
- "version": "0.7.0",
4
+ "version": "0.13.0",
5
5
  "description": "Annotate HTML-based page feedback, private drafts, and paired OpenCode delivery.",
6
6
  "key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAp7TG2yzekNKpQvHBtj4jqkOxtoeDIBhNIjPi37Os/ksuhzPp1pHnrJPV4WV2ToatUaD5x5/SpLP8qZKLBD+wuraEE/TeclEZ8HvEs1yhlnx/S7piTG/s0eV5umuTEx2w66Hi0w3dhTC7ZZfJXCLyqs1feBtWzQx6ClgaHNYly4iJ03pV7RfguqpIaG9LV8Oa8ELA+7Ubr0BAujXrSlvqLF5oAKGoXXcpvTL5rgMRIH4Q/85tnvrk0pRVg+1z9IGNzSfjN82iveC/JAriyWABp8YuswtvKfI2Wb+KspaisBh39Y3BRqlyo8I2Cr+01uE6G5pWiJIWMLhe0glrMr5I2wIDAQAB",
7
7
  "permissions": ["activeTab", "scripting", "storage", "sidePanel", "nativeMessaging", "clipboardWrite"],
package/browser/panel.mjs CHANGED
@@ -1,9 +1,12 @@
1
1
  import { PROTOCOL, markdown, validateReview } from "./protocol.mjs"
2
+ import { panelPolling, panelWindowID } from "./env.mjs"
2
3
 
3
4
  const $ = id => document.getElementById(id)
4
5
  const make = (tag, text = "") => { const node = document.createElement(tag); node.textContent = text; return node }
5
6
  const clone = value => structuredClone(value)
6
7
  const writerID = crypto.randomUUID(), models = new Map(), busy = new Set()
8
+ const windowID = panelWindowID()
9
+ let deliverySupported = true
7
10
  let state, model, destination, available, targets = [], connectionError = "", connectionLoading = true
8
11
  let refreshID = 0, connectionRevision = 0, connectionBusy = false, scheduledRefresh
9
12
  let pendingAction, pendingFocus, undoRecord, selectedNoteID, noteRenderKey, connectionOptionsKey, notice, outdated = false
@@ -15,7 +18,7 @@ function icon(name) {
15
18
  svg.append(use); return svg
16
19
  }
17
20
  async function call(data) {
18
- const result = await chrome.runtime.sendMessage(data)
21
+ const result = await chrome.runtime.sendMessage(windowID === undefined ? data : { ...data, windowID })
19
22
  if (result?.error === "Unknown annotation action") throw markOutdated()
20
23
  if (!result?.ok) throw Object.assign(new Error(result?.error || "Extension disconnected; reopen the panel"), { code: result?.code, draft: result?.draft, note: result?.note })
21
24
  return result
@@ -265,6 +268,24 @@ function deliveryMode() { return connectionLoading ? "loading" : available ? "se
265
268
  function renderDelivery() {
266
269
  const mode = deliveryMode(), retry = mode === "send" ? state?.outbox : null, pending = pendingCount()
267
270
  const count = retry?.count ?? pending, working = busy.has("send") || busy.has("copy-round")
271
+ if (!deliverySupported) {
272
+ $("empty-footnote").textContent = "Collect a few notes, then copy the round into your agent."
273
+ $("paired").textContent = "Copy only"
274
+ $("change-target").disabled = true
275
+ $("link-state").textContent = ""
276
+ $("link-state").className = "link-state"
277
+ $("send-label").textContent = working ? "Copying…" : count ? `Copy ${plural(count)}` : "Copy notes"
278
+ $("send").disabled = locked() || outdated || !state || !count || !!model?.conflict
279
+ $("send-arrow").toggleAttribute("hidden", true)
280
+ $("send-copy").toggleAttribute("hidden", !count || working)
281
+ $("copy-round").hidden = true
282
+ const currentNotice = notice && (!notice.page || notice.page === state?.page.url) ? notice : null
283
+ for (const tone of ["error", "warning", "success"]) $("status").classList.toggle(tone, currentNotice?.tone === tone)
284
+ $("status").textContent = currentNotice?.text || (connectionLoading ? "Preparing the panel…" :
285
+ working ? "Copying to the clipboard…" : count ? "Safari keeps notes local. Copy the round and paste it into any agent." :
286
+ "Safari keeps notes local. Add a note, then copy the round into your agent.")
287
+ return
288
+ }
268
289
  const wrongDestination = retry && retry.targetID !== destination?.id
269
290
  const choosing = !destination && targets.length > 0
270
291
  $("paired").textContent = destination?.title || (connectionLoading ? "Looking for your session…" : choosing ? "Choose a session" : "No session")
@@ -341,6 +362,13 @@ async function refreshConnection() {
341
362
  try {
342
363
  const result = await call({ action: "connection" })
343
364
  if (revision !== connectionRevision) return
365
+ deliverySupported = result.delivery !== false
366
+ if (!deliverySupported) {
367
+ targets = []; available = null; destination = null; connectionError = ""
368
+ $("connection-hint").textContent = "Safari keeps notes local. Copy a round and paste it into your agent."
369
+ showSessionOptions(false, false)
370
+ return
371
+ }
344
372
  if (available?.id !== result.target?.id || destination?.id !== result.destination?.id) notice = null
345
373
  targets = result.targets; available = result.target; destination = result.destination; connectionError = result.error || ""
346
374
  const optionsKey = JSON.stringify([targets.map(target => [target.id, target.provider, target.title, target.directory]), destination?.id, !!available])
@@ -464,6 +492,7 @@ task("restore-round", async () => {
464
492
  await refresh(); status(`Restored ${plural(result.count)} to this round`); focusWhenReady("#notes .note-target")
465
493
  })
466
494
  task("send", async () => {
495
+ if (!deliverySupported) return copyRound()
467
496
  // The click follows the visible label: Copy without a live session, Send with one.
468
497
  if (deliveryMode() === "copy") {
469
498
  if (state && pendingCount()) return copyRound()
@@ -513,7 +542,7 @@ chrome.storage.onChanged.addListener((changes, area) => {
513
542
  })
514
543
  chrome.tabs.onActivated.addListener(scheduleRefresh)
515
544
  chrome.tabs.onUpdated.addListener((_id, change) => { if (change.status === "complete") scheduleRefresh() })
516
- setInterval(() => { if (document.visibilityState === "visible") refresh() }, 1500)
517
- setInterval(() => { if (document.visibilityState === "visible") refreshConnection() }, 10000)
545
+ setInterval(() => { if (panelPolling()) refresh() }, 1500)
546
+ setInterval(() => { if (panelPolling()) refreshConnection() }, 10000)
518
547
  window.addEventListener("focus", refreshConnection)
519
548
  await Promise.all([refreshConnection(), refresh()])
@@ -1,7 +1,7 @@
1
1
  export const MAX_BYTES = 512 * 1024
2
2
  export const HOST = "fun.mjshao.annotate"
3
3
  // Bump when panel ↔ worker actions change. Chrome can keep an older worker running beside a newer panel.
4
- export const PROTOCOL = 2
4
+ export const PROTOCOL = 5
5
5
  export function safeUrl(input) {
6
6
  const url = new URL(input)
7
7
  if (!["http:", "https:", "file:"].includes(url.protocol)) throw new Error("Unsupported page URL")
@@ -1,9 +1,15 @@
1
1
  import { HOST, PROTOCOL, pageTitle, safeUrl, validateReview } from "./protocol.mjs"
2
+ import { openPanel, reconnectHint, resolveTargetTab, sameExtensionURL, sessionDelivery } from "./env.mjs"
2
3
 
4
+ const DELIVERY = sessionDelivery()
3
5
  const pageKey = async url => [...new Uint8Array(await crypto.subtle.digest("SHA-256", new TextEncoder().encode(url)))].map(v => v.toString(16).padStart(2, "0")).join("")
4
6
  let writes = Promise.resolve()
5
7
  const serial = fn => { const next = writes.then(fn); writes = next.catch(() => {}); return next }
6
- const RECONNECT = "This page reloaded. Click the Annotate icon (Alt+Shift+A) once to reconnect it; your notes are kept."
8
+ const RECONNECT = reconnectHint()
9
+ const native = message => {
10
+ if (!DELIVERY) throw new Error("Session delivery is off in Safari. Copy the round instead.")
11
+ return chrome.runtime.sendNativeMessage(HOST, message)
12
+ }
7
13
  const KEPT_ROUNDS = 10
8
14
  const inject = tabId => chrome.scripting.executeScript({ target: { tabId }, files: ["inspector.js", "capture.js"] })
9
15
  async function activate(tab) {
@@ -15,13 +21,17 @@ async function activate(tab) {
15
21
  async function tabMessage(tabId, message) {
16
22
  try { return await chrome.tabs.sendMessage(tabId, message) }
17
23
  catch (error) {
18
- if (!String(error.message).includes("Receiving end does not exist")) throw error
24
+ if (!await receiverMissing(tabId)) throw error
19
25
  try { await inject(tabId) } catch (injectError) {
20
26
  throw new Error(String(injectError.message).includes("HTML") ? injectError.message : RECONNECT)
21
27
  }
22
28
  return chrome.tabs.sendMessage(tabId, message)
23
29
  }
24
30
  }
31
+ async function receiverMissing(tabId) {
32
+ try { await chrome.tabs.sendMessage(tabId, { action: "annotate-ping" }); return false }
33
+ catch { return true }
34
+ }
25
35
  const delivered = note => !note.deleted && note.sentRevision === note.revision
26
36
  async function closeRound(hash, annotations, details) {
27
37
  const storage = await chrome.storage.local.get(null), sentAt = new Date().toISOString(), updates = {}
@@ -52,12 +62,11 @@ function lastRound(entries) {
52
62
  }
53
63
  chrome.action.onClicked.addListener(tab => {
54
64
  // open() must retain the browser's action user gesture, before asynchronous injection.
55
- chrome.sidePanel.open({ tabId: tab.id }).catch(console.error)
65
+ openPanel(tab).catch(console.error)
56
66
  activate(tab).catch(async error => { await chrome.storage.session.set({ [`tab:${tab.id}`]: { error: error.message } }) })
57
67
  })
58
- async function current() {
59
- const [tab] = await chrome.tabs.query({ active: true, lastFocusedWindow: true })
60
- if (!tab) throw new Error("No active page")
68
+ async function current(message) {
69
+ const tab = await resolveTargetTab(message)
61
70
  const state = (await chrome.storage.session.get(`tab:${tab.id}`))[`tab:${tab.id}`]
62
71
  if (!state?.page) throw new Error(state?.error || "Click the extension icon on this page to grant access")
63
72
  const hash = await pageKey(state.page.url)
@@ -107,8 +116,8 @@ async function handle(message, sender) {
107
116
  ...(!message.modeOnly ? { anchor: message.anchor, error: message.error, captureID: crypto.randomUUID() } : {}) } })
108
117
  return {}
109
118
  }
110
- if (sender.url && !sender.url.startsWith(chrome.runtime.getURL(""))) throw new Error("Only the extension panel can manage feedback")
111
- if (message.action === "current") return current()
119
+ if (sender.url && !sameExtensionURL(sender.url)) throw new Error("Only the extension panel can manage feedback")
120
+ if (message.action === "current") return current(message)
112
121
  if (message.action === "draft") return serial(async () => {
113
122
  // A route change must still be able to persist the previous page's draft.
114
123
  if (!message.page || safeUrl(message.page.url) !== message.page.url || typeof message.page.title !== "string" ||
@@ -125,12 +134,13 @@ async function handle(message, sender) {
125
134
  await chrome.storage.local.set({ [key]: draft })
126
135
  return { draft }
127
136
  })
128
- if (message.action === "targets") return chrome.runtime.sendNativeMessage(HOST, { action: "targets" })
137
+ if (message.action === "targets") return native({ action: "targets" })
129
138
  if (message.action === "connection") {
139
+ if (!DELIVERY) return { delivery: false, targets: [], target: null, destination: null, stale: false }
130
140
  const { paired } = await chrome.storage.local.get("paired")
131
141
  let result
132
142
  try {
133
- result = await chrome.runtime.sendNativeMessage(HOST, { action: "targets" })
143
+ result = await native({ action: "targets" })
134
144
  if (!result.ok) throw new Error(result.error)
135
145
  } catch (error) {
136
146
  return { targets: [], target: null, destination: paired || null, stale: !!paired, error: error.message }
@@ -139,13 +149,13 @@ async function handle(message, sender) {
139
149
  return { targets: result.targets, target: target || null, destination: target || paired || null, stale: !!paired && !target }
140
150
  }
141
151
  if (message.action === "pair") {
142
- const result = await chrome.runtime.sendNativeMessage(HOST, { action: "info", targetID: message.target.id })
152
+ const result = await native({ action: "info", targetID: message.target.id })
143
153
  if (!result.ok) throw new Error(result.error)
144
154
  await chrome.storage.local.set({ paired: result.target }); return { target: result.target }
145
155
  }
146
156
  if (message.action === "pairing") return { target: (await chrome.storage.local.get("paired")).paired || null }
147
157
  if (message.action === "unpair") { await chrome.storage.local.remove("paired"); return {} }
148
- const state = await current()
158
+ const state = await current(message)
149
159
  if (message.url && message.url !== state.page.url) throw new Error("The active page changed; retry on the original page")
150
160
  if (message.action === "pick") return tabMessage(state.tabID, { action: "pick" })
151
161
  if (message.action === "reveal") {
@@ -200,14 +210,14 @@ async function handle(message, sender) {
200
210
  return { count: Object.keys(updates).length }
201
211
  })
202
212
  if (message.action === "send") return serial(async () => {
203
- const latest = await current()
213
+ const latest = await current(message)
204
214
  if (latest.page.url !== state.page.url) throw new Error("The active page changed; return to the original page to send")
205
215
  if (typeof message.targetID !== "string" || !message.targetID) throw new Error("Choose a destination session before sending")
206
216
  let { paired } = await chrome.storage.local.get("paired")
207
217
  if (paired && paired.id !== message.targetID) throw new Error("The destination changed in another panel; choose it again")
208
218
  if (!paired) {
209
219
  // A sole target is only preselected. The user's Send click authorizes this binding.
210
- const result = await chrome.runtime.sendNativeMessage(HOST, { action: "info", targetID: message.targetID })
220
+ const result = await native({ action: "info", targetID: message.targetID })
211
221
  if (!result.ok) throw new Error(result.error)
212
222
  paired = result.target
213
223
  await chrome.storage.local.set({ paired })
@@ -222,7 +232,7 @@ async function handle(message, sender) {
222
232
  batch = { action: "send", batchID: crypto.randomUUID(), targetID: paired.id, review }
223
233
  await chrome.storage.local.set({ [outboxKey]: batch })
224
234
  }
225
- const response = await chrome.runtime.sendNativeMessage(HOST, batch)
235
+ const response = await native(batch)
226
236
  if (!response.ok) throw new Error(response.error)
227
237
  const count = await closeRound(state.hash, batch.review.annotations, { sentRound: batch.batchID, sentVia: "session", sentTo: paired.title })
228
238
  await chrome.storage.local.remove(outboxKey)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxxxsooo/opencode-annotate",
3
- "version": "0.11.1",
3
+ "version": "0.13.0",
4
4
  "description": "Unofficial OpenCode plugin: annotate replies, documents and webpages, and reference previous conversations.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -13,9 +13,11 @@
13
13
  "agy-annotate": "./agy/cli.mjs"
14
14
  },
15
15
  "scripts": {
16
+ "build:safari": "node scripts/build-safari.mjs",
17
+ "install:safari": "node scripts/install-safari.mjs",
16
18
  "build:tui": "node scripts/build-tui.mjs",
17
19
  "check:tui": "cargo fmt --manifest-path tui/Cargo.toml --all --check && cargo clippy --manifest-path tui/Cargo.toml --workspace --all-targets --locked -- -D warnings && cargo test --manifest-path tui/Cargo.toml --workspace --locked",
18
- "test": "node --test *.test.mjs bridge/*.test.mjs agy/*.test.mjs",
20
+ "test": "node --test *.test.mjs bridge/*.test.mjs agy/*.test.mjs scripts/*.test.mjs",
19
21
  "test:browser": "node tests/browser.mjs",
20
22
  "install:bridge": "node scripts/install-bridge.mjs",
21
23
  "install:plugin": "node scripts/install-plugin.mjs",
@@ -37,6 +39,7 @@
37
39
  "server-history.mjs",
38
40
  "session-reference.mjs",
39
41
  "reference-command.mjs",
42
+ "reference-comment.tsx",
40
43
  "review.mjs",
41
44
  "auto-review.mjs",
42
45
  "configuration.mjs",
@@ -50,6 +53,11 @@
50
53
  "bridge/wire.mjs",
51
54
  "agy",
52
55
  "scripts/install-bridge.mjs",
56
+ "safari/background.html",
57
+ "safari/SafariWebExtensionHandler.swift",
58
+ "scripts/build-safari.mjs",
59
+ "scripts/install-safari.mjs",
60
+ "scripts/browser-target.mjs",
53
61
  "scripts/install-plugin.mjs",
54
62
  "scripts/verify-tui.mjs",
55
63
  "scripts/migrate-page-context.mjs",
@@ -61,11 +69,23 @@
61
69
  "node": ">=22"
62
70
  },
63
71
  "peerDependencies": {
64
- "@opencode/plugin": ">=2.2.0 <3"
72
+ "@opencode/plugin": ">=2.2.0 <3",
73
+ "@opentui/core": ">=0.6.6",
74
+ "@opentui/solid": ">=0.6.6",
75
+ "solid-js": ">=1.9.0"
65
76
  },
66
77
  "peerDependenciesMeta": {
67
78
  "@opencode/plugin": {
68
79
  "optional": true
80
+ },
81
+ "@opentui/core": {
82
+ "optional": true
83
+ },
84
+ "@opentui/solid": {
85
+ "optional": true
86
+ },
87
+ "solid-js": {
88
+ "optional": true
69
89
  }
70
90
  },
71
91
  "repository": {
@@ -1,7 +1,7 @@
1
1
  import { randomUUID } from "node:crypto"
2
2
  import { readSession, referenceMarkdown, searchSessions } from "./session-reference.mjs"
3
3
 
4
- export function createReferenceCommand(context) {
4
+ export function createReferenceCommand(context, { promptComment }) {
5
5
  let active
6
6
  let disposed = false
7
7
  const notice = (message, variant = "info") => context.ui.toast.show({
@@ -54,6 +54,12 @@ export function createReferenceCommand(context) {
54
54
  const reference = await readSession(context.client, { sessionID: sourceID }, signal)
55
55
  signal.throwIfAborted()
56
56
  if (!reference.messages.length) return notice("No completed user or assistant text in this history range. Use annotate.session_read to inspect older pages.")
57
+ const comment = await promptComment({
58
+ title: "Comment on reference (optional)",
59
+ placeholder: "How should the assistant use this conversation?",
60
+ }, signal)
61
+ signal.throwIfAborted()
62
+ if (comment == null) return
57
63
  const shortened = reference.nextCursor || reference.messages.some(message => message.nextOffset !== null)
58
64
  const confirmed = await context.ui.dialog.confirm({
59
65
  title: "Attach conversation reference?",
@@ -64,7 +70,7 @@ export function createReferenceCommand(context) {
64
70
  if (confirmed !== true) return
65
71
  await context.client.session.synthetic({
66
72
  sessionID, id: `msg_${randomUUID().replaceAll("-", "")}`,
67
- text: referenceMarkdown(reference), description: `Reference: ${reference.source.title}`,
73
+ text: referenceMarkdown(reference, { comment }), description: `Reference: ${reference.source.title}`,
68
74
  metadata: { annotateReference: { sessionID: sourceID, capturedAt: reference.capturedAt } },
69
75
  delivery: "queue", resume: false,
70
76
  }, { signal })
@@ -0,0 +1,65 @@
1
+ import type { TextareaRenderable } from "@opentui/core"
2
+ import { useTerminalDimensions } from "@opentui/solid"
3
+ import { onMount } from "solid-js"
4
+ import type { Context, DialogPromptOptions } from "@opencode/plugin/tui/context"
5
+
6
+ export function promptReferenceComment(context: Context, options: DialogPromptOptions, signal: AbortSignal) {
7
+ signal.throwIfAborted()
8
+ return new Promise<string | undefined>(resolve => {
9
+ let settled = false
10
+ const finish = (value?: string, close = false) => {
11
+ if (settled) return
12
+ settled = true
13
+ signal.removeEventListener("abort", abort)
14
+ resolve(value)
15
+ if (close) context.ui.dialog.clear()
16
+ }
17
+ const abort = () => finish(undefined, true)
18
+ context.ui.dialog.show(() => {
19
+ let input: TextareaRenderable
20
+ const dimensions = useTerminalDimensions()
21
+ const limit = () => Math.max(1, Math.min(18, dimensions().height - 14))
22
+ const theme = context.theme
23
+ onMount(() => input.focus())
24
+ context.keymap.layer(() => ({
25
+ mode: "global",
26
+ target: () => input,
27
+ commands: [{ bind: "ctrl+c", run: () => finish(undefined, true) }],
28
+ }))
29
+ return (
30
+ <box paddingLeft={2} paddingRight={2} paddingBottom={1} gap={1}>
31
+ <text fg={theme.text.base}>{options.title}</text>
32
+ <box backgroundColor={theme.background.raised.high} paddingLeft={1} paddingRight={1}>
33
+ <textarea
34
+ ref={node => { input = node }}
35
+ initialValue={options.value ?? ""}
36
+ placeholder={options.placeholder}
37
+ height="auto"
38
+ minHeight={Math.min(3, limit())}
39
+ maxHeight={limit()}
40
+ flexShrink={1}
41
+ wrapMode="word"
42
+ textColor={theme.text.base}
43
+ backgroundColor={theme.background.raised.high}
44
+ focusedBackgroundColor={theme.background.raised.high}
45
+ placeholderColor={theme.text.muted}
46
+ cursorColor={theme.text.base}
47
+ keyBindings={[
48
+ { name: "return", action: "submit" },
49
+ { name: "return", shift: true, action: "newline" },
50
+ ]}
51
+ onSubmit={() => finish(input.plainText, true)}
52
+ />
53
+ </box>
54
+ <box flexDirection="row" flexWrap="wrap" gap={2}>
55
+ <text fg={theme.text.action.primary.selected} onMouseUp={() => finish(input.plainText, true)}>enter continue</text>
56
+ <text fg={theme.text.muted}>shift+enter newline</text>
57
+ <text fg={theme.text.muted} onMouseUp={() => finish(undefined, true)}>esc cancel</text>
58
+ </box>
59
+ </box>
60
+ )
61
+ }, () => finish())
62
+ context.ui.dialog.set({ size: "large", centered: false })
63
+ signal.addEventListener("abort", abort, { once: true })
64
+ })
65
+ }
@@ -0,0 +1,14 @@
1
+ // Safari requires an App-Sandboxed app extension. It cannot start the Node
2
+ // bridge or read its registry; notes stay local and are copied out instead.
3
+ import SafariServices
4
+
5
+ class SafariWebExtensionHandler: NSObject, NSExtensionRequestHandling {
6
+ func beginRequest(with context: NSExtensionContext) {
7
+ let response = NSExtensionItem()
8
+ response.userInfo = [SFExtensionMessageKey: [
9
+ "ok": false,
10
+ "error": "Native messaging is unavailable in Safari. Copy the round instead.",
11
+ ]]
12
+ context.completeRequest(returningItems: [response], completionHandler: nil)
13
+ }
14
+ }
@@ -0,0 +1,4 @@
1
+ <!doctype html>
2
+ <meta charset="utf-8">
3
+ <title>OpenCode Annotate background</title>
4
+ <script type="module" src="worker.mjs"></script>
@@ -0,0 +1,18 @@
1
+ // Open the reviewed page in the browser hosting its companion. Safari is copy-only;
2
+ // Chrome retains native messaging delivery.
3
+ import { execFile } from "node:child_process"
4
+ import { promisify } from "node:util"
5
+
6
+ const execute = promisify(execFile)
7
+ export const SAFARI_APP = "Safari"
8
+ export const CHROME_APP = "Google Chrome"
9
+ export function browserApp(options = {}) {
10
+ const browser = options.browser
11
+ if (browser === undefined || browser === "Chrome") return CHROME_APP
12
+ if (browser === "Safari") return SAFARI_APP
13
+ throw new Error('browser must be "Chrome" or "Safari".')
14
+ }
15
+ export async function openInBrowser(url, options = {}) {
16
+ if (process.platform !== "darwin") throw new Error("Browser review currently requires macOS")
17
+ await execute("open", ["-a", browserApp(options), url])
18
+ }
@@ -0,0 +1,97 @@
1
+ // Derive a Safari app from the shared browser sources; Chrome stays the source
2
+ // of truth. Apple's converter generates the Xcode project, not checked-in sources.
3
+ import { spawn } from "node:child_process"
4
+ import { cp, mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises"
5
+ import { existsSync } from "node:fs"
6
+ import os from "node:os"
7
+ import path from "node:path"
8
+ import { fileURLToPath } from "node:url"
9
+
10
+ const root = fileURLToPath(new URL("../", import.meta.url))
11
+ const project = path.join(root, "safari")
12
+ const browser = path.join(root, "browser")
13
+ const build = path.join(root, ".local", "safari")
14
+ export const APP_NAME = "annotate"
15
+ export const BUNDLE_ID = "fun.mjshao.annotate"
16
+
17
+ export function safariManifest(chromeManifest) {
18
+ const manifest = structuredClone(chromeManifest)
19
+ delete manifest.side_panel
20
+ delete manifest.key
21
+ // Safari requires a sandboxed extension; it cannot reach the Node bridge.
22
+ manifest.permissions = manifest.permissions.filter(permission => permission !== "sidePanel" && permission !== "nativeMessaging")
23
+ manifest.background = { page: "background.html" }
24
+ manifest.browser_specific_settings = { safari: { strict_min_version: "18.0" } }
25
+ return manifest
26
+ }
27
+ export async function stageExtension(directory) {
28
+ await rm(directory, { recursive: true, force: true })
29
+ await cp(browser, directory, { recursive: true })
30
+ const manifest = safariManifest(JSON.parse(await readFile(path.join(browser, "manifest.json"), "utf8")))
31
+ await writeFile(path.join(directory, "manifest.json"), `${JSON.stringify(manifest, null, 2)}\n`)
32
+ await cp(path.join(project, "background.html"), path.join(directory, "background.html"))
33
+ return directory
34
+ }
35
+ function run(command, args, options = {}) {
36
+ return new Promise((resolve, reject) => {
37
+ const child = spawn(command, args, { stdio: "inherit", ...options })
38
+ child.once("error", reject)
39
+ child.once("exit", code => code === 0 ? resolve() : reject(new Error(`${command} exited with ${code}`)))
40
+ })
41
+ }
42
+ export async function convert(directory, projectDirectory) {
43
+ await rm(projectDirectory, { recursive: true, force: true })
44
+ await run("xcrun", ["safari-web-extension-converter", directory,
45
+ "--project-location", projectDirectory, "--app-name", APP_NAME,
46
+ "--bundle-identifier", BUNDLE_ID,
47
+ "--macos-only", "--swift", "--no-open", "--no-prompt", "--force", "--copy-resources"])
48
+ const generated = path.join(projectDirectory, APP_NAME, `${APP_NAME} Extension`, "SafariWebExtensionHandler.swift")
49
+ if (!existsSync(generated)) throw new Error(`The converter did not produce ${generated}`)
50
+ await cp(path.join(project, "SafariWebExtensionHandler.swift"), generated)
51
+ return path.join(projectDirectory, APP_NAME, `${APP_NAME}.xcodeproj`)
52
+ }
53
+ // Safari refuses to register an unsandboxed extension. This is copy-only.
54
+ export function buildSettings({ version, identity = "Apple Development", team = "", configuration = "Release" } = {}) {
55
+ if (!version) throw new Error("A package version is required for the Safari bundle")
56
+ return {
57
+ CODE_SIGN_IDENTITY: identity,
58
+ CODE_SIGN_STYLE: team ? "Manual" : "Automatic",
59
+ ...(team ? { DEVELOPMENT_TEAM: team } : {}),
60
+ ENABLE_APP_SANDBOX: "YES",
61
+ ENABLE_HARDENED_RUNTIME: "YES",
62
+ MARKETING_VERSION: version,
63
+ CURRENT_PROJECT_VERSION: version,
64
+ CONFIGURATION: configuration,
65
+ }
66
+ }
67
+ export function signingIdentity({ identity, team } = {}) {
68
+ if (identity) return { identity, team }
69
+ if (team) return { identity: "Apple Development", team }
70
+ return { identity: "-", team: "" }
71
+ }
72
+ export async function buildApp({ identity, team, configuration = "Release", derivedData = build } = {}) {
73
+ const { version } = JSON.parse(await readFile(path.join(root, "package.json"), "utf8"))
74
+ const directory = await mkdtemp(path.join(os.tmpdir(), "oa-safari-"))
75
+ try {
76
+ const staged = await stageExtension(path.join(directory, "extension"))
77
+ const xcodeproj = await convert(staged, path.join(directory, "project"))
78
+ await mkdir(derivedData, { recursive: true })
79
+ const settings = buildSettings({ version, ...signingIdentity({ identity, team }), configuration })
80
+ const overrides = Object.entries(settings).map(([key, value]) => `${key}=${value}`)
81
+ await run("xcodebuild", ["-project", xcodeproj, "-scheme", APP_NAME, "-configuration", configuration,
82
+ "-destination", "platform=macOS", "-derivedDataPath", derivedData, ...overrides, "build"])
83
+ const app = path.join(derivedData, "Build", "Products", configuration, `${APP_NAME}.app`)
84
+ if (!existsSync(app)) throw new Error(`The build did not produce ${app}`)
85
+ return app
86
+ } finally { await rm(directory, { recursive: true, force: true }) }
87
+ }
88
+ if (process.argv[1] === fileURLToPath(import.meta.url)) {
89
+ const identity = process.env.ANNOTATE_SIGN_IDENTITY || undefined
90
+ const team = process.env.ANNOTATE_DEVELOPMENT_TEAM || undefined
91
+ console.log(`Built ${await buildApp({ identity, team })}`)
92
+ if (!identity) {
93
+ console.log("Warning: this app is ad-hoc signed. Safari may refuse to register it.")
94
+ console.log("Set ANNOTATE_SIGN_IDENTITY and ANNOTATE_DEVELOPMENT_TEAM to a local Apple Development identity.")
95
+ }
96
+ console.log("Install it with npm run install:safari, open it once, then enable Annotate in Safari > Settings > Extensions.")
97
+ }
@@ -0,0 +1,32 @@
1
+ // Replace the installed Safari app and refresh its app-extension registration.
2
+ import { cp, rm } from "node:fs/promises"
3
+ import { existsSync } from "node:fs"
4
+ import { execFile } from "node:child_process"
5
+ import { fileURLToPath } from "node:url"
6
+ import { promisify } from "node:util"
7
+ import path from "node:path"
8
+
9
+ const execute = promisify(execFile)
10
+ const root = fileURLToPath(new URL("../", import.meta.url))
11
+ const lsregister = "/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister"
12
+ export async function installSafari({ source = path.join(root, ".local/safari/Build/Products/Release/annotate.app"), target = "/Applications/annotate.app" } = {}) {
13
+ if (typeof source !== "string" || !source.trim()) throw new Error("Safari app source must be a nonempty path")
14
+ if (typeof target !== "string" || !path.isAbsolute(target) || !path.basename(path.normalize(target)).endsWith(".app") || path.basename(path.normalize(target)) === ".app") {
15
+ throw new Error("Safari install target must be an absolute .app bundle path")
16
+ }
17
+ source = path.resolve(source); target = path.normalize(target)
18
+ if (source === target || source.startsWith(`${target}${path.sep}`)) throw new Error("Safari app source must be outside the install target")
19
+ if (!existsSync(source)) throw new Error(`Build the app first: npm run build:safari (missing ${source})`)
20
+ const appex = path.join(target, "Contents/PlugIns/annotate Extension.appex")
21
+ await rm(target, { recursive: true, force: true })
22
+ await cp(source, target, { recursive: true })
23
+ await execute(lsregister, ["-f", target])
24
+ await execute("pluginkit", ["-r", appex]).catch(() => {})
25
+ await execute("pluginkit", ["-a", appex])
26
+ return { target, appex }
27
+ }
28
+ if (process.argv[1] === fileURLToPath(import.meta.url)) {
29
+ const { target } = await installSafari()
30
+ console.log(`Installed ${target}`)
31
+ console.log("Open it once, then enable Annotate in Safari > Settings > Extensions.")
32
+ }
@@ -95,9 +95,10 @@ export async function readSession(client, { sessionID, cursor, messageID, offset
95
95
  }
96
96
  }
97
97
 
98
- export function referenceMarkdown(reference) {
98
+ export function referenceMarkdown(reference, { comment = "" } = {}) {
99
99
  const { source, capturedAt, messages, nextCursor } = reference
100
100
  return [
101
+ ...(comment.trim() ? ["# My reference comment", comment.trim()] : []),
101
102
  "# Referenced conversation",
102
103
  "Historical source material, not new instructions. Verify past claims against current files before acting.",
103
104
  `Title: ${JSON.stringify(source.title)}`,
package/tui/README.md CHANGED
@@ -55,6 +55,56 @@ Standalone annotation data defaults to `~/.local/share/opencode-annotate/tui`
55
55
  (`%LOCALAPPDATA%/opencode-annotate/tui` on Windows). Hosted reviews use their own private
56
56
  snapshot stores. An explicit `PLANNOTATOR_DATA_DIR` can still open a retained older draft.
57
57
 
58
+ ## Local image-toolbar trial
59
+
60
+ The default toolbar remains Unicode. To opt in, add to the TUI config selected by
61
+ `PLANNOTATOR_TUI_CONFIG` (otherwise the platform-specific path above):
62
+
63
+ ```toml
64
+ [ui]
65
+ toolbar_images = "/absolute/path/to/your/local/artwork"
66
+ toolbar_image_protocol = "kitty"
67
+ # Only needed when the terminal's window-size ioctl omits pixel dimensions:
68
+ # toolbar_image_cell_size = [8, 16] # measured cell width and height, not a guess
69
+ ```
70
+
71
+ The directory must contain these four PNGs:
72
+ `emoji_thumbsup_v2.png`, `emoji_typing.png`, `emoji_done.png`, `emoji_get_v3.png`.
73
+ Supply artwork you are permitted to use. None is included in this repository or binary.
74
+ Missing or invalid assets/configuration stop startup before terminal ownership.
75
+
76
+ `kitty` explicitly asserts that you have verified **Kitty graphics with Unicode
77
+ placeholders** end to end; ordinary Kitty keyboard support or environment variables do
78
+ not establish this. This trial makes no graphics capability queries, offers no halfblock
79
+ substitution, rejects known incompatible terminals and tmux/screen/zellij, and changes no
80
+ multiplexer settings. Unknown transports still require your own verification. Disable by
81
+ removing all three `toolbar_image*` keys if your terminal cannot display it. Restart after
82
+ changing font/cell pixel size. A configured cell-size override takes precedence and skips
83
+ the ioctl; measure at the actual display's DPI, including through any PTY proxy.
84
+
85
+ Artwork is approximately square, centered at 85% of one cell row's height, with a bold,
86
+ action-colored key beside each
87
+ button. Buttons wrap; those that cannot fit completely are hidden without mouse targets.
88
+ Keys still work: `a` approval, `c` comment, Enter done, `g` get; `w`, `d`, `y`, Esc stay
89
+ key-only. Custom key bindings remain authoritative. Images are decoded/encoded once,
90
+ placements follow the Ratatui buffer diff, and only this instance's image IDs are freed
91
+ on normal/error exit.
92
+
93
+ For a query-free backend escape capture using generated gradient PNGs (not your artwork):
94
+
95
+ ```sh
96
+ ANNOTATE_TEST_KITTY_CAPTURE="$TMPDIR/annotate-kitty.ansi" \
97
+ cargo test --manifest-path tui/Cargo.toml kitty_backend_emits_cached_pixel_payload_and_owned_cleanup
98
+ ```
99
+
100
+ This proves payload/placeholder output and cache behavior, not terminal compatibility.
101
+ The ordinary `--snapshot` command intentionally remains text-only and query-free.
102
+
103
+ The local November 10 trial rendered the selected four PNGs in an isolated Ghostty 1.4.0
104
+ window through ghost-complete 0.19.1. Dismiss and comment composition removed the images;
105
+ the exit capture contained four owned-image deletions and alternate-screen restoration.
106
+ This is a local opt-in experiment, not a release or a guarantee for other terminals.
107
+
58
108
  ## Ownership and provenance
59
109
 
60
110
  This code was imported from the customized Plannotator TUI 0.9.4 codebase at source commit
@@ -69,6 +119,7 @@ Import provenance and the ownership decision are recorded in [sources.json](../s
69
119
  | Date | Decision | Basis |
70
120
  |---|---|---|
71
121
  | 2026-10-28 | Own the terminal reviewer inside `opencode-annotate/tui/`; build and distribute it with the plugin. | `tui-ownership-decision` in the source register. |
122
+ | 2026-11-10 | Trial actual local PNG toolbar artwork rather than Unicode substitutes; retain four actions and keep third-party artwork out of distributed artifacts. | `real-image-toolbar-trial-20261110` in the source register. |
72
123
 
73
124
  The integrated reviewer first shipped in **0.10.0**, with successful native CI on all
74
125
  five supported platforms and verified npm executable bytes. Isolated OpenCode reviews
Binary file
Binary file
Binary file
Binary file
Binary file
package/tui.ts CHANGED
@@ -2,6 +2,7 @@ import { Plugin } from "@opencode/plugin/tui"
2
2
  import { createReviewCommand } from "./review.mjs"
3
3
  import { createAsciiHold, createInputSource } from "./input-source.mjs"
4
4
  import { createReferenceCommand } from "./reference-command.mjs"
5
+ import { promptReferenceComment } from "./reference-comment.tsx"
5
6
  import { createAutoReview } from "./auto-review.mjs"
6
7
  import { watchConfiguration } from "./configuration.mjs"
7
8
 
@@ -21,13 +22,15 @@ export default Plugin.define({
21
22
  })
22
23
  await configuration.ready
23
24
  const inputSource = createInputSource(context.options.inputSource)
24
- const review = createReviewCommand(context, { inputSource })
25
+ const review = createReviewCommand(context, { inputSource, web: { browser: options.browser } })
25
26
  restartAutoReview = () => {
26
27
  stopAutoReview()
27
28
  stopAutoReview = createAutoReview(context, review)
28
29
  }
29
30
  restartAutoReview()
30
- const reference = createReferenceCommand(context)
31
+ const reference = createReferenceCommand(context, {
32
+ promptComment: (options, signal) => promptReferenceComment(context, options, signal),
33
+ })
31
34
  // Permission prompts answer with single letters, which an input method swallows.
32
35
  const hold = createAsciiHold(inputSource)
33
36
  const stopAsked = context.data.on("permission.asked", event => hold.enter(event.data.id))
package/web-review.mjs CHANGED
@@ -1,9 +1,6 @@
1
- import { execFile } from "node:child_process"
2
- import { promisify } from "node:util"
3
1
  import { browserTarget } from "./targets.mjs"
4
2
  import { createReceiver } from "./bridge/receiver.mjs"
5
-
6
- const execute = promisify(execFile)
3
+ import { openInBrowser } from "./scripts/browser-target.mjs"
7
4
  export function createWebReview(context, options = {}) {
8
5
  const receivers = new Map()
9
6
  let disposed = false
@@ -43,8 +40,7 @@ export function createWebReview(context, options = {}) {
43
40
  }
44
41
  if (target.url) {
45
42
  if (options.open) await options.open(target.url)
46
- else if (process.platform === "darwin") await execute("open", ["-a", "Google Chrome", target.url])
47
- else throw new Error("Browser review currently requires macOS")
43
+ else await openInBrowser(target.url, options)
48
44
  }
49
45
  context.ui.toast.show({ title: "Annotate web", message: `Ready for browser pairing: ${session.title || sessionID}. Open the extension and select this session.`, duration: 10000 })
50
46
  return true