@nxxxsooo/opencode-annotate 0.5.0 → 0.6.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 +30 -0
- package/README.md +75 -24
- package/browser/capture.js +23 -3
- package/browser/manifest.json +1 -1
- package/browser/panel.css +114 -3
- package/browser/panel.html +50 -17
- package/browser/panel.mjs +385 -105
- package/browser/worker.mjs +88 -10
- package/package.json +3 -2
- package/review.mjs +111 -36
- package/theme.mjs +115 -0
- package/tui.ts +26 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.0 — annotate any session text
|
|
4
|
+
|
|
5
|
+
### Text review
|
|
6
|
+
|
|
7
|
+
- Add `/annotate-pick` to choose among recent replies and mid-turn progress updates, and
|
|
8
|
+
`/annotate-selection` to review the message containing the last transcript selection.
|
|
9
|
+
- Move browser review to `/annotate-web` (pairing, URL, HTML file or `off`); `/annotate`
|
|
10
|
+
now handles replies and documents only. Retire numbered `/annotate N`.
|
|
11
|
+
|
|
12
|
+
### Inherited TUI colors
|
|
13
|
+
|
|
14
|
+
- Add opt-in `inheritTheme` support for the color-capable Plannotator fork, including
|
|
15
|
+
the OpenCode canvas, text, Markdown, borders, selection and cursor contrast pairs.
|
|
16
|
+
Inherited colors also cover strong/emphasis text, list markers, rules, link labels,
|
|
17
|
+
table headers and the send button.
|
|
18
|
+
- Validate a private per-review configuration before suspending the terminal; preserve
|
|
19
|
+
the user's layout settings, including the fork's `doc_width`, and keep the themed
|
|
20
|
+
config with recoverable drafts.
|
|
21
|
+
|
|
22
|
+
### Compact browser workspace
|
|
23
|
+
|
|
24
|
+
- Replace the always-expanded browser form with a selection-focused composer, numbered
|
|
25
|
+
note queue, and persistent destination/delivery bar; keep controls visible at narrow widths and zoom.
|
|
26
|
+
- Autosave unfinished feedback by page, recover it after navigation or panel reload, and
|
|
27
|
+
protect selection changes and competing-panel edits with explicit draft choices.
|
|
28
|
+
- Fix cancelling and reselecting the same element, add safe Show on page and revision-aware
|
|
29
|
+
deletion Undo, and keep the intended destination visible while disconnected.
|
|
30
|
+
- Show pending/sent counts, distinguish original-batch retries from new feedback, and move
|
|
31
|
+
copy/export/context utilities into More review options. **Save note** is now **Add note**.
|
|
32
|
+
|
|
3
33
|
## 0.5.0 — new package name
|
|
4
34
|
|
|
5
35
|
- Publish as `@nxxxsooo/opencode-annotate` from `nxxxsooo/opencode-annotate`. The old
|
package/README.md
CHANGED
|
@@ -17,23 +17,28 @@ Published on npm as `@nxxxsooo/opencode-annotate`. It replaces `opencode-plannot
|
|
|
17
17
|
|
|
18
18
|
```text
|
|
19
19
|
/annotate Review the last completed assistant reply
|
|
20
|
-
/annotate 2 Review the second most recent reply
|
|
21
|
-
/annotate 3 Review the third most recent reply
|
|
22
20
|
/annotate docs/plan.md Review a Markdown document
|
|
23
21
|
/annotate "docs/release plan.md" Review a path containing spaces
|
|
24
22
|
/annotate ~/Documents/notes.txt Review a plain-text document
|
|
25
|
-
/annotate
|
|
26
|
-
/annotate
|
|
27
|
-
/annotate
|
|
28
|
-
/annotate
|
|
23
|
+
/annotate-pick Choose a recent reply or mid-turn progress update
|
|
24
|
+
/annotate-selection Review the message containing your last transcript selection
|
|
25
|
+
/annotate-web Open this session for browser pairing
|
|
26
|
+
/annotate-web page.html Review the specified local HTML in Chrome
|
|
27
|
+
/annotate-web https://example.com Review the specified webpage
|
|
28
|
+
/annotate-web off Revoke this session's browser pairing
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
`/annotate-last` always reviews the latest completed reply; any supplied argument is ignored.
|
|
32
32
|
|
|
33
|
+
Progress updates written during a long tool run are not replies, so `/annotate` skips them.
|
|
34
|
+
Reach them with `/annotate-pick`, or drag over text in the transcript and run
|
|
35
|
+
`/annotate-selection`: the plugin opens the reply or progress update containing that text,
|
|
36
|
+
or just the selected text when it spans messages. Numbered `/annotate N` is retired.
|
|
37
|
+
|
|
33
38
|
## Install
|
|
34
39
|
|
|
35
40
|
Requires **OpenCode 2.0.22+** and a separately installed `plannotator-tui` on your PATH.
|
|
36
|
-
Tested with OpenCode 2.1.
|
|
41
|
+
Tested with OpenCode 2.1.2 and Plannotator TUI 0.9.4 on macOS; unit tests also run on
|
|
37
42
|
Linux. Windows terminal handoff has not been verified.
|
|
38
43
|
|
|
39
44
|
Install the upstream TUI on macOS or Linux:
|
|
@@ -64,6 +69,20 @@ Manual configuration, preserving other entries:
|
|
|
64
69
|
}
|
|
65
70
|
```
|
|
66
71
|
|
|
72
|
+
### Match OpenCode's colors (fork required)
|
|
73
|
+
|
|
74
|
+
Set `"inheritTheme": true` in the plugin's `options`, alongside `binary`. It requires
|
|
75
|
+
the extended color-capable Plannotator fork
|
|
76
|
+
([nxxxsooo/plannotator-tui](https://github.com/nxxxsooo/plannotator-tui), branch
|
|
77
|
+
`feat/layout`); upstream 0.9.4 does not support it. The same fork adds `[ui].doc_width`
|
|
78
|
+
to cap the text column on wide terminals. See [TUI theme integration](docs/tui-theme.md).
|
|
79
|
+
|
|
80
|
+
Each review uses OpenCode's current resolved colors for the canvas, text, Markdown,
|
|
81
|
+
borders, highlights, cursor and selection. The plugin asks the chosen binary for its
|
|
82
|
+
effective configuration, copies it into that review's private directory, and validates
|
|
83
|
+
the themed copy before taking over the terminal. Your original settings stay intact.
|
|
84
|
+
Launchers must honor an existing `PLANNOTATOR_TUI_CONFIG`.
|
|
85
|
+
|
|
67
86
|
## Browser review (optional)
|
|
68
87
|
|
|
69
88
|
Requirements: macOS and Chrome 116+, plus Node 22+ for the native host.
|
|
@@ -75,28 +94,40 @@ Requirements: macOS and Chrome 116+, plus Node 22+ for the native host.
|
|
|
75
94
|
opens no HTTP port.
|
|
76
95
|
3. Reopen the OpenCode terminal client; the shared service needs no restart.
|
|
77
96
|
|
|
78
|
-
Run `/annotate
|
|
79
|
-
session is shown automatically; with several sessions, choose one once.
|
|
80
|
-
|
|
81
|
-
|
|
97
|
+
Run `/annotate-web` in a target session, then open the Chrome extension. A sole live
|
|
98
|
+
session is shown automatically; with several sessions, choose one once. Click the
|
|
99
|
+
destination beside **To** to change or refresh it. Its title stays visible beside Send,
|
|
100
|
+
including while disconnected, with its directory available on hover and in the chooser.
|
|
101
|
+
A sole target is only preselected: no binding or model turn occurs until
|
|
82
102
|
the user clicks **Send & continue**. A disconnected destination never silently switches to another session.
|
|
83
103
|
|
|
84
|
-
Pick
|
|
85
|
-
|
|
86
|
-
|
|
104
|
+
Choose **Pick element** or select text, then write a comment or question. The composer
|
|
105
|
+
appears for that selection. **Send N notes & continue** saves the current feedback and
|
|
106
|
+
sends pending notes in one action; **Add note** collects feedback locally for a batch.
|
|
107
|
+
Cmd/Ctrl+Enter adds a note or saves an edit. This sends pending notes to that captured
|
|
87
108
|
session and starts a normal model turn; pairing and saving notes make no model call.
|
|
88
|
-
Switching terminal tabs never changes the paired target. Revoke with `/annotate
|
|
109
|
+
Switching terminal tabs never changes the paired target. Revoke with `/annotate-web off`.
|
|
110
|
+
|
|
111
|
+
The numbered queue matches the page markers. Click a note's quoted target to show it
|
|
112
|
+
on the page without activating the element; **Edit** changes the feedback, and **Undo**
|
|
113
|
+
restores a deleted note. The delivery bar shows the pending count, destination, and sent
|
|
114
|
+
state. **More review options** contains Markdown copy, JSON export, and a preview of
|
|
115
|
+
all saved notes.
|
|
89
116
|
|
|
90
117
|
### Explicit routing
|
|
91
118
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
119
|
+
`/annotate`, `/annotate-pick` and `/annotate-selection` always use the TUI; Markdown and
|
|
120
|
+
plain-text files do too. Only `/annotate-web` enters the browser workflow; passing a URL or
|
|
121
|
+
HTML file to `/annotate` points you there. A reply containing HTML links or code fences does
|
|
122
|
+
not change the default.
|
|
95
123
|
|
|
96
124
|
### Browser safeguards and limitations
|
|
97
125
|
|
|
98
|
-
|
|
99
|
-
|
|
126
|
+
Written drafts autosave locally and restore after panel reload or a return to the same URL,
|
|
127
|
+
including SPA routes. Selecting another target with unfinished feedback offers **Add/Save
|
|
128
|
+
& switch**, **Keep editing**, or **Discard & switch**. Storage failures keep the input and
|
|
129
|
+
offer a retry; competing panels require an explicit choice of draft. Saved-note revision
|
|
130
|
+
checks likewise prevent stale tabs overwriting newer feedback. Full JSON/Markdown exports include
|
|
100
131
|
redacted URLs, exact selected text/context, verified selector hints, styles and accessibility.
|
|
101
132
|
Missing/changed/ambiguous targets are labeled in the sidebar instead of silently rebound.
|
|
102
133
|
Comments and drafts live in extension-owned UI/storage; the page receives only selection
|
|
@@ -104,8 +135,10 @@ metadata and numbered markers, not your written feedback.
|
|
|
104
135
|
|
|
105
136
|
Native delivery requires an open, paired local TUI. If the receiver closes, feedback stays
|
|
106
137
|
pending. A failed batch retains its original target and ID for safe retry; if that target
|
|
107
|
-
is permanently gone, export the notes before starting a new review.
|
|
108
|
-
|
|
138
|
+
is permanently gone, export the notes before starting a new review. **Retry N notes &
|
|
139
|
+
continue** retries that original batch; newly composed feedback stays local for the next
|
|
140
|
+
send. Changed sent notes become new pending revisions; unchanged edits send nothing new.
|
|
141
|
+
Clipboard failures expose a selectable preview. Browser-internal pages, PDF,
|
|
109
142
|
cross-origin iframes, Canvas and remote SSH TUI clients are outside this version's scope.
|
|
110
143
|
Page Context is retired only after exporting its drafts and verifying this replacement.
|
|
111
144
|
|
|
@@ -115,6 +148,23 @@ See [implementation plan](docs/annotate-html-integration-plan.md) and
|
|
|
115
148
|
`npm run test:browser` verify each layer; the browser test uses an existing Playwright installation
|
|
116
149
|
(`PLAYWRIGHT_MODULE`) and browser executable (`CHROMIUM_PATH`) in an isolated profile.
|
|
117
150
|
|
|
151
|
+
### Reload after browser companion updates
|
|
152
|
+
|
|
153
|
+
After updating the unpacked `browser/` files, open `chrome://extensions` and click
|
|
154
|
+
**Reload** for **OpenCode Annotate**. Return to the target webpage and open Annotate
|
|
155
|
+
using its extension icon or **Alt+Shift+A**.
|
|
156
|
+
|
|
157
|
+
A newly opened sidebar can load the updated `panel.mjs` while Chrome still runs an
|
|
158
|
+
older `worker.mjs`. With the compact workspace, that mismatch produces
|
|
159
|
+
`Cannot read properties of undefined (reading 'value')`: the sidebar expects a
|
|
160
|
+
`draft` record that the older worker does not return. Reload the whole extension;
|
|
161
|
+
reopening only the sidebar does not ensure the background code is refreshed.
|
|
162
|
+
Saved extension-local data survives an extension reload.
|
|
163
|
+
|
|
164
|
+
For diagnosis, compare the running worker's source (DevTools/CDP
|
|
165
|
+
`Debugger.getScriptSource`) with `browser/worker.mjs` in the loaded checkout.
|
|
166
|
+
The manifest version alone cannot identify edits to an unpacked extension.
|
|
167
|
+
|
|
118
168
|
## Review and send
|
|
119
169
|
|
|
120
170
|
1. Run `/annotate` or `/annotate path/to/file.md` in a session.
|
|
@@ -237,10 +287,11 @@ See [release instructions](docs/releasing.md) and [changelog](CHANGELOG.md).
|
|
|
237
287
|
这是**非官方 OpenCode 批注插件**:文本用 Plannotator TUI,网页用 Chrome 伴随扩展。
|
|
238
288
|
|
|
239
289
|
- `/annotate`:批注上一条完整回复。
|
|
240
|
-
- `/annotate 2`:批注倒数第二条,`3`、`4` 依次往前;`1` 等同于默认。
|
|
241
290
|
- `/annotate 文档.md`:批注文档,支持中文、空格和相对路径。
|
|
291
|
+
- `/annotate-pick`:从最近的回复和运行中的进度说明里选一条批注。
|
|
292
|
+
- `/annotate-selection`:先在会话里拖选文字,再批注包含这段文字的消息。
|
|
242
293
|
- `/annotate-last`:固定批注最新一条完整回复,忽略附带参数。
|
|
243
|
-
- `/annotate 页面.html`、`/annotate https
|
|
294
|
+
- `/annotate-web`:配对 Chrome;`/annotate-web 页面.html`、`/annotate-web https://…` 批注网页;`/annotate-web off` 撤销配对。
|
|
244
295
|
- 选中文字 → `c` 写批注 → Enter 保存 → `q` 返回 →「Send and continue」。
|
|
245
296
|
- 文档采用独立快照,反馈附原文件路径,确认后发回发起批注的会话。
|
|
246
297
|
- 更新:`opencode plugin update @nxxxsooo/opencode-annotate@latest`,然后重新打开终端客户端。
|
package/browser/capture.js
CHANGED
|
@@ -9,9 +9,11 @@
|
|
|
9
9
|
host.style.cssText = "all:initial!important;position:fixed!important;inset:0!important;pointer-events:none!important;z-index:2147483647!important"
|
|
10
10
|
const root = host.attachShadow({ mode: "closed" })
|
|
11
11
|
const style = document.createElement("style")
|
|
12
|
-
style.textContent = '.box{position:fixed;pointer-events:none;border:2px solid #c96442;background:#c9644210}.pin{position:fixed;background:#c96442;color:#fff;border:2px solid #fff;border-radius:50%;font:600 12px system-ui;width:26px;height:26px;pointer-events:none}'
|
|
12
|
+
style.textContent = '.box{position:fixed;pointer-events:none;border:2px solid #c96442;background:#c9644210}.pin{position:fixed;display:grid;place-items:center;background:#c96442;color:#fff;border:2px solid #fff;border-radius:50%;font:600 12px/1 system-ui;width:26px;height:26px;pointer-events:none}'
|
|
13
13
|
root.append(style); document.documentElement.append(host)
|
|
14
14
|
const box = document.createElement("div"); box.className = "box"
|
|
15
|
+
const highlight = document.createElement("div"); highlight.className = "box"
|
|
16
|
+
let highlighted, highlightTimer
|
|
15
17
|
let picking = false, url = location.href, timer, markers = [], active = true
|
|
16
18
|
function send(anchor = null, error = null, modeOnly = false) {
|
|
17
19
|
if (!active) return
|
|
@@ -53,6 +55,20 @@
|
|
|
53
55
|
if (message.action === "pick") { setPicking(!picking); respond({ ok: true, picking }) }
|
|
54
56
|
if (message.action === "markers") { markers = message.notes || []; draw(); respond({ ok: true }) }
|
|
55
57
|
if (message.action === "locate") respond({ states: message.anchors.map(locate) })
|
|
58
|
+
if (message.action === "reveal") {
|
|
59
|
+
const state = locate(message.anchor)
|
|
60
|
+
if (state !== "located") {
|
|
61
|
+
respond({ ok: false, error: `This element is ${state}. Your feedback is kept.` })
|
|
62
|
+
return
|
|
63
|
+
}
|
|
64
|
+
setPicking(false)
|
|
65
|
+
highlighted = document.querySelector(message.anchor.selector)
|
|
66
|
+
highlighted.scrollIntoView({ block: "center", inline: "nearest", behavior: matchMedia("(prefers-reduced-motion: reduce)").matches ? "instant" : "smooth" })
|
|
67
|
+
root.append(highlight); draw()
|
|
68
|
+
clearTimeout(highlightTimer)
|
|
69
|
+
highlightTimer = setTimeout(() => { highlighted = null; highlight.remove() }, 1600)
|
|
70
|
+
respond({ ok: true })
|
|
71
|
+
}
|
|
56
72
|
}
|
|
57
73
|
chrome.runtime.onMessage.addListener(onMessage)
|
|
58
74
|
function locate(anchor) {
|
|
@@ -68,6 +84,10 @@
|
|
|
68
84
|
} catch { return "invalid selector" }
|
|
69
85
|
}
|
|
70
86
|
function draw() {
|
|
87
|
+
if (highlighted?.isConnected) {
|
|
88
|
+
const rect = highlighted.getBoundingClientRect()
|
|
89
|
+
highlight.style.cssText = `left:${rect.left}px;top:${rect.top}px;width:${rect.width}px;height:${rect.height}px`
|
|
90
|
+
} else highlight.remove()
|
|
71
91
|
root.querySelectorAll(".pin").forEach(node => node.remove())
|
|
72
92
|
for (const [index, note] of markers.entries()) {
|
|
73
93
|
let matches
|
|
@@ -81,13 +101,13 @@
|
|
|
81
101
|
pin.style.cssText = `left:${rect.left - 10}px;top:${rect.top - 10}px`; root.append(pin)
|
|
82
102
|
}
|
|
83
103
|
}
|
|
84
|
-
on(
|
|
104
|
+
on(document, "scroll", draw, { capture: true, passive: true }); on(window, "resize", draw)
|
|
85
105
|
const observer = new MutationObserver(() => { clearTimeout(timer); timer = setTimeout(draw, 160) })
|
|
86
106
|
observer.observe(document.body, { childList: true, subtree: true, characterData: true })
|
|
87
107
|
const routeTimer = setInterval(() => { if (!active) { observer.disconnect(); return } if (url !== location.href) { url = location.href; markers = []; draw(); send() } }, 700)
|
|
88
108
|
function dispose() {
|
|
89
109
|
if (!active) return
|
|
90
|
-
active = false; listeners.abort(); clearInterval(routeTimer); clearTimeout(timer); observer.disconnect(); host.remove()
|
|
110
|
+
active = false; listeners.abort(); clearInterval(routeTimer); clearTimeout(timer); clearTimeout(highlightTimer); observer.disconnect(); host.remove()
|
|
91
111
|
try { chrome.runtime.onMessage.removeListener(onMessage) } catch { /* previous extension context may already be invalidated */ }
|
|
92
112
|
delete globalThis.__opencodeAnnotate
|
|
93
113
|
}
|
package/browser/manifest.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"manifest_version": 3,
|
|
3
3
|
"name": "OpenCode Annotate",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.6.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"],
|
package/browser/panel.css
CHANGED
|
@@ -1,3 +1,114 @@
|
|
|
1
|
-
:root{
|
|
2
|
-
|
|
3
|
-
:
|
|
1
|
+
:root {
|
|
2
|
+
color-scheme: light dark;
|
|
3
|
+
--bg: light-dark(#faf9f5, #20201f);
|
|
4
|
+
--surface: light-dark(#fff, #292927);
|
|
5
|
+
--soft: light-dark(#f0eee8, #33322f);
|
|
6
|
+
--text: light-dark(#27251f, #f2eee5);
|
|
7
|
+
--muted: light-dark(#686257, #c2bbae);
|
|
8
|
+
--line: light-dark(#ddd8ce, #49463f);
|
|
9
|
+
--input: light-dark(#8c8475, #928a7e);
|
|
10
|
+
--accent: light-dark(#944525, #f2ad90);
|
|
11
|
+
--on-accent: light-dark(#fff, #29201b);
|
|
12
|
+
--success: light-dark(#3c6548, #a5c6ab);
|
|
13
|
+
--warning: light-dark(#865122, #e9bb7e);
|
|
14
|
+
--error: light-dark(#a12929, #ffb3ac);
|
|
15
|
+
}
|
|
16
|
+
* { box-sizing: border-box; }
|
|
17
|
+
[hidden] { display: none !important; }
|
|
18
|
+
body { height: 100dvh; margin: 0; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; overflow: hidden; background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, -apple-system, sans-serif; }
|
|
19
|
+
p, h1, h2 { margin: 0; }
|
|
20
|
+
button, select, textarea { font: inherit; color: var(--text); }
|
|
21
|
+
button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; padding: 7px 11px; border: 1px solid var(--input); border-radius: 6px; background: var(--surface); cursor: pointer; font-size: 13px; font-weight: 550; }
|
|
22
|
+
button:hover { border-color: var(--accent); }
|
|
23
|
+
button:disabled { color: var(--muted); opacity: .6; cursor: default; }
|
|
24
|
+
button:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
|
|
25
|
+
::selection { background: var(--accent); color: var(--on-accent); }
|
|
26
|
+
textarea { caret-color: var(--accent); }
|
|
27
|
+
.icon-definitions { position: absolute; width: 0; height: 0; overflow: hidden; }
|
|
28
|
+
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
|
|
29
|
+
.panel-header { padding: 12px 16px 13px; border-bottom: 1px solid var(--line); }
|
|
30
|
+
.identity-row { display: flex; align-items: center; gap: 8px; }
|
|
31
|
+
.identity-row h1 { flex: 1; font-size: 16px; font-weight: 650; letter-spacing: -.015em; }
|
|
32
|
+
.identity-row > .icon { width: 19px; height: 19px; color: var(--accent); }
|
|
33
|
+
.icon-button { width: 32px; height: 32px; min-height: 32px; padding: 0; flex: none; border: 1px solid transparent; border-radius: 5px; background: transparent; color: var(--muted); }
|
|
34
|
+
.icon-button:hover { background: var(--soft); color: var(--text); border-color: transparent; }
|
|
35
|
+
.page-context { display: flex; align-items: baseline; gap: 8px; min-width: 0; margin-top: 9px; font-size: 13px; }
|
|
36
|
+
#page-title { min-width: 0; max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
|
|
37
|
+
#page-url { min-width: 0; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
38
|
+
main { min-height: 0; min-width: 0; overflow: auto; padding: 14px 16px 20px; scrollbar-width: thin; scrollbar-color: var(--input) transparent; scroll-padding: 16px; }
|
|
39
|
+
.picker-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
|
|
40
|
+
#pick { flex: none; }
|
|
41
|
+
#pick-hint { font-size: 13px; color: var(--muted); }
|
|
42
|
+
#pick[aria-pressed="true"] { width: 100%; background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
|
|
43
|
+
.composer { margin-top: 18px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
|
|
44
|
+
.section-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
|
|
45
|
+
.section-heading h2 { font-size: 14px; font-weight: 650; }
|
|
46
|
+
.section-heading > span { font-size: 13px; color: var(--muted); }
|
|
47
|
+
.selected-quote { display: flex; align-items: flex-start; gap: 8px; margin: 0 0 12px; padding: 10px; border: 1px solid var(--line); border-radius: 5px; background: var(--soft); }
|
|
48
|
+
.selected-quote .icon { width: 16px; height: 16px; margin-top: 2px; color: var(--muted); }
|
|
49
|
+
#quote { max-height: 80px; overflow: auto; overflow-wrap: anywhere; white-space: pre-wrap; font-size: 13px; }
|
|
50
|
+
.kind-row { display: flex; flex-wrap: wrap; align-items: center; gap: 3px; margin-bottom: 11px; }
|
|
51
|
+
.kind-row button { min-height: 32px; padding: 4px 9px; gap: 5px; background: transparent; border-color: transparent; border-radius: 5px; color: var(--muted); font-weight: 400; }
|
|
52
|
+
.kind-row button[aria-checked="true"] { background: var(--surface); border-color: var(--input); color: var(--text); }
|
|
53
|
+
.kind-row .icon { width: 15px; height: 15px; }
|
|
54
|
+
label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; }
|
|
55
|
+
textarea, select { width: 100%; display: block; border: 1px solid var(--input); border-radius: 6px; background: var(--surface); padding: 10px; }
|
|
56
|
+
textarea { min-height: 96px; resize: vertical; line-height: 1.5; font-size: 14px; }
|
|
57
|
+
textarea::placeholder { color: var(--muted); opacity: 1; }
|
|
58
|
+
.composer-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
|
|
59
|
+
kbd { font: 12px/1.3 system-ui; color: var(--muted); }
|
|
60
|
+
.text-button { min-height: 32px; padding: 4px 3px; border: 0; background: transparent; color: var(--muted); font-size: 13px; font-weight: 400; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: transparent; }
|
|
61
|
+
.text-button:hover { color: var(--text); text-decoration-color: currentColor; }
|
|
62
|
+
.soft { background: transparent; border-color: var(--line); }
|
|
63
|
+
.switch-notice, .draft-error { margin: 12px 0; padding: 10px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 13px; }
|
|
64
|
+
.switch-notice strong { display: block; margin-bottom: 4px; color: var(--warning); }
|
|
65
|
+
.switch-notice p, .draft-error p { margin-bottom: 8px; color: var(--muted); }
|
|
66
|
+
.switch-actions { display: flex; flex-wrap: wrap; gap: 6px; }
|
|
67
|
+
.notes-section { margin-top: 22px; }
|
|
68
|
+
ol { list-style: none; margin: 0; padding: 0; }
|
|
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; }
|
|
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
|
+
.note.is-current .note-number { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }
|
|
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; }
|
|
74
|
+
.note-target span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
|
|
75
|
+
.note-target .icon { width: 14px; height: 14px; margin-top: 3px; }
|
|
76
|
+
.note-target:hover { color: var(--accent); }
|
|
77
|
+
.note-comment { margin: 4px 0 7px; overflow-wrap: anywhere; white-space: pre-wrap; }
|
|
78
|
+
.note-bottom { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
|
|
79
|
+
.note-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; flex: 1 1 90px; font-size: 13px; color: var(--muted); }
|
|
80
|
+
.sent-mark { color: var(--success); display: inline-flex; align-items: center; gap: 3px; }
|
|
81
|
+
.sent-mark .icon { width: 14px; height: 14px; }
|
|
82
|
+
.note-bottom .text-button { padding-right: 6px; }
|
|
83
|
+
.warning { margin: 7px 0; font-size: 13px; color: var(--warning); }
|
|
84
|
+
.error, .draft-error .error { color: var(--error); overflow-wrap: anywhere; }
|
|
85
|
+
#page-error { margin-bottom: 12px; font-size: 13px; }
|
|
86
|
+
.empty-state { margin-top: 28px; }
|
|
87
|
+
.empty-state h2 { font-size: 17px; font-weight: 600; letter-spacing: -.015em; margin-bottom: 9px; }
|
|
88
|
+
.empty-state p { color: var(--muted); max-width: 28ch; }
|
|
89
|
+
.empty-state .empty-footnote { margin-top: 24px; font-size: 13px; }
|
|
90
|
+
.inline-notice { display: flex; align-items: center; gap: 8px; padding: 10px 0; margin-top: 12px; font-size: 13px; color: var(--muted); }
|
|
91
|
+
.inline-notice span { flex: 1; }
|
|
92
|
+
.delivery { min-width: 0; padding: 10px 16px 12px; border-top: 1px solid var(--line); background: var(--bg); }
|
|
93
|
+
.destination { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; min-width: 0; }
|
|
94
|
+
.destination > .icon { width: 16px; height: 16px; color: var(--muted); }
|
|
95
|
+
.destination-label { color: var(--muted); font-size: 13px; }
|
|
96
|
+
.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; }
|
|
97
|
+
#paired { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
98
|
+
.destination-button .icon { width: 14px; height: 14px; color: var(--muted); }
|
|
99
|
+
#send { width: 100%; min-height: 39px; font-size: 14px; font-weight: 600; }
|
|
100
|
+
.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
|
|
101
|
+
.primary:disabled { opacity: 1; background: var(--soft); border-color: var(--line); color: var(--muted); }
|
|
102
|
+
#status { margin-top: 7px; min-height: 19px; font-size: 13px; color: var(--muted); text-align: center; overflow-wrap: anywhere; }
|
|
103
|
+
#status.error { color: var(--error); }
|
|
104
|
+
#status.success { color: var(--success); }
|
|
105
|
+
.session-chooser, .utilities { margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
|
|
106
|
+
.session-chooser select { padding: 8px; font-size: 13px; }
|
|
107
|
+
.hint { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
|
|
108
|
+
#connection-hint { margin-top: 7px; }
|
|
109
|
+
#refresh-targets { margin-top: 8px; }
|
|
110
|
+
.utility-row { display: flex; flex-wrap: wrap; gap: 8px; }
|
|
111
|
+
details { margin-top: 10px; }
|
|
112
|
+
summary { min-height: 30px; padding: 4px 0; cursor: pointer; color: var(--muted); font-size: 13px; }
|
|
113
|
+
pre { max-height: 240px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--muted); font: 12px/1.5 ui-monospace, monospace; }
|
|
114
|
+
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
|
package/browser/panel.html
CHANGED
|
@@ -1,23 +1,56 @@
|
|
|
1
1
|
<!doctype html>
|
|
2
|
-
<html lang="en"
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>OpenCode Annotate</title><link rel="stylesheet" href="panel.css"></head>
|
|
3
4
|
<body>
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
<
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
<svg class="icon-definitions" aria-hidden="true"><defs>
|
|
6
|
+
<symbol id="icon-annotate" viewBox="0 0 24 24"><path d="M4 4h16v12H9l-5 4V4Z"/><path d="m9 12 6-6 3 3-6 6H9v-3Z"/></symbol>
|
|
7
|
+
<symbol id="icon-pick" viewBox="0 0 24 24"><path d="M8 3H3v5m13-5h5v5M3 16v5h5m13-5v5h-5M9 9l3 10 2-5 5-2-10-3Z"/></symbol>
|
|
8
|
+
<symbol id="icon-more" viewBox="0 0 24 24"><circle cx="5" cy="12" r="1"/><circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/></symbol>
|
|
9
|
+
<symbol id="icon-chevron" viewBox="0 0 24 24"><path d="m7 10 5 5 5-5"/></symbol>
|
|
10
|
+
<symbol id="icon-comment" viewBox="0 0 24 24"><path d="M4 4h16v12H9l-5 4V4Z"/></symbol>
|
|
11
|
+
<symbol id="icon-question" viewBox="0 0 24 24"><circle cx="12" cy="12" r="9"/><path d="M9.5 8a2.7 2.7 0 0 1 5 .7c0 2-2.5 2.2-2.5 4.3m0 3v.1"/></symbol>
|
|
12
|
+
<symbol id="icon-arrow" viewBox="0 0 24 24"><path d="M5 12h14m-6-6 6 6-6 6"/></symbol>
|
|
13
|
+
<symbol id="icon-reveal" viewBox="0 0 24 24"><path d="M13 5h6v6m0-6L9 15M9 5H5v14h14v-4"/></symbol>
|
|
14
|
+
<symbol id="icon-check" viewBox="0 0 24 24"><path d="m5 12 4 4L19 6"/></symbol>
|
|
15
|
+
<symbol id="icon-trash" viewBox="0 0 24 24"><path d="M4 6h16M9 6V3h6v3M6 6l1 15h10l1-15M10 10v7m4-7v7"/></symbol>
|
|
16
|
+
<symbol id="icon-session" viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="16" rx="2"/><path d="m7 9 3 3-3 3m6 0h4"/></symbol>
|
|
17
|
+
<symbol id="icon-copy" viewBox="0 0 24 24"><rect x="8" y="8" width="12" height="13" rx="2"/><path d="M16 8V3H3v13h5"/></symbol>
|
|
18
|
+
<symbol id="icon-download" viewBox="0 0 24 24"><path d="M12 3v12m-5-5 5 5 5-5M4 16v5h16v-5"/></symbol>
|
|
19
|
+
</defs></svg>
|
|
20
|
+
<header class="panel-header">
|
|
21
|
+
<div class="identity-row"><svg class="icon" aria-hidden="true"><use href="#icon-annotate"/></svg><h1>Annotate</h1><button id="more" class="icon-button" aria-label="More review options" title="More review options" aria-expanded="false" aria-controls="utilities"><svg class="icon" aria-hidden="true"><use href="#icon-more"/></svg></button></div>
|
|
22
|
+
<div class="page-context"><strong id="page-title">Open a page</strong><span id="page-url"></span></div>
|
|
23
|
+
</header>
|
|
24
|
+
<main id="panel-body">
|
|
25
|
+
<section id="utilities" class="utilities" aria-label="Review utilities" hidden>
|
|
26
|
+
<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>
|
|
27
|
+
<details id="context-details"><summary>Review context · all saved notes</summary><pre id="preview"></pre></details>
|
|
10
28
|
</section>
|
|
11
|
-
<section
|
|
12
|
-
<
|
|
13
|
-
<
|
|
14
|
-
<label for="kind">Feedback type</label><select id="kind"><option value="comment">Comment</option><option value="ask">Question</option></select>
|
|
15
|
-
<label for="comment">My feedback</label><textarea id="comment" rows="4" maxlength="8000" placeholder="What should change, or what would you like to understand?"></textarea>
|
|
16
|
-
<div class="actions"><button id="save">Save note</button><button id="cancel">Cancel edit</button></div>
|
|
29
|
+
<section id="session-options" class="session-chooser" aria-label="Destination selection" hidden>
|
|
30
|
+
<label for="targets">Choose session</label><select id="targets"><option value="">Choose a session…</option></select>
|
|
31
|
+
<p id="connection-hint" class="hint" aria-live="polite"></p><button id="refresh-targets">Refresh sessions</button>
|
|
17
32
|
</section>
|
|
18
|
-
<
|
|
19
|
-
<
|
|
33
|
+
<p id="page-error" class="error" role="alert" hidden></p>
|
|
34
|
+
<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>
|
|
35
|
+
<section id="composer" class="composer" aria-label="Current annotation" hidden>
|
|
36
|
+
<div class="section-heading"><h2 id="composer-title">New note</h2><span id="draft-state" aria-live="polite"></span></div>
|
|
37
|
+
<blockquote class="selected-quote"><svg class="icon" aria-hidden="true"><use href="#icon-pick"/></svg><p id="quote"></p></blockquote>
|
|
38
|
+
<p id="anchor-warning" class="warning" hidden></p>
|
|
39
|
+
<div id="switch-notice" class="switch-notice" aria-live="polite" hidden><strong>Keep feedback with this selection</strong><p id="switch-description"></p><div class="switch-actions"><button id="save-switch">Add & switch</button><button id="keep-editing" class="soft">Keep editing</button><button id="discard-switch" class="text-button">Discard & switch</button></div></div>
|
|
40
|
+
<div id="kind" class="kind-row" role="radiogroup" aria-label="Feedback type"><button id="kind-comment" role="radio" aria-checked="true" tabindex="0" data-kind="comment"><svg class="icon" aria-hidden="true"><use href="#icon-comment"/></svg>Comment</button><button id="kind-ask" role="radio" aria-checked="false" tabindex="-1" data-kind="ask"><svg class="icon" aria-hidden="true"><use href="#icon-question"/></svg>Question</button></div>
|
|
41
|
+
<label for="comment">Your feedback</label><textarea id="comment" rows="4" maxlength="8000" placeholder="What should change, or what would you like to know?"></textarea>
|
|
42
|
+
<div id="draft-error" class="draft-error" hidden><p id="draft-error-text" class="error" role="alert"></p><div class="switch-actions"><button id="retry-draft">Retry saving draft</button><button id="reload-draft">Load saved draft</button><button id="keep-draft">Keep my draft</button><button id="copy-draft" class="text-button">Copy my draft</button></div></div>
|
|
43
|
+
<div class="composer-actions"><button id="save" aria-keyshortcuts="Control+Enter Meta+Enter"><span id="save-label">Add note</span><kbd id="save-shortcut" title="Command or Control + Enter" aria-hidden="true">⌘↵</kbd></button><button id="cancel" class="text-button">Discard draft</button></div>
|
|
44
|
+
</section>
|
|
45
|
+
<div id="undo-notice" class="inline-notice" aria-live="polite" hidden><span>Note removed.</span><button id="undo" class="text-button">Undo</button></div>
|
|
46
|
+
<section id="notes-section" class="notes-section" aria-label="Collected notes" hidden><div class="section-heading"><h2>Notes</h2><span id="count">0 notes</span></div><ol id="notes"></ol></section>
|
|
47
|
+
<section id="empty-state" class="empty-state"><h2>Start with what you see.</h2><p>Pick an element or highlight text on the page, then describe what needs attention.</p><p class="empty-footnote">Send one note straight away, or collect a few first. Your feedback stays local until you send.</p></section>
|
|
20
48
|
</main>
|
|
21
|
-
<footer
|
|
49
|
+
<footer class="delivery">
|
|
50
|
+
<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></div>
|
|
51
|
+
<button id="send" class="primary" aria-describedby="paired status"><svg id="send-check" class="icon" aria-hidden="true" hidden><use href="#icon-check"/></svg><span id="send-label">Send & continue</span><svg id="send-arrow" class="icon" aria-hidden="true" hidden><use href="#icon-arrow"/></svg></button>
|
|
52
|
+
<p id="status" role="status" aria-live="polite">Looking for your OpenCode session…</p>
|
|
53
|
+
</footer>
|
|
22
54
|
<script type="module" src="panel.mjs"></script>
|
|
23
|
-
</body
|
|
55
|
+
</body>
|
|
56
|
+
</html>
|