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/public/app.js CHANGED
@@ -6,6 +6,7 @@ const THEME_KEY = 'theme';
6
6
  const COLOR_THEME_KEY = 'color-theme';
7
7
  // Shared too, so after a config-dir switch the cursor goes where it was on the board just left.
8
8
  const FOCUS_ZONE_KEY = 'focus-zone';
9
+ const SILENT_STATUS_HINT_KEY = 'silent-status-hint';
9
10
  const GLOBAL_KEYS = new Set([THEME_KEY, COLOR_THEME_KEY, FOCUS_ZONE_KEY]);
10
11
  // localStorage names are kept as they are: renaming one drops what users saved under it.
11
12
  const MESSAGE_PANEL_OPEN_KEY = 'message-panel-open';
@@ -150,6 +151,9 @@ let appConfig = { marketplaceUrl: null, costUrl: null, memoryUrl: null, scratchA
150
151
  let runningTerminals = new Set();
151
152
  // Embedded sessions stuck on Claude Code's folder-trust dialog. No hook runs before it, so the server reads it off the screen.
152
153
  let trustWaiting = new Set();
154
+ // What a program in an embedded terminal says it is doing (OSC 7501), by session id. It wins over the hook and transcript signals.
155
+ let reportedStatus = new Map();
156
+ let cardStatus = true;
153
157
  let selectedSessionIdx = -1;
154
158
  let selectedSessionKbId = null;
155
159
  let sessionJustSelected = false;
@@ -340,9 +344,12 @@ async function fetchSessions(includeTasks = true, focusId = currentSessionId) {
340
344
  // session members come back through `include`, as they may be past the page limit.
341
345
  const zenScope = !!(zenGroup || zenProject);
342
346
  const zenIds = zenGroup && sessionFilter !== 'active' ? sgSubtreeIds(zenGroup) : new Set();
343
- const zenMembers = sessionGroups
344
- .filter((g) => zenIds.has(g.id))
345
- .flatMap((g) => g.members.filter((m) => m.type === 'session').map((m) => m.ref));
347
+ // A project's zen also holds the sessions of other projects placed `under` it in its group,
348
+ // which its project filter would drop. The client's Active rule still applies to them.
349
+ const inZen = (g, m) => zenIds.has(g.id) || (zenProject && m.under === zenProject);
350
+ const zenMembers = sessionGroups.flatMap((g) =>
351
+ g.members.filter((m) => m.type === 'session' && inZen(g, m)).map((m) => m.ref),
352
+ );
346
353
  const include = [
347
354
  focusId,
348
355
  revealedPlanSessionId,
@@ -359,6 +366,7 @@ async function fetchSessions(includeTasks = true, focusId = currentSessionId) {
359
366
  include: include.length ? include.join(',') : null,
360
367
  recentHours: recent ? RECENT_PROJECT_HOURS : null,
361
368
  project,
369
+ nest: zenProject ? 1 : null,
362
370
  filter: sessionFilter === 'active' ? 'active' : null,
363
371
  },
364
372
  });
@@ -387,17 +395,27 @@ async function fetchSessions(includeTasks = true, focusId = currentSessionId) {
387
395
  }
388
396
  }
389
397
 
390
- // The Stop hook leaves _stop.json when a session ends its turn; deleting it marks the session read.
398
+ // The Stop hook leaves _stop.json when a session ends its turn; the read route deletes it and
399
+ // marks the terminal's reported done or error seen.
391
400
  function markSessionRead(sessionId) {
392
401
  const session = sessions.find((s) => s.id === sessionId);
393
- if (!session?.unread) return;
394
- session.unread = false;
395
- document.querySelector(`.session-item[data-session-id="${CSS.escape(sessionId)}"]`)?.classList.remove('unread');
402
+ const unread = session?.unread;
403
+ const report = reportedFinish(sessionId) && reportedStatus.get(sessionId);
404
+ if (!unread && !report) return;
405
+ if (unread) {
406
+ session.unread = false;
407
+ document.querySelector(`.session-item[data-session-id="${CSS.escape(sessionId)}"]`)?.classList.remove('unread');
408
+ }
409
+ if (report) {
410
+ report.seen = true;
411
+ renderSessionViews();
412
+ }
396
413
  api(apiPath`/api/sessions/${sessionId}/read`, { method: 'POST' }).catch((e) => console.error('[markSessionRead]', e));
397
414
  }
398
415
 
399
416
  function markOpenSessionRead() {
400
- if (currentSessionId && viewMode === 'session' && isOnScreen()) markSessionRead(currentSessionId);
417
+ if (!currentSessionId || viewMode !== 'session' || !isOnScreen()) return;
418
+ markSessionRead(currentSessionId);
401
419
  }
402
420
 
