@nxxxsooo/opencode-annotate 0.14.0 → 0.15.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,25 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.15.0 — browser rounds and automatic connection
4
+
5
+ - Collect browser annotations across pages in one round, grouped by page in the panel
6
+ and in one Send/Copy message. Keep page-local drafts, off-page note actions and global
7
+ round recovery. Browser protocol 6 uses review envelope v2 with per-note pages.
8
+ - Register the Chrome native host and current/new sessions automatically. Resolve the
9
+ real Node.js executable during setup; no separate host-install or pairing command is
10
+ needed in normal use. Discover new sessions faster and share overlapping checks.
11
+ - Replace `/annotate-web` with `/annotate <url-or-html>`, and remove `/annotate-last`;
12
+ plain `/annotate` still reviews the latest completed reply.
13
+ - Keep Send and Copy instead as separate actions. Choose destinations in one automatically
14
+ refreshed, filterable picker with current titles and activity/creation/title sorting.
15
+ - Create empty OpenCode sessions from the extension without a prompt or model turn.
16
+ Disconnect/reconnect delivery without losing drafts or retries, and reconnect restarted
17
+ receivers by stable provider/session identity, carrying retries to the replacement.
18
+ - Continue after confirmed text/browser annotation sends with `steer` / `resume: true`:
19
+ idle sessions start immediately; running turns receive feedback at the next boundary.
20
+ - Preserve Safari's existing sandboxed, copy-only boundary. Reload the Chrome extension
21
+ after updating; protocol and review-envelope changes require matching companion files.
22
+
3
23
  ## 0.14.0 — references as prompts
4
24
 
5
25
  - Submit the referenced conversation, optional comment and inline annotations together
