claude-code-kanban 7.31.0 → 7.33.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/app.js CHANGED
@@ -4151,10 +4151,65 @@ function showNoSession() {
4151
4151
  updateUrl();
4152
4152
  sessionView.classList.remove('visible');
4153
4153
  noSession.style.display = '';
4154
+ renderHomeKeys();
4154
4155
  renderSessions();
4155
4156
  renderActivityChip();
4156
4157
  }
4157
4158
 
4159
+ // The home view: no session open. Each row runs its action on a click too.
4160
+ const HOME_ROWS = [
4161
+ {
4162
+ keys: ['Ctrl', 'Alt', 'N'],
4163
+ combo: true,
4164
+ hubMod: true,
4165
+ label: 'New session',
4166
+ run: openNewSession,
4167
+ when: terminalAvailable,
4168
+ },
4169
+ {
4170
+ keys: ['Ctrl', 'Shift', 'K'],
4171
+ combo: true,
4172
+ label: 'Ask Kanbot',
4173
+ run: () => toggleKanbot(true, 'docked'),
4174
+ when: kanbotAvailable,
4175
+ },
4176
+ { keys: ['Ctrl', '`'], combo: true, label: 'Show / hide terminal', run: toggleTerminal, when: terminalAvailable },
4177
+ { keys: ['Ctrl', 'Shift', 'P'], combo: true, label: 'Find a session', run: openSessionPicker },
4178
+ {
4179
+ keys: ['Ctrl', 'Alt', 'Shift', 'S'],
4180
+ combo: true,
4181
+ hubMod: true,
4182
+ label: 'Next session that needs you',
4183
+ run: nextNeedsYou,
4184
+ },
4185
+ {
4186
+ keys: ['Ctrl', 'Alt', 'S'],
4187
+ combo: true,
4188
+ hubMod: true,
4189
+ label: 'Back to the last session',
4190
+ run: swapToPreviousSession,
4191
+ },
4192
+ { keys: ['?'], label: 'All shortcuts', run: showHelpModal },
4193
+ ];
4194
+
4195
+ function renderHomeKeys() {
4196
+ const list = document.getElementById('home-keys');
4197
+ const rows = HOME_ROWS.filter((r) => (!r.when || r.when()) && helpKeys(r).length);
4198
+ list.innerHTML = rows
4199
+ .map(
4200
+ (row) =>
4201
+ `<button type="button" class="home-key"><span>${escapeHtml(row.label)}</span><span class="home-key-kbd">${keyChipsHtml(row)}</span></button>`,
4202
+ )
4203
+ .join('');
4204
+ list.querySelectorAll('.home-key').forEach((btn, i) => {
4205
+ btn.addEventListener('click', () => rows[i].run());
4206
+ });
4207
+ }
4208
+
4209
+ function goHome() {
4210
+ if (viewMode !== 'none') showNoSession();
4211
+ }
4212
+
4158
4213
  // Filter pipeline: active filter → force-include revealed/current (non-pinned) sessions →
4159
4214
  // project filter → search filter → ensure pinned/sticky sessions are always included.
4160
4215
  // Pure over module state, so the session picker can ask for the same list without a render.