403
421
  async function loadSearchTasks() {
@@ -571,14 +589,46 @@ function toggleSection(containerId, chevronId) {
571
589
  }
572
590
 
573
591
  function isWaitingSession(s) {
574
- return !!s.hasWaitingForUser || trustWaiting.has(s.id);
592
+ if (trustWaiting.has(s.id)) return true;
593
+ const reported = reportedStatus.get(s.id);
594
+ return reported ? reported.state === 'blocked' : !!s.hasWaitingForUser;
595
+ }
596
+ const REPORT_KIND_LABELS = { permission: 'Permission', question: 'Question', auth: 'Sign-in' };
597
+ const reportKindLabel = (r) => REPORT_KIND_LABELS[r.kind] || 'Needs you';
598
+ const isFinishState = (state) => state === 'done' || state === 'error';
599
+
600
+ function reportedBlocked(id) {
601
+ return reportedStatus.get(id)?.state === 'blocked' && !trustWaiting.has(id);
602
+ }
603
+ // A reported done or error stays on the card until the user opens the session (done until seen).
604
+ function reportedFinish(id) {
605
+ const r = reportedStatus.get(id);
606
+ return isFinishState(r?.state) && !r.seen ? r.state : null;
575
607
  }
576
608
  function sessionBarClass(s) {
577
609
  if (isWaitingSession(s)) return 'permission-pending';
578
- return s.unread ? 'unread' : '';
610
+ const finish = reportedFinish(s.id);
611
+ if (finish === 'error') return 'reported-error';
612
+ return s.unread || finish === 'done' ? 'unread' : '';
613
+ }
614
+ function reportedStatusHtml(s, timeText) {
615
+ const r = reportedStatus.get(s.id);
616
+ if (!r || !cardStatus || trustWaiting.has(s.id)) return '';
617
+ const finish = reportedFinish(s.id);
618
+ const chip = r.state === 'blocked' ? reportKindLabel(r) : finish === 'error' ? 'Error' : null;
619
+ const showMsg = r.msg && (r.state === 'blocked' || r.state === 'working' || finish);
620
+ if (!chip && !showMsg) return '';
621
+ const app = r.app && r.app !== 'claude-code' ? `<span class="report-app">${escapeHtml(r.app)}</span>` : '';
622
+ const msg = showMsg
623
+ ? `<span class="report-msg" title="${escapeHtml(r.msg)}">${escapeHtml(r.msg)}</span>`
624
+ : `<span class="report-msg">${timeText}</span>`;
625
+ return `<span class="session-report report-${escapeHtml(r.state)}">${chip ? `<span class="report-chip">${chip}</span>` : ''}${app}${msg}</span>`;
579
626
  }
580
627
  function isActiveSession(s) {
581
- return !isWaitingSession(s) && (s.inProgress > 0 || s.hasRecentLog || s.hasRunningAgents);
628
+ if (isWaitingSession(s)) return false;
629
+ const reported = reportedStatus.get(s.id);
630
+ if (reported) return reported.state === 'working';
631
+ return s.inProgress > 0 || s.hasRecentLog || s.hasRunningAgents;
582
632
  }
583
633
  function sessionState(s) {
584
634
  return isWaitingSession(s) ? 'waiting' : isActiveSession(s) ? 'working' : 'idle';
@@ -586,6 +636,8 @@ function sessionState(s) {
586
636
  // hasRecentLog carries the server's registry-idle correction: an open-but-idle
587
637
  // terminal keeps touching its JSONL, so mtime alone is not proof of activity.
588
638
  function isSessionLive(s) {
639
+ const reported = reportedStatus.get(s.id);
640
+ if (reported && reported.state !== 'working') return false;
589
641
  return !!s.hasRecentLog && Date.now() - Date.parse(s.modifiedAt) <= LIVE_INDICATOR_MS;
590
642
  }
591
643
  function isJustFinished(s) {
@@ -2865,14 +2917,14 @@ function showToast(msg, type, action, hint) {
2865
2917
  el.replaceChildren(text);
2866
2918
  } else el.textContent = msg;
2867
2919
  const hide = () => el.classList.remove('visible', 'has-action');
2868
- if (action) {
2920
+ for (const a of action ? [].concat(action) : []) {
2869
2921
  const btn = document.createElement('button');
2870
2922
  btn.type = 'button';
2871
2923
  btn.className = 'toast-action';
2872
- btn.textContent = action.label;
2924
+ btn.textContent = a.label;
2873
2925
  btn.addEventListener('click', () => {
2874
2926
  hide();
2875
- action.onClick();
2927
+ a.onClick();
2876
2928
  });
2877
2929
  el.append(btn);
2878
2930
  el.classList.add('has-action');
@@ -4192,9 +4244,17 @@ const HOME_ROWS = [
4192
4244
  { keys: ['?'], label: 'All shortcuts', run: showHelpModal },
4193
4245
  ];
4194
4246
 
4247
+ const ZEN_EMPTY_ROWS = [
4248
+ HOME_ROWS.find((r) => r.run === openSessionPicker),
4249
+ { keys: ['Ctrl', 'Shift', 'Z'], combo: true, label: 'Leave zen mode', run: toggleZenMode },
4250
+ ];
4251
+
4195
4252
  function renderHomeKeys() {
4196
- const list = document.getElementById('home-keys');
4197
- const rows = HOME_ROWS.filter((r) => (!r.when || r.when()) && helpKeys(r).length);
4253
+ renderKeyRows(document.getElementById('home-keys'), HOME_ROWS);
4254
+ }
4255
+
4256
+ function renderKeyRows(list, allRows) {
4257
+ const rows = allRows.filter((r) => (!r.when || r.when()) && helpKeys(r).length);
4198
4258
  list.innerHTML = rows
4199
4259
  .map(
4200
4260
  (row) =>
@@ -4371,11 +4431,13 @@ function renderSessions() {
4371
4431
  // and still offers everything, or there would be no way to switch sessions without leaving zen.
4372
4432
  const zenSession = zenMode && currentSessionId ? sessions.find((s) => s.id === currentSessionId) : null;
4373
4433
  const zenScope = !!(zenGroup || zenProject);
4374
- sessionsList.classList.toggle('zen', !!zenSession || zenScope);
4434
+ sessionsList.classList.toggle('zen', zenMode || zenScope);
4375
4435
  sessionsList.dataset.zenState = zenSession ? sessionState(zenSession) : '';
4376
4436
  let filteredSessions;
4377
4437
  if (zenScope) {
4378
4438
  const scoped = getFilteredSessions({ zen: true });
4439
+ // inZenScope places a nested child with its parent, so the anchors come from the unscoped list.
4440
+ if (zenProject) childAnchors = computeChildAnchors(scoped);
4379
4441
  filteredSessions = applyStableSessionOrder(zenProject ? scoped.filter(inZenScope) : scoped);
4380
4442
  } else if (zenMode) filteredSessions = zenSession ? [zenSession] : [];
4381
4443
  else filteredSessions = applyStableSessionOrder(getFilteredSessions());
@@ -4385,7 +4447,9 @@ function renderSessions() {
4385
4447
  const childDepth = new Map();
4386
4448
  const parentOf = new Map();
4387
4449
  for (const g of sessionGroups) for (const m of g.members) if (m.parent) parentOf.set(m.ref, m.parent);
4388
- childAnchors = computeChildAnchors(filteredSessions);
4450
+ // Project zen keeps the anchors of the unscoped list: leaveZenScopeFor must see that a hidden
4451
+ // child sits with a parent outside the scope.
4452
+ if (!zenProject) childAnchors = computeChildAnchors(filteredSessions);
4389
4453
  for (const s of filteredSessions) {
4390
4454
  if (childAnchors.has(s.id) && !parentOf.has(s.id)) parentOf.set(s.id, s.nest.parent);
4391
4455
  }
@@ -4454,6 +4518,8 @@ function renderSessions() {
4454
4518
  ? `<div class="session-progress" title="${escapeHtml(`${session.pending} pending, ${session.inProgress} in progress, ${session.completed} completed`)}"><div class="progress-bar"><div class="progress-fill done" style="width: ${pct(session.completed)}%"></div>${session.inProgress > 0 ? `<div class="progress-fill wip" style="width: ${pct(session.inProgress)}%"></div>` : ''}</div><span class="progress-text">${session.completed + session.inProgress}/${total}</span></div>`
4455
4519
  : '';
4456
4520
  const metricsHtml = progressHtml + (showCtx ? renderContextBar(session) : '');
4521
+ const timeText = formatDate(session.modifiedAt);
4522
+ const reportHtml = reportedStatusHtml(session, timeText);
4457
4523
  return `
4458
4524
  <button onclick="openSession('${sid}')" draggable="true" data-hub-part="session-card" data-session-id="${escapeHtml(session.id)}" class="session-item ${isActive ? 'active' : ''} ${sessionBarClass(session)} ${tempClass} ${idleClass} ${justFinishedClass}${childDepthClass(childDepth.get(session.id))}">
4459
4525
  <span class="session-pin-btn${pinClass}" onclick="event.stopPropagation();toggleSessionPin('${sid}')" title="${pinTitle} session">${pinState === 'sticky' ? SESSION_STAR_SVG : SESSION_PIN_SVG}</span>
@@ -4461,7 +4527,7 @@ function renderSessions() {
4461
4527
  ${renderSessionIdentity(projectHtml, session.gitBranch)}
4462
4528
  ${metricsHtml ? `<div class="session-metrics">${metricsHtml}</div>` : ''}
4463
4529
  <div class="session-footer">
4464
- <div class="session-time">${formatDate(session.modifiedAt)}</div>
4530
+ <div class="session-time${reportHtml ? ' has-report' : ''}"${reportHtml ? ` title="${escapeHtml(timeText)}"` : ''}>${reportHtml || timeText}</div>
4465
4531
  <span class="session-indicators">
4466
4532
  ${isTeam ? `<span class="team-badge" title="${memberCount} team members"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M23 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg>${memberCount}</span>` : ''}
4467
4533
  ${isTeam || session.project || showCtx ? `<span class="team-info-btn" onclick="event.stopPropagation(); showSessionInfoModal('${sid}')" title="View session info"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg></span>` : ''}
@@ -4509,14 +4575,48 @@ function renderSessions() {
4509
4575
  )
4510
4576
  : '';
4511
4577
 
4578
+ // Zen draws one card and its panel, so it returns before the grouping below — leaving it in
4579
+ // that chain would build the whole list only to discard it.
4580
+ if (zenMode) {
4581
+ if (!zenSession) {
4582
+ const picks = applyStableSessionOrder(getFilteredSessions()).slice(0, 5);
4583
+ sessionsList.innerHTML = `
4584
+ <div class="zen-empty">
4585
+ <div class="zen-empty-head">
4586
+ <p class="zen-empty-title">No session open</p>
4587
+ <p class="zen-empty-hint">Zen mode shows one session.${picks.length ? ' Pick one to continue.' : ''}</p>
4588
+ </div>
4589
+ ${picks.length ? `<div class="zen-empty-list">${picks.map((s) => renderSessionCard(s)).join('')}</div>` : ''}
4590
+ <div class="home-keys"></div>
4591
+ </div>`;
4592
+ renderKeyRows(sessionsList.querySelector('.home-keys'), ZEN_EMPTY_ROWS);
4593
+ restoreSessionCursor();
4594
+ return;
4595
+ }
4596
+ sessionsList.innerHTML = `${renderSessionCard(zenSession)}
4597
+ <div class="zen-panel">
4598
+ ${renderContextDetail(zenSession, { tokens: false }) || '<div class="zen-panel-empty">No context data for this session</div>'}
4599
+ ${renderScratchpadRow(zenSession)}
4600
+ ${renderLinkedDocsHtml(zenSession.id)}
4601
+ ${renderArtifactsHtml(zenSession.id)}
4602
+ ${renderZenBookmarksHtml(zenSession.id)}
4603
+ </div>
4604
+ ${zenSession.hasWorkflow ? renderWorkflowLiveHtml(zenSession.id) : ''}
4605
+ <div class="zen-agents"></div>`;
4606
+ renderZenAgents(visibleAgents());
4607
+ bindLinkedDocsHandlers(sessionsList.querySelector('.linked-docs-section'), zenSession.id);
4608
+ artifactsSection.load(zenSession.id);
4609
+ scratchFilesSection.load(zenSession.id);
4610
+ if (zenSession.hasWorkflow) pollWorkflowLive(zenSession.id);
4611
+ restoreSessionCursor();
4612
+ return;
4613
+ }
4614
+
4512
4615
  if (filteredSessions.length === 0 && !zenScope) {
4513
4616
  let emptyMsg = 'No sessions found';
4514
4617
  let emptyHint = 'Tasks appear when you use Claude Code';
4515
4618
 
4516
- if (zenMode) {
4517
- emptyMsg = 'Zen mode: no session open';
4518
- emptyHint = 'Press Ctrl+Shift+Z to leave zen mode, then open a session';
4519
- } else if (searchQuery) {
4619
+ if (searchQuery) {
4520
4620
  emptyMsg = `No results for "${escapeHtml(searchQuery)}"`;
4521
4621
  emptyHint = outside.rows.length
4522
4622
  ? 'Matches outside the current filters are below'
@@ -4542,28 +4642,6 @@ function renderSessions() {
4542
4642
  return;
4543
4643
  }
4544
4644
 
4545
- // Zen draws one card and its panel, so it returns before the grouping below — leaving it in
4546
- // that chain would build the whole list only to discard it.
4547
- if (zenMode) {
4548
- sessionsList.innerHTML = `${renderSessionCard(zenSession)}
4549
- <div class="zen-panel">
4550
- ${renderContextDetail(zenSession, { tokens: false }) || '<div class="zen-panel-empty">No context data for this session</div>'}
4551
- ${renderScratchpadRow(zenSession)}
4552
- ${renderLinkedDocsHtml(zenSession.id)}
4553
- ${renderArtifactsHtml(zenSession.id)}
4554
- ${renderZenBookmarksHtml(zenSession.id)}
4555
- </div>
4556
- ${zenSession.hasWorkflow ? renderWorkflowLiveHtml(zenSession.id) : ''}
4557
- <div class="zen-agents"></div>`;
4558
- renderZenAgents(visibleAgents());
4559
- bindLinkedDocsHandlers(sessionsList.querySelector('.linked-docs-section'), zenSession.id);
4560
- artifactsSection.load(zenSession.id);
4561
- scratchFilesSection.load(zenSession.id);
4562
- if (zenSession.hasWorkflow) pollWorkflowLive(zenSession.id);
4563
- restoreSessionCursor();
4564
- return;
4565
- }
4566
-
4567
4645
  const nestedCards = (list) =>
4568
4646
  nestChildren(list)
4569
4647
  .map((s) => renderSessionCard(s))
@@ -4867,11 +4945,6 @@ function renderSession() {
4867
4945
  const session = sessions.find((s) => s.id === currentSessionId);
4868
4946
  if (!session) return;
4869
4947
 
4870
- // Opening the session, not opening a linked-docs surface: the card badge is the
4871
- // first place a pad shows up, and it would otherwise stay at zero until the user
4872
- // happened to open the info modal or zen panel.
4873
- loadSessionPads(currentSessionId);
4874
-
4875
4948
  const displayName = session.name || session.description || currentSessionId;
4876
4949
 
4877
4950
  sessionTitle.textContent = displayName;
@@ -8381,13 +8454,16 @@ function dismissSessionFromList(sid) {
8381
8454
  return;
8382
8455
  }
8383
8456
  // Ctrl+Alt+S would reveal the dismissed session, and revealing restores it.
8384
- const fallback = currentSessionId === sid && swapHistory[0] === sid ? swapHistory[1] : null;
8385
8457
  forgetSwapHistory(sid);
8458
+ const fallback =
8459
+ currentSessionId === sid
8460
+ ? swapHistory.find((id) => !dismissedSessionIds.has(id) && sessions.some((s) => s.id === id))
8461
+ : null;
8386
8462
  const targetIdx = newItems.length > 0 ? Math.max(0, prevIdx - 1) : -1;
8387
8463
  // If the dismissed session is currently open, navigate to the previous one
8388
8464
  if (currentSessionId === sid || selectedSessionId === sid) {
8389
8465
  selectedSessionId = null;
8390
- if (fallback && !dismissedSessionIds.has(fallback) && sessions.some((s) => s.id === fallback)) {
8466
+ if (fallback) {
8391
8467
  revealSession(fallback).then(() => {
8392
8468
  const items = getNavigableItems();
8393
8469
  const idx = items.findIndex((el) => el.dataset?.sessionId === fallback);
@@ -10204,7 +10280,13 @@ function openPreviewInEditor() {
10204
10280
  // answer to "not previewable" rather than a failure: callers that have a fallback
10205
10281
  // destination pass `onUnsupported` instead of keeping a copy of the extension list here.
10206
10282
  // A link followed inside an open preview keeps the preview's session.
10207
- async function openPreviewByPath(filePath, base, onUnsupported, sessionId = previewSessionId || currentSessionId) {
10283
+ async function openPreviewByPath(
10284
+ filePath,
10285
+ base,
10286
+ onUnsupported,
10287
+ sessionId = previewSessionId || currentSessionId,
10288
+ folderDirect = false,
10289
+ ) {
10208
10290
  if (!filePath) return;
10209
10291
  try {
10210
10292
  const r = await api('/api/preview', { query: { path: filePath, base: base || null } });
@@ -10217,6 +10299,10 @@ async function openPreviewByPath(filePath, base, onUnsupported, sessionId = prev
10217
10299
  showToast('File not found', 'error');
10218
10300
  return;
10219
10301
  }
10302
+ if (data.dir) {
10303
+ openFolder(data.path, folderDirect);
10304
+ return;
10305
+ }
10220
10306
  if (data.kind === null) {
10221
10307
  if (onUnsupported) onUnsupported(data.path);
10222
10308
  else showToast('Nothing to preview in this file');
@@ -10228,6 +10314,66 @@ async function openPreviewByPath(filePath, base, onUnsupported, sessionId = prev
10228
10314
  }
10229
10315
  }
10230
10316
 
10317
+ const FILE_MANAGER = /^Win/i.test(navigator.userAgentData?.platform || navigator.platform || '')
10318
+ ? 'Explorer'
10319
+ : IS_MAC
10320
+ ? 'Finder'
10321
+ : 'file manager';
10322
+
10323
+ function revealPath(target) {
10324
+ postAndToast('/api/reveal', { path: target }, `in ${FILE_MANAGER}`);
10325
+ }
10326
+
10327
+ // The global add-on with this key (the id in its addon.json) takes folders: the board shows it
10328
+ // in the dock and sends it the folder (`cck-addon:path`).
10329
+ const FOLDER_ADDON_KEY = 'file-explorer';
10330
+ const folderWaiting = new Map();
10331
+
10332
+ function folderAddon() {
10333
+ const a = showState.terminalId && dockAddonList?.global.find((x) => x.key === FOLDER_ADDON_KEY);
10334
+ return (a && dockItems().find((p) => p.id === a.id)) || null;
10335
+ }
10336
+
10337
+ // Sends the waiting folder to the add-on's page and gives the frame focus: this add-on hands the
10338
+ // board's keys back, so its frame can take it.
10339
+ function flushFolder(id, frame) {
10340
+ const dir = folderWaiting.get(id);
10341
+ if (!folderWaiting.delete(id)) return;
10342
+ const origin = URL.parse(frame.src)?.origin;
10343
+ if (origin) frame.contentWindow?.postMessage({ type: 'cck-addon:path', path: dir }, origin);
10344
+ frame.focus({ preventScroll: true });
10345
+ frame.contentWindow?.focus();
10346
+ }
10347
+
10348
+ // Runs on each load of a dock frame: a folder asked for before the page was there goes to it now.
10349
+ function onDockFrameLoad(id, frame) {
10350
+ frame.pageLoaded = true;
10351
+ flushFolder(id, frame);
10352
+ }
10353
+
10354
+ function openFolderInAddon(dir, addon) {
10355
+ if (dockActivePane()?.id !== addon.id) {
10356
+ setDockAddon(addon.id);
10357
+ renderShow();
10358
+ }
10359
+ const frame = dockFrames.get(addon.id);
10360
+ folderWaiting.set(addon.id, dir);
10361
+ if (frame?.pageLoaded) flushFolder(addon.id, frame);
10362
+ }
10363
+
10364
+ // A folder has no preview. The toast offers the file explorer add-on when the dock has it, else
10365
+ // the OS file manager; `direct` (Ctrl+click in the terminal) goes to the add-on at once.
10366
+ function openFolder(dir, direct) {
10367
+ const explorer = folderAddon();
10368
+ if (explorer && direct) return openFolderInAddon(dir, explorer);
10369
+ showToast(`Folder: ${pathBasename(dir)}`, 'info', [
10370
+ explorer
10371
+ ? { label: `Open in ${explorer.title}`, onClick: () => openFolderInAddon(dir, explorer) }
10372
+ : { label: `Open in ${FILE_MANAGER}`, onClick: () => revealPath(dir) },
10373
+ { label: 'Copy path', onClick: () => copyText(dir, 'path') },
10374
+ ]);
10375
+ }
10376
+
10231
10377
  function handleSessionOpenEvent(data) {
10232
10378
  const { id } = data;
10233
10379
  if (!id) return;
@@ -10326,37 +10472,8 @@ async function loadPreviewKinds(sessionId, paths) {
10326
10472
  afterLinkedDocsChanged(sessionId);
10327
10473
  }
10328
10474
 
10329
- // A pad the session made with `scratch new` becomes an ordinary linked document.
10330
- // The server derives the pads on every read, so this record of the ones already
10331
- // linked is what stops the next read undoing an unlink.
10475
+ // Nothing writes these keys now; the orphan sweep still clears the ones older boards left.
10332
10476
  const PAD_LINKED_PREFIX = 'autolinked-pads-';
10333
- const padsFetched = new Set();
10334
-
10335
- function getOfferedPadPaths(sessionId) {
10336
- return readStoredList(PAD_LINKED_PREFIX + sessionId);
10337
- }
10338
-
10339
- function setOfferedPadPaths(sessionId, paths) {
10340
- store.writeJson(PAD_LINKED_PREFIX + sessionId, paths);
10341
- }
10342
-
10343
- async function loadSessionPads(sessionId) {
10344
- if (!sessionId || padsFetched.has(sessionId)) return;
10345
- padsFetched.add(sessionId);
10346
- const data = await getJson(apiPath`/api/sessions/${sessionId}/pads`);
10347
- if (!data) {
10348
- padsFetched.delete(sessionId);
10349
- return;
10350
- }
10351
- const pads = data.pads || [];
10352
- const offered = new Set(getOfferedPadPaths(sessionId).map(canonicalPath));
10353
- const fresh = pads.map((p) => p.path).filter((p) => !offered.has(canonicalPath(p)));
10354
- if (!fresh.length) return;
10355
- // Recorded before the link, so a render triggered by the link already sees a pad
10356
- // that will not be offered again.
10357
- setOfferedPadPaths(sessionId, [...offered, ...fresh]);
10358
- for (const p of fresh) setSessionDocLink(sessionId, p, false);
10359
- }
10360
10477
 
10361
10478
  // A scratchpad manifest opens in the external `scratch` viewer, not the editor —
10362
10479
  // the raw JSON is a manifest, not the document the user linked.
@@ -10366,12 +10483,17 @@ function isScratchpadPath(p) {
10366
10483
 
10367
10484
  // `linkedDocOpener` is the only place a linked path is classified; the row's tag,
10368
10485
  // tooltip and action are all read from here, so a new destination is one entry.
10486
+ const SCRATCHPAD_OPEN = 'scratchpad.open';
10369
10487
  const LINKED_DOC_OPENERS = {
10370
10488
  preview: { tag: '', hint: '', cls: '', noun: 'path' },
10371
10489
  url: { tag: '', hint: ' — opens in a new tab', cls: ' is-url', noun: 'URL' },
10372
10490
  scratch: {
10373
10491
  tag: '(scratchpad)',
10374
- hint: ' — opens in the scratch viewer; Ctrl+click opens it in a pane',
10492
+ get hint() {
10493
+ return hub.can(SCRATCHPAD_OPEN)
10494
+ ? ' — opens in a pane; Shift+click opens the Scratchpads tab; Ctrl+click opens the scratch viewer'
10495
+ : ' — opens in the scratch viewer';
10496
+ },
10375
10497
  cls: ' is-editor',
10376
10498
  noun: 'path',
10377
10499
  url: '/api/scratchpad/open',
@@ -10834,9 +10956,14 @@ function bindLinkedDocsHandlers(container, sessionId) {
10834
10956
  removeSessionPreviewPath(sessionId, hit.dataset.path);
10835
10957
  forgetServerLinkedDoc(sessionId, hit.dataset.path);
10836
10958
  afterLinkedDocsChanged(sessionId);
10837
- } else if ((e.ctrlKey || e.metaKey) && linkedDocOpener(hit.dataset.path) === 'scratch') {
10959
+ } else if (
10960
+ !(e.ctrlKey || e.metaKey) &&
10961
+ linkedDocOpener(hit.dataset.path) === 'scratch' &&
10962
+ hub.can(SCRATCHPAD_OPEN)
10963
+ ) {
10838
10964
  if (container.closest('#team-modal')) closeTeamModal();
10839
- openScratchpadPane(sessionId, hit.dataset.path);
10965
+ if (e.shiftKey) openScratchpadTab(sessionId, hit.dataset.path);
10966
+ else openScratchpadPane(sessionId, hit.dataset.path);
10840
10967
  } else {
10841
10968
  openLinkedDoc(hit.dataset.path, getSessionBaseDir(sessionId));
10842
10969
  }
@@ -10957,8 +11084,6 @@ function setupEventSource() {
10957
11084
  fetchSessions().catch(() => {});
10958
11085
  if (currentSessionId) fetchTasks(currentSessionId);
10959
11086
  refetchPaneLayout();
10960
- // A restarted board started none of the viewers the frames still point at.
10961
- onScratchpadExited(null);
10962
11087
  if (sgRev === null) syncSessionGroups();
10963
11088
  else if (sgUnsent) persistSessionGroups();
10964
11089
  else sgRefresh();
@@ -11026,8 +11151,10 @@ function setupEventSource() {
11026
11151
  if (!skipOffScreen()) refreshOpenPlan();
11027
11152
  }
11028
11153
 
11029
- if (data.type === 'terminals-update' && Array.isArray(data.ids))
11030
- setRunningTerminals(data.ids, data.awaitingTrust);
11154
+ if (data.type === 'terminals-update' && Array.isArray(data.ids)) {
11155
+ setRunningTerminals(data.ids, data.awaitingTrust, data.programStatus);
11156
+ hintSilentStatus(data.statusSilent);
11157
+ }
11031
11158
 
11032
11159
  if (data.type === 'terminal:ended' && typeof data.id === 'string') onTerminalEnded(data.id);
11033
11160
 
@@ -11098,10 +11225,6 @@ function setupEventSource() {
11098
11225
  applyPaneLayout(data.sessionId, data.layout);
11099
11226
  }
11100
11227
 
11101
- if (data.type === 'scratchpad:exited') {
11102
- onScratchpadExited(data.manifest);
11103
- }
11104
-
11105
11228
  if (data.type === 'addon:changed' && dockSid) {
11106
11229
  fetchDockAddons(dockSid);
11107
11230
  }
@@ -12477,9 +12600,12 @@ function setZenScope(group, project) {
12477
12600
  else store.removeItem(ZEN_SCOPE_KEY);
12478
12601
  }
12479
12602
 
12603
+ // A project's zen holds what its block holds in the full list.
12480
12604
  function inZenScope(session) {
12481
- if (zenGroup) return sgSubtreeIds(zenGroup).has(sgGroupForSession(session)?.id);
12482
- return sessionProjectKey(session) === zenProject;
12605
+ const group = sgGroupForSession(session);
12606
+ if (zenGroup) return sgSubtreeIds(zenGroup).has(group?.id);
12607
+ if (!group) return sessionProjectKey(placementOf(session)) === zenProject;
12608
+ return sgHostOf(group, session) === zenProject;
12483
12609
  }
12484
12610
 
12485
12611
  // Opening a session the scope hides would leave it off screen, so the scope gives way.
@@ -12499,6 +12625,11 @@ function applyHubSettings(s) {
12499
12625
  else delete sessionsList.dataset.zenPattern;
12500
12626
  terminalHost = s.terminalHost || null;
12501
12627
  syncTerminalHost();
12628
+ const showCardStatus = s.cardStatus !== false;
12629
+ if (showCardStatus !== cardStatus) {
12630
+ cardStatus = showCardStatus;
12631
+ renderSessionViews();
12632
+ }
12502
12633
  }
12503
12634
 
12504
12635
  // The settings can land before /api/config says whether this board has a terminal.
@@ -12901,7 +13032,6 @@ function initSidebarResize() {
12901
13032
  onStart() {
12902
13033
  if (sidebar.classList.contains('collapsed')) return false;
12903
13034
  startWidth = sidebar.offsetWidth;
12904
- sidebar.classList.add('resizing');
12905
13035
  },
12906
13036
  onMove(dx) {
12907
13037
  const w = Math.min(600, Math.max(200, startWidth + dx));
@@ -12909,7 +13039,6 @@ function initSidebarResize() {
12909
13039
  sidebar.style.width = `${w}px`;
12910
13040
  },
12911
13041
  onEnd() {
12912
- sidebar.classList.remove('resizing');
12913
13042
  store.setItem(SIDEBAR_WIDTH_KEY, sidebar.style.getPropertyValue('--sidebar-width'));
12914
13043
  },
12915
13044
  });
@@ -12960,10 +13089,6 @@ async function showSessionInfoModal(sessionId) {
12960
13089
  const cachedTasks = currentSessionId === sessionId ? currentTasks : [];
12961
13090
  showInfoModal(session, null, cachedTasks, null, null);
12962
13091
  artifactsSection.load(sessionId);
12963
- // The modal reaches any card's session, not just the open one, so this is the second
12964
- // place a pad can first be seen. Linking belongs on the two open events rather than
12965
- // in renderLinkedDocsHtml, which only builds a string and runs on every repaint.
12966
- loadSessionPads(sessionId);
12967
13092
 
12968
13093
  const rerender = (teamConfig, tasks, planContent, parentInfo) => {
12969
13094
  if (_planSessionId !== sessionId) return; // user opened a different modal
@@ -13484,6 +13609,15 @@ function spDotHtml(session) {
13484
13609
  return `${SP_STATES[spState(session)]}${runningTerminals.has(session.id) ? SP_TERMINAL : SP_DOT}</span>`;
13485
13610
  }
13486
13611
 
13612
+ function spReportHtml(session) {
13613
+ if (reportedBlocked(session.id)) {
13614
+ const r = reportedStatus.get(session.id);
13615
+ const label = reportKindLabel(r);
13616
+ return `<span class="report-chip sp-report" title="${escapeHtml(r.msg || label)}">${label}</span>`;
13617
+ }
13618
+ return reportedFinish(session.id) === 'error' ? '<span class="report-chip sp-report report-error">Error</span>' : '';
13619
+ }
13620
+
13487
13621
  function spPinHtml(session) {
13488
13622
  const state = getSessionPinState(session.id);
13489
13623
  if (state === 'sticky') return `<span class="sp-pin sticky" title="Sticky">${SESSION_STAR_SVG}</span>`;
@@ -13565,6 +13699,7 @@ function renderSessionPicker() {
13565
13699
  return `${below && i === local.length ? section : ''}<button class="sp-row${s.id === currentSessionId ? ' current' : ''}${below ? ' outside' : ''} ${sessionBarClass(s)}" data-idx="${i}" title="${escapeHtml(s.project ? `${s.id}\n${s.project}` : s.id)}">
13566
13700
  ${spDotHtml(s)}
13567
13701
  <span class="sp-name">${escapeHtml(sessionDisplayName(s))}</span>
13702
+ ${spReportHtml(s)}
13568
13703
  <span class="sp-project">${escapeHtml(project)}</span>
13569
13704
  ${s.gitBranch ? `<span class="sp-branch">${escapeHtml(s.gitBranch)}</span>` : ''}
13570
13705
  <span class="sp-count">${s.completed}/${s.taskCount}</span>
@@ -14898,6 +15033,7 @@ function paneUrlFrame(pane, className) {
14898
15033
  frame.addEventListener('load', () => {
14899
15034
  postToShowFrames(() => ({ type: `${SHOW_MSG}tokens`, tokens: showTokens() }), [frame]);
14900
15035
  frame.hostKeysSig = null;
15036
+ frame.hostPlainKeys = null;
14901
15037
  pushTerminalClaims();
14902
15038
  });
14903
15039
  return frame;
@@ -14932,7 +15068,7 @@ async function loadPaneView(sid, pane, view, scroll) {
14932
15068
  return;
14933
15069
  }
14934
15070
  if (pane.kind === 'scratchpad') {
14935
- await loadScratchpadPaneView(pane, view);
15071
+ await loadScratchpadPaneView(sid, pane, view);
14936
15072
  return;
14937
15073
  }
14938
15074
  if (pane.kind === 'shell') {
@@ -14973,38 +15109,28 @@ async function loadPaneView(sid, pane, view, scroll) {
14973
15109
  view.insertAdjacentHTML('beforeend', paneCardHtml(title, text, button));
14974
15110
  }
14975
15111
 
14976
- // The viewer runs on its own loopback port, a different origin from the board and the hub, so the
14977
- // URL pane sandbox holds. The board asks for the URL each time it mounts the view, because the
14978
- // viewer dies with cck and is started again on demand.
14979
- async function loadScratchpadPaneView(pane, view) {
14980
- view.insertAdjacentHTML(
14981
- 'beforeend',
14982
- '<div class="pane-card pane-starting"><div class="pane-card-box"><p>Starting the scratch viewer…</p></div></div>',
14983
- );
14984
- const res = await paneRequest('POST', '/api/scratchpad/serve', { path: pane.target });
14985
- view.querySelector('.pane-starting')?.remove();
14986
- if (!res.url) {
15112
+ // The pad's viewer belongs to the hub's Scratchpads app; the board asks it for the URL each time it
15113
+ // mounts the view, because the app stops a viewer that no page has open.
15114
+ function scratchpadOpenArgs(sid, path) {
15115
+ return { path, project: sessions.find((s) => s.id === sid)?.project || '', session: sid };
15116
+ }
15117
+
15118
+ async function loadScratchpadPaneView(sid, pane, view) {
15119
+ const { url } = hub.can(SCRATCHPAD_OPEN)
15120
+ ? await hub.invoke(SCRATCHPAD_OPEN, scratchpadOpenArgs(sid, pane.target), { open: 'pane' })
15121
+ : {};
15122
+ if (!url) {
14987
15123
  view.insertAdjacentHTML(
14988
15124
  'beforeend',
14989
- paneCardHtml('Scratch viewer unavailable', res.error || pane.target, 'Open in scratch viewer'),
15125
+ paneCardHtml(
15126
+ 'Scratchpads app unavailable',
15127
+ 'Install the Scratchpads hub app to view pads in a pane.',
15128
+ 'Open in scratch viewer',
15129
+ ),
14990
15130
  );
14991
15131
  return;
14992
15132
  }
14993
- mountPaneUrlFrame({ ...pane, target: res.url }, view);
14994
- }
14995
-
14996
- // A viewer that exited leaves its frames on a dead port; the views on screen mount again now,
14997
- // the others when shown.
14998
- function onScratchpadExited(manifest) {
14999
- const dead = [];
15000
- for (const key of paneFrames.keys()) {
15001
- const [sid, paneId] = key.split('/');
15002
- const pane = paneLayout(sid).panes.find((p) => p.id === paneId);
15003
- if (pane?.kind === 'scratchpad' && (!manifest || canonicalPath(pane.target) === manifest)) dead.push([sid, paneId]);
15004
- }
15005
- if (!dead.length) return;
15006
- for (const [sid, paneId] of dead) unmountPane(sid, paneId);
15007
- syncPanes();
15133
+ mountPaneUrlFrame({ ...pane, target: url }, view);
15008
15134
  }
15009
15135
 
15010
15136
  // The target is the message's pin id, `type|timestamp|text`. The log holds only the latest pages,
@@ -15613,6 +15739,9 @@ function openPaneMenu(x, y, id) {
15613
15739
  ? 'Open in scratch viewer'
15614
15740
  : 'Open in preview',
15615
15741
  )) +
15742
+ (pane.kind === 'scratchpad' && hub.can(SCRATCHPAD_OPEN)
15743
+ ? paneMenuItem('openTab', 'Open in Scratchpads tab')
15744
+ : '') +
15616
15745
  (message || shell
15617
15746
  ? ''
15618
15747
  : paneMenuItem('link', paneIsLinked(pane) ? 'Remove from linked documents' : 'Add to linked documents')) +
@@ -15672,6 +15801,10 @@ function showPaneMenu(x, y, id, ariaLabel, html) {
15672
15801
  const PANE_MENU_ACTIONS = {
15673
15802
  copy: copyPaneTarget,
15674
15803
  open: openPaneExternally,
15804
+ openTab: (id) => {
15805
+ const pane = paneById(id);
15806
+ if (pane) openScratchpadTab(paneSessionId(), pane.target);
15807
+ },
15675
15808
  link: togglePaneLink,
15676
15809
  rename: beginPaneRename,
15677
15810
  reload: reloadPane,
@@ -15697,17 +15830,24 @@ function paneTargetFrom(raw) {
15697
15830
  }
15698
15831
 
15699
15832
  // The same target again answers the existing pane, so this also switches to it.
15700
- async function addPane(raw) {
15701
- const sid = paneSessionId();
15833
+ // `show` also leaves the terminal view when it covers the pane, and moves focus into the pane.
15834
+ async function addPane(raw, { sid = paneSessionId(), show = false, label } = {}) {
15702
15835
  const t = sid && paneTargetFrom(raw);
15703
15836
  if (!t) return;
15704
15837
  if (t.error) {
15705
15838
  showToast(t.error, 'error');
15706
15839
  return;
15707
15840
  }
15708
- if (!(await postPane(sid, { target: t.target, base: getSessionBaseDir(sid) || undefined }))) return;
15841
+ const onScreen = await postPane(sid, { target: t.target, base: getSessionBaseDir(sid) || undefined });
15842
+ if (onScreen === null) return;
15843
+ if (!show && !onScreen) {
15844
+ if (label) toastPaneAdded(sid, onScreen, label);
15845
+ return;
15846
+ }
15709
15847
  closePanePop();
15710
- syncPanes();
15848
+ if (!show) return syncPanes();
15849
+ revealPane(sid, onScreen);
15850
+ if (sid === paneSessionId() && !wantsTerminal()) focusActivePane();
15711
15851
  }
15712
15852
 
15713
15853
  // Shows the added pane. True when its session is still on screen, null when the add failed.
@@ -15733,11 +15873,14 @@ function applyPaneLine(view) {
15733
15873
  markSourceLine(body, line);
15734
15874
  }
15735
15875
 
15736
- // The same pad again returns its pane, so a second Ctrl+click only shows it.
15876
+ // The same pad again returns its pane, so a second click only shows it.
15737
15877
  async function openScratchpadPane(sid, manifest) {
15738
15878
  const onScreen = await postPane(sid, { kind: 'scratchpad', target: manifest });
15739
- if (onScreen) syncPanes();
15740
- toastPaneAdded(sid, onScreen, linkedDocLabel(manifest));
15879
+ if (onScreen !== null) revealPane(sid, onScreen);
15880
+ }
15881
+
15882
+ function openScratchpadTab(sid, manifest) {
15883
+ hub.invoke(SCRATCHPAD_OPEN, scratchpadOpenArgs(sid, manifest));
15741
15884
  }
15742
15885
 
15743
15886
  async function openPaneAtLine(sid, { path, line }, base) {
@@ -15774,7 +15917,7 @@ function openPreviewInPane() {
15774
15917
  const sid = previewSessionId;
15775
15918
  const target = currentPreviewPath;
15776
15919
  closePreviewModal();
15777
- addPaneToSession(sid, target, pathBasename(target));
15920
+ addPane(target, { sid, label: pathBasename(target) });
15778
15921
  }
15779
15922
 
15780
15923
  // The plan modal also opens other sessions' plans; the pane goes to the plan's session, wherever it is.
@@ -15790,17 +15933,7 @@ function openPlanInPane() {
15790
15933
  const sid = _planSessionId;
15791
15934
  const target = _pendingPlanPath;
15792
15935
  closePlanModal();
15793
- addPaneToSession(sid, target, 'Plan');
15794
- }
15795
-
15796
- async function addPaneToSession(sid, target, label) {
15797
- if (sid === paneSessionId()) return addPane(target);
15798
- if ((await postPane(sid, { target, base: getSessionBaseDir(sid) || undefined })) !== false) return;
15799
- const s = sessions.find((x) => x.id === sid);
15800
- showToast(`${label} added to ${s ? sessionDisplayName(s) : 'its session'}`, 'success', {
15801
- label: 'Open',
15802
- onClick: () => openSession(sid),
15803
- });
15936
+ addPane(target, { sid, label: 'Plan' });
15804
15937
  }
15805
15938
 
15806
15939
  function msgDetailPaneSource() {
@@ -16661,8 +16794,8 @@ function terminalInitOptions(themeOptions) {
16661
16794
  };
16662
16795
  }
16663
16796
 
16664
- function openTerminalLink(href) {
16665
- if (typeof href === 'string' && isLocalHref(href)) return openLocalHref(href);
16797
+ function openTerminalLink({ href, ctrl }) {
16798
+ if (typeof href === 'string' && isLocalHref(href)) return openLocalHref(href, ctrl === true);
16666
16799
  const url = linkUrl(href);
16667
16800
  if (url) hub.openExternal(url);
16668
16801
  }
@@ -16686,7 +16819,7 @@ function onTerminalFrameMessage(t, m) {
16686
16819
  reconnectTerminal();
16687
16820
  }
16688
16821
  } else if (t === 'key') replayKey(m, document.getElementById('terminal-key-proxy'));
16689
- else if (t === 'link') openTerminalLink(m.href);
16822
+ else if (t === 'link') openTerminalLink(m);
16690
16823
  // Chrome does not always fire focusin on the iframe element when its content takes focus.
16691
16824
  else if (t === 'focused') terminalHadFocus = terminalPaneFocused();
16692
16825
  else if (t === 'opening') {
@@ -16775,11 +16908,14 @@ function sendBridgeClaimsAll(frames, base) {
16775
16908
  }
16776
16909
 
16777
16910
  // A hub app in a URL pane runs the SDK, which hands back these keys (hub protocol §5.2). Only keys with
16778
- // Ctrl, Alt or Meta: the page keeps Escape, brackets and its own letter keys.
16911
+ // Ctrl, Alt or Meta, so the page keeps Escape, brackets and its own letter keys, plus the plain keys
16912
+ // its hub:hostReady named.
16779
16913
  function sendHostKeys(frames, bridged) {
16780
- const keys = bridged.keys.filter((k) => k.ctrlKey || k.altKey || k.metaKey);
16781
- const sig = JSON.stringify(keys);
16914
+ const modified = (k) => k.ctrlKey || k.altKey || k.metaKey;
16782
16915
  for (const f of frames) {
16916
+ const plain = f.hostPlainKeys || [];
16917
+ const keys = bridged.keys.filter((k) => modified(k) || plain.includes(k.key));
16918
+ const sig = JSON.stringify(keys);
16783
16919
  const origin = URL.parse(f.src)?.origin;
16784
16920
  if (!origin || origin === 'null' || f.hostKeysSig === sig) continue;
16785
16921
  f.hostKeysSig = sig;
@@ -16789,14 +16925,43 @@ function sendHostKeys(frames, bridged) {
16789
16925
 
16790
16926
  const urlPaneFrames = () => [...paneViews.querySelectorAll('.pane-url-frame')];
16791
16927
 
16928
+ function isAddonOrigin(origin) {
16929
+ const list = dockAddonList;
16930
+ return !!list && [...list.global, ...list.session].some((a) => URL.parse(a.url)?.origin === origin);
16931
+ }
16932
+
16933
+ // The dock or URL pane frame a message came from, when the message's origin is that frame's page.
16934
+ function pageFrameOf(e) {
16935
+ const dock = dockFrameEls().find((f) => f.contentWindow === e.source);
16936
+ const frame = dock || urlPaneFrames().find((f) => f.contentWindow === e.source);
16937
+ return frame && URL.parse(frame.src)?.origin === e.origin ? { dock, frame } : {};
16938
+ }
16939
+
16940
+ // An add-on page asks the board to open a local path (`cck-addon:open` {path, pane?, reveal?}):
16941
+ // the preview modal, with `pane` a pane of the session, with `reveal` the file manager.
16942
+ window.addEventListener('message', (e) => {
16943
+ const { type, path: target, reveal, pane } = e.data || {};
16944
+ if (type !== 'cck-addon:open' || typeof target !== 'string' || !isLocalHref(target)) return;
16945
+ const { dock, frame } = pageFrameOf(e);
16946
+ if (!frame || !isAddonOrigin(e.origin)) return;
16947
+ const sid = dock ? dockSid : paneSessionId();
16948
+ if (reveal === true) revealPath(target);
16949
+ else if (pane === true) addPane(target, { sid, show: true });
16950
+ else openPreviewByPath(target, undefined, undefined, sid);
16951
+ });
16952
+
16792
16953
  window.addEventListener('message', (e) => {
16793
16954
  const type = e.data?.type;
16794
16955
  if (type !== 'hub:hostKey' && type !== 'hub:hostReady') return;
16795
- const dock = dockFrameEls().find((f) => f.contentWindow === e.source);
16796
- const frame = dock || urlPaneFrames().find((f) => f.contentWindow === e.source);
16797
- if (!frame || URL.parse(frame.src)?.origin !== e.origin) return;
16956
+ const { dock, frame } = pageFrameOf(e);
16957
+ if (!frame) return;
16798
16958
  if (type === 'hub:hostReady') {
16799
16959
  if (!dock) frame.parentElement.classList.add('keys-bridged');
16960
+ const plain = Array.isArray(e.data.plainKeys) ? e.data.plainKeys.filter((k) => typeof k === 'string') : [];
16961
+ if (plain.length) {
16962
+ frame.hostPlainKeys = plain;
16963
+ pushTerminalClaims();
16964
+ }
16800
16965
  return;
16801
16966
  }
16802
16967
  // A page has focus when it gets a keydown, even one that never posts its focus.
@@ -17719,7 +17884,7 @@ window.addEventListener('message', (e) => {
17719
17884
  return;
17720
17885
  }
17721
17886
  if (t === 'link') {
17722
- openTerminalLink(m.href);
17887
+ openTerminalLink(m);
17723
17888
  return;
17724
17889
  }
17725
17890
  if (t === 'focused') {
@@ -18550,14 +18715,20 @@ window.addEventListener('message', (e) => {
18550
18715
 
18551
18716
  // The same body attributes the terminal theme watches; a markdown card follows the board's CSS.
18552
18717
  // The body's style also changes on every drag, so a push with the same tokens is dropped.
18718
+ // A theme switch changes the class and the style in separate steps, so one frame collects them.
18553
18719
  let sentTokens = '';
18720
+ let tokensRaf = 0;
18554
18721
  new MutationObserver(() => {
18555
- postToShowFrames(() => {
18556
- const tokens = showTokens();
18557
- const key = JSON.stringify(tokens);
18558
- if (key === sentTokens) return null;
18559
- sentTokens = key;
18560
- return { type: `${SHOW_MSG}tokens`, tokens };
18722
+ if (tokensRaf) return;
18723
+ tokensRaf = requestAnimationFrame(() => {
18724
+ tokensRaf = 0;
18725
+ postToShowFrames(() => {
18726
+ const tokens = showTokens();
18727
+ const key = JSON.stringify(tokens);
18728
+ if (key === sentTokens) return null;
18729
+ sentTokens = key;
18730
+ return { type: `${SHOW_MSG}tokens`, tokens };
18731
+ });
18561
18732
  });
18562
18733
  }).observe(document.body, { attributes: true, attributeFilter: ['class', 'data-color-theme', 'style'] });
18563
18734
 
@@ -18850,6 +19021,7 @@ function createDockView(pane) {
18850
19021
  if (pane.run && !dockAddonUp.has(pane.id)) return startDockAddon(pane);
18851
19022
  const frame = paneUrlFrame(pane, 'dock-addon-frame');
18852
19023
  frame.dataset.target = pane.target;
19024
+ frame.addEventListener('load', () => onDockFrameLoad(pane.id, frame));
18853
19025
  if (pane.addon || paneFraming.get(pane.target)) return frame;
18854
19026
  const sid = dockSid;
18855
19027
  probePaneFraming(sid, pane).then((frameable) => {
@@ -19052,7 +19224,7 @@ function initDockRail() {
19052
19224
  if (e.target.closest('[data-dock="close"]')) dockRailCommand(pane.id);
19053
19225
  else if (e.target.closest('[data-dock="expand"]')) setDockExpanded(!dockExpanded);
19054
19226
  else if (e.target.closest('[data-dock="remove"]')) removeDockItem(pane);
19055
- else if (e.target.closest('[data-dock="pane"]')) addPaneToSession(dockSid, pane.target, pane.title);
19227
+ else if (e.target.closest('[data-dock="pane"]')) addPane(pane.target, { sid: dockSid, show: true });
19056
19228
  else if (e.target.closest('[data-dock="reload"]')) {
19057
19229
  dockAddonUp.delete(pane.id);
19058
19230
  dropDockView(pane.id);
@@ -19399,6 +19571,9 @@ async function loadTerminals() {
19399
19571
  const list = data.sessions || [];
19400
19572
  runningTerminals = new Set(list.map((t) => t.id));
19401
19573
  setTrustWaiting(list.filter((t) => t.awaitingTrust).map((t) => t.id));
19574
+ reportedStatus = new Map(list.filter((t) => t.programStatus).map((t) => [t.id, t.programStatus]));
19575
+ markOpenSessionRead();
19576
+ hintSilentStatus(list.filter((t) => t.statusSilent).map((t) => t.id));
19402
19577
  rememberTerminalIds(list);
19403
19578
  syncShowCard();
19404
19579
  pushTerminalClaims();
@@ -19423,8 +19598,10 @@ function setTrustWaiting(ids) {
19423
19598
  }
19424
19599
  }
19425
19600
 
19426
- function setRunningTerminals(ids, awaitingTrust = []) {
19601
+ function setRunningTerminals(ids, awaitingTrust = [], programStatus = {}) {
19427
19602
  runningTerminals = new Set(ids);
19603
+ reportedStatus = new Map(Object.entries(programStatus));
19604
+ markOpenSessionRead();
19428
19605
  setTrustWaiting(awaitingTrust);
19429
19606
  forgetEndedTerminals();
19430
19607
  syncShowCard();
@@ -19434,6 +19611,19 @@ function setRunningTerminals(ids, awaitingTrust = []) {
19434
19611
  renderActivityChip();
19435
19612
  }
19436
19613
 
19614
+ // Once per page: a program asked for status reports and none came, so the reply was lost.
19615
+ let silentStatusHinted = false;
19616
+ function hintSilentStatus(ids) {
19617
+ if (silentStatusHinted || !ids?.length || store.getItem(SILENT_STATUS_HINT_KEY) === 'off') return;
19618
+ silentStatusHinted = true;
19619
+ showToast(
19620
+ 'Claude Code cannot report its status in this terminal',
19621
+ 'info',
19622
+ { label: "Don't show again", onClick: () => store.setItem(SILENT_STATUS_HINT_KEY, 'off') },
19623
+ 'Set Terminal host (Windows) to Bundled in the Kanban settings, then start a new terminal.',
19624
+ );
19625
+ }
19626
+
19437
19627
  function showSessionTerminal(sessionId) {
19438
19628
  setTerminalMode(sessionId, true);
19439
19629
  if (currentSessionId === sessionId && viewMode === 'session') syncTerminal();
@@ -20471,13 +20661,25 @@ function answerWaitingFromHub(behavior, message) {
20471
20661
 
20472
20662
  function needsYouQueue() {
20473
20663
  const live = sessions.filter((s) => (!s.placeholder || trustWaiting.has(s.id)) && !dismissedSessionIds.has(s.id));
20474
- return [...live.filter(isWaitingSession), ...live.filter((s) => !isWaitingSession(s) && s.unread)];
20664
+ return [...live.filter(isWaitingSession), ...live.filter((s) => !isWaitingSession(s) && sessionBarClass(s))];
20475
20665
  }
20476
20666
 
20667
+ // Opening a session marks it read or answered, which drops it from the queue, so the next press
20668
+ // goes on in the order the queue had when this one was opened, not back to the start.
20669
+ let needsYouLast = { id: null, after: [] };
20670
+
20477
20671
  function nextNeedsYou() {
20478
20672
  const queue = needsYouQueue();
20479
- const next = queue[(queue.findIndex((s) => s.id === currentSessionId) + 1) % queue.length];
20673
+ const at = queue.findIndex((s) => s.id === currentSessionId);
20674
+ let i = (at + 1) % queue.length;
20675
+ if (at < 0 && needsYouLast.id === currentSessionId) {
20676
+ const ahead = needsYouLast.after.find((id) => queue.some((s) => s.id === id));
20677
+ if (ahead) i = queue.findIndex((s) => s.id === ahead);
20678
+ }
20679
+ const next = queue[i];
20480
20680
  if (!next || next.id === currentSessionId) return showToast('No other session needs you', 'info');
20681
+ const ids = queue.map((s) => s.id);
20682
+ needsYouLast = { id: next.id, after: [...ids.slice(i + 1), ...ids.slice(0, i)] };
20481
20683
  if (terminalPaneFocused() || isShowCardFocused()) termState.focusNext = true;
20482
20684
  return revealSession(next.id);
20483
20685
  }
@@ -20615,9 +20817,29 @@ function schedulePublish() {
20615
20817
  publishTimer = setTimeout(() => {
20616
20818
  publishSession();
20617
20819
  publishVoiceContext();
20820
+ publishAttention();
20618
20821
  }, 150);
20619
20822
  }
20620
20823
 
20824
+ // attention.changed lists the sessions whose terminal reports blocked, for the hub's title,
20825
+ // taskbar badge and toast. Only the id, name and kind cross: the program's msg stays on the board.
20826
+ let publishedAttention = '[]';
20827
+ const ATTENTION_MAX = 20;
20828
+
20829
+ function publishAttention() {
20830
+ const blocked = [];
20831
+ for (const [id, r] of reportedStatus) {
20832
+ if (!reportedBlocked(id)) continue;
20833
+ const s = sessions.find((x) => x.id === id);
20834
+ blocked.push({ id, name: s ? sessionDisplayName(s) : id.slice(0, 8), kind: r.kind });
20835
+ if (blocked.length === ATTENTION_MAX) break;
20836
+ }
20837
+ const key = JSON.stringify(blocked);
20838
+ if (key === publishedAttention) return;
20839
+ publishedAttention = key;
20840
+ hub.publish('attention.changed', { blocked });
20841
+ }
20842
+
20621
20843
  function publishSession() {
20622
20844
  if (currentSessionId === publishedSessionId) return;
20623
20845
  const s = currentSessionId ? sessions.find((x) => x.id === currentSessionId) : null;
@@ -20653,8 +20875,8 @@ function isLocalHref(href) {
20653
20875
  return /^file:/i.test(href) || (isAbsolutePath(href) && !href.startsWith('//'));
20654
20876
  }
20655
20877
 
20656
- function openLocalHref(href) {
20657
- openPreviewByPath(href.replace(/#.*$/, ''), undefined, openFileInEditor);
20878
+ function openLocalHref(href, folderDirect) {
20879
+ openPreviewByPath(href.replace(/#.*$/, ''), undefined, openFileInEditor, undefined, folderDirect);
20658
20880
  }
20659
20881
 
20660
20882
  // Capture, because the modals stop a click's propagation, and stopped here so a link in a message
@@ -20676,7 +20898,7 @@ document.addEventListener(
20676
20898
  if (!local && (!external || hub.inHub)) return;
20677
20899
  e.preventDefault();
20678
20900
  e.stopPropagation();
20679
- if (local) openLocalHref(href);
20901
+ if (local) openLocalHref(href, e.ctrlKey || e.metaKey);
20680
20902
  else hub.openExternal(url.href);
20681
20903
  },
20682
20904
  true,