package/README.md CHANGED
@@ -13,8 +13,8 @@ This **unofficial OpenCode plugin** bundles the native [terminal reviewer](tui/R
13
13
  | Surface | Reviews | Entry point |
14
14
  |---|---|---|
15
15
  | Terminal (bundled TUI) | AI replies, Markdown, plain text | `/annotate` |
16
- | Chrome (optional) | Webpages, local HTML | `/annotate-web` |
17
- | Safari (optional, copy-only) | Webpages | `/annotate-web` |
16
+ | Chrome (optional) | Webpages, local HTML | `/annotate <url-or-html>` or extension |
17
+ | Safari (optional, copy-only) | Webpages | `/annotate <url-or-html>` or extension |
18
18
 
19
19
  ## Install
20
20
 
@@ -51,7 +51,7 @@ Manual configuration, preserving other entries:
51
51
 
52
52
  Empty and cancelled reviews submit nothing. Opening a review makes no model call.
53
53
 
54
- **`Ctrl+S`** saves the current comment and sends in one step. The header's **Send N back (q)** button does the same as `q`. **`Ctrl+C`** returns without sending, and OpenCode asks whether to send. `E` and `S` send as well, following any `[keys]` rebinding.
54
+ **`Ctrl+S`** saves the current comment and sends in one step. The header's **Send N back (q)** button does the same as `q`. **`Ctrl+C`** returns without sending, and OpenCode asks whether to send. `E` and `S` send as well, following any `[keys]` rebinding. Confirmed text and browser sends continue the captured session with `steer` / `resume: true`, including while a turn is running.
55
55
 
56
56
  <a id="what-it-reviews"></a>
57
57
 
@@ -61,7 +61,7 @@ Empty and cancelled reviews submit nothing. Opening a review makes no model call
61
61
 
62
62
  `/annotate` opens the last completed reply. `/annotate-pick` chooses from recent replies and progress updates. `/annotate-selection` opens the message containing your last transcript selection. Reasoning, tool-call commentary, and in-progress messages are excluded.
63
63
 
64
- `/annotate-last` always reviews the latest completed reply; any supplied argument is ignored. For a selection that spans messages, `/annotate-selection` reviews just the selected text.
64
+ For a selection that spans messages, `/annotate-selection` reviews just the selected text.
65
65
 
66
66
  ### Review Markdown and text documents
67
67
 
@@ -77,19 +77,17 @@ The reviewer reads a fixed snapshot and does not edit the original file. Feedbac
77
77
 
78
78
  ### Browser webpage feedback
79
79
 
80
- Run `/annotate-web` to pair the current session with the Chrome extension, then open the extension panel on any webpage. Select text or pick an element, write notes, and send them back to the paired session.
80
+ Open the extension panel on any webpage and choose an automatically registered OpenCode session. Select text or pick an element, write notes across pages, and send the grouped round to that destination. `/annotate` can also open an explicit browser target:
81
81
 
82
82
  ```text
83
- /annotate-web # Pair this session
84
- /annotate-web page.html # Review a local HTML file
85
- /annotate-web https://example.com # Review a webpage
86
- /annotate-web off # Revoke this session's browser pairing
83
+ /annotate page.html # Review a local HTML file
84
+ /annotate https://example.com # Review a webpage
87
85
  ```
88
86
 
89
87
  <p align="center">
90
88
  <img src="https://raw.githubusercontent.com/nxxxsooo/opencode-annotate/main/docs/assets/browser-review.png" alt="Chrome extension panel with a saved webpage comment and an explicit Send 1 note button" width="440">
91
89
  <br>
92
- <em>Real extension panel with synthetic page feedback; captured in an isolated headless tab.</em>
90
+ <em>Real v0.13.0 extension panel with synthetic feedback; captured in an isolated headless tab. The current panel adds cross-page rounds and a destination picker.</em>
93
91
  </p>
94
92
 
95
93
  Browser setup is separate from the plugin install. Safari supports local notes and copying only; see [Browser review](#browser-review-optional) below.
@@ -112,16 +110,13 @@ Two Code Mode tools are registered for agent use: `annotate.session_search` and
112
110
 
113
111
  ```text
114
112
  /annotate Review the last completed assistant reply
115
- /annotate-last Review the latest reply, ignoring arguments
116
113
  /annotate docs/plan.md Review a Markdown document
117
114
  /annotate "docs/release plan.md" Review a path containing spaces
118
115
  /annotate ~/Documents/notes.txt Review a plain-text document
119
116
  /annotate-pick Choose a recent reply or mid-turn progress update
120
117
  /annotate-selection Review the message containing your last transcript selection
121
- /annotate-web Pair this session, or create an empty one from home
122
- /annotate-web page.html Review the specified local HTML in Chrome
123
- /annotate-web https://example.com Review the specified webpage
124
- /annotate-web off Revoke this session's browser pairing
118
+ /annotate page.html Review local HTML in the configured browser
119
+ /annotate https://example.com Review the specified webpage
125
120
  /ref Choose a conversation from this project
126
121
  /ref authentication Search conversation titles in this project
127
122
  /ref --all authentication Search titles across projects
@@ -129,7 +124,7 @@ Two Code Mode tools are registered for agent use: `annotate.session_search` and
129
124
  /ref ses_… Attach a specific conversation
130
125
  ```
131
126
 
132
- Numbered `/annotate N` is retired.
127
+ Numbered `/annotate N`, `/annotate-last` and `/annotate-web` are retired. Use `/annotate-pick` for earlier text, `/annotate` for the latest reply, and `/annotate <url-or-html>` for a page. Browser connection controls live in the extension's destination menu.
133
128
 
134
129
  ## Upgrading from the TUI-only package
135
130
 
@@ -174,7 +169,7 @@ Recovery starts in `reference-command.mjs` for `/ref`, `session-tools.mjs` for a
174
169
 
175
170
  `opencode-annotate` provides companion support for Google Antigravity CLI (`agy`) via `agy-annotate`:
176
171
 
177
- - **Slash commands `/annotate` & `/annotate-web`**: Built-in AGY skill at `agy/skills/annotate/` handles review directly within active AGY sessions.
172
+ - **Slash command `/annotate`**: Built-in AGY skill at `agy/skills/annotate/` handles text and explicit URL/HTML review within active AGY sessions.
178
173
  - **Interactive TUI**: Uses the same bundled reviewer as OpenCode, with Dracula theme inheritance and one-key send.
179
174
  - **Native Delivery**: Hooks into AGY lifecycle (`SessionStart`, `PreInvocation`, `Stop`) to deliver feedback directly into the conversation turn without network listeners.
180
175
  - **CLI Commands**:
@@ -211,37 +206,37 @@ Click the Annotate toolbar button, or use Option+Shift+A where Safari supports t
211
206
 
212
207
  Safari requires an App-Sandboxed app extension, so it cannot start the Node bridge or read the session registry. It has no direct session delivery or session chooser; Chrome retains both. Safari also has no docked side panel: its separate window stays bound to the reviewed browser window and keeps polling while you work on the page.
213
208
 
214
- Set the plugin option `"browser": "Safari"` so `/annotate-web <url-or-html-file>` opens the page in Safari. The only public values are `"Chrome"` (default) and `"Safari"`; Chrome maps to the macOS app Google Chrome. AGY supports the same choice with `agy-annotate web <url> --browser Safari`. Restart the client after changing the option. `/annotate-web` keeps its existing pairing lifecycle; Safari ignores that pairing and copies notes instead. `/annotate` remains the text/TUI command.
209
+ Set the plugin option `"browser": "Safari"` so `/annotate <url-or-html-file>` opens the page in Safari. The only public values are `"Chrome"` (default) and `"Safari"`; Chrome maps to the macOS app Google Chrome. AGY supports the same choice with `agy-annotate web <url> --browser Safari`. Safari ignores session registration and copies notes instead. Plain `/annotate` still opens the text reviewer.
215
210
 
216
211
  After updates, run `npm run build:safari` with the signing variables again, then `npm run install:safari`. Reopen the app and re-enable the extension if needed. An unpacked Chrome reload does not update the installed Safari app.
217
212
 
218
213
  ### Chrome (direct delivery)
219
214
 
220
215
  1. Clone this repository and load its `browser/` directory as an unpacked extension in `chrome://extensions`. Allow file URL access if reviewing local HTML.
221
- 2. Run `npm run install:bridge` in the clone to register the native host. It allows only this companion's fixed extension ID and resolves Node absolutely. The host starts on demand and opens no HTTP port.
222
- 3. Reopen the OpenCode terminal client; the shared service needs no restart.
216
+ 2. Reopen the OpenCode terminal client. The plugin registers the native host and active sessions automatically on macOS; the shared service needs no restart. The host allows only this companion's fixed extension ID, resolves Node absolutely, starts on demand and opens no HTTP port.
217
+ 3. Open the extension panel and choose a destination. If automatic setup reports an error, run `npm run install:bridge` in the clone to repair it.
223
218
 
224
- Run `/annotate-web`, then open the Chrome extension. From the blank home screen, it creates an empty session in the current directory using the selected model; no first prompt is needed. In an existing session, it pairs that session. A sole live session is shown automatically; with several sessions, choose one once. Click the destination beside **To** to change or refresh it. Its title stays visible beside Send, including while disconnected, with its directory available on hover and in the chooser. A sole target is only preselected: no binding or model turn occurs until the user clicks **Send & continue**. A disconnected destination never silently switches to another session.
219
+ Click the destination beside **To** to filter sessions by title or directory and sort by recent activity, creation or title. The picker refreshes automatically and shows current session titles. **New session** creates an empty session with the chosen session's location/model, or the blank OpenCode home's current selection, without starting a model turn. **Disconnect** keeps the destination named and notes local; choosing that session again reconnects. A disconnected destination never silently switches to another session. Restarted receivers reconnect by stable provider/session identity, carrying any retry batch to the replacement.
225
220
 
226
- Choose **Pick element** or select text, then write a comment or question. The composer appears for that selection. **Send N notes & continue** saves the current feedback and sends pending notes in one action; **Add note** collects feedback locally for a batch. Cmd/Ctrl+Enter adds a note or saves an edit. This sends pending notes to that captured session and starts a normal model turn; pairing and saving notes make no model call. Switching terminal tabs never changes the paired target. Revoke with `/annotate-web off`.
221
+ Choose **Pick element** or select text, then write a comment or question. The composer appears for that selection. **Send N notes & continue** saves current feedback and sends all pending notes across pages; **Add note** collects feedback locally. Cmd/Ctrl+Enter adds a note or saves an edit. Confirmed sends use `steer` / `resume: true`: idle sessions start immediately and running turns receive feedback at their next processing boundary. Registering, creating sessions and saving notes make no model call. Switching terminal tabs never changes the captured destination.
227
222
 
228
- The numbered queue matches the page markers. Click a note's quoted target to show it on the page without activating the element; **Edit** changes the feedback, and **Undo** restores a deleted note. The delivery bar shows the round's note count and destination.
223
+ The queue groups notes by page, with contiguous numbers matching page markers and delivered Markdown. Click a note's quoted target to show it on its page without activating the element; off-page notes can open their page. **Edit** changes the feedback, and **Undo** restores a deleted note. The delivery bar shows the whole round's count and destination; drafts remain page-local.
229
224
 
230
- Each send closes a review round: delivered notes leave the list and the panel is ready for the next round. **Restore last round** returns the most recent delivered notes to the list; the last ten rounds per page are kept.
225
+ Each send closes the global review round: delivered notes leave the list and the panel is ready for the next round. **Restore last round** returns the most recent round's notes across pages; the last ten rounds are kept globally.
231
226
 
232
- Delivery has two modes, shown beside the destination. With a **Live** session the primary button is **Send N notes**, and the copy icon beside it copies the round instead. When the session is **Offline**, or none is connected, the button is **Copy N notes**: it copies the round as Markdown for any agent and closes it the same way. Run `/annotate-web` in a session to switch back to Send. If a session drops during Send, the notes are kept and the panel switches to Copy. **More review options** contains a non-closing Markdown copy, JSON export, and a preview of the current round.
227
+ **Send** and **Copy instead** remain separate actions. Send requires a live destination; Copy instead copies the grouped round as Markdown for any agent and closes it the same way. If a session drops during Send, notes remain available for retry or copying. **More review options** contains a non-closing Markdown copy, JSON export, and a preview of the current round.
233
228
 
234
229
  After a page reload or same-site navigation, the panel reconnects its page tools automatically. If Chrome has withdrawn access (for example after moving to another site), the panel asks you to click the extension icon once; saved notes are kept.
235
230
 
236
231
  ### Explicit routing
237
232
 
238
- `/annotate`, `/annotate-pick` and `/annotate-selection` always use the TUI; Markdown and plain-text files do too. Only `/annotate-web` enters the browser workflow; passing a URL or HTML file to `/annotate` points you there. A reply containing HTML links or code fences does not change the default.
233
+ Plain `/annotate`, `/annotate-pick` and `/annotate-selection` use the TUI; Markdown and plain-text files do too. Explicit URLs and HTML paths passed to `/annotate` enter the browser workflow. A reply containing HTML links or code fences does not change the default.
239
234
 
240
235
  ### Browser safeguards and limitations
241
236
 
242
237
  Written drafts autosave locally and restore after panel reload or a return to the same URL, including SPA routes. Selecting another target with unfinished feedback offers **Add/Save & switch**, **Keep editing**, or **Discard & switch**. Storage failures keep the input and offer a retry; competing panels require an explicit choice of draft. Saved-note revision checks likewise prevent stale tabs overwriting newer feedback. Full JSON/Markdown exports include redacted URLs, exact selected text/context, verified selector hints, styles and accessibility. Missing/changed/ambiguous targets are labeled in the sidebar instead of silently rebound. Comments and drafts live in extension-owned UI/storage; the page receives only selection metadata and numbered markers, not your written feedback.
243
238
 
244
- Native delivery requires an open, paired local TUI. If the receiver closes, feedback stays pending. A failed batch retains its original target and ID for safe retry; if that target is permanently gone, export the notes before starting a new review. **Retry N notes & continue** retries that original batch; newly composed feedback stays local for the next send. Copying a round instead supersedes a failed batch. Clipboard failures expose a selectable preview and keep the round open. Browser-internal pages, PDF, cross-origin iframes, Canvas and remote SSH TUI clients are outside this version's scope. Page Context is retired only after exporting its drafts and verifying this replacement.
239
+ Native delivery requires an open local TUI and a connected destination. If the receiver closes, feedback stays pending. A failed batch retains its original target and ID for safe retry; if that session is permanently gone, export the notes before starting a new review. **Retry N notes & continue** retries that original batch; newly composed feedback stays local for the next send. Copying a round instead supersedes a failed batch. Clipboard failures expose a selectable preview and keep the round open. Browser-internal pages, PDF, cross-origin iframes, Canvas and remote SSH TUI clients are outside this version's scope. Page Context is retired only after exporting its drafts and verifying this replacement.
245
240
 
246
241
  See [implementation plan](docs/annotate-html-integration-plan.md) and [shipped-artifact evaluation](docs/annotate-html-evaluation.md), plus [browser provenance](browser/UPSTREAM.md). `npm test`, `npm run test:smoke`, and `npm run test:browser` verify each layer; the browser test uses an existing Playwright installation (`PLAYWRIGHT_MODULE`) and browser executable (`CHROMIUM_PATH`) in an isolated profile.
247
242
 
@@ -387,9 +382,8 @@ See [release instructions](docs/releasing.md) and [changelog](CHANGELOG.md).
387
382
  - `/annotate 文档.md`:批注文档,支持中文、空格和相对路径。
388
383
  - `/annotate-pick`:从最近的回复和运行中的进度说明里选一条批注。
389
384
  - `/annotate-selection`:先在会话里拖选文字,再批注包含这段文字的消息。
390
- - `/annotate-last`:固定批注最新一条完整回复,忽略附带参数。
391
385
  - `/ref`:选择并引用同项目的历史会话,可附整段评论;选择器中按 `Ctrl+A` 切换项目范围,按 `Ctrl+T` 打开 TUI 添加逐段批注;`/ref --all 关键词` 跨项目搜索;`/ref --tui 关键词` 直接进入 TUI 流程;`/ref ses_…` 直接指定。快照、评论和批注合并为一条普通用户提示,确认后继续对话;在首条消息之前(包括 OpenCode 首页,确认后才新建会话),只附加不启动助手,可多次引用后再开口。
392
- - `/annotate-web`:配对 Chrome;空白首页会先创建空会话,无需先发提示词。`/annotate-web 页面.html`、`/annotate-web https://…` 批注网页;`/annotate-web off` 撤销配对。
386
+ - `/annotate 页面.html`、`/annotate https://…`:打开网页批注。Chrome 自动注册主机和会话,扩展目的地菜单可筛选、新建空会话、断开及重连;Safari 保持仅复制。跨页备注汇成一轮,Send 与 Copy instead 分开,确认发送后自动继续原会话。
393
387
  - 选中文字 → `c` 写批注 → Enter 保存 → `q` 发送并返回。
394
388
  - 写批注中途按 `Ctrl+S`,一步保存、返回并发送(中文输入法开着也有效);`Ctrl+C` 返回后由 OpenCode 询问。
395
389
  - 文档采用独立快照,反馈附原文件路径,确认后发回发起批注的会话。
@@ -10,10 +10,10 @@ import { listTargets } from "../bridge/receiver.mjs"
10
10
  import { request } from "../bridge/wire.mjs"
11
11
 
12
12
  const sampleReview = () => ({
13
- version: 1,
14
- page: { url: "https://example.test/app", title: "App Preview" },
13
+ version: 2,
15
14
  annotations: [
16
15
  {
16
+ page: { url: "https://example.test/app", title: "App Preview" },
17
17
  id: "note-1",
18
18
  revision: 1,
19
19
  kind: "comment",
@@ -1,11 +1,11 @@
1
1
  ---
2
2
  name: annotate
3
- description: Review assistant replies or local documents in the bundled Annotate TUI, or pair the Chrome companion for webpage annotation. Use for /annotate, /annotate-web, reply/document annotation, or webpage review in an AGY session.
3
+ description: Review assistant replies or local documents in the bundled Annotate TUI, or connect the Chrome companion for webpage annotation. Use for /annotate, reply/document annotation, or webpage review in an AGY session.
4
4
  ---
5
5
 
6
6
  # Annotate (`agy-annotate`)
7
7
 
8
- Use this skill when the user runs `/annotate`, `/annotate-web`, or asks to annotate assistant responses, documents, or webpages.
8
+ Use this skill when the user runs `/annotate` or asks to annotate assistant responses, documents, or webpages.
9
9
 
10
10
  ## Execution Guide for the Agent:
11
11
 
@@ -22,7 +22,7 @@ Run the command:
22
22
  npx --yes --package @nxxxsooo/opencode-annotate@latest agy-annotate tui "<path/to/doc.md>"
23
23
  ```
24
24
 
25
- ### 3. When the user types `/annotate-web` (or provides a URL/HTML file):
25
+ ### 3. When the user provides a URL/HTML file (e.g., `/annotate page.html`) or asks for webpage review:
26
26
  Run the command:
27
27
  ```bash
28
28
  npx --yes --package @nxxxsooo/opencode-annotate@latest agy-annotate web [url-or-html-path]
@@ -16,12 +16,15 @@ decodeStream(process.stdin, async message => {
16
16
  const targets = await listTargets(config.targetsDirectory)
17
17
  if (message.action === "targets") {
18
18
  const live = await Promise.all(targets.map(async target => {
19
- try { return (await request(target.socket, { action: "info", targetID: target.id })).target } catch { return null }
19
+ try {
20
+ const result = await request(target.socket, { action: "info", targetID: target.id })
21
+ return result.ok && result.target ? result.target : null
22
+ } catch { return null }
20
23
  }))
21
24
  response = { ok: true, targets: live.filter(Boolean) }
22
25
  } else {
23
26
  const target = targets.find(target => target.id === message.targetID)
24
- if (!target) throw new Error("Paired session is offline; run /annotate-web in it to reconnect")
27
+ if (!target) throw new Error("Paired session is offline; reopen it in OpenCode or AGY to reconnect")
25
28
  response = await request(target.socket, message)
26
29
  }
27
30
  } catch (error) { response = { ok: false, error: error.message } }
@@ -5,6 +5,7 @@ import os from "node:os"
5
5
  import path from "node:path"
6
6
  import { encode, decodeStream } from "./wire.mjs"
7
7
  import { markdown, validateReview } from "../browser/protocol.mjs"
8
+ import { feedbackInput } from "../delivery.mjs"
8
9
 
9
10
  export const registryRoot = () => path.join(os.homedir(), ".local/share/opencode-annotate/targets")
10
11
  export async function listTargets(root = registryRoot()) {
@@ -24,14 +25,24 @@ export async function listTargets(root = registryRoot()) {
24
25
  }
25
26
  return results
26
27
  }
27
- export async function createReceiver({ sessionID, title, directory, provider = "opencode", deliver, client, root = registryRoot(), resume = true, onError = () => {} }) {
28
+ export async function createReceiver({ sessionID, title, directory, provider = "opencode", deliver, client, getInfo, createSession, root = registryRoot(), resume = true, onError = () => {} }) {
28
29
  await mkdir(root, { recursive: true, mode: 0o700 }); await chmod(root, 0o700)
29
- const id = randomUUID(), socketPath = path.join(root, `${id}.sock`)
30
+ const id = randomUUID(), registered = Date.now(), socketPath = path.join(root, `${id}.sock`)
30
31
  // macOS sockaddr_un is limited to 104 bytes, including the NUL terminator.
31
32
  if (Buffer.byteLength(socketPath) > 103) throw new Error("Annotation socket path is too long")
32
- const target = { id, title, directory, sessionID, provider, socket: socketPath, pid: process.pid }
33
- const received = new Map(), sockets = new Set()
34
- let closed = false
33
+ const kind = sessionID ? "session" : "workspace"
34
+ const target = { id, title, directory, sessionID, provider, kind, socket: socketPath, pid: process.pid }
35
+ const received = new Map(), creations = new Map(), sockets = new Set()
36
+ let closed = false, connected = !!sessionID
37
+ async function info() {
38
+ if (closed) throw new Error("Annotation connection is closed")
39
+ const extra = getInfo ? await getInfo() : {}
40
+ if (extra === null) return null
41
+ const session = client && sessionID ? await client.session.get({ sessionID }) : undefined
42
+ const time = session?.time ? { created: session.time.created, updated: session.time.updated } : {}
43
+ return { id, title: session?.title || title, directory, provider, sessionID, kind, registered,
44
+ ...time, ...extra, connected, canCreate: !!createSession }
45
+ }
35
46
  const server = net.createServer(socket => {
36
47
  let handled = false
37
48
  sockets.add(socket); socket.once("close", () => sockets.delete(socket)); socket.on("error", () => {})
@@ -42,12 +53,27 @@ export async function createReceiver({ sessionID, title, directory, provider = "
42
53
  try {
43
54
  if (closed || message.targetID !== id) throw new Error("Pairing is no longer active")
44
55
  if (message.action === "info") {
45
- if (client) await client.session.get({ sessionID })
46
- socket.end(encode({ ok: true, target: { id, title, directory, provider } })); return
56
+ // Registration happens before OpenCode generates a title; report the live one.
57
+ socket.end(encode({ ok: true, target: await info() })); return
58
+ }
59
+ if (["connect", "disconnect"].includes(message.action)) {
60
+ if (!sessionID) throw new Error("Create a session in this workspace first")
61
+ connected = message.action === "connect"
62
+ socket.end(encode({ ok: true, target: await info() })); return
63
+ }
64
+ if (message.action === "create-session") {
65
+ if (!createSession || !/^[a-f0-9-]{36}$/.test(message.requestID)) throw new Error("Invalid session creation request")
66
+ if (!creations.has(message.requestID)) {
67
+ const promise = Promise.resolve().then(createSession)
68
+ creations.set(message.requestID, promise)
69
+ promise.catch(() => creations.delete(message.requestID))
70
+ }
71
+ socket.end(encode({ ok: true, target: await creations.get(message.requestID) })); return
47
72
  }
73
+ if (!connected) throw new Error("Session disconnected; select it in Annotate to reconnect")
48
74
  if (message.action !== "send" || !/^[a-f0-9-]{36}$/.test(message.batchID)) throw new Error("Invalid delivery request")
49
- validateReview(message.review)
50
- const digest = createHash("sha256").update(JSON.stringify(message.review)).digest("hex")
75
+ const review = structuredClone(validateReview(message.review)), text = markdown(review)
76
+ const digest = createHash("sha256").update(JSON.stringify(review)).digest("hex")
51
77
  const existing = received.get(message.batchID)
52
78
  if (existing && existing.digest !== digest) throw new Error("Batch ID was reused with different content")
53
79
  if (!existing) {
@@ -55,11 +81,11 @@ export async function createReceiver({ sessionID, title, directory, provider = "
55
81
  const promptID = `msg_${createHash("sha256").update(`${id}:${message.batchID}`).digest("hex").slice(0, 32)}`
56
82
  const promise = (async () => {
57
83
  if (deliver) {
58
- const res = await deliver({ review: message.review, promptID, markdown: markdown(message.review), batchID: message.batchID })
84
+ const res = await deliver({ review, promptID, markdown: text, batchID: message.batchID })
59
85
  return { ok: true, messageID: res?.id || promptID, state: "admitted" }
60
86
  }
61
87
  await client.session.get({ sessionID })
62
- const response = await client.session.prompt({ sessionID, id: promptID, text: markdown(message.review), delivery: "queue", resume })
88
+ const response = await client.session.prompt(feedbackInput({ sessionID, id: promptID, text, resume }))
63
89
  return { ok: true, messageID: response?.id || promptID, state: "admitted" }
64
90
  })()
65
91
  received.set(message.batchID, { digest, promise })
@@ -75,7 +101,7 @@ export async function createReceiver({ sessionID, title, directory, provider = "
75
101
  const registration = path.join(root, `${id}.json`)
76
102
  try { await writeFile(registration, JSON.stringify(target), { mode: 0o600, flag: "wx" }) }
77
103
  catch (error) { await new Promise(resolve => server.close(resolve)); await rm(socketPath, { force: true }); throw error }
78
- return { target, async close() {
104
+ return { target, info, async close() {
79
105
  if (closed) return
80
106
  closed = true; for (const socket of sockets) socket.destroy()
81
107
  await new Promise(resolve => server.close(resolve))
@@ -6,4 +6,6 @@ Based on Asim Sayed's MIT-licensed [Annotate HTML](https://github.com/AsimSayed/
6
6
 
7
7
  `inspector.js` adapts the original element identification, computed-style snapshot, and accessibility collectors. This local enhancement replaces the in-page comment popup and volatile state with an extension-origin side panel, durable per-note storage, exact range context and validated selectors. It adds complete export and opt-in paired session delivery. The original upstream implementation is not injected alongside the enhanced runtime.
8
8
 
9
- This is a distinct local extension with its own ID, not an official Annotate HTML update. It has no upstream update URL, analytics or external data service. Only user-requested Native Messaging can send feedback to a paired local OpenCode client. Native Messaging and side-panel installation are macOS/Chrome-only in this version.
9
+ This is a distinct local extension with its own ID, not an official Annotate HTML update. It has no upstream update URL, analytics or external data service. Only user-requested Native Messaging can send feedback to a paired local OpenCode client.
10
+
11
+ This version runs in Chrome and Safari. Chrome uses its native messaging host and a docked side panel. Safari has no docked panel, and it only registers an App-Sandboxed app extension, which cannot reach the local Node bridge. The Safari build therefore keeps notes local and copies rounds out, and the panel opens as its own window. Chrome keeps Native Messaging and session delivery. Both browsers are macOS-only in this version.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "OpenCode Annotate",
4
- "version": "0.14.0",
4
+ "version": "0.15.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.css CHANGED
@@ -67,7 +67,7 @@ kbd { font: 12px/1.3 system-ui; color: var(--muted); }
67
67
  .notes-section { margin-top: 22px; }
68
68
  ol { list-style: none; margin: 0; padding: 0; }
69
69
  .note { display: grid; grid-template-columns: 24px minmax(0, 1fr); column-gap: 10px; border-top: 1px solid var(--line); padding: 15px 0 14px; }
70
- .note:first-child { border-top: 0; padding-top: 5px; }
70
+ .note:first-child, .page-group + .note { border-top: 0; padding-top: 5px; }
71
71
  .note-number { display: grid; place-items: center; width: 24px; height: 24px; margin-top: 2px; border: 1px solid var(--input); border-radius: 50%; color: var(--muted); font-size: 12px; font-weight: 650; font-variant-numeric: tabular-nums; }
72
72
  .note.is-current .note-number { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }
73
73
  .note-target { display: flex; align-items: flex-start; gap: 6px; width: 100%; min-height: 28px; padding: 2px 0; border: 0; background: transparent; color: var(--muted); font-size: 13px; line-height: 1.5; font-weight: 400; text-align: left; }
@@ -87,16 +87,16 @@ ol { list-style: none; margin: 0; padding: 0; }
87
87
  .empty-state .empty-footnote { margin-top: 24px; font-size: 13px; }
88
88
  .inline-notice { display: flex; align-items: center; gap: 8px; padding: 10px 0; margin-top: 12px; font-size: 13px; color: var(--muted); }
89
89
  .inline-notice span { flex: 1; }
90
- .delivery { min-width: 0; padding: 10px 16px 12px; border-top: 1px solid var(--line); background: var(--bg); }
90
+ .delivery { position: relative; min-width: 0; padding: 10px 16px 12px; border-top: 1px solid var(--line); background: var(--bg); }
91
91
  .destination { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; min-width: 0; }
92
92
  .destination > .icon { width: 16px; height: 16px; color: var(--muted); }
93
93
  .destination-label { color: var(--muted); font-size: 13px; }
94
94
  .destination-button { display: inline-flex; align-items: center; justify-content: flex-start; gap: 5px; min-width: 0; flex: 1; min-height: 28px; padding: 3px 0; border: 0; background: transparent; font-size: 13px; font-weight: 400; text-align: left; }
95
95
  #paired { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
96
96
  .destination-button .icon { width: 14px; height: 14px; color: var(--muted); }
97
- .send-row { display: flex; gap: 6px; }
98
- #send { flex: 1; min-width: 0; min-height: 39px; font-size: 14px; font-weight: 600; }
99
- #copy-round { width: 39px; height: 39px; min-height: 39px; border-color: var(--line); }
97
+ .send-row { display: flex; flex-wrap: wrap; gap: 6px; }
98
+ #send { flex: 1 1 130px; min-width: 0; min-height: 39px; font-size: 14px; font-weight: 600; }
99
+ #copy-round { flex: 1 1 110px; min-height: 39px; border-color: var(--line); white-space: nowrap; }
100
100
  .empty-state #restore-round { margin-top: 10px; }
101
101
  .primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
102
102
  .primary:disabled { opacity: 1; background: var(--soft); border-color: var(--line); color: var(--muted); }
@@ -111,13 +111,30 @@ ol { list-style: none; margin: 0; padding: 0; }
111
111
  #status.error { color: var(--error); }
112
112
  #status.warning { color: var(--warning); }
113
113
  #status.success { color: var(--success); }
114
- .session-chooser, .utilities { margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
115
- .session-chooser select { padding: 8px; font-size: 13px; }
114
+ .utilities { margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
115
+ .session-chooser { position: absolute; z-index: 2; right: 12px; bottom: calc(100% - 4px); left: 12px; max-height: 45dvh; overflow: auto; padding: 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); box-shadow: 0 8px 24px light-dark(#27251f20, #0006); }
116
+ .session-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
117
+ .session-tools input { flex: 1 1 8rem; min-width: 0; padding: 6px 9px; border: 1px solid var(--input); border-radius: 6px; background: var(--surface); color: var(--text); font: inherit; font-size: 13px; }
118
+ .session-tools input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
119
+ .session-tools select { width: auto; flex: none; padding: 6px 8px; font-size: 12px; }
120
+ .session-list { display: grid; gap: 2px; }
121
+ .session-row { display: grid; justify-content: stretch; justify-items: start; gap: 1px; width: 100%; min-height: 0; padding: 6px 8px; border: 1px solid transparent; border-radius: 5px; background: transparent; text-align: left; font-weight: 400; }
122
+ .session-row:hover:not(:disabled) { background: var(--soft); border-color: transparent; }
123
+ .session-row[aria-pressed="true"] { border-color: var(--input); background: var(--soft); }
124
+ .session-row:focus-visible { outline-offset: 0; }
125
+ .session-title, .session-meta { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
126
+ .session-title { font-size: 13px; }
127
+ .session-meta { font-size: 11.5px; color: var(--muted); }
128
+ #show-all-sessions { margin-top: 2px; }
129
+ .session-actions { display: flex; flex-wrap: wrap; gap: 12px; }
130
+ #workspaces { margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--line); }
116
131
  .hint { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
132
+ #connection-hint:empty { display: none; }
117
133
  #connection-hint { margin-top: 7px; }
118
- #refresh-targets { margin-top: 8px; }
119
134
  .utility-row { display: flex; flex-wrap: wrap; gap: 8px; }
120
135
  details { margin-top: 10px; }
121
136
  summary { min-height: 30px; padding: 4px 0; cursor: pointer; color: var(--muted); font-size: 13px; }
122
137
  pre { max-height: 240px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--muted); font: 12px/1.5 ui-monospace, monospace; }
123
138
  @media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
139
+ .page-group { list-style: none; display: grid; gap: 2px; padding: 12px 0 4px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
140
+ .page-group strong { color: var(--text); font-size: 13px; font-weight: 650; }
@@ -25,10 +25,6 @@
25
25
  <div class="utility-row"><button id="copy"><svg class="icon" aria-hidden="true"><use href="#icon-copy"/></svg>Copy Markdown</button><button id="export"><svg class="icon" aria-hidden="true"><use href="#icon-download"/></svg>Export JSON</button></div>
26
26
  <details id="context-details"><summary>Review context · current round</summary><pre id="preview"></pre></details>
27
27
  </section>
28
- <section id="session-options" class="session-chooser" aria-label="Destination selection" hidden>
29
- <label for="targets">Choose session</label><select id="targets"><option value="">Choose a session…</option></select>
30
- <p id="connection-hint" class="hint" aria-live="polite"></p><button id="refresh-targets">Refresh sessions</button>
31
- </section>
32
28
  <div id="update-notice" class="update-notice" role="status" hidden><strong>Annotate was updated</strong><p>Reload once to finish. Notes and drafts are kept; reopen the panel with the icon or Alt+Shift+A afterwards.</p><button id="reload-extension" class="primary">Reload Annotate</button></div>
33
29
  <p id="page-error" class="error" role="alert" hidden></p>
34
30
  <div class="picker-row"><button id="pick" aria-pressed="false"><svg class="icon" aria-hidden="true"><use href="#icon-pick"/></svg><span id="pick-label">Pick element</span></button><span id="pick-hint">or select text</span></div>
@@ -47,8 +43,16 @@
47
43
  <section id="empty-state" class="empty-state"><h2 id="empty-title">Start with what you see.</h2><p>Pick an element or highlight text on the page, then describe what needs attention.</p><p id="empty-footnote" class="empty-footnote">Send one note straight away, or collect a few first. Your feedback stays local until you send.</p><button id="restore-round" class="text-button" hidden>Restore last round</button></section>
48
44
  </main>
49
45
  <footer class="delivery">
46
+ <section id="session-options" class="session-chooser" aria-label="Destination selection" hidden>
47
+ <div class="session-tools"><input id="session-filter" type="search" placeholder="Filter sessions" aria-label="Filter sessions" autocomplete="off" spellcheck="false"><select id="session-sort" aria-label="Sort sessions"><option value="updated">Recently updated</option><option value="created">Recently created</option><option value="title">Title</option></select></div>
48
+ <div id="targets" class="session-list" role="group" aria-label="Destination session"></div>
49
+ <button id="show-all-sessions" class="text-button" type="button" hidden></button>
50
+ <div id="workspaces" class="session-list" aria-label="OpenCode workspaces" hidden></div>
51
+ <div class="session-actions"><button id="new-session" class="text-button" type="button" hidden>New session</button><button id="disconnect" class="text-button" type="button" hidden>Disconnect</button></div>
52
+ <p id="connection-hint" class="hint" aria-live="polite"></p>
53
+ </section>
50
54
  <div class="destination"><svg class="icon" aria-hidden="true"><use href="#icon-session"/></svg><span class="destination-label">To</span><button id="change-target" class="destination-button" aria-label="Change destination session" aria-expanded="false" aria-controls="session-options"><span id="paired">Looking for your session…</span><svg class="icon" aria-hidden="true"><use href="#icon-chevron"/></svg></button><span id="link-state" class="link-state"></span></div>
51
- <div class="send-row"><button id="send" class="primary" aria-describedby="paired status"><svg id="send-copy" class="icon" aria-hidden="true" hidden><use href="#icon-copy"/></svg><span id="send-label">Send &amp; continue</span><svg id="send-arrow" class="icon" aria-hidden="true" hidden><use href="#icon-arrow"/></svg></button><button id="copy-round" class="icon-button" aria-label="Copy notes instead and start the next round" title="Copy instead · paste into any agent" hidden><svg class="icon" aria-hidden="true"><use href="#icon-copy"/></svg></button></div>
55
+ <div class="send-row"><button id="send" class="primary" aria-describedby="paired status"><span id="send-label">Send notes</span><svg id="send-arrow" class="icon" aria-hidden="true" hidden><use href="#icon-arrow"/></svg></button><button id="copy-round" class="soft" aria-label="Copy notes instead and start the next round" title="Copy instead · paste into any agent" hidden><svg class="icon" aria-hidden="true"><use href="#icon-copy"/></svg><span>Copy instead</span></button></div>
52
56
  <p id="status" role="status" aria-live="polite">Looking for your OpenCode session…</p>
53
57
  </footer>
54
58
  <script type="module" src="panel.mjs"></script>