claude-code-kanban 7.29.0 → 7.31.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/public/index.html CHANGED
@@ -980,9 +980,12 @@
980
980
  </div>
981
981
  <input id="pane-pop-input" class="form-input" placeholder="Search linked docs, or paste a URL or a file path" autocomplete="off" data-bwignore data-1p-ignore data-lpignore="true" spellcheck="false">
982
982
  <div id="pane-pop-detect" class="pane-pop-detect"></div>
983
+ <button id="pane-pop-shell" class="pane-pop-row pane-pop-shell" type="button" onclick="addShellPane()" title="A plain shell, no claude, in the session's folder or the folder typed above (Ctrl+Enter)">
984
+ <svg class="kind" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="4 17 10 11 4 5"/><line x1="12" y1="19" x2="20" y2="19"/></svg><span>New shell</span><span class="pane-pop-shell-dir"></span>
985
+ </button>
983
986
  <div class="pane-pop-label">Linked docs</div>
984
987
  <div id="pane-pop-docs" class="pane-pop-docs"></div>
985
- <div class="sp-hint"><kbd>Enter</kbd> add &middot; <kbd>&uarr;</kbd><kbd>&darr;</kbd> select &middot; <kbd>Esc</kbd> close</div>
988
+ <div class="sp-hint"><kbd>Enter</kbd> add &middot; <kbd>Ctrl</kbd><kbd>Enter</kbd> new shell &middot; <kbd>&uarr;</kbd><kbd>&darr;</kbd> select &middot; <kbd>Esc</kbd> close</div>
986
989
  </div>
987
990
  </div>
988
991
 
package/public/style.css CHANGED
@@ -5008,7 +5008,7 @@ body.show-resizing iframe {
5008
5008
  border: 1px solid var(--border);
5009
5009
  border-bottom: 0;
5010
5010
  border-radius: 7px 7px 0 0;
5011
- background: var(--bg-elevated);
5011
+ background: none;
5012
5012
  }
5013
5013
 
5014
5014
  .pane-pair.on {
@@ -5612,6 +5612,21 @@ body.show-resizing iframe {
5612
5612
  border-top: 1px solid var(--border);
5613
5613
  }
5614
5614
 
5615
+ .pane-pop-shell {
5616
+ margin: 0 -6px;
5617
+ width: calc(100% + 12px);
5618
+ }
5619
+
5620
+ .pane-pop-shell[hidden] {
5621
+ display: none;
5622
+ }
5623
+
5624
+ .pane-pop-shell-dir {
5625
+ margin-left: auto;
5626
+ color: var(--text-muted);
5627
+ font-size: 11px;
5628
+ }
5629
+
5615
5630
  .pane-pop-label {
5616
5631
  margin: 6px 2px;
5617
5632
  color: var(--text-muted);
package/server.js CHANGED
@@ -126,6 +126,7 @@ const SHOW_DIR = path.join(CCK_DIR, 'show');
126
126
  const PINS_FILE = path.join(CCK_DIR, 'pins.json');
127
127
  const USER_GROUPS_FILE = path.join(CCK_DIR, 'groups.json');
128
128
  const DISPATCHED_FILE = path.join(CCK_DIR, 'dispatched.json');
129
+ const FORKS_FILE = path.join(CCK_DIR, 'forks.json');
129
130
  const WORKTREES_FILE = path.join(CCK_DIR, 'worktrees.json');
130
131
  const LINKED_DOCS_FILE = path.join(CCK_DIR, 'linked-docs.json');
131
132
  const PANES_FILE = path.join(CCK_DIR, 'panes.json');
@@ -1556,6 +1557,11 @@ app.get('/api/sessions', async (req, res) => {
1556
1557
  // comes from lookupParentSession, not from the anchor's presence.
1557
1558
  const compactSuppressed = new Set();
1558
1559
  for (const [sid] of sessionsMap) {
1560
+ const fork = forks.get(sid);
1561
+ if (fork) {
1562
+ sessionsMap.get(sid).forkedFromSessionId = fork.parent;
1563
+ continue;
1564
+ }
1559
1565
  // Cheap pre-gate: only a session with a boundary anchor can be a continuation,
1560
1566
  // and lookupParentSession reads JSONLs on a cold cache. A fork with no boundary
1561
1567
  // gets its badge only once a verdict exists (the info modal computes one).
@@ -3332,6 +3338,8 @@ function isAllowedFolder(dir) {
3332
3338
  // Restore runs before the first full metadata scan, so until that scan has run a session's
3333
3339
  // folder is read from its own JSONL, by the same rules the scan uses.
3334
3340
  function resolveSessionFolder(id) {
3341
+ const shell = panes.shellPane(id);
3342
+ if (shell) return shell.cwd || null;
3335
3343
  if (lastMetadataRefresh || !isSafeId(id)) {
3336
3344
  const meta = loadSessionMetadata()[id];
3337
3345
  return meta ? meta.project || meta.cwd || null : null;
@@ -3381,13 +3389,20 @@ const terminal = createTerminalClient({
3381
3389
  // The project, not the last cwd: `claude --resume` finds a session under the
3382
3390
  // project dir it started in, and cwd drifts into subdirectories.
3383
3391
  resolveCwd: resolveSessionFolder,
3392
+ shellRun: (id) => panes.shellPane(id)?.run || null,
3384
3393
  isAllowedFolder,
3385
3394
  onChange: () => broadcast({ type: 'terminals-update', ids: terminal.ids(), awaitingTrust: terminal.awaitingTrust() }),
3386
3395
  onExit: (id) => {
3387
3396
  if (dispatched.get(id)) broadcast({ type: 'dispatch-update' });
3388
3397
  },
3389
3398
  onRekey: (from, to) => {
3390
- if (dispatched.move(from, to)) broadcast({ type: 'dispatch-update' });
3399
+ const moved = dispatched.move(from, to);
3400
+ if (forks.move(from, to) || moved) broadcast({ type: 'dispatch-update' });
3401
+ },
3402
+ onFork: (id, parent) => {
3403
+ if (!isUUID(id) || !isUUID(parent) || forks.get(id)) return;
3404
+ forks.record(id, { parent, child: true });
3405
+ broadcast({ type: 'dispatch-update' });
3391
3406
  },
3392
3407
  });
3393
3408
 
@@ -3415,6 +3430,14 @@ app.post('/api/terminal/pick-folder', async (req, res) => {
3415
3430
  }
3416
3431
  });
3417
3432
 
3433
+ // The hub's terminalHost setting reaches only the board page, which relays it here.
3434
+ app.post('/api/terminal/options', (req, res) => {
3435
+ if (!terminal.authorized(req.get('x-terminal-token'))) return res.status(401).json({ error: 'invalid terminal token' });
3436
+ if (typeof req.body?.conptyDll !== 'boolean') return res.status(400).json({ error: 'conptyDll must be a boolean' });
3437
+ terminal.setConptyDll(req.body.conptyDll);
3438
+ res.status(204).end();
3439
+ });
3440
+
3418
3441
  // A tab whose terminal is off, or whose token died with an earlier server, ignores
3419
3442
  // `session:launched`, so only a tab that claims the session counts as showing it.
3420
3443
  const LAUNCH_CLAIM_MS = 3000;
@@ -3513,6 +3536,7 @@ app.get('/api/terminals', terminalRoute(async (_req, res) => {
3513
3536
  res.json({
3514
3537
  sessions: sessions.map((t) => {
3515
3538
  if (t.id === kanbot.ptyId) return { ...t, kanbot: true };
3539
+ if (t.mode === 'shell' && panes.shellPane(t.id)) return { ...t, pane: true };
3516
3540
  const marker = dispatched.get(t.id);
3517
3541
  return marker ? { ...t, dispatched: { parent: marker.parent || null } } : t;
3518
3542
  }),
@@ -3592,13 +3616,23 @@ app.get('/vendor/xterm/:file', (req, res) => {
3592
3616
 
3593
3617
  // #region DISPATCH
3594
3618
  const dispatched = createDispatchedStore(jsonFile(DISPATCHED_FILE));
3619
+ // Forks started from the board's Fork menu: same shape, no dispatch semantics.
3620
+ const forks = createDispatchedStore(jsonFile(FORKS_FILE));
3595
3621
 
3596
3622
  const linkedDocs = createLinkedDocStore(jsonFile(LINKED_DOCS_FILE));
3597
3623
 
3624
+ const nestStoreOf = (id) => (dispatched.get(id) ? dispatched : forks.get(id) ? forks : null);
3625
+
3598
3626
  function withDispatchMarker(sessions) {
3599
3627
  return sessions.map((s) => {
3600
3628
  const marker = dispatched.get(s.id);
3601
- return marker ? { ...s, dispatched: { parent: marker.parent, child: marker.child } } : s;
3629
+ const nest = marker || forks.get(s.id);
3630
+ if (!nest) return s;
3631
+ return {
3632
+ ...s,
3633
+ ...(marker ? { dispatched: { parent: marker.parent, child: marker.child } } : {}),
3634
+ nest: { parent: nest.parent, child: nest.child },
3635
+ };
3602
3636
  });
3603
3637
  }
3604
3638
 
@@ -3641,10 +3675,10 @@ app.post('/api/dispatch', terminalRoute(async (req, res) => {
3641
3675
  app.post('/api/dispatch/:id/child', (req, res) => {
3642
3676
  const { child } = req.body || {};
3643
3677
  if (typeof child !== 'boolean') return res.status(400).json({ error: 'child must be true or false' });
3644
- const marker = dispatched.get(req.params.id);
3645
- if (!marker) return res.status(404).json({ error: 'not a dispatched session' });
3646
- if (child && !marker.parent) return res.status(400).json({ error: 'child needs a parent session' });
3647
- if (dispatched.setChild(req.params.id, child)) broadcast({ type: 'dispatch-update' });
3678
+ const store = nestStoreOf(req.params.id);
3679
+ if (!store) return res.status(404).json({ error: 'not a dispatched session or a fork started from the board' });
3680
+ if (child && !store.get(req.params.id).parent) return res.status(400).json({ error: 'child needs a parent session' });
3681
+ if (store.setChild(req.params.id, child)) broadcast({ type: 'dispatch-update' });
3648
3682
  res.json({ session: req.params.id, child });
3649
3683
  });
3650
3684
 
@@ -4435,10 +4469,28 @@ async function resolveScratchpadPane(target) {
4435
4469
  return { kind: 'scratchpad', target: await fs.realpath(path.join(resolveScratchpad(target).dir, SCRATCHPAD_MANIFEST)) };
4436
4470
  }
4437
4471
 
4472
+ const MAX_SHELL_RUN = 1000;
4473
+
4474
+ // The target names the folder; the pane's target becomes a fresh PTY id, which the board's frame
4475
+ // starts in shell mode on first attach. `resolveSessionFolder` gives that id the folder, and
4476
+ // `shellRun` the command each start of the shell types and runs.
4477
+ async function resolveShellPane(target, _base, run) {
4478
+ const reason = terminal.unavailableReason();
4479
+ if (reason) throw previewError(409, `The terminal is off: ${reason}`, 'terminal_off');
4480
+ if (!path.isAbsolute(target) || !isAllowedFolder(target)) {
4481
+ throw previewError(400, 'A shell pane needs an absolute path to an existing folder', 'bad_target');
4482
+ }
4483
+ if (run !== undefined && (typeof run !== 'string' || /[\r\n]/.test(run) || run.length > MAX_SHELL_RUN)) {
4484
+ throw previewError(400, `run must be one line of at most ${MAX_SHELL_RUN} characters`, 'bad_run');
4485
+ }
4486
+ return { kind: 'shell', target: crypto.randomUUID(), cwd: await fs.realpath(target), run: run?.trim() || undefined };
4487
+ }
4488
+
4438
4489
  // A message target is a session log message id, which the board resolves when it shows the pane.
4439
4490
  const PANE_RESOLVERS = new Map([
4440
4491
  ['message', async (target) => ({ kind: 'message', target })],
4441
4492
  ['scratchpad', resolveScratchpadPane],
4493
+ ['shell', resolveShellPane],
4442
4494
  ]);
4443
4495
 
4444
4496
  app.get('/api/panes/:sessionId', (req, res) => {
@@ -4448,9 +4500,9 @@ app.get('/api/panes/:sessionId', (req, res) => {
4448
4500
 
4449
4501
  app.post('/api/panes/:sessionId', async (req, res) => {
4450
4502
  try {
4451
- const { target, base, title, kind, show } = req.body || {};
4503
+ const { target, base, title, kind, show, run } = req.body || {};
4452
4504
  if (typeof target !== 'string' || !target) throw previewError(400, 'target is required', 'bad_target');
4453
- const resolved = await (PANE_RESOLVERS.get(kind) ?? resolvePaneTarget)(target, base);
4505
+ const resolved = await (PANE_RESOLVERS.get(kind) ?? resolvePaneTarget)(target, base, run);
4454
4506
  res.json(panes.add(req.params.sessionId, { ...resolved, title, show: show === true }));
4455
4507
  } catch (error) {
4456
4508
  paneRouteError(res, error, 'POST /api/panes');
@@ -4503,8 +4555,10 @@ app.patch('/api/panes/:sessionId/:paneId', (req, res) => {
4503
4555
 
4504
4556
  app.delete('/api/panes/:sessionId/:paneId', (req, res) => {
4505
4557
  const { sessionId, paneId } = req.params;
4558
+ const pane = panes.get(sessionId).panes.find((p) => p.id === paneId);
4506
4559
  const layout = panes.remove(sessionId, paneId);
4507
4560
  if (!layout) return res.status(404).json({ error: `No pane ${paneId} in session ${sessionId}`, code: 'no_pane' });
4561
+ if (pane?.kind === 'shell') terminal.end(pane.target, terminal.token).catch(() => {});
4508
4562
  res.json({ layout });
4509
4563
  });
4510
4564
  // #endregion
@@ -5058,6 +5112,7 @@ async function runRetention() {
5058
5112
  const scan = await scanTranscripts(PROJECTS_DIR);
5059
5113
  const opts = { known: scan?.ids, maxAgeMs: retentionMs(CLAUDE_DIR) };
5060
5114
  const markers = dispatched.prune(opts);
5115
+ const forkMarkers = forks.prune(opts);
5061
5116
  const layouts = panes.prune(opts);
5062
5117
  if (layouts) queuePaneFileWatch();
5063
5118
  const addonSessions = addons.prune(opts);
@@ -5068,8 +5123,8 @@ async function runRetention() {
5068
5123
  const wts = worktrees.prune(scan?.dirs);
5069
5124
  const taskMaps = await pruneTaskMaps(TASK_MAPS_DIR, opts);
5070
5125
  const grouped = expireGroupMembers(scan?.ids);
5071
- if (markers || layouts || addonSessions || reviews || attachments || shows || contexts || wts || taskMaps || grouped.members) {
5072
- console.log(`[retention] removed ${markers} dispatch markers, ${layouts} pane layouts, ${addonSessions} add-on sessions, ${reviews} reviews, ${attachments} attachments, ${shows} show files, ${contexts} context status files, ${wts} worktrees, ${taskMaps} task-list mappings, ${grouped.members} group members, ${grouped.groups} groups`);
5126
+ if (markers || forkMarkers || layouts || addonSessions || reviews || attachments || shows || contexts || wts || taskMaps || grouped.members) {
5127
+ console.log(`[retention] removed ${markers} dispatch markers, ${forkMarkers} fork markers, ${layouts} pane layouts, ${addonSessions} add-on sessions, ${reviews} reviews, ${attachments} attachments, ${shows} show files, ${contexts} context status files, ${wts} worktrees, ${taskMaps} task-list mappings, ${grouped.members} group members, ${grouped.groups} groups`);
5073
5128
  }
5074
5129
  } catch (e) {
5075
5130
  console.warn('[retention] failed:', e.message);