@@ -4812,11 +4867,6 @@ function renderSession() {
4812
4867
  const session = sessions.find((s) => s.id === currentSessionId);
4813
4868
  if (!session) return;
4814
4869
 
4815
- // Opening the session, not opening a linked-docs surface: the card badge is the
4816
- // first place a pad shows up, and it would otherwise stay at zero until the user
4817
- // happened to open the info modal or zen panel.
4818
- loadSessionPads(currentSessionId);
4819
-
4820
4870
  const displayName = session.name || session.description || currentSessionId;
4821
4871
 
4822
4872
  sessionTitle.textContent = displayName;
@@ -7105,6 +7155,7 @@ const SHORTCUT_TABS = [
7105
7155
  {
7106
7156
  title: 'View',
7107
7157
  rows: [
7158
+ { keys: ['H'], label: 'Home: close the session' },
7108
7159
  { keys: ['\\'], label: 'Toggle sidebar' },
7109
7160
  { keys: ['T'], label: 'Toggle theme' },
7110
7161
  { keys: ['Shift', 'S'], combo: true, label: 'Storage manager' },
@@ -7147,11 +7198,11 @@ const SHORTCUT_TABS = [
7147
7198
  {
7148
7199
  title: 'Sessions',
7149
7200
  rows: [
7150
- { keys: ['Ctrl', 'Alt', 'N'], combo: true, hubMod: true, label: 'New session' },
7201
+ { keys: ['Ctrl', 'Alt', 'N'], combo: true, hubMod: true, label: 'New session', cmd: 'session.new' },
7151
7202
  { keys: ['Ctrl', 'Alt', 'R'], combo: true, hubMod: true, label: 'Resume session (claude -r)' },
7152
7203
  { keys: ['Ctrl', 'Alt', 'S'], combo: true, hubMod: true, label: 'Swap to previous session' },
7153
7204
  { keys: ['Ctrl', 'Alt', 'Shift', 'S'], combo: true, hubMod: true, label: 'Next session that needs you' },
7154
- { keys: ['Shift', 'C'], combo: true, label: 'Copy session id' },
7205
+ { keys: ['Shift', 'C'], combo: true, label: 'Copy session id', cmd: 'session.copyId' },
7155
7206
  { keys: ['Ctrl', 'Shift', 'C'], combo: true, label: 'Copy session name (SendMessage address)' },
7156
7207
  ],
7157
7208
  },
@@ -7164,10 +7215,10 @@ const SHORTCUT_TABS = [
7164
7215
  title: 'Terminal',
7165
7216
  rows: [
7166
7217
  { keys: ['Ctrl', '`'], combo: true, label: 'Show / hide terminal' },
7167
- { keys: ['Alt', '`'], combo: true, label: 'Focus terminal / page' },
7218
+ { keys: ['Alt', '`'], combo: true, label: 'Focus terminal / page; from a shell pane, sidebar and back' },
7168
7219
  { keys: ['Ctrl', 'Alt', '`'], combo: true, hubMod: true, label: 'Focus terminal / show card' },
7169
7220
  { keys: ['Alt', 'Shift', '`'], combo: true, label: 'End terminal' },
7170
- { keys: ['Ctrl', 'Shift', '`'], combo: true, label: 'All terminals' },
7221
+ { keys: ['Ctrl', 'Shift', '`'], combo: true, label: 'All terminals', cmd: 'terminal.manager' },
7171
7222
  { keys: ['Ctrl', '+/−/0'], combo: true, label: 'Terminal text size' },
7172
7223
  ],
7173
7224
  },
@@ -7246,6 +7297,12 @@ function termKbd() {
7246
7297
  // The keys of a help row as they read on this system. The hub's modifier is Ctrl+Alt, and on
7247
7298
  // macOS Control+Option for the tab numbers too (Windows and Linux use bare Alt for those). A hub
7248
7299
  // row shows the keys the hub reports, which the user can change; row.keys until it answers.
7300
+ function keyChipsHtml(row, parts) {
7301
+ parts ??= helpKeys(row);
7302
+ const sep = row.combo ? '<span class="sc-plus">+</span>' : '<span class="sc-or">/</span>';
7303
+ return parts.map((k) => `<kbd>${escapeHtml(k)}</kbd>`).join(sep);
7304
+ }
7305
+
7249
7306
  function helpKeys(row, mac = IS_MAC, keyLabel = hub.keyLabel) {
7250
7307
  const live = row.action && keyLabel(row.action);
7251
7308
  if (live) return live;
@@ -7279,8 +7336,7 @@ function buildHelpShortcuts(groups) {
7279
7336
  }
7280
7337
  const parts = row && helpKeys(row);
7281
7338
  if (!parts?.length) continue;
7282
- const sep = row.combo ? '<span class="sc-plus">+</span>' : '<span class="sc-or">/</span>';
7283
- const keys = parts.map((k) => `<kbd>${escapeHtml(k)}</kbd>`).join(sep);
7339
+ const keys = keyChipsHtml(row, parts);
7284
7340
  const label = escapeHtml(row.label);
7285
7341
  cells.push(`<dt class="${escapeHtml(side)}">${keys}</dt><dd class="${escapeHtml(side)}">${label}</dd>`);
7286
7342
  }
@@ -8289,6 +8345,12 @@ function shiftOnly(e, code) {
8289
8345
  return e.code === code && e.shiftKey && !e.ctrlKey && !e.altKey && !e.metaKey;
8290
8346
  }
8291
8347
 
8348
+ // The combo of a press as the hub names it: the character on a Latin layout, the US key in the same
8349
+ // place on any other, so a letter key works whatever the input language.
8350
+ function comboIs(e, ...combos) {
8351
+ return combos.includes(ClaudeHub.comboOf(e));
8352
+ }
8353
+
8292
8354
  // xterm runs in another process, so blur() in the board leaves it focused and the modal's arrow keys go
8293
8355
  // to it. Focusing a board element takes the focus.
8294
8356
  function toggleLastMessage() {
@@ -8823,6 +8885,11 @@ document.addEventListener('keydown', (e) => {
8823
8885
  });
8824
8886
  return;
8825
8887
  }
8888
+ if (matchKey(e, 'KeyH')) {
8889
+ e.preventDefault();
8890
+ goHome();
8891
+ return;
8892
+ }
8826
8893
  if (matchKey(e, 'KeyT')) {
8827
8894
  e.preventDefault();
8828
8895
  toggleTheme();
@@ -9489,7 +9556,7 @@ function onReviewOfferKey(e) {
9489
9556
  sendReview();
9490
9557
  return;
9491
9558
  }
9492
- if (reviewPopMode !== 'offer' || !matchKey(e, 'c', 'C')) return;
9559
+ if (reviewPopMode !== 'offer' || !comboIs(e, 'c')) return;
9493
9560
  e.preventDefault();
9494
9561
  e.stopImmediatePropagation();
9495
9562
  reviewPopEl().querySelector('.review-offer-btn').click();
@@ -10254,37 +10321,8 @@ async function loadPreviewKinds(sessionId, paths) {
10254
10321
  afterLinkedDocsChanged(sessionId);
10255
10322
  }
10256
10323
 
10257
- // A pad the session made with `scratch new` becomes an ordinary linked document.
10258
- // The server derives the pads on every read, so this record of the ones already
10259
- // linked is what stops the next read undoing an unlink.
10324
+ // Nothing writes these keys now; the orphan sweep still clears the ones older boards left.
10260
10325
  const PAD_LINKED_PREFIX = 'autolinked-pads-';
10261
- const padsFetched = new Set();
10262
-
10263
- function getOfferedPadPaths(sessionId) {
10264
- return readStoredList(PAD_LINKED_PREFIX + sessionId);
10265
- }
10266
-
10267
- function setOfferedPadPaths(sessionId, paths) {
10268
- store.writeJson(PAD_LINKED_PREFIX + sessionId, paths);
10269
- }
10270
-
10271
- async function loadSessionPads(sessionId) {
10272
- if (!sessionId || padsFetched.has(sessionId)) return;
10273
- padsFetched.add(sessionId);
10274
- const data = await getJson(apiPath`/api/sessions/${sessionId}/pads`);
10275
- if (!data) {
10276
- padsFetched.delete(sessionId);
10277
- return;
10278
- }
10279
- const pads = data.pads || [];
10280
- const offered = new Set(getOfferedPadPaths(sessionId).map(canonicalPath));
10281
- const fresh = pads.map((p) => p.path).filter((p) => !offered.has(canonicalPath(p)));
10282
- if (!fresh.length) return;
10283
- // Recorded before the link, so a render triggered by the link already sees a pad
10284
- // that will not be offered again.
10285
- setOfferedPadPaths(sessionId, [...offered, ...fresh]);
10286
- for (const p of fresh) setSessionDocLink(sessionId, p, false);
10287
- }
10288
10326
 
10289
10327
  // A scratchpad manifest opens in the external `scratch` viewer, not the editor —
10290
10328
  // the raw JSON is a manifest, not the document the user linked.
@@ -10294,12 +10332,17 @@ function isScratchpadPath(p) {
10294
10332
 
10295
10333
  // `linkedDocOpener` is the only place a linked path is classified; the row's tag,
10296
10334
  // tooltip and action are all read from here, so a new destination is one entry.
10335
+ const SCRATCHPAD_OPEN = 'scratchpad.open';
10297
10336
  const LINKED_DOC_OPENERS = {
10298
10337
  preview: { tag: '', hint: '', cls: '', noun: 'path' },
10299
10338
  url: { tag: '', hint: ' — opens in a new tab', cls: ' is-url', noun: 'URL' },
10300
10339
  scratch: {
10301
10340
  tag: '(scratchpad)',
10302
- hint: ' — opens in the scratch viewer; Ctrl+click opens it in a pane',
10341
+ get hint() {
10342
+ return hub.can(SCRATCHPAD_OPEN)
10343
+ ? ' — opens in a pane; Shift+click opens the Scratchpads tab; Ctrl+click opens the scratch viewer'
10344
+ : ' — opens in the scratch viewer';
10345
+ },
10303
10346
  cls: ' is-editor',
10304
10347
  noun: 'path',
10305
10348
  url: '/api/scratchpad/open',
@@ -10762,9 +10805,14 @@ function bindLinkedDocsHandlers(container, sessionId) {
10762
10805
  removeSessionPreviewPath(sessionId, hit.dataset.path);
10763
10806
  forgetServerLinkedDoc(sessionId, hit.dataset.path);
10764
10807
  afterLinkedDocsChanged(sessionId);
10765
- } else if ((e.ctrlKey || e.metaKey) && linkedDocOpener(hit.dataset.path) === 'scratch') {
10808
+ } else if (
10809
+ !(e.ctrlKey || e.metaKey) &&
10810
+ linkedDocOpener(hit.dataset.path) === 'scratch' &&
10811
+ hub.can(SCRATCHPAD_OPEN)
10812
+ ) {
10766
10813
  if (container.closest('#team-modal')) closeTeamModal();
10767
- openScratchpadPane(sessionId, hit.dataset.path);
10814
+ if (e.shiftKey) openScratchpadTab(sessionId, hit.dataset.path);
10815
+ else openScratchpadPane(sessionId, hit.dataset.path);
10768
10816
  } else {
10769
10817
  openLinkedDoc(hit.dataset.path, getSessionBaseDir(sessionId));
10770
10818
  }
@@ -10885,8 +10933,6 @@ function setupEventSource() {
10885
10933
  fetchSessions().catch(() => {});
10886
10934
  if (currentSessionId) fetchTasks(currentSessionId);
10887
10935
  refetchPaneLayout();
10888
- // A restarted board started none of the viewers the frames still point at.
10889
- onScratchpadExited(null);
10890
10936
  if (sgRev === null) syncSessionGroups();
10891
10937
  else if (sgUnsent) persistSessionGroups();
10892
10938
  else sgRefresh();
@@ -11026,10 +11072,6 @@ function setupEventSource() {
11026
11072
  applyPaneLayout(data.sessionId, data.layout);
11027
11073
  }
11028
11074
 
11029
- if (data.type === 'scratchpad:exited') {
11030
- onScratchpadExited(data.manifest);
11031
- }
11032
-
11033
11075
  if (data.type === 'addon:changed' && dockSid) {
11034
11076
  fetchDockAddons(dockSid);
11035
11077
  }
@@ -12829,7 +12871,6 @@ function initSidebarResize() {
12829
12871
  onStart() {
12830
12872
  if (sidebar.classList.contains('collapsed')) return false;
12831
12873
  startWidth = sidebar.offsetWidth;
12832
- sidebar.classList.add('resizing');
12833
12874
  },
12834
12875
  onMove(dx) {
12835
12876
  const w = Math.min(600, Math.max(200, startWidth + dx));
@@ -12837,7 +12878,6 @@ function initSidebarResize() {
12837
12878
  sidebar.style.width = `${w}px`;
12838
12879
  },
12839
12880
  onEnd() {
12840
- sidebar.classList.remove('resizing');
12841
12881
  store.setItem(SIDEBAR_WIDTH_KEY, sidebar.style.getPropertyValue('--sidebar-width'));
12842
12882
  },
12843
12883
  });
@@ -12888,10 +12928,6 @@ async function showSessionInfoModal(sessionId) {
12888
12928
  const cachedTasks = currentSessionId === sessionId ? currentTasks : [];
12889
12929
  showInfoModal(session, null, cachedTasks, null, null);
12890
12930
  artifactsSection.load(sessionId);
12891
- // The modal reaches any card's session, not just the open one, so this is the second
12892
- // place a pad can first be seen. Linking belongs on the two open events rather than
12893
- // in renderLinkedDocsHtml, which only builds a string and runs on every repaint.
12894
- loadSessionPads(sessionId);
12895
12931
 
12896
12932
  const rerender = (teamConfig, tasks, planContent, parentInfo) => {
12897
12933
  if (_planSessionId !== sessionId) return; // user opened a different modal
@@ -13196,6 +13232,56 @@ const spPeekCache = new Map();
13196
13232
  let spScope = 'board';
13197
13233
  let spRecent = { rows: [], limit: 0, hasMore: true, loading: false };
13198
13234
  let spRowEls = [];
13235
+ // A query that starts with '>' lists commands in place of sessions. A command runs on the session
13236
+ // that was current when the picker opened; `when` hides it when that session cannot run it.
13237
+ // A command's key comes from the shortcut help row whose `opens` or `cmd` is the command's id.
13238
+ let spCommandMode = false;
13239
+ let spTarget = null;
13240
+ const SP_COMMANDS = [
13241
+ {
13242
+ id: 'session.openInEditor',
13243
+ title: 'Open project in editor',
13244
+ when: (s) => !!s?.project,
13245
+ run: (s) => openFolderInEditor(s.project),
13246
+ },
13247
+ {
13248
+ id: 'session.copyId',
13249
+ title: 'Copy session ID',
13250
+ when: (s) => !!s,
13251
+ run: (s) => copyText(s.id, 'session id', `Copied session id: ${s.id.slice(0, 8)}`),
13252
+ },
13253
+ {
13254
+ id: 'session.cost',
13255
+ title: 'Show session cost',
13256
+ when: (s) => !!s && hub.can('session.cost'),
13257
+ run: (s) => openCost(s.id),
13258
+ },
13259
+ {
13260
+ id: 'project.plugins',
13261
+ title: 'Show project plugins',
13262
+ when: (s) => !!s?.project && hub.can('project.plugins'),
13263
+ run: (s) => openMarketplace(s.id),
13264
+ },
13265
+ {
13266
+ id: 'project.memory',
13267
+ title: 'Show project memory',
13268
+ when: (s) => !!s?.project && hub.can('project.memory'),
13269
+ run: (s) => openMemory(s.id),
13270
+ },
13271
+ { id: 'session.new', title: 'New session', when: terminalAvailable, run: (s) => openNewSession(s?.project ?? null) },
13272
+ {
13273
+ id: 'session.shell',
13274
+ title: 'New terminal shell',
13275
+ when: (s) => !!s && terminalAvailable() && !!getSessionBaseDir(s.id),
13276
+ run: (s) => openShellForSession(s.id),
13277
+ },
13278
+ { id: 'terminal.manager', title: 'Open terminal manager', when: terminalAvailable, run: openTerminalManager },
13279
+ ];
13280
+ const SP_COMMAND_KEYS = new Map(
13281
+ SHORTCUT_TABS.flatMap((t) => t.groups.flatMap((g) => g.rows))
13282
+ .filter((r) => r.opens || r.cmd)
13283
+ .map((r) => [r.opens || r.cmd, r]),
13284
+ );
13199
13285
  const SP_RECENT_PAGE = 50;
13200
13286
  const SP_RECENT_TAIL = 5;
13201
13287
 
@@ -13235,7 +13321,8 @@ function spSetScope(scope) {
13235
13321
 
13236
13322
  // Also run after each load: a page too short to scroll gives no scroll event.
13237
13323
  function spLoadMoreNearEnd() {
13238
- if (spScope === 'all') loadMoreIfNearEnd(document.getElementById('session-picker-list'), spLoadRecent);
13324
+ if (!spCommandMode && spScope === 'all')
13325
+ loadMoreIfNearEnd(document.getElementById('session-picker-list'), spLoadRecent);
13239
13326
  }
13240
13327
 
13241
13328
  const spSearch = sessionSearch(() => {
@@ -13248,6 +13335,7 @@ function openSessionPicker({ query = '', ranked = null } = {}) {
13248
13335
  input.value = query;
13249
13336
  spRanked = ranked;
13250
13337
  spSource = getFilteredSessions().sort((a, b) => Date.parse(b.modifiedAt) - Date.parse(a.modifiedAt));
13338
+ spTarget = sessions.find((s) => s.id === currentSessionId) ?? null;
13251
13339
  spPeekCache.clear();
13252
13340
  spRenderedQuery = null;
13253
13341
  spRecent = { rows: [], limit: 0, hasMore: true, loading: false };
@@ -13367,9 +13455,45 @@ function spPinHtml(session) {
13367
13455
  return '<span class="sp-pin"></span>';
13368
13456
  }
13369
13457
 
13458
+ function renderPickerCommands(list, query) {
13459
+ const selectedId = spRows[spIdx]?.id;
13460
+ spRows = SP_COMMANDS.filter((c) => c.when(spTarget) && fuzzyMatch(c.title, query));
13461
+ const target = spTarget
13462
+ ? `<div class="sp-target">Session: <b>${escapeHtml(sessionDisplayName(spTarget))}</b>${spTarget.project ? ` · ${escapeHtml(pathBasename(spTarget.project))}` : ''}</div>`
13463
+ : '<div class="sp-target">No current session</div>';
13464
+ const rows = spRows
13465
+ .map((c, i) => {
13466
+ const keyRow = SP_COMMAND_KEYS.get(c.id);
13467
+ const keys = keyRow ? `<span class="sp-keys">${keyChipsHtml(keyRow)}</span>` : '';
13468
+ return `<button class="sp-row" data-idx="${i}"><span class="sp-name">${escapeHtml(c.title)}</span>${keys}</button>`;
13469
+ })
13470
+ .join('');
13471
+ list.innerHTML = target + (rows || '<div class="sp-empty">No command matches</div>');
13472
+ spRowEls = list.querySelectorAll('.sp-row');
13473
+ spIdx = -1;
13474
+ spSelect(
13475
+ Math.max(
13476
+ 0,
13477
+ spRows.findIndex((c) => c.id === selectedId),
13478
+ ),
13479
+ );
13480
+ }
13481
+
13370
13482
  function renderSessionPicker() {
13371
13483
  const list = document.getElementById('session-picker-list');
13372
- const query = document.getElementById('session-picker-input').value.trim();
13484
+ const raw = document.getElementById('session-picker-input').value.trimStart();
13485
+ const commandMode = raw.startsWith('>');
13486
+ if (commandMode !== spCommandMode) {
13487
+ spCommandMode = commandMode;
13488
+ if (commandMode) spSetPeeking(false);
13489
+ _modalEl('session-picker-modal').classList.toggle('commands', commandMode);
13490
+ }
13491
+ if (commandMode) {
13492
+ spRenderedQuery = null;
13493
+ renderPickerCommands(list, raw.slice(1).trim());
13494
+ return;
13495
+ }
13496
+ const query = raw.trim();
13373
13497
  // Rows that arrive for the same query and scope append below, so the cursor stays on its row.
13374
13498
  const renderKey = `${spScope}\n${query}`;
13375
13499
  const selectedId = renderKey === spRenderedQuery ? spRows[spIdx]?.id : null;
@@ -13427,10 +13551,17 @@ function spSelect(idx) {
13427
13551
  row?.classList.add('selected');
13428
13552
  row?.scrollIntoView({ block: 'nearest' });
13429
13553
  spSchedulePeek();
13430
- if (spScope === 'all' && spIdx >= spRows.length - 5) spLoadRecent();
13554
+ if (!spCommandMode && spScope === 'all' && spIdx >= spRows.length - 5) spLoadRecent();
13431
13555
  }
13432
13556
 
13433
13557
  async function spOpen(idx) {
13558
+ if (spCommandMode) {
13559
+ const command = spRows[idx];
13560
+ if (!command) return;
13561
+ closeSessionPicker();
13562
+ command.run(spTarget);
13563
+ return;
13564
+ }
13434
13565
  const session = spRows[idx];
13435
13566
  if (!session) return;
13436
13567
  closeSessionPicker({ refocus: false });
@@ -13447,12 +13578,14 @@ function initSessionPicker() {
13447
13578
  // Bound on the input: the global handler returns early on INPUT targets.
13448
13579
  input.addEventListener('keydown', (e) => {
13449
13580
  if (e.key === 'Escape') closeSessionPicker();
13450
- else if (matchKey(e, 'ArrowDown') || (e.ctrlKey && e.key === 'n')) spSelect(spIdx + 1);
13451
- else if (matchKey(e, 'ArrowUp') || (e.ctrlKey && !e.shiftKey && e.key === 'p')) spSelect(spIdx - 1);
13581
+ else if (matchKey(e, 'ArrowDown') || comboIs(e, 'ctrl+n', 'ctrl+shift+n')) spSelect(spIdx + 1);
13582
+ else if (matchKey(e, 'ArrowUp') || comboIs(e, 'ctrl+p')) spSelect(spIdx - 1);
13452
13583
  else if (e.key === 'Enter') spOpen(spIdx);
13453
- else if (e.ctrlKey && e.code === 'Space') spSetPeeking(!spIsPeeking());
13454
- else if (e.key === 'Tab' && !e.ctrlKey && !e.altKey && !e.metaKey) spSetScope(spScope === 'all' ? 'board' : 'all');
13455
- else return;
13584
+ else if (e.ctrlKey && e.code === 'Space') {
13585
+ if (!spCommandMode) spSetPeeking(!spIsPeeking());
13586
+ } else if (e.key === 'Tab' && !e.ctrlKey && !e.altKey && !e.metaKey) {
13587
+ if (!spCommandMode) spSetScope(spScope === 'all' ? 'board' : 'all');
13588
+ } else return;
13456
13589
  e.preventDefault();
13457
13590
  e.stopPropagation();
13458
13591
  });
@@ -13569,8 +13702,8 @@ function initProjectPicker() {
13569
13702
  input.addEventListener('input', renderProjectPicker);
13570
13703
  input.addEventListener('keydown', (e) => {
13571
13704
  if (e.key === 'Escape') closeProjectPicker();
13572
- else if (matchKey(e, 'ArrowDown') || (e.ctrlKey && e.key === 'n')) ppSelect(ppIdx + 1);
13573
- else if (matchKey(e, 'ArrowUp') || (e.ctrlKey && !e.shiftKey && e.key === 'p')) ppSelect(ppIdx - 1);
13705
+ else if (matchKey(e, 'ArrowDown') || comboIs(e, 'ctrl+n', 'ctrl+shift+n')) ppSelect(ppIdx + 1);
13706
+ else if (matchKey(e, 'ArrowUp') || comboIs(e, 'ctrl+p')) ppSelect(ppIdx - 1);
13574
13707
  else if (e.key === 'Enter') ppApply(ppIdx);
13575
13708
  else if (e.altKey && !e.ctrlKey && !e.metaKey && e.code === 'KeyR') {
13576
13709
  if (!e.repeat) ppToggleRecentOnly();
@@ -13969,7 +14102,6 @@ function openPlanInEditor() {
13969
14102
  postAndToast(apiPath`/api/sessions/${_planSessionId}/plan/open`, {}, 'in editor');
13970
14103
  }
13971
14104
 
13972
- // biome-ignore lint/correctness/noUnusedVariables: used in HTML
13973
14105
  function openFolderInEditor(folder, file) {
13974
14106
  const body = {};
13975
14107
  if (folder) body.folder = folder;
@@ -14730,6 +14862,7 @@ function paneUrlFrame(pane, className) {
14730
14862
  frame.addEventListener('load', () => {
14731
14863
  postToShowFrames(() => ({ type: `${SHOW_MSG}tokens`, tokens: showTokens() }), [frame]);
14732
14864
  frame.hostKeysSig = null;
14865
+ frame.hostPlainKeys = null;
14733
14866
  pushTerminalClaims();
14734
14867
  });
14735
14868
  return frame;
@@ -14764,7 +14897,7 @@ async function loadPaneView(sid, pane, view, scroll) {
14764
14897
  return;
14765
14898
  }
14766
14899
  if (pane.kind === 'scratchpad') {
14767
- await loadScratchpadPaneView(pane, view);
14900
+ await loadScratchpadPaneView(sid, pane, view);
14768
14901
  return;
14769
14902
  }
14770
14903
  if (pane.kind === 'shell') {
@@ -14805,38 +14938,28 @@ async function loadPaneView(sid, pane, view, scroll) {
14805
14938
  view.insertAdjacentHTML('beforeend', paneCardHtml(title, text, button));
14806
14939
  }
14807
14940
 
14808
- // The viewer runs on its own loopback port, a different origin from the board and the hub, so the
14809
- // URL pane sandbox holds. The board asks for the URL each time it mounts the view, because the
14810
- // viewer dies with cck and is started again on demand.
14811
- async function loadScratchpadPaneView(pane, view) {
14812
- view.insertAdjacentHTML(
14813
- 'beforeend',
14814
- '<div class="pane-card pane-starting"><div class="pane-card-box"><p>Starting the scratch viewer…</p></div></div>',
14815
- );
14816
- const res = await paneRequest('POST', '/api/scratchpad/serve', { path: pane.target });
14817
- view.querySelector('.pane-starting')?.remove();
14818
- if (!res.url) {
14941
+ // The pad's viewer belongs to the hub's Scratchpads app; the board asks it for the URL each time it
14942
+ // mounts the view, because the app stops a viewer that no page has open.
14943
+ function scratchpadOpenArgs(sid, path) {
14944
+ return { path, project: sessions.find((s) => s.id === sid)?.project || '', session: sid };
14945
+ }
14946
+
14947
+ async function loadScratchpadPaneView(sid, pane, view) {
14948
+ const { url } = hub.can(SCRATCHPAD_OPEN)
14949
+ ? await hub.invoke(SCRATCHPAD_OPEN, scratchpadOpenArgs(sid, pane.target), { open: 'pane' })
14950
+ : {};
14951
+ if (!url) {
14819
14952
  view.insertAdjacentHTML(
14820
14953
  'beforeend',
14821
- paneCardHtml('Scratch viewer unavailable', res.error || pane.target, 'Open in scratch viewer'),
14954
+ paneCardHtml(
14955
+ 'Scratchpads app unavailable',
14956
+ 'Install the Scratchpads hub app to view pads in a pane.',
14957
+ 'Open in scratch viewer',
14958
+ ),
14822
14959
  );
14823
14960
  return;
14824
14961
  }
14825
- mountPaneUrlFrame({ ...pane, target: res.url }, view);
14826
- }
14827
-
14828
- // A viewer that exited leaves its frames on a dead port; the views on screen mount again now,
14829
- // the others when shown.
14830
- function onScratchpadExited(manifest) {
14831
- const dead = [];
14832
- for (const key of paneFrames.keys()) {
14833
- const [sid, paneId] = key.split('/');
14834
- const pane = paneLayout(sid).panes.find((p) => p.id === paneId);
14835
- if (pane?.kind === 'scratchpad' && (!manifest || canonicalPath(pane.target) === manifest)) dead.push([sid, paneId]);
14836
- }
14837
- if (!dead.length) return;
14838
- for (const [sid, paneId] of dead) unmountPane(sid, paneId);
14839
- syncPanes();
14962
+ mountPaneUrlFrame({ ...pane, target: url }, view);
14840
14963
  }
14841
14964
 
14842
14965
  // The target is the message's pin id, `type|timestamp|text`. The log holds only the latest pages,
@@ -15445,6 +15568,9 @@ function openPaneMenu(x, y, id) {
15445
15568
  ? 'Open in scratch viewer'
15446
15569
  : 'Open in preview',
15447
15570
  )) +
15571
+ (pane.kind === 'scratchpad' && hub.can(SCRATCHPAD_OPEN)
15572
+ ? paneMenuItem('openTab', 'Open in Scratchpads tab')
15573
+ : '') +
15448
15574
  (message || shell
15449
15575
  ? ''
15450
15576
  : paneMenuItem('link', paneIsLinked(pane) ? 'Remove from linked documents' : 'Add to linked documents')) +
@@ -15504,6 +15630,10 @@ function showPaneMenu(x, y, id, ariaLabel, html) {
15504
15630
  const PANE_MENU_ACTIONS = {
15505
15631
  copy: copyPaneTarget,
15506
15632
  open: openPaneExternally,
15633
+ openTab: (id) => {
15634
+ const pane = paneById(id);
15635
+ if (pane) openScratchpadTab(paneSessionId(), pane.target);
15636
+ },
15507
15637
  link: togglePaneLink,
15508
15638
  rename: beginPaneRename,
15509
15639
  reload: reloadPane,
@@ -15565,11 +15695,14 @@ function applyPaneLine(view) {
15565
15695
  markSourceLine(body, line);
15566
15696
  }
15567
15697
 
15568
- // The same pad again returns its pane, so a second Ctrl+click only shows it.
15698
+ // The same pad again returns its pane, so a second click only shows it.
15569
15699
  async function openScratchpadPane(sid, manifest) {
15570
15700
  const onScreen = await postPane(sid, { kind: 'scratchpad', target: manifest });
15571
- if (onScreen) syncPanes();
15572
- toastPaneAdded(sid, onScreen, linkedDocLabel(manifest));
15701
+ if (onScreen !== null) revealPane(sid, onScreen);
15702
+ }
15703
+
15704
+ function openScratchpadTab(sid, manifest) {
15705
+ hub.invoke(SCRATCHPAD_OPEN, scratchpadOpenArgs(sid, manifest));
15573
15706
  }
15574
15707
 
15575
15708
  async function openPaneAtLine(sid, { path, line }, base) {
@@ -16219,8 +16352,23 @@ async function swapToPreviousSession() {
16219
16352
  await revealSession(target);
16220
16353
  }
16221
16354
 
16355
+ // A shell types the keys that reach the sidebar, so Alt+` takes a shell pane there and back.
16356
+ let shellLeftForSidebar = null;
16357
+
16222
16358
  // Esc belongs to Claude, so leaving the terminal without hiding it needs its own key.
16223
16359
  function toggleTerminalFocus() {
16360
+ const active = document.activeElement;
16361
+ if (shellFrames.has(active)) {
16362
+ leaveTerminalPane();
16363
+ shellLeftForSidebar = active;
16364
+ return;
16365
+ }
16366
+ const shell = shellLeftForSidebar;
16367
+ shellLeftForSidebar = null;
16368
+ if (shell && focusZone === 'sidebar' && paneFocusTarget(activePaneView()) === shell) {
16369
+ focusActivePane();
16370
+ return;
16371
+ }
16224
16372
  if (!wantsTerminal()) {
16225
16373
  toggleTerminal();
16226
16374
  return;
@@ -16592,11 +16740,14 @@ function sendBridgeClaimsAll(frames, base) {
16592
16740
  }
16593
16741
 
16594
16742
  // A hub app in a URL pane runs the SDK, which hands back these keys (hub protocol §5.2). Only keys with
16595
- // Ctrl, Alt or Meta: the page keeps Escape, brackets and its own letter keys.
16743
+ // Ctrl, Alt or Meta, so the page keeps Escape, brackets and its own letter keys, plus the plain keys
16744
+ // its hub:hostReady named.
16596
16745
  function sendHostKeys(frames, bridged) {
16597
- const keys = bridged.keys.filter((k) => k.ctrlKey || k.altKey || k.metaKey);
16598
- const sig = JSON.stringify(keys);
16746
+ const modified = (k) => k.ctrlKey || k.altKey || k.metaKey;
16599
16747
  for (const f of frames) {
16748
+ const plain = f.hostPlainKeys || [];
16749
+ const keys = bridged.keys.filter((k) => modified(k) || plain.includes(k.key));
16750
+ const sig = JSON.stringify(keys);
16600
16751
  const origin = URL.parse(f.src)?.origin;
16601
16752
  if (!origin || origin === 'null' || f.hostKeysSig === sig) continue;
16602
16753
  f.hostKeysSig = sig;
@@ -16614,6 +16765,11 @@ window.addEventListener('message', (e) => {
16614
16765
  if (!frame || URL.parse(frame.src)?.origin !== e.origin) return;
16615
16766
  if (type === 'hub:hostReady') {
16616
16767
  if (!dock) frame.parentElement.classList.add('keys-bridged');
16768
+ const plain = Array.isArray(e.data.plainKeys) ? e.data.plainKeys.filter((k) => typeof k === 'string') : [];
16769
+ if (plain.length) {
16770
+ frame.hostPlainKeys = plain;
16771
+ pushTerminalClaims();
16772
+ }
16617
16773
  return;
16618
16774
  }
16619
16775
  // A page has focus when it gets a keydown, even one that never posts its focus.
@@ -16862,11 +17018,13 @@ function restoreTerminalFocus(zone, sessionId) {
16862
17018
 
16863
17019
  // The terminal stands in for the board, so it takes the board zone however focus arrives
16864
17020
  // (Tab, Alt+`, a click); leaveTerminalPane hands it back to the sidebar.
16865
- document.getElementById('terminal-pane').addEventListener('focusin', () => {
17021
+ function takeBoardZone() {
16866
17022
  if (focusZone !== 'sidebar') return;
16867
17023
  clearKbSelection();
16868
17024
  focusZone = 'board';
16869
- });
17025
+ }
17026
+ document.getElementById('terminal-pane').addEventListener('focusin', takeBoardZone);
17027
+ paneViews.addEventListener('focusin', takeBoardZone);
16870
17028
 
16871
17029
  function detachTerminal() {
16872
17030
  const had = termState.socket;
@@ -17286,7 +17444,7 @@ function ensureKanbotPopover() {
17286
17444
  return el;
17287
17445
  }
17288
17446
 
17289
- function setKanbotLayout(layout) {
17447
+ function setKanbotLayout(layout, save = true) {
17290
17448
  const el = kanbotState.el;
17291
17449
  const docked = layout === 'docked';
17292
17450
  const expanded = layout === 'expanded';
@@ -17301,7 +17459,7 @@ function setKanbotLayout(layout) {
17301
17459
  expand.innerHTML = showIcon(expanded ? 'restore' : 'expand');
17302
17460
  expand.title = expanded ? 'Restore' : 'Expand';
17303
17461
  expand.setAttribute('aria-label', expand.title);
17304
- store.setItem(KANBOT_LAYOUT_KEY, layout);
17462
+ if (save) store.setItem(KANBOT_LAYOUT_KEY, layout);
17305
17463
  postToKanbotFrame('focus');
17306
17464
  }
17307
17465
 
@@ -17329,8 +17487,10 @@ function setKanbotAttached(on) {
17329
17487
  syncCloseGuard();
17330
17488
  }
17331
17489
 
17332
- function toggleKanbot(force) {
17490
+ // `layout` applies for this page only; the saved layout comes back on reload.
17491
+ function toggleKanbot(force, layout) {
17333
17492
  const el = ensureKanbotPopover();
17493
+ if (layout) setKanbotLayout(layout, false);
17334
17494
  const show = typeof force === 'boolean' ? force : !el.classList.contains('visible');
17335
17495
  const wasShown = el.classList.contains('visible');
17336
17496
  el.classList.toggle('visible', show);
@@ -17815,6 +17975,8 @@ const SHOW_ICONS = {
17815
17975
  dock: '<path d="M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2zM15 3v18"/>',
17816
17976
  clear: '<path d="M3 6h18M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2"/>',
17817
17977
  close: '<path d="M18 6L6 18M6 6l12 12"/>',
17978
+ alert: '<circle cx="12" cy="12" r="9"/><path d="M12 8v5M12 16h.01"/>',
17979
+ upgrade: '<circle cx="12" cy="12" r="9"/><path d="M12 16V8M8.5 11.5 12 8l3.5 3.5"/>',
17818
17980
  pane: '<use href="#icon-pane"/>',
17819
17981
  card: '<rect x="3" y="4" width="18" height="16" rx="2"/><path d="M13 4v7h8"/>',
17820
17982
  external: '<path d="M15 3h6v6M10 14L21 3M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/>',
@@ -18361,14 +18523,20 @@ window.addEventListener('message', (e) => {
18361
18523
 
18362
18524
  // The same body attributes the terminal theme watches; a markdown card follows the board's CSS.
18363
18525
  // The body's style also changes on every drag, so a push with the same tokens is dropped.
18526
+ // A theme switch changes the class and the style in separate steps, so one frame collects them.
18364
18527
  let sentTokens = '';
18528
+ let tokensRaf = 0;
18365
18529
  new MutationObserver(() => {
18366
- postToShowFrames(() => {
18367
- const tokens = showTokens();
18368
- const key = JSON.stringify(tokens);
18369
- if (key === sentTokens) return null;
18370
- sentTokens = key;
18371
- return { type: `${SHOW_MSG}tokens`, tokens };
18530
+ if (tokensRaf) return;
18531
+ tokensRaf = requestAnimationFrame(() => {
18532
+ tokensRaf = 0;
18533
+ postToShowFrames(() => {
18534
+ const tokens = showTokens();
18535
+ const key = JSON.stringify(tokens);
18536
+ if (key === sentTokens) return null;
18537
+ sentTokens = key;
18538
+ return { type: `${SHOW_MSG}tokens`, tokens };
18539
+ });
18372
18540
  });
18373
18541
  }).observe(document.body, { attributes: true, attributeFilter: ['class', 'data-color-theme', 'style'] });
18374
18542
 
@@ -19397,15 +19565,14 @@ function renderFolderList() {
19397
19565
  const query = input.value.trim();
19398
19566
  const all = knownFolders();
19399
19567
  ns.matches = (query && query !== ns.folder ? rankFolders(all, query) : all).slice(0, NS_MAX_MATCHES);
19568
+ if (!ns.matches.length) return closeFolderList();
19400
19569
  if (ns.idx >= ns.matches.length) ns.idx = ns.matches.length - 1;
19401
- list.innerHTML = ns.matches.length
19402
- ? ns.matches
19403
- .map(
19404
- (p, i) =>
19405
- `<div class="ns-option${i === ns.idx ? ' active' : ''}" role="option" data-idx="${i}" aria-selected="${i === ns.idx}"><span class="ns-option-name">${escapeHtml(pathBasename(p))}</span><span class="ns-option-path">${escapeHtml(p)}</span></div>`,
19406
- )
19407
- .join('')
19408
- : '<div class="ns-empty"><span>No project matches</span><button type="button" class="btn btn-secondary ns-browse" data-browse>Browse…</button></div>';
19570
+ list.innerHTML = ns.matches
19571
+ .map(
19572
+ (p, i) =>
19573
+ `<div class="ns-option${i === ns.idx ? ' active' : ''}" role="option" data-idx="${i}" aria-selected="${i === ns.idx}"><span class="ns-option-name">${escapeHtml(pathBasename(p))}</span><span class="ns-option-path">${escapeHtml(p)}</span></div>`,
19574
+ )
19575
+ .join('');
19409
19576
  list.hidden = false;
19410
19577
  input.setAttribute('aria-expanded', 'true');
19411
19578
  }
@@ -19502,6 +19669,7 @@ function setNewSessionBusy(on) {
19502
19669
  renderNewSessionForm();
19503
19670
  }
19504
19671
 
19672
+ // biome-ignore lint/correctness/noUnusedVariables: used in HTML
19505
19673
  async function browseNewSessionFolder() {
19506
19674
  if (ns.busy) return;
19507
19675
  closeFolderList();
@@ -19700,7 +19868,6 @@ function initNewSession() {
19700
19868
  // mousedown, not click: the input's blur would close the list before a click lands.
19701
19869
  list.addEventListener('mousedown', (e) => {
19702
19870
  e.preventDefault();
19703
- if (e.target.closest('[data-browse]')) return browseNewSessionFolder();
19704
19871
  const row = e.target.closest('.ns-option');
19705
19872
  if (row) pickFolderOption(Number(row.dataset.idx));
19706
19873
  });
@@ -19978,18 +20145,25 @@ function pluginWarning(plugin) {
19978
20145
  mismatch: `Plugin ${plugin.installed} is installed, this board ships ${plugin.bundled}`,
19979
20146
  }[plugin.state];
19980
20147
  if (!problem) return null;
19981
- const fix =
19982
- plugin.state === 'disabled'
19983
- ? 'Enable it with /plugin in Claude Code.'
20148
+ let fix = 'Enable it with /plugin in Claude Code.';
20149
+ if (plugin.state !== 'disabled')
20150
+ fix = hub.can('hub.updates')
20151
+ ? 'Click to update the plugins.'
19984
20152
  : `Click to copy: ${plugin.installCommand}\nThen restart open sessions, they keep the old hooks.`;
19985
20153
  const btn = document.createElement('button');
19986
20154
  btn.type = 'button';
19987
20155
  btn.className = 'footer-plugin-warning';
19988
- btn.textContent = '⚠';
20156
+ btn.dataset.state = plugin.state;
20157
+ const [icon, word] = { missing: ['upgrade', 'install'], disabled: ['alert', 'off'], mismatch: ['upgrade', 'update'] }[
20158
+ plugin.state
20159
+ ];
20160
+ btn.innerHTML = showIcon(icon) + word;
19989
20161
  btn.title = `${problem} (${plugin.configDir}).\n${fix}`;
19990
20162
  btn.setAttribute('aria-label', problem);
19991
20163
  if (plugin.state !== 'disabled') {
19992
- btn.addEventListener('click', () => copyText(plugin.installCommand, 'install command'));
20164
+ btn.addEventListener('click', () =>
20165
+ hub.can('hub.updates') ? hub.invoke('hub.updates') : copyText(plugin.installCommand, 'install command'),
20166
+ );
19993
20167
  }
19994
20168
  return btn;
19995
20169
  }
@@ -20058,6 +20232,7 @@ getJson('/api/config')
20058
20232
  .then((c) => {
20059
20233
  if (c) appConfig = c;
20060
20234
  syncTerminalHost();
20235
+ renderHomeKeys();
20061
20236
  if (appConfig.kanbot && footerState.version) renderSidebarFooter(footerState.rl);
20062
20237
  })
20063
20238
  .then(restorePendingSessions)
@@ -20153,6 +20328,8 @@ hub.onActive((active) => {
20153
20328
  pushTerminalClaims();
20154
20329
  });
20155
20330
  hub.onStatus(pushTerminalClaims);
20331
+ // A hub before SDK 1.12 has no onKeys.
20332
+ hub.onKeys?.(pushTerminalClaims);
20156
20333
  hub.onSettings(applyHubSettings);
20157
20334
  hub.handle('session.open', (p) => p.session && openSessionFromOutside(p.session));
20158
20335
  hub.handle('session.find', (p) => findSessionFromHub(p));