claude-code-kanban 7.32.0 → 7.34.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/cli.js +12 -2
- package/hub-app.json +8 -1
- package/lib/parsers.js +0 -43
- package/lib/program-status.js +194 -0
- package/lib/reveal.js +30 -0
- package/lib/terminal-client.js +13 -1
- package/lib/terminal-host.js +3 -0
- package/lib/terminal.js +82 -11
- package/package.json +1 -1
- package/plugin/plugins/claude-code-kanban/.claude-plugin/plugin.json +1 -1
- package/plugin/plugins/claude-code-kanban/skills/kanban/SKILL.md +4 -0
- package/public/app.js +394 -172
- package/public/index.html +4 -2
- package/public/style.css +107 -11
- package/public/terminal-frame.js +55 -5
- package/server.js +75 -126
- package/lib/scratch-servers.js +0 -119
package/public/index.html
CHANGED
|
@@ -513,7 +513,10 @@
|
|
|
513
513
|
<div id="preview-modal" class="modal-overlay" style="z-index:10002;" onclick="closePreviewModal()">
|
|
514
514
|
<div class="modal preview-modal-dialog review-host" tabindex="-1" onclick="event.stopPropagation()">
|
|
515
515
|
<div class="modal-header">
|
|
516
|
-
<
|
|
516
|
+
<div class="preview-heading">
|
|
517
|
+
<h3 class="modal-title" id="preview-modal-title">Preview</h3>
|
|
518
|
+
<div id="preview-modal-meta" title="Click to copy path" onclick="copyPreviewPath(this)"></div>
|
|
519
|
+
</div>
|
|
517
520
|
<div style="display:flex;gap:4px;align-items:center;">
|
|
518
521
|
<button id="preview-pane-btn" class="icon-btn" aria-label="Open in a pane" title="Open in a pane" onclick="openPreviewInPane()">
|
|
519
522
|
<svg fill="none" stroke="currentColor" stroke-width="2" width="16" height="16"><use href="#icon-pane"/></svg>
|
|
@@ -543,7 +546,6 @@
|
|
|
543
546
|
<div id="preview-modal-body" class="rendered-md modal-zoomable"></div>
|
|
544
547
|
<aside id="preview-review-panel" class="review-panel" hidden></aside>
|
|
545
548
|
</div>
|
|
546
|
-
<div id="preview-modal-meta" title="Click to copy path" onclick="copyPreviewPath(this)"></div>
|
|
547
549
|
</div>
|
|
548
550
|
</div>
|
|
549
551
|
</div>
|
package/public/style.css
CHANGED
|
@@ -163,11 +163,6 @@ body::before {
|
|
|
163
163
|
flex-shrink: 0;
|
|
164
164
|
position: relative;
|
|
165
165
|
overflow: hidden;
|
|
166
|
-
transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
.sidebar.resizing {
|
|
170
|
-
transition: none;
|
|
171
166
|
}
|
|
172
167
|
|
|
173
168
|
.sidebar-header {
|
|
@@ -345,7 +340,6 @@ body::before {
|
|
|
345
340
|
.sidebar-toggle-btn svg {
|
|
346
341
|
width: 16px;
|
|
347
342
|
height: 16px;
|
|
348
|
-
transition: transform 0.25s ease;
|
|
349
343
|
}
|
|
350
344
|
|
|
351
345
|
.sidebar.collapsed .sidebar-toggle-btn svg {
|
|
@@ -900,6 +894,34 @@ body::before {
|
|
|
900
894
|
flex-shrink: 0;
|
|
901
895
|
}
|
|
902
896
|
|
|
897
|
+
.zen-empty {
|
|
898
|
+
display: flex;
|
|
899
|
+
flex-direction: column;
|
|
900
|
+
gap: 12px;
|
|
901
|
+
padding: 14px 0 8px;
|
|
902
|
+
}
|
|
903
|
+
.zen-empty-head {
|
|
904
|
+
padding: 0 8px;
|
|
905
|
+
}
|
|
906
|
+
.zen-empty-title {
|
|
907
|
+
font-size: 13px;
|
|
908
|
+
font-weight: 600;
|
|
909
|
+
color: var(--text-primary);
|
|
910
|
+
}
|
|
911
|
+
.zen-empty-hint {
|
|
912
|
+
margin-top: 4px;
|
|
913
|
+
font-size: 11.5px;
|
|
914
|
+
color: var(--text-muted);
|
|
915
|
+
}
|
|
916
|
+
.zen-empty .home-keys {
|
|
917
|
+
width: auto;
|
|
918
|
+
margin: 0;
|
|
919
|
+
}
|
|
920
|
+
.zen-empty .home-key {
|
|
921
|
+
padding: 6px 8px;
|
|
922
|
+
font-size: 12px;
|
|
923
|
+
}
|
|
924
|
+
|
|
903
925
|
/* After the ::after spacer, so the agents sit at the bottom of the free space. */
|
|
904
926
|
.zen-agents {
|
|
905
927
|
order: 1;
|
|
@@ -1164,7 +1186,9 @@ body.booting .boot-splash {
|
|
|
1164
1186
|
.session-item.unread::before,
|
|
1165
1187
|
.session-item.permission-pending::before,
|
|
1166
1188
|
.sp-row.unread::before,
|
|
1167
|
-
.sp-row.permission-pending::before
|
|
1189
|
+
.sp-row.permission-pending::before,
|
|
1190
|
+
.session-item.reported-error::before,
|
|
1191
|
+
.sp-row.reported-error::before {
|
|
1168
1192
|
content: '';
|
|
1169
1193
|
position: absolute;
|
|
1170
1194
|
inset: -1px;
|
|
@@ -1173,7 +1197,8 @@ body.booting .boot-splash {
|
|
|
1173
1197
|
}
|
|
1174
1198
|
|
|
1175
1199
|
.session-item.unread::before,
|
|
1176
|
-
.session-item.permission-pending::before
|
|
1200
|
+
.session-item.permission-pending::before,
|
|
1201
|
+
.session-item.reported-error::before {
|
|
1177
1202
|
border-radius: inherit;
|
|
1178
1203
|
}
|
|
1179
1204
|
|
|
@@ -1183,6 +1208,62 @@ body.booting .boot-splash {
|
|
|
1183
1208
|
animation: agent-badge-pulse 1.6s ease-in-out infinite;
|
|
1184
1209
|
}
|
|
1185
1210
|
|
|
1211
|
+
.session-item.reported-error::before,
|
|
1212
|
+
.sp-row.reported-error::before {
|
|
1213
|
+
border-left-color: var(--danger);
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
.session-footer .session-time.has-report {
|
|
1217
|
+
flex: 1;
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
.session-report {
|
|
1221
|
+
display: flex;
|
|
1222
|
+
flex: 1;
|
|
1223
|
+
align-items: center;
|
|
1224
|
+
gap: 6px;
|
|
1225
|
+
min-width: 0;
|
|
1226
|
+
font-family: var(--sans);
|
|
1227
|
+
font-size: 12px;
|
|
1228
|
+
line-height: 16px;
|
|
1229
|
+
color: var(--text-secondary);
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
.report-chip {
|
|
1233
|
+
flex: none;
|
|
1234
|
+
padding: 0 6px;
|
|
1235
|
+
border: 1px solid currentColor;
|
|
1236
|
+
border-radius: 8px;
|
|
1237
|
+
font-size: 10px;
|
|
1238
|
+
font-weight: 600;
|
|
1239
|
+
line-height: 14px;
|
|
1240
|
+
color: var(--warning);
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
.report-error .report-chip,
|
|
1244
|
+
.report-chip.report-error {
|
|
1245
|
+
color: var(--danger);
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1248
|
+
.report-app {
|
|
1249
|
+
flex: none;
|
|
1250
|
+
font-family: var(--mono);
|
|
1251
|
+
font-size: 11px;
|
|
1252
|
+
color: var(--text-tertiary);
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
.report-msg {
|
|
1256
|
+
flex: 1;
|
|
1257
|
+
min-width: 0;
|
|
1258
|
+
overflow: hidden;
|
|
1259
|
+
white-space: nowrap;
|
|
1260
|
+
text-overflow: ellipsis;
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
.sp-report {
|
|
1264
|
+
margin-left: 6px;
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1186
1267
|
@media (prefers-reduced-motion: reduce) {
|
|
1187
1268
|
.session-item.permission-pending::before,
|
|
1188
1269
|
.sp-row.permission-pending::before {
|
|
@@ -1918,6 +1999,12 @@ body.booting .boot-splash {
|
|
|
1918
1999
|
color: var(--text-primary);
|
|
1919
2000
|
}
|
|
1920
2001
|
|
|
2002
|
+
/* keycaps share --bg-hover with the active row; lift them so they stay visible */
|
|
2003
|
+
.home-key:hover kbd,
|
|
2004
|
+
.home-key:focus-visible kbd {
|
|
2005
|
+
background: var(--bg-elevated);
|
|
2006
|
+
}
|
|
2007
|
+
|
|
1921
2008
|
.home-key-kbd {
|
|
1922
2009
|
display: inline-flex;
|
|
1923
2010
|
align-items: center;
|
|
@@ -8738,13 +8825,22 @@ body.light .msg-assistant .msg-text {
|
|
|
8738
8825
|
max-height: 70vh;
|
|
8739
8826
|
}
|
|
8740
8827
|
|
|
8828
|
+
.preview-heading {
|
|
8829
|
+
flex: 1;
|
|
8830
|
+
min-width: 0;
|
|
8831
|
+
margin-right: 12px;
|
|
8832
|
+
}
|
|
8833
|
+
|
|
8741
8834
|
#preview-modal-meta {
|
|
8742
|
-
margin-top:
|
|
8835
|
+
margin-top: 2px;
|
|
8743
8836
|
font-size: 11px;
|
|
8744
8837
|
color: var(--text-muted);
|
|
8745
|
-
flex-shrink: 0;
|
|
8746
8838
|
cursor: copy;
|
|
8747
|
-
|
|
8839
|
+
width: fit-content;
|
|
8840
|
+
max-width: 100%;
|
|
8841
|
+
overflow: hidden;
|
|
8842
|
+
text-overflow: ellipsis;
|
|
8843
|
+
white-space: nowrap;
|
|
8748
8844
|
}
|
|
8749
8845
|
|
|
8750
8846
|
#preview-modal-meta:hover {
|
package/public/terminal-frame.js
CHANGED
|
@@ -108,6 +108,11 @@
|
|
|
108
108
|
if (parentOrigin) win.parent.postMessage({ ...data, type: MSG + t }, parentOrigin);
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
+
// Ctrl+click (Cmd on macOS) on a folder skips the board's toast and opens the folder at once.
|
|
112
|
+
function upLink(e, href) {
|
|
113
|
+
up('link', e?.ctrlKey || e?.metaKey ? { href, ctrl: true } : { href });
|
|
114
|
+
}
|
|
115
|
+
|
|
111
116
|
function send(msg) {
|
|
112
117
|
if (state.ws?.readyState === win.WebSocket.OPEN) state.ws.send(JSON.stringify(msg));
|
|
113
118
|
}
|
|
@@ -123,12 +128,52 @@
|
|
|
123
128
|
term.refresh(0, term.rows - 1);
|
|
124
129
|
}
|
|
125
130
|
|
|
131
|
+
// A resize clears the WebGL canvas, and xterm 6 draws it again only on the next animation frame,
|
|
132
|
+
// so the terminal shows one blank frame. Its private _renderRows draws in this frame instead.
|
|
133
|
+
function paintNow() {
|
|
134
|
+
const rs = state.term?._core?._renderService;
|
|
135
|
+
if (typeof rs?._renderRows !== 'function') return;
|
|
136
|
+
try {
|
|
137
|
+
rs._renderRows(0, state.term.rows - 1);
|
|
138
|
+
} catch (_) {}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// ConPTY drops DEC 2026, so the app's redraw after a resize lands over several frames and shows
|
|
142
|
+
// as a sweep. Turning the mode on locally keeps the old screen until the output goes quiet.
|
|
143
|
+
const HOLD_CAP_MS = 250;
|
|
144
|
+
const HOLD_QUIET_MS = 40;
|
|
145
|
+
const hold = { cap: 0, quiet: 0 };
|
|
146
|
+
|
|
147
|
+
function holdForRedraw() {
|
|
148
|
+
if (!state.attached || !state.holdRedraw || hold.cap) return;
|
|
149
|
+
state.term.write('\x1b[?2026h');
|
|
150
|
+
hold.cap = win.setTimeout(releaseHold, HOLD_CAP_MS);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function releaseHold() {
|
|
154
|
+
win.clearTimeout(hold.cap);
|
|
155
|
+
win.clearTimeout(hold.quiet);
|
|
156
|
+
hold.cap = 0;
|
|
157
|
+
hold.quiet = 0;
|
|
158
|
+
state.term.write('\x1b[?2026l');
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function noteOutput() {
|
|
162
|
+
if (!hold.cap) return;
|
|
163
|
+
win.clearTimeout(hold.quiet);
|
|
164
|
+
hold.quiet = win.setTimeout(releaseHold, HOLD_QUIET_MS);
|
|
165
|
+
}
|
|
166
|
+
|
|
126
167
|
// The fit addon measures 0×0 while the board's pane (or the hub's iframe) is display:none.
|
|
127
168
|
function fit() {
|
|
128
169
|
if (!state.fit || !host.offsetWidth || !host.offsetHeight) return;
|
|
170
|
+
const { cols, rows } = state.term;
|
|
129
171
|
try {
|
|
130
172
|
state.fit.fit();
|
|
131
173
|
} catch (_) {}
|
|
174
|
+
if (state.term.cols === cols && state.term.rows === rows) return false;
|
|
175
|
+
paintNow();
|
|
176
|
+
return true;
|
|
132
177
|
}
|
|
133
178
|
|
|
134
179
|
function setBg(options) {
|
|
@@ -144,7 +189,7 @@
|
|
|
144
189
|
function applyFont(size) {
|
|
145
190
|
const term = state.term;
|
|
146
191
|
term.options.fontSize = size;
|
|
147
|
-
fit();
|
|
192
|
+
if (!fit()) paintNow();
|
|
148
193
|
doc.fonts
|
|
149
194
|
?.load(`${size}px ${term.options.fontFamily}`)
|
|
150
195
|
.then(repaint)
|
|
@@ -181,7 +226,7 @@
|
|
|
181
226
|
cursorBlink: true,
|
|
182
227
|
allowProposedApi: true,
|
|
183
228
|
// xterm's default asks with confirm() and opens a window, which the installed hub window blocks.
|
|
184
|
-
linkHandler: { activate:
|
|
229
|
+
linkHandler: { activate: upLink, allowNonHttpProtocols: true },
|
|
185
230
|
...o.themeOptions,
|
|
186
231
|
});
|
|
187
232
|
state.term = term;
|
|
@@ -190,7 +235,7 @@
|
|
|
190
235
|
term.loadAddon(new win.Unicode11Addon.Unicode11Addon());
|
|
191
236
|
term.unicode.activeVersion = '11';
|
|
192
237
|
// Link providers scan a line only when the pointer moves onto it, never on output.
|
|
193
|
-
term.loadAddon(new win.WebLinksAddon.WebLinksAddon(
|
|
238
|
+
term.loadAddon(new win.WebLinksAddon.WebLinksAddon(upLink));
|
|
194
239
|
const cellReuse = term.buffer.active.getNullCell();
|
|
195
240
|
term.registerLinkProvider({
|
|
196
241
|
provideLinks(y, done) {
|
|
@@ -200,7 +245,7 @@
|
|
|
200
245
|
const links = pathsIn(text).map((p) => ({
|
|
201
246
|
text: p.text,
|
|
202
247
|
range: { start: { x: xs[p.index] + 1, y }, end: { x: xs[p.index + p.text.length - 1] + 1, y } },
|
|
203
|
-
activate: () =>
|
|
248
|
+
activate: (e) => upLink(e, p.path),
|
|
204
249
|
}));
|
|
205
250
|
done(links.length ? links : undefined);
|
|
206
251
|
},
|
|
@@ -253,7 +298,10 @@
|
|
|
253
298
|
});
|
|
254
299
|
}
|
|
255
300
|
term.onData((d) => send({ t: 'in', d }));
|
|
256
|
-
term.onResize(({ cols, rows }) =>
|
|
301
|
+
term.onResize(({ cols, rows }) => {
|
|
302
|
+
send({ t: 'resize', cols, rows });
|
|
303
|
+
holdForRedraw();
|
|
304
|
+
});
|
|
257
305
|
// One fit per frame while a drag resizes the pane. The atlas is rebuilt only when the frame comes
|
|
258
306
|
// back from 0×0, which is also how a hidden hub iframe or pane shows again.
|
|
259
307
|
let frame = 0;
|
|
@@ -336,6 +384,7 @@
|
|
|
336
384
|
const bytes = new Uint8Array(ev.data);
|
|
337
385
|
term.write(bytes, () => {
|
|
338
386
|
ack(ws, bytes.length);
|
|
387
|
+
noteOutput();
|
|
339
388
|
if (!outputSent && state.ws === ws && tailOf(term.buffer.active, 1)) {
|
|
340
389
|
outputSent = true;
|
|
341
390
|
up('output', { socketId });
|
|
@@ -351,6 +400,7 @@
|
|
|
351
400
|
}
|
|
352
401
|
if (msg.t === 'ready') {
|
|
353
402
|
state.attached = true;
|
|
403
|
+
state.holdRedraw = !!msg.holdRedraw;
|
|
354
404
|
// A retry keeps the last screen until the replay arrives.
|
|
355
405
|
if (!reset) clearScreen();
|
|
356
406
|
send({ t: 'resize', cols: term.cols, rows: term.rows });
|
package/server.js
CHANGED
|
@@ -25,6 +25,7 @@ const os = require('node:os');
|
|
|
25
25
|
const crypto = require('node:crypto');
|
|
26
26
|
const { spawn } = require('node:child_process');
|
|
27
27
|
const { assertOpenTarget, openInEditor, whichSync, exeBehindShim } = require('./lib/open-editor');
|
|
28
|
+
const { revealInFileManager } = require('./lib/reveal');
|
|
28
29
|
const { createNetGuard } = require('./lib/net-guard');
|
|
29
30
|
const { isContained, realpathDeepest } = require('./lib/contain');
|
|
30
31
|
const { resolveScratchSubdir, listScratchDir } = require('./lib/scratch-files');
|
|
@@ -43,7 +44,6 @@ const {
|
|
|
43
44
|
readCompactSummaries,
|
|
44
45
|
fillCompactSummaries,
|
|
45
46
|
readArtifactLinks,
|
|
46
|
-
readScratchpadCreations,
|
|
47
47
|
extractPromptFromTranscript,
|
|
48
48
|
extractModelFromTranscript,
|
|
49
49
|
readSubagentMeta,
|
|
@@ -77,7 +77,6 @@ const { createDispatchedStore, scanTranscripts, pruneSessionDirs, pruneContextSt
|
|
|
77
77
|
const { freshRateLimits } = require('./lib/rate-limits');
|
|
78
78
|
const { createWorktreeStore } = require('./lib/worktrees');
|
|
79
79
|
const { createScratchpadDirResolver, scratchpadRoot } = require('./lib/scratchpad-dir');
|
|
80
|
-
const { createScratchServers } = require('./lib/scratch-servers');
|
|
81
80
|
const { readSettings } = require('./lib/claude-settings');
|
|
82
81
|
const { readGitBranch, sessionGitBranch } = require('./lib/git-branch');
|
|
83
82
|
const { createLinkedDocStore, linkUrl } = require('./lib/linked-docs');
|
|
@@ -1623,6 +1622,7 @@ app.get('/api/sessions', async (req, res) => {
|
|
|
1623
1622
|
// the project filter, because pinning is a preference and the filter is an intent.
|
|
1624
1623
|
// The client sends the session it currently has open, which it cannot render at all
|
|
1625
1624
|
// if the row is missing — that one is not a preference.
|
|
1625
|
+
const unfiltered = sessions;
|
|
1626
1626
|
if (projectFilter) {
|
|
1627
1627
|
const matches = projectMatcher(String(projectFilter));
|
|
1628
1628
|
sessions = sessions.filter(s => matches(s.project, s.worktree?.repo) || includeIds.has(s.id));
|
|
@@ -1647,6 +1647,10 @@ app.get('/api/sessions', async (req, res) => {
|
|
|
1647
1647
|
const missingPinned = sessions.filter(s => pinnedIds.has(s.id) && !topIds.has(s.id));
|
|
1648
1648
|
sessions = [...top, ...missingPinned];
|
|
1649
1649
|
}
|
|
1650
|
+
// `nest=1` (zen on a project): the sidebar draws a nested child in its parent's place, so the
|
|
1651
|
+
// client needs both ends of each nest link of the page to place a session as the full list does.
|
|
1652
|
+
// Added after the limit, like pins, so they take no page slots.
|
|
1653
|
+
if (projectFilter && req.query.nest === '1') sessions = withNestRelatives(sessions, unfiltered);
|
|
1650
1654
|
|
|
1651
1655
|
// Loop info can mean a full read of the transcript, so only the rows sent pay for it, and
|
|
1652
1656
|
// `lite=1` (the CLI's group list, which only counts and names sessions) skips it.
|
|
@@ -1901,108 +1905,9 @@ app.get('/api/sessions/:sessionId/artifacts', async (req, res) => {
|
|
|
1901
1905
|
|
|
1902
1906
|
// A scratchpad is a folder plus a `scratchpad.json` manifest, rendered by the
|
|
1903
1907
|
// external `scratch` CLI. cck only recognizes the shape and launches the viewer —
|
|
1904
|
-
// it reads nothing from the manifest
|
|
1905
|
-
// independently versioned.
|
|
1908
|
+
// it reads nothing from the manifest, so the two stay independently versioned.
|
|
1906
1909
|
const SCRATCHPAD_MANIFEST = 'scratchpad.json';
|
|
1907
1910
|
|
|
1908
|
-
// Fallback only, for a `scratch new` whose output the transcript never captured. A pad
|
|
1909
|
-
// has no central registry — the CLI treats the folder path as the pad's identity and
|
|
1910
|
-
// finds pads by scanning — and `_scratchpads/` is one user's habit, not a convention it
|
|
1911
|
-
// knows, so there is no layout to guess. Depth 3 rather than a deeper walk for the
|
|
1912
|
-
// reason docs/session-scanning.md records: pruned, it measures 0-3 ms on the worst-case
|
|
1913
|
-
// project dirs, while an unpruned walk of the same dirs costs ~800 ms.
|
|
1914
|
-
const PAD_SCAN_IGNORE = new Set(['node_modules', '.git', '.hg', '.svn', 'dist', 'build']);
|
|
1915
|
-
const PAD_SCAN_MAX_DEPTH = 3;
|
|
1916
|
-
// A pad manifest's `created` is written after the tool call starts, so the match is
|
|
1917
|
-
// a window, not an instant. Measured lag on a real `scratch new` was 4.1 s; the
|
|
1918
|
-
// window is wide enough to survive a slow disk and far too narrow to reach a pad
|
|
1919
|
-
// made in an earlier session.
|
|
1920
|
-
const PAD_CREATE_WINDOW_MS = 120000;
|
|
1921
|
-
|
|
1922
|
-
async function findPads(root, depth = 0) {
|
|
1923
|
-
let entries;
|
|
1924
|
-
try { entries = await fs.readdir(root, { withFileTypes: true }); } catch (_) { return []; }
|
|
1925
|
-
// A pad is never nested inside another pad, so a manifest ends the descent.
|
|
1926
|
-
if (entries.some((e) => e.isFile() && e.name === SCRATCHPAD_MANIFEST)) return [root];
|
|
1927
|
-
if (depth >= PAD_SCAN_MAX_DEPTH) return [];
|
|
1928
|
-
const nested = await Promise.all(
|
|
1929
|
-
entries
|
|
1930
|
-
.filter((e) => e.isDirectory() && !PAD_SCAN_IGNORE.has(e.name))
|
|
1931
|
-
.map((e) => findPads(path.join(root, e.name), depth + 1)),
|
|
1932
|
-
);
|
|
1933
|
-
return nested.flat();
|
|
1934
|
-
}
|
|
1935
|
-
|
|
1936
|
-
// The pads a session made, as linked-doc rows. Derived on every read rather than
|
|
1937
|
-
// stored, so re-reading a transcript cannot drift; the client links each pad once
|
|
1938
|
-
// and records that it did, which is what stops a re-read undoing an unlink.
|
|
1939
|
-
async function readCreatedPads(meta) {
|
|
1940
|
-
const creations = await readScratchpadCreations(meta.jsonlPath);
|
|
1941
|
-
// No `scratch new` in the transcript means no disk work at all, so sessions that
|
|
1942
|
-
// never touch the CLI pay a substring pass over the transcript and nothing more.
|
|
1943
|
-
if (!creations.length) return [];
|
|
1944
|
-
const reported = new Set(creations.filter((c) => c.path).map((c) => c.path));
|
|
1945
|
-
const unresolved = creations.filter((c) => !c.path);
|
|
1946
|
-
const askedFor = new Set(unresolved.map((c) => c.name).filter(Boolean));
|
|
1947
|
-
// Only a call whose name could not be read falls back to the clock, and it compares
|
|
1948
|
-
// against the call's second, not the call: the manifest records `created` to the
|
|
1949
|
-
// second while the transcript timestamps to the millisecond, so a pad written during
|
|
1950
|
-
// the same second as its own command otherwise reads as older than it.
|
|
1951
|
-
const byClock = unresolved.filter((c) => !c.name).map((c) => Math.floor(c.ts / 1000) * 1000);
|
|
1952
|
-
const sessionId = path.basename(meta.jsonlPath, '.jsonl');
|
|
1953
|
-
// The project, not `meta.cwd`: cwd is wherever the session last stood, which drifts
|
|
1954
|
-
// into subdirectories — a session that made a pad and then worked inside it reports
|
|
1955
|
-
// a cwd below the pad, and a scan from there finds nothing above it.
|
|
1956
|
-
// The session's own scratchpad dir too: a pad made there sits outside the project.
|
|
1957
|
-
const roots = unresolved.length ? [meta.project || meta.cwd, getScratchpadDir(sessionId, meta)] : [];
|
|
1958
|
-
const scanned = (await Promise.all(roots.filter(Boolean).map((r) => findPads(r)))).flat();
|
|
1959
|
-
const candidates = [...new Set([...reported, ...scanned.map((dir) => path.join(dir, SCRATCHPAD_MANIFEST))])];
|
|
1960
|
-
const rows = await Promise.all(
|
|
1961
|
-
candidates.map(async (file) => {
|
|
1962
|
-
let manifest;
|
|
1963
|
-
try { manifest = JSON.parse(await fs.readFile(file, 'utf8')); } catch (_) { return null; }
|
|
1964
|
-
const created = Date.parse(manifest?.created);
|
|
1965
|
-
if (!Number.isFinite(created)) return null;
|
|
1966
|
-
const name = manifest.name || path.basename(path.dirname(file));
|
|
1967
|
-
// A path the CLI printed names its pad outright. Otherwise `scratch new --id`
|
|
1968
|
-
// settles it: the flag stamps the session that asked for the pad into the
|
|
1969
|
-
// manifest, so an id decides ownership both ways — one naming another session
|
|
1970
|
-
// disowns the pad whatever the name or the clock say. Only a pad with no id is
|
|
1971
|
-
// guessed at, by the name the command asked for and then by the clock.
|
|
1972
|
-
const claimed =
|
|
1973
|
-
reported.has(file) ||
|
|
1974
|
-
(manifest.id
|
|
1975
|
-
? manifest.id === sessionId
|
|
1976
|
-
: askedFor.has(name) || byClock.some((from) => created >= from && created - from <= PAD_CREATE_WINDOW_MS));
|
|
1977
|
-
if (!claimed) return null;
|
|
1978
|
-
return { path: file, name, created: manifest.created, ts: created };
|
|
1979
|
-
}),
|
|
1980
|
-
);
|
|
1981
|
-
return rows
|
|
1982
|
-
.filter(Boolean)
|
|
1983
|
-
.sort((a, b) => a.ts - b.ts)
|
|
1984
|
-
.map(({ ts: _ts, ...row }) => row);
|
|
1985
|
-
}
|
|
1986
|
-
|
|
1987
|
-
// Cold path — a full transcript scan, and a directory walk when the transcript did not
|
|
1988
|
-
// carry the pad paths, so the result is held until the transcript grows.
|
|
1989
|
-
const padsByPath = new Map();
|
|
1990
|
-
|
|
1991
|
-
function getCreatedPads(meta) {
|
|
1992
|
-
return cachedByFileStat(padsByPath, meta.jsonlPath, () => readCreatedPads(meta)) || [];
|
|
1993
|
-
}
|
|
1994
|
-
|
|
1995
|
-
app.get('/api/sessions/:sessionId/pads', async (req, res) => {
|
|
1996
|
-
try {
|
|
1997
|
-
const meta = sessionMetaFor(req.params.sessionId);
|
|
1998
|
-
if (!meta?.jsonlPath) return res.json({ pads: [] });
|
|
1999
|
-
res.json({ pads: await getCreatedPads(meta) });
|
|
2000
|
-
} catch (error) {
|
|
2001
|
-
console.error('Error reading created pads:', error);
|
|
2002
|
-
res.status(500).json({ error: 'Failed to read created pads' });
|
|
2003
|
-
}
|
|
2004
|
-
});
|
|
2005
|
-
|
|
2006
1911
|
// API: List one level of a session's scratchpad dir — the root, or the folder named by
|
|
2007
1912
|
// `?path=`, which is the absolute path a previous listing handed out and must still sit
|
|
2008
1913
|
// under the root. One readdir per request, never a walk: sessions drop clones and
|
|
@@ -2360,6 +2265,19 @@ app.post('/api/open-folder', (req, res) => {
|
|
|
2360
2265
|
}
|
|
2361
2266
|
});
|
|
2362
2267
|
|
|
2268
|
+
// API: Show a folder, or a file selected in its folder, in the OS file manager.
|
|
2269
|
+
app.post('/api/reveal', (req, res) => {
|
|
2270
|
+
try {
|
|
2271
|
+
const target = assertOpenTarget(resolvePreviewPath(req.body?.path) || '', 'path');
|
|
2272
|
+
revealInFileManager(target);
|
|
2273
|
+
res.json({ success: true, path: target });
|
|
2274
|
+
} catch (error) {
|
|
2275
|
+
if (error.status) return res.status(error.status).json({ error: error.message });
|
|
2276
|
+
console.error('Error revealing path:', error);
|
|
2277
|
+
res.status(500).json({ error: 'Failed to open the file manager' });
|
|
2278
|
+
}
|
|
2279
|
+
});
|
|
2280
|
+
|
|
2363
2281
|
// API: Open file in editor — either an existing path ({ file }) or content as a temp file ({ content, title })
|
|
2364
2282
|
app.post('/api/open-in-editor', (req, res) => {
|
|
2365
2283
|
try {
|
|
@@ -2404,23 +2322,6 @@ function scratchExecutable() {
|
|
|
2404
2322
|
return file ? { file } : { error: 'scratch CLI cannot be launched without a shell' };
|
|
2405
2323
|
}
|
|
2406
2324
|
|
|
2407
|
-
const scratchServers = createScratchServers({
|
|
2408
|
-
resolveBin: () => scratchExecutable().file || null,
|
|
2409
|
-
spawn,
|
|
2410
|
-
onExit: (pad) => broadcast({ type: 'scratchpad:exited', manifest: `${pad}/${SCRATCHPAD_MANIFEST}` }),
|
|
2411
|
-
});
|
|
2412
|
-
|
|
2413
|
-
// API: The URL of a pad's browser viewer for a scratchpad pane, started on first use.
|
|
2414
|
-
app.post('/api/scratchpad/serve', async (req, res) => {
|
|
2415
|
-
try {
|
|
2416
|
-
res.json({ url: await scratchServers.serve(resolveScratchpad(req.body?.path).dir) });
|
|
2417
|
-
} catch (error) {
|
|
2418
|
-
if (error.status) return res.status(error.status).json({ error: error.message });
|
|
2419
|
-
console.error('Error serving scratchpad:', error.message);
|
|
2420
|
-
res.status(502).json({ error: error.message });
|
|
2421
|
-
}
|
|
2422
|
-
});
|
|
2423
|
-
|
|
2424
2325
|
// API: Open a scratchpad in the external `scratch` viewer — the window outlives
|
|
2425
2326
|
// this request and cck never waits on it.
|
|
2426
2327
|
app.post('/api/scratchpad/open', (req, res) => {
|
|
@@ -2750,7 +2651,9 @@ app.post('/api/sessions/:sessionId/waiting/discard', (req, res) => {
|
|
|
2750
2651
|
|
|
2751
2652
|
app.post('/api/sessions/:sessionId/read', (req, res) => {
|
|
2752
2653
|
try {
|
|
2753
|
-
|
|
2654
|
+
const sessionId = resolveSessionId(req.params.sessionId);
|
|
2655
|
+
terminal.markStatusSeen(sessionId);
|
|
2656
|
+
clearActivityMarker(sessionId, '_stop.json');
|
|
2754
2657
|
res.json({ ok: true });
|
|
2755
2658
|
} catch {
|
|
2756
2659
|
res.status(500).json({ error: 'Failed to mark session read' });
|
|
@@ -3391,7 +3294,7 @@ const terminal = createTerminalClient({
|
|
|
3391
3294
|
resolveCwd: resolveSessionFolder,
|
|
3392
3295
|
shellRun: (id) => panes.shellPane(id)?.run || null,
|
|
3393
3296
|
isAllowedFolder,
|
|
3394
|
-
onChange: () => broadcast({ type: 'terminals-update', ids: terminal.ids(), awaitingTrust: terminal.awaitingTrust() }),
|
|
3297
|
+
onChange: () => broadcast({ type: 'terminals-update', ids: terminal.ids(), awaitingTrust: terminal.awaitingTrust(), programStatus: terminal.programStatus(), statusSilent: terminal.statusSilent() }),
|
|
3395
3298
|
onExit: (id) => {
|
|
3396
3299
|
if (dispatched.get(id)) broadcast({ type: 'dispatch-update' });
|
|
3397
3300
|
},
|
|
@@ -3430,7 +3333,7 @@ app.post('/api/terminal/pick-folder', async (req, res) => {
|
|
|
3430
3333
|
}
|
|
3431
3334
|
});
|
|
3432
3335
|
|
|
3433
|
-
//
|
|
3336
|
+
// A change to the hub's terminalHost setting reaches only the board page, which relays it here.
|
|
3434
3337
|
app.post('/api/terminal/options', (req, res) => {
|
|
3435
3338
|
if (!terminal.authorized(req.get('x-terminal-token'))) return res.status(401).json({ error: 'invalid terminal token' });
|
|
3436
3339
|
if (typeof req.body?.conptyDll !== 'boolean') return res.status(400).json({ error: 'conptyDll must be a boolean' });
|
|
@@ -3622,11 +3525,43 @@ const forks = createDispatchedStore(jsonFile(FORKS_FILE));
|
|
|
3622
3525
|
const linkedDocs = createLinkedDocStore(jsonFile(LINKED_DOCS_FILE));
|
|
3623
3526
|
|
|
3624
3527
|
const nestStoreOf = (id) => (dispatched.get(id) ? dispatched : forks.get(id) ? forks : null);
|
|
3528
|
+
const nestOf = (id) => nestStoreOf(id)?.get(id);
|
|
3529
|
+
|
|
3530
|
+
// The ancestors and descendants of the page's sessions along nest links, not their siblings.
|
|
3531
|
+
function withNestRelatives(page, all) {
|
|
3532
|
+
const byId = new Map(all.map((s) => [s.id, s]));
|
|
3533
|
+
const parentOf = new Map();
|
|
3534
|
+
const childrenOf = new Map();
|
|
3535
|
+
for (const s of all) {
|
|
3536
|
+
const nest = nestOf(s.id);
|
|
3537
|
+
if (!nest?.child || !byId.has(nest.parent)) continue;
|
|
3538
|
+
parentOf.set(s.id, nest.parent);
|
|
3539
|
+
if (!childrenOf.has(nest.parent)) childrenOf.set(nest.parent, []);
|
|
3540
|
+
childrenOf.get(nest.parent).push(s.id);
|
|
3541
|
+
}
|
|
3542
|
+
const keep = new Set(page.map((s) => s.id));
|
|
3543
|
+
const added = [];
|
|
3544
|
+
const add = (id) => {
|
|
3545
|
+
if (keep.has(id)) return false;
|
|
3546
|
+
keep.add(id);
|
|
3547
|
+
added.push(byId.get(id));
|
|
3548
|
+
return true;
|
|
3549
|
+
};
|
|
3550
|
+
for (const s of page) {
|
|
3551
|
+
for (let id = parentOf.get(s.id); id && add(id); id = parentOf.get(id));
|
|
3552
|
+
const down = [...(childrenOf.get(s.id) || [])];
|
|
3553
|
+
while (down.length) {
|
|
3554
|
+
const id = down.pop();
|
|
3555
|
+
if (add(id)) down.push(...(childrenOf.get(id) || []));
|
|
3556
|
+
}
|
|
3557
|
+
}
|
|
3558
|
+
return added.length ? [...page, ...added] : page;
|
|
3559
|
+
}
|
|
3625
3560
|
|
|
3626
3561
|
function withDispatchMarker(sessions) {
|
|
3627
3562
|
return sessions.map((s) => {
|
|
3628
3563
|
const marker = dispatched.get(s.id);
|
|
3629
|
-
const nest =
|
|
3564
|
+
const nest = nestOf(s.id);
|
|
3630
3565
|
if (!nest) return s;
|
|
3631
3566
|
return {
|
|
3632
3567
|
...s,
|
|
@@ -3977,9 +3912,20 @@ async function readHead(absPath) {
|
|
|
3977
3912
|
}
|
|
3978
3913
|
}
|
|
3979
3914
|
|
|
3915
|
+
// A name the allowlist does not know (.gitignore, Dockerfile, LICENSE) is text when its head
|
|
3916
|
+
// is also valid UTF-8: a stricter test than a listed extension gets, because here the name
|
|
3917
|
+
// claims nothing.
|
|
3980
3918
|
async function confirmKind(absPath, kind) {
|
|
3981
|
-
if (!kind) return null;
|
|
3982
|
-
|
|
3919
|
+
if (!kind && PREVIEW_OPAQUE_EXTS.has(previewExtFor(absPath))) return null;
|
|
3920
|
+
const head = await readHead(absPath);
|
|
3921
|
+
if (head.includes(0)) return null;
|
|
3922
|
+
if (kind) return kind;
|
|
3923
|
+
try {
|
|
3924
|
+
new TextDecoder('utf-8', { fatal: true }).decode(head, { stream: true });
|
|
3925
|
+
return 'text';
|
|
3926
|
+
} catch {
|
|
3927
|
+
return null;
|
|
3928
|
+
}
|
|
3983
3929
|
}
|
|
3984
3930
|
|
|
3985
3931
|
// Whole files are pushed into a modal, so anything huge freezes the tab regardless of kind.
|
|
@@ -3993,13 +3939,14 @@ const PREVIEW_TEXT_MAX_BYTES = 2 * 1024 * 1024;
|
|
|
3993
3939
|
async function statFileTarget(absPath) {
|
|
3994
3940
|
try {
|
|
3995
3941
|
const stats = await fs.stat(absPath);
|
|
3942
|
+
if (stats.isDirectory()) throw previewError(400, 'Not a file', 'is_dir');
|
|
3996
3943
|
if (!stats.isFile()) throw previewError(400, 'Not a file', 'not_a_file');
|
|
3997
3944
|
const kind = previewKindFor(absPath);
|
|
3998
3945
|
return { size: stats.size, kind: kind === 'image' ? kind : await confirmKind(absPath, kind) };
|
|
3999
3946
|
} catch (e) {
|
|
4000
3947
|
if (e.status) throw e;
|
|
4001
3948
|
if (e.code === 'ENOENT') throw previewError(404, 'File not found', 'file_not_found');
|
|
4002
|
-
if (e.code === 'EISDIR') throw previewError(400, 'Not a file', '
|
|
3949
|
+
if (e.code === 'EISDIR') throw previewError(400, 'Not a file', 'is_dir');
|
|
4003
3950
|
throw e;
|
|
4004
3951
|
}
|
|
4005
3952
|
}
|
|
@@ -4328,6 +4275,8 @@ app.get('/api/preview', async (req, res) => {
|
|
|
4328
4275
|
// document is followed without knowing the target is there, so a link to a deleted
|
|
4329
4276
|
// file would put a 404 in the browser console. The caller toasts it from `exists`.
|
|
4330
4277
|
if (error.status === 404) return res.json({ path: abs, exists: false, content: null, kind: null });
|
|
4278
|
+
// A folder is an answer too: the caller offers the file manager instead of a preview.
|
|
4279
|
+
if (error.code === 'is_dir') return res.json({ path: abs, exists: true, content: null, kind: null, dir: true });
|
|
4331
4280
|
// A previewError carries the status it wants reported and is an answer, not a
|
|
4332
4281
|
// failure — a missing file or one too large to render is the user's doing.
|
|
4333
4282
|
if (!error.status) console.error('Error in GET /api/preview:', error);
|