claude-code-kanban 7.29.0 → 7.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.js +14 -5
- package/hub-app.json +12 -1
- package/lib/panes.js +17 -3
- package/lib/terminal-client.js +11 -1
- package/lib/terminal-host.js +6 -1
- package/lib/terminal.js +26 -9
- package/package.json +1 -1
- package/plugin/plugins/claude-code-kanban/.claude-plugin/plugin.json +1 -1
- package/plugin/plugins/claude-code-kanban/skills/addon/references/build.md +15 -3
- package/plugin/plugins/claude-code-kanban/skills/addon/scripts/theme-check.mjs +94 -0
- package/public/app.js +368 -125
- package/public/index.html +4 -1
- package/public/style.css +16 -1
- package/server.js +65 -10
package/public/app.js
CHANGED
|
@@ -95,10 +95,11 @@ let sessionsHasMore = false;
|
|
|
95
95
|
// URL, so a query string would not survive a hub reload.
|
|
96
96
|
const ZEN_KEY = 'zenMode';
|
|
97
97
|
let zenMode = store.getItem(ZEN_KEY) === 'true';
|
|
98
|
-
// Group and project zen: the sidebar shows one group's subtree or one project.
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
let
|
|
98
|
+
// Group and project zen: the sidebar shows one group's subtree or one project.
|
|
99
|
+
const ZEN_SCOPE_KEY = 'zenScope';
|
|
100
|
+
const savedZenScope = store.readJson(ZEN_SCOPE_KEY);
|
|
101
|
+
let zenGroup = typeof savedZenScope?.group === 'string' ? savedZenScope.group : null;
|
|
102
|
+
let zenProject = typeof savedZenScope?.project === 'string' ? savedZenScope.project : null;
|
|
102
103
|
let filterProject = FILTER_DEFAULTS.project; // null = all, '__recent__' = last 24h, or project path
|
|
103
104
|
let recentProjects = new Set();
|
|
104
105
|
let projectsCacheDirty = true;
|
|
@@ -123,8 +124,6 @@ let currentWaiting = null;
|
|
|
123
124
|
let lastWaitingHash = '';
|
|
124
125
|
let lastAgentsHash = '';
|
|
125
126
|
let messagePanelOpen = false;
|
|
126
|
-
let logAutoOpened = false;
|
|
127
|
-
const logDismissed = new Set();
|
|
128
127
|
let lastMessagesHash = '';
|
|
129
128
|
let currentMessages = [];
|
|
130
129
|
let agentDurationInterval = null;
|
|
@@ -232,7 +231,7 @@ function updateUrl() {
|
|
|
232
231
|
if (filterProject && filterProject !== FILTER_DEFAULTS.project) params.set('project', filterProject);
|
|
233
232
|
if (ownerFilter) params.set('owner', ownerFilter);
|
|
234
233
|
if (searchQuery) params.set('search', searchQuery);
|
|
235
|
-
if (messagePanelOpen
|
|
234
|
+
if (messagePanelOpen) params.set('messages', '1');
|
|
236
235
|
const qs = params.toString();
|
|
237
236
|
const url = qs ? `?${qs}` : window.location.pathname;
|
|
238
237
|
history.replaceState(null, '', url);
|
|
@@ -264,9 +263,7 @@ function resetState() {
|
|
|
264
263
|
sessionLimit = SESSION_PAGE;
|
|
265
264
|
filterProject = FILTER_DEFAULTS.project;
|
|
266
265
|
zenMode = false;
|
|
267
|
-
|
|
268
|
-
zenProject = null;
|
|
269
|
-
setZenPeek(null);
|
|
266
|
+
setZenScope(null, null);
|
|
270
267
|
store.removeItem(ZEN_KEY);
|
|
271
268
|
renderZenState();
|
|
272
269
|
searchQuery = '';
|
|
@@ -803,9 +800,9 @@ async function fetchTasks(sessionId) {
|
|
|
803
800
|
if (currentSessionId && currentSessionId !== sessionId) deferredPinPlacement.delete(currentSessionId);
|
|
804
801
|
pushSwapHistory(sessionId);
|
|
805
802
|
const switched = sessionId !== currentSessionId;
|
|
803
|
+
if (switched) leaveZenScopeFor(sessionId);
|
|
806
804
|
currentSessionId = sessionId;
|
|
807
805
|
markOpenSessionRead();
|
|
808
|
-
if (switched) autoRevealLog(sessionId);
|
|
809
806
|
// A task change in the open session must not reset the messages, the agents or the owner
|
|
810
807
|
// filter: that reset rebuilds the panels and reads as a reload after each card move.
|
|
811
808
|
if (!refresh) {
|
|
@@ -962,30 +959,7 @@ async function refreshProjectAgents() {
|
|
|
962
959
|
//#endregion
|
|
963
960
|
|
|
964
961
|
//#region MESSAGE_PANEL
|
|
965
|
-
function setMessagePanelVisible(open) {
|
|
966
|
-
messagePanelOpen = open;
|
|
967
|
-
document.getElementById('message-panel').classList.toggle('visible', open);
|
|
968
|
-
document.getElementById('message-toggle')?.classList.toggle('active', open);
|
|
969
|
-
}
|
|
970
|
-
|
|
971
|
-
// An empty board has nothing to show, so the log opens in its place. It is not the user's choice,
|
|
972
|
-
// so it is not stored, it closes again on a session with tasks or panes, and a manual close sticks for that session.
|
|
973
|
-
// The pane layout loads after the switch, and applyPaneLayout asks again once it is in.
|
|
974
|
-
function autoRevealLog(sessionId) {
|
|
975
|
-
if (!paneLayouts.has(sessionId)) return;
|
|
976
|
-
const empty = !currentTasks.length && !paneLayout(sessionId).panes.length;
|
|
977
|
-
if (empty && !messagePanelOpen && !logDismissed.has(sessionId) && !wantsTerminal()) {
|
|
978
|
-
setMessagePanelVisible(true);
|
|
979
|
-
logAutoOpened = true;
|
|
980
|
-
} else if (!empty && logAutoOpened) {
|
|
981
|
-
setMessagePanelVisible(false);
|
|
982
|
-
logAutoOpened = false;
|
|
983
|
-
}
|
|
984
|
-
}
|
|
985
|
-
|
|
986
962
|
function toggleMessagePanel() {
|
|
987
|
-
if (logAutoOpened && messagePanelOpen && currentSessionId) logDismissed.add(currentSessionId);
|
|
988
|
-
logAutoOpened = false;
|
|
989
963
|
const panel = document.getElementById('message-panel');
|
|
990
964
|
messagePanelOpen = !messagePanelOpen;
|
|
991
965
|
termState.panelHidden = false;
|
|
@@ -4333,23 +4307,21 @@ function renderSessions() {
|
|
|
4333
4307
|
refreshProjectList();
|
|
4334
4308
|
syncPinPeek();
|
|
4335
4309
|
|
|
4336
|
-
if (zenGroup && !sgGroupById(zenGroup)) {
|
|
4337
|
-
zenGroup = null;
|
|
4310
|
+
if (zenGroup && sgRev !== null && !sgGroupById(zenGroup)) {
|
|
4338
4311
|
zenPeekKey = null;
|
|
4312
|
+
setZenScope(null, null);
|
|
4339
4313
|
renderZenState();
|
|
4340
4314
|
}
|
|
4341
4315
|
// Zen narrows the rendered list only — the session picker keeps calling getFilteredSessions()
|
|
4342
4316
|
// and still offers everything, or there would be no way to switch sessions without leaving zen.
|
|
4343
4317
|
const zenSession = zenMode && currentSessionId ? sessions.find((s) => s.id === currentSessionId) : null;
|
|
4344
|
-
sessionsList.classList.toggle('zen', !!zenSession);
|
|
4345
|
-
sessionsList.dataset.zenState = zenSession ? sessionState(zenSession) : '';
|
|
4346
4318
|
const zenScope = !!(zenGroup || zenProject);
|
|
4319
|
+
sessionsList.classList.toggle('zen', !!zenSession || zenScope);
|
|
4320
|
+
sessionsList.dataset.zenState = zenSession ? sessionState(zenSession) : '';
|
|
4347
4321
|
let filteredSessions;
|
|
4348
4322
|
if (zenScope) {
|
|
4349
4323
|
const scoped = getFilteredSessions({ zen: true });
|
|
4350
|
-
filteredSessions = applyStableSessionOrder(
|
|
4351
|
-
zenProject ? scoped.filter((s) => sessionProjectKey(s) === zenProject) : scoped,
|
|
4352
|
-
);
|
|
4324
|
+
filteredSessions = applyStableSessionOrder(zenProject ? scoped.filter(inZenScope) : scoped);
|
|
4353
4325
|
} else if (zenMode) filteredSessions = zenSession ? [zenSession] : [];
|
|
4354
4326
|
else filteredSessions = applyStableSessionOrder(getFilteredSessions());
|
|
4355
4327
|
|
|
@@ -4360,7 +4332,7 @@ function renderSessions() {
|
|
|
4360
4332
|
for (const g of sessionGroups) for (const m of g.members) if (m.parent) parentOf.set(m.ref, m.parent);
|
|
4361
4333
|
childAnchors = computeChildAnchors(filteredSessions);
|
|
4362
4334
|
for (const s of filteredSessions) {
|
|
4363
|
-
if (childAnchors.has(s.id) && !parentOf.has(s.id)) parentOf.set(s.id, s.
|
|
4335
|
+
if (childAnchors.has(s.id) && !parentOf.has(s.id)) parentOf.set(s.id, s.nest.parent);
|
|
4364
4336
|
}
|
|
4365
4337
|
const nestChildren = (list) => {
|
|
4366
4338
|
if (parentOf.size === 0) return list;
|
|
@@ -5572,19 +5544,20 @@ function sgGroupForSession(session) {
|
|
|
5572
5544
|
return sgGroupOf('session', s.id) || (project ? sgGroupOf('project', project) : null);
|
|
5573
5545
|
}
|
|
5574
5546
|
|
|
5575
|
-
// A `dispatch start --child` session renders in its
|
|
5576
|
-
// the
|
|
5577
|
-
// (drag, pins, search, reveal) agrees with what
|
|
5547
|
+
// A `dispatch start --child` session, or a fork from the Fork menu, renders in its parent's place,
|
|
5548
|
+
// unless the user placed or unnested it or the parent is not in the rendered list. Set by
|
|
5549
|
+
// renderSessions, so every other placement lookup (drag, pins, search, reveal) agrees with what
|
|
5550
|
+
// the sidebar shows.
|
|
5578
5551
|
let childAnchors = new Map();
|
|
5579
5552
|
const placementOf = (session) => childAnchors.get(session.id) ?? session;
|
|
5580
5553
|
|
|
5581
5554
|
function computeChildAnchors(list) {
|
|
5582
5555
|
const out = new Map();
|
|
5583
|
-
if (!list.some((s) => s.
|
|
5556
|
+
if (!list.some((s) => s.nest?.child)) return out;
|
|
5584
5557
|
const byId = new Map(list.map((s) => [s.id, s]));
|
|
5585
5558
|
const placed = new Set();
|
|
5586
5559
|
for (const g of sessionGroups) for (const m of g.members) if (m.type === 'session') placed.add(m.ref);
|
|
5587
|
-
const up = (s) => (s.
|
|
5560
|
+
const up = (s) => (s.nest?.child && !placed.has(s.id) ? byId.get(s.nest.parent) : null);
|
|
5588
5561
|
for (const s of list) {
|
|
5589
5562
|
let anchor = up(s);
|
|
5590
5563
|
if (!anchor) continue;
|
|
@@ -5598,10 +5571,10 @@ function computeChildAnchors(list) {
|
|
|
5598
5571
|
return out;
|
|
5599
5572
|
}
|
|
5600
5573
|
|
|
5601
|
-
function
|
|
5574
|
+
function setNestChild(id, child) {
|
|
5602
5575
|
const s = sessions.find((x) => x.id === id);
|
|
5603
|
-
if (!s?.
|
|
5604
|
-
s.
|
|
5576
|
+
if (!s?.nest || !!s.nest.child === child || (child && !s.nest.parent)) return;
|
|
5577
|
+
s.nest = { ...s.nest, child };
|
|
5605
5578
|
if (child && sgGroupOf('session', id)) {
|
|
5606
5579
|
sgDetach('session', id);
|
|
5607
5580
|
persistSessionGroups();
|
|
@@ -5979,7 +5952,7 @@ function sgGroupDropZone(target) {
|
|
|
5979
5952
|
const targetSessionId = zone.dataset.sessionId;
|
|
5980
5953
|
if (targetSessionId) {
|
|
5981
5954
|
if (targetSessionId === sgDrag.ref) return null;
|
|
5982
|
-
if (dragSession?.
|
|
5955
|
+
if (dragSession?.nest?.parent === targetSessionId) return anchored ? null : { zone, nest: true };
|
|
5983
5956
|
const targetSession = sessions.find((s) => s.id === targetSessionId);
|
|
5984
5957
|
const targetGroup = targetSession ? sgGroupForSession(targetSession) : null;
|
|
5985
5958
|
const targetGroupId = targetGroup?.id || null;
|
|
@@ -6062,13 +6035,13 @@ function sgOnDrop(e) {
|
|
|
6062
6035
|
return;
|
|
6063
6036
|
}
|
|
6064
6037
|
if (hit.nest) {
|
|
6065
|
-
|
|
6038
|
+
setNestChild(drag.ref, true);
|
|
6066
6039
|
sgFinishDrag();
|
|
6067
6040
|
return;
|
|
6068
6041
|
}
|
|
6069
6042
|
// Any other move takes a `--child` session out of its starter's place for good, so it stays
|
|
6070
6043
|
// where it was put after it leaves a group.
|
|
6071
|
-
if (drag.kind === 'session')
|
|
6044
|
+
if (drag.kind === 'session') setNestChild(drag.ref, false);
|
|
6072
6045
|
if (hit.unnest) {
|
|
6073
6046
|
sgFinishDrag();
|
|
6074
6047
|
return;
|
|
@@ -6248,15 +6221,21 @@ function sgOpenMenu(x, y, kind, ref) {
|
|
|
6248
6221
|
menu.setAttribute('role', 'menu');
|
|
6249
6222
|
const canFork = kind === 'session' && !!forkableSession(ref);
|
|
6250
6223
|
const canEnd = kind === 'session' && runningTerminals.has(ref);
|
|
6251
|
-
const
|
|
6224
|
+
const canShell = kind === 'session' && terminalAvailable() && !!getSessionBaseDir(ref);
|
|
6225
|
+
const marker = kind === 'session' ? sessions.find((s) => s.id === ref)?.nest : null;
|
|
6252
6226
|
const nestItem = marker?.child
|
|
6253
6227
|
? '<button class="sg-menu-item" role="menuitem" data-sg-action="unnest">Unnest</button>'
|
|
6254
|
-
:
|
|
6228
|
+
: marker?.parent && sessions.some((s) => s.id === marker.parent)
|
|
6229
|
+
? '<button class="sg-menu-item" role="menuitem" data-sg-action="nest">Nest under parent</button>'
|
|
6230
|
+
: '';
|
|
6255
6231
|
const actions =
|
|
6256
6232
|
nestItem +
|
|
6257
6233
|
(canFork
|
|
6258
6234
|
? '<button class="sg-menu-item" role="menuitem" data-sg-action="fork" title="claude --resume --fork-session">Fork</button>'
|
|
6259
6235
|
: '') +
|
|
6236
|
+
(canShell
|
|
6237
|
+
? '<button class="sg-menu-item" role="menuitem" data-sg-action="shell" title="A plain shell in the session\'s folder, in a pane">New shell</button>'
|
|
6238
|
+
: '') +
|
|
6260
6239
|
(canEnd
|
|
6261
6240
|
? '<button class="sg-menu-item" role="menuitem" data-sg-action="end" title="Alt+Shift+`">End terminal</button>'
|
|
6262
6241
|
: '');
|
|
@@ -6314,11 +6293,12 @@ document.addEventListener('click', (e) => {
|
|
|
6314
6293
|
sgCloseMenu();
|
|
6315
6294
|
if (item.dataset.sgAction === 'fork') return forkSession(sgRef);
|
|
6316
6295
|
if (item.dataset.sgAction === 'end') return closeTerminalSession(sgRef);
|
|
6317
|
-
if (item.dataset.sgAction === '
|
|
6318
|
-
|
|
6296
|
+
if (item.dataset.sgAction === 'shell') return openShellForSession(sgRef);
|
|
6297
|
+
if (item.dataset.sgAction === 'unnest' || item.dataset.sgAction === 'nest') {
|
|
6298
|
+
setNestChild(sgRef, item.dataset.sgAction === 'nest');
|
|
6319
6299
|
return renderSessions();
|
|
6320
6300
|
}
|
|
6321
|
-
if (sgKind === 'session')
|
|
6301
|
+
if (sgKind === 'session') setNestChild(sgRef, false);
|
|
6322
6302
|
if (move === '__none__') {
|
|
6323
6303
|
sgDetach(sgKind, sgRef);
|
|
6324
6304
|
persistSessionGroups();
|
|
@@ -7109,9 +7089,15 @@ const SHORTCUT_TABS = [
|
|
|
7109
7089
|
yields: 'ctrl+alt+1',
|
|
7110
7090
|
label: 'Go to tab or group N (the board is 1)',
|
|
7111
7091
|
},
|
|
7112
|
-
{
|
|
7092
|
+
{
|
|
7093
|
+
keys: ['Alt', '[ / ]'],
|
|
7094
|
+
combo: true,
|
|
7095
|
+
label: 'Change the tab in the focused side of a split, else previous / next tab',
|
|
7096
|
+
},
|
|
7113
7097
|
{ keys: ['|'], label: 'Split with the tab before it / unsplit (or drag a tab onto a side)' },
|
|
7098
|
+
{ keys: ['Alt', '|'], combo: true, label: 'Split / unsplit, from a shell too' },
|
|
7114
7099
|
{ keys: ['{', '}'], label: 'Focus left / right side of a split' },
|
|
7100
|
+
{ keys: ['Alt', '{ / }'], combo: true, label: 'Focus left / right side of a split, from a shell too' },
|
|
7115
7101
|
{ keys: ['Alt', 'W'], combo: true, label: 'Close the focused pane' },
|
|
7116
7102
|
{ keys: ['Shift', 'F10'], combo: true, label: 'Focused tab menu (or Menu key)' },
|
|
7117
7103
|
],
|
|
@@ -8582,8 +8568,10 @@ document.addEventListener('keydown', (e) => {
|
|
|
8582
8568
|
return;
|
|
8583
8569
|
}
|
|
8584
8570
|
const altOnly = e.altKey && !e.ctrlKey && !e.metaKey && !e.shiftKey;
|
|
8585
|
-
|
|
8586
|
-
|
|
8571
|
+
// The Alt forms work from a shell pane, which types the plain [ ] { }.
|
|
8572
|
+
const bracket = e.code === 'BracketLeft' ? -1 : e.code === 'BracketRight' ? 1 : 0;
|
|
8573
|
+
if (altOnly && bracket) {
|
|
8574
|
+
if (cyclePane(bracket) || cyclePaneStrip(bracket)) {
|
|
8587
8575
|
e.preventDefault();
|
|
8588
8576
|
focusActivePane();
|
|
8589
8577
|
}
|
|
@@ -8604,11 +8592,13 @@ document.addEventListener('keydown', (e) => {
|
|
|
8604
8592
|
return;
|
|
8605
8593
|
}
|
|
8606
8594
|
const plainShift = !e.ctrlKey && !e.altKey && !e.metaKey;
|
|
8607
|
-
|
|
8595
|
+
const altShift = e.altKey && e.shiftKey && !e.ctrlKey && !e.metaKey;
|
|
8596
|
+
if (((plainShift && e.key === '|') || (altShift && e.code === 'Backslash')) && togglePaneSplit()) {
|
|
8608
8597
|
e.preventDefault();
|
|
8609
8598
|
return;
|
|
8610
8599
|
}
|
|
8611
|
-
|
|
8600
|
+
const toSide = plainShift && e.key === '{' ? -1 : plainShift && e.key === '}' ? 1 : altShift ? bracket : 0;
|
|
8601
|
+
if (toSide && focusPaneSide(toSide < 0 ? 'l' : 'r')) {
|
|
8612
8602
|
e.preventDefault();
|
|
8613
8603
|
focusActivePane();
|
|
8614
8604
|
return;
|
|
@@ -9403,6 +9393,12 @@ const PANE_CLAIMS = [
|
|
|
9403
9393
|
{ key: 'Unidentified', code: 'KeyM' },
|
|
9404
9394
|
{ ctrlKey: true, key: 'm', code: '' },
|
|
9405
9395
|
...['BracketLeft', 'BracketRight', 'KeyW'].map((code) => ({ altKey: true, key: 'Unidentified', code })),
|
|
9396
|
+
...['BracketLeft', 'BracketRight', 'Backslash'].map((code) => ({
|
|
9397
|
+
altKey: true,
|
|
9398
|
+
shiftKey: true,
|
|
9399
|
+
key: 'Unidentified',
|
|
9400
|
+
code,
|
|
9401
|
+
})),
|
|
9406
9402
|
...['KeyL', 'KeyM', 'KeyP', 'KeyS', 'KeyZ'].map((code) => ({ shiftKey: true, key: 'Unidentified', code })),
|
|
9407
9403
|
...'123456789'.split('').map((n) => ({ ctrlKey: true, altKey: true, key: 'Unidentified', code: `Digit${n}` })),
|
|
9408
9404
|
];
|
|
@@ -12382,15 +12378,16 @@ function renderFilterState() {
|
|
|
12382
12378
|
function toggleZenMode() {
|
|
12383
12379
|
const leavingSessionZen = zenMode;
|
|
12384
12380
|
if (zenMode) zenMode = false;
|
|
12385
|
-
else if (zenGroup || zenProject)
|
|
12381
|
+
else if (zenGroup || zenProject) setZenScope(null, null);
|
|
12386
12382
|
else {
|
|
12387
12383
|
const el = focusZone === 'sidebar' && sessionsList.querySelector('.kb-selected');
|
|
12388
12384
|
const sel = el && sgDragPayload(el);
|
|
12389
|
-
|
|
12390
|
-
|
|
12385
|
+
setZenScope(
|
|
12386
|
+
sel?.kind === 'group' ? sgGroupById(sel.ref)?.id || null : null,
|
|
12387
|
+
sel?.kind === 'project' ? sel.ref : null,
|
|
12388
|
+
);
|
|
12391
12389
|
zenMode = !zenGroup && !zenProject;
|
|
12392
12390
|
}
|
|
12393
|
-
setZenPeek(zenGroup ? sgKey(zenGroup) : zenProject);
|
|
12394
12391
|
store.setItem(ZEN_KEY, String(zenMode));
|
|
12395
12392
|
renderZenState();
|
|
12396
12393
|
if (zenMode) closeFilterMenu();
|
|
@@ -12400,10 +12397,48 @@ function toggleZenMode() {
|
|
|
12400
12397
|
if (!leavingSessionZen) fetchSessions(false);
|
|
12401
12398
|
}
|
|
12402
12399
|
|
|
12400
|
+
function setZenScope(group, project) {
|
|
12401
|
+
zenGroup = group;
|
|
12402
|
+
zenProject = group ? null : project;
|
|
12403
|
+
setZenPeek(zenGroup ? sgKey(zenGroup) : zenProject);
|
|
12404
|
+
if (zenGroup || zenProject) store.writeJson(ZEN_SCOPE_KEY, { group: zenGroup, project: zenProject });
|
|
12405
|
+
else store.removeItem(ZEN_SCOPE_KEY);
|
|
12406
|
+
}
|
|
12407
|
+
|
|
12408
|
+
function inZenScope(session) {
|
|
12409
|
+
if (zenGroup) return sgSubtreeIds(zenGroup).has(sgGroupForSession(session)?.id);
|
|
12410
|
+
return sessionProjectKey(session) === zenProject;
|
|
12411
|
+
}
|
|
12412
|
+
|
|
12413
|
+
// Opening a session the scope hides would leave it off screen, so the scope gives way.
|
|
12414
|
+
// Not while booting: the restored session may sit outside the restored scope.
|
|
12415
|
+
function leaveZenScopeFor(sessionId) {
|
|
12416
|
+
if ((!zenGroup && !zenProject) || document.body.classList.contains('booting')) return;
|
|
12417
|
+
const session = sessions.find((s) => s.id === sessionId);
|
|
12418
|
+
if (!session || !inZenScope(session)) toggleZenMode();
|
|
12419
|
+
}
|
|
12420
|
+
|
|
12421
|
+
let terminalHost = null;
|
|
12422
|
+
let sentTerminalHost = null;
|
|
12423
|
+
|
|
12403
12424
|
function applyHubSettings(s) {
|
|
12404
12425
|
sessionsList.classList.toggle('zen-centered', s.zenCentered === true);
|
|
12405
12426
|
if (s.zenPattern) sessionsList.dataset.zenPattern = s.zenPattern;
|
|
12406
12427
|
else delete sessionsList.dataset.zenPattern;
|
|
12428
|
+
terminalHost = s.terminalHost || null;
|
|
12429
|
+
syncTerminalHost();
|
|
12430
|
+
}
|
|
12431
|
+
|
|
12432
|
+
// The settings can land before /api/config says whether this board has a terminal.
|
|
12433
|
+
function syncTerminalHost() {
|
|
12434
|
+
if (!terminalHost || terminalHost === sentTerminalHost || !terminalAvailable()) return;
|
|
12435
|
+
const host = terminalHost;
|
|
12436
|
+
sentTerminalHost = host;
|
|
12437
|
+
terminalFetch('/api/terminal/options', 'POST', { conptyDll: host === 'bundled' })
|
|
12438
|
+
.then((res) => res.ok || Promise.reject())
|
|
12439
|
+
.catch(() => {
|
|
12440
|
+
if (sentTerminalHost === host) sentTerminalHost = null;
|
|
12441
|
+
});
|
|
12407
12442
|
}
|
|
12408
12443
|
|
|
12409
12444
|
function renderZenState() {
|
|
@@ -14181,7 +14216,6 @@ function applyPaneLayout(sid, layout) {
|
|
|
14181
14216
|
if (sid === dockSid) renderDockRail();
|
|
14182
14217
|
if (sid !== paneSessionId()) return;
|
|
14183
14218
|
syncPanes();
|
|
14184
|
-
autoRevealLog(sid);
|
|
14185
14219
|
}
|
|
14186
14220
|
|
|
14187
14221
|
async function fetchPaneLayout(sid) {
|
|
@@ -14439,12 +14473,16 @@ const PANE_ICONS = {
|
|
|
14439
14473
|
'<svg class="kind" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>',
|
|
14440
14474
|
scratchpad:
|
|
14441
14475
|
'<svg class="kind" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>',
|
|
14476
|
+
shell:
|
|
14477
|
+
'<svg class="kind" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="4 17 10 11 4 5"/><line x1="12" y1="19" x2="20" y2="19"/></svg>',
|
|
14442
14478
|
warning:
|
|
14443
14479
|
'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10.3 3.9 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12" y2="17"/></svg>',
|
|
14444
14480
|
};
|
|
14445
14481
|
// Map order is recency: the first entry is the one evicted. Keys are `${sessionId}/${paneId}`,
|
|
14446
14482
|
// and the limit spans sessions, so a session switch cannot pile up frames.
|
|
14447
14483
|
const paneFrames = new Map();
|
|
14484
|
+
// Entries go with their view, in mountPane's eviction and unmountPane.
|
|
14485
|
+
const shellFrames = new Map();
|
|
14448
14486
|
const paneReviews = new WeakMap();
|
|
14449
14487
|
// Off-screen views whose file changed; they reload when shown.
|
|
14450
14488
|
const stalePaneViews = new WeakSet();
|
|
@@ -14547,7 +14585,7 @@ function markPaneSide(el, side, focused) {
|
|
|
14547
14585
|
el.classList.toggle('pane-focus', focused);
|
|
14548
14586
|
}
|
|
14549
14587
|
|
|
14550
|
-
const paneLabel = (p) => (p.kind === 'message' ? p.title : p.target);
|
|
14588
|
+
const paneLabel = (p) => (p.kind === 'message' ? p.title : p.kind === 'shell' ? p.cwd || 'Shell' : p.target);
|
|
14551
14589
|
|
|
14552
14590
|
function paneMenuLabel(pane, label) {
|
|
14553
14591
|
const cut =
|
|
@@ -14662,6 +14700,7 @@ function mountPane(sid, pane) {
|
|
|
14662
14700
|
while (paneFrames.size > PANE_FRAME_LIMIT) {
|
|
14663
14701
|
const [oldKey, oldView] = paneFrames.entries().next().value;
|
|
14664
14702
|
paneFrames.delete(oldKey);
|
|
14703
|
+
shellFrames.delete(oldView.querySelector('.pane-shell-frame'));
|
|
14665
14704
|
oldView.remove();
|
|
14666
14705
|
}
|
|
14667
14706
|
return key;
|
|
@@ -14687,16 +14726,18 @@ function paneUrlFrame(pane, className) {
|
|
|
14687
14726
|
frame.setAttribute('referrerpolicy', 'no-referrer');
|
|
14688
14727
|
frame.title = pane.title;
|
|
14689
14728
|
frame.src = pane.target;
|
|
14729
|
+
// Each load is a new page: it needs the theme and the host keys again.
|
|
14730
|
+
frame.addEventListener('load', () => {
|
|
14731
|
+
postToShowFrames(() => ({ type: `${SHOW_MSG}tokens`, tokens: showTokens() }), [frame]);
|
|
14732
|
+
frame.hostKeysSig = null;
|
|
14733
|
+
pushTerminalClaims();
|
|
14734
|
+
});
|
|
14690
14735
|
return frame;
|
|
14691
14736
|
}
|
|
14692
14737
|
|
|
14693
14738
|
function mountPaneUrlFrame(pane, view) {
|
|
14694
14739
|
const frame = paneUrlFrame(pane, 'pane-frame pane-url-frame modal-zoomable');
|
|
14695
|
-
frame.addEventListener('load', () =>
|
|
14696
|
-
view.classList.remove('keys-bridged');
|
|
14697
|
-
frame.hostKeysSig = null;
|
|
14698
|
-
pushTerminalClaims();
|
|
14699
|
-
});
|
|
14740
|
+
frame.addEventListener('load', () => view.classList.remove('keys-bridged'));
|
|
14700
14741
|
view.appendChild(frame);
|
|
14701
14742
|
view.insertAdjacentHTML('beforeend', paneUrlBarHtml());
|
|
14702
14743
|
return frame;
|
|
@@ -14726,6 +14767,10 @@ async function loadPaneView(sid, pane, view, scroll) {
|
|
|
14726
14767
|
await loadScratchpadPaneView(pane, view);
|
|
14727
14768
|
return;
|
|
14728
14769
|
}
|
|
14770
|
+
if (pane.kind === 'shell') {
|
|
14771
|
+
loadShellPaneView(pane, view);
|
|
14772
|
+
return;
|
|
14773
|
+
}
|
|
14729
14774
|
const data = await getJson('/api/preview', null, { query: { path: pane.target } });
|
|
14730
14775
|
if (data?.kind === 'html') {
|
|
14731
14776
|
// A show card's own zoom follows the text zoom (showBridge), so its frame is not .modal-zoomable.
|
|
@@ -14967,6 +15012,7 @@ function focusActivePane() {
|
|
|
14967
15012
|
function focusPaneTarget(target) {
|
|
14968
15013
|
target.focus({ preventScroll: true });
|
|
14969
15014
|
target.contentWindow?.focus();
|
|
15015
|
+
shellFrames.get(target)?.post('focus');
|
|
14970
15016
|
}
|
|
14971
15017
|
|
|
14972
15018
|
function isPaneDocOnScreen() {
|
|
@@ -14994,6 +15040,7 @@ function unmountPane(sid, paneId) {
|
|
|
14994
15040
|
const hadFocus = view?.contains(document.activeElement);
|
|
14995
15041
|
view?.remove();
|
|
14996
15042
|
paneFrames.delete(key);
|
|
15043
|
+
shellFrames.delete(view?.querySelector('.pane-shell-frame'));
|
|
14997
15044
|
// Chrome leaves the window without focus when a focused frame is removed, so no key reaches
|
|
14998
15045
|
// the board until a click. Only when it had focus: under the hub, cck may be off screen.
|
|
14999
15046
|
if (hadFocus) window.focus();
|
|
@@ -15008,7 +15055,7 @@ function selectPane(id) {
|
|
|
15008
15055
|
}
|
|
15009
15056
|
|
|
15010
15057
|
// Flips the focused side of the split through the free tabs. Returns false with no split on
|
|
15011
|
-
// screen, so the key keeps its other meaning.
|
|
15058
|
+
// screen or no other free tab, so the key keeps its other meaning.
|
|
15012
15059
|
function cyclePane(step) {
|
|
15013
15060
|
const sid = paneSessionId();
|
|
15014
15061
|
const split = sid && !wantsTerminal() && getPaneSplit(sid);
|
|
@@ -15016,7 +15063,7 @@ function cyclePane(step) {
|
|
|
15016
15063
|
const active = getActivePaneId(sid);
|
|
15017
15064
|
const pairs = getPanePairs(sid);
|
|
15018
15065
|
const ids = freePaneTabs(sid, active, pairs);
|
|
15019
|
-
if (ids.length < 2) return
|
|
15066
|
+
if (ids.length < 2) return false;
|
|
15020
15067
|
const next = ids[(ids.indexOf(active) + step + ids.length) % ids.length];
|
|
15021
15068
|
const side = splitSideOf(split, active);
|
|
15022
15069
|
setPanePairs(
|
|
@@ -15170,6 +15217,10 @@ async function reloadPane(id) {
|
|
|
15170
15217
|
if (!pane) return;
|
|
15171
15218
|
const sid = paneSessionId();
|
|
15172
15219
|
const view = paneFrames.get(`${sid}/${pane.id}`);
|
|
15220
|
+
if (pane.kind === 'shell') {
|
|
15221
|
+
await restartShellPane(sid, pane);
|
|
15222
|
+
return;
|
|
15223
|
+
}
|
|
15173
15224
|
if (pane.kind !== 'url' && pane.kind !== 'scratchpad' && view) {
|
|
15174
15225
|
await reloadPaneView(sid, pane, view);
|
|
15175
15226
|
} else {
|
|
@@ -15182,7 +15233,7 @@ async function reloadPane(id) {
|
|
|
15182
15233
|
|
|
15183
15234
|
function openPaneExternally(id) {
|
|
15184
15235
|
const pane = paneById(id);
|
|
15185
|
-
if (!pane) return;
|
|
15236
|
+
if (!pane || pane.kind === 'shell') return;
|
|
15186
15237
|
if (pane.kind === 'message') {
|
|
15187
15238
|
openPaneMessageDetail(pane);
|
|
15188
15239
|
return;
|
|
@@ -15206,7 +15257,8 @@ async function openPaneMessageDetail(pane) {
|
|
|
15206
15257
|
function copyPaneTarget(id) {
|
|
15207
15258
|
const pane = paneById(id);
|
|
15208
15259
|
if (!pane) return;
|
|
15209
|
-
|
|
15260
|
+
if (pane.kind === 'shell') copyText(pane.cwd || '', 'path');
|
|
15261
|
+
else copyText(pane.target, pane.kind === 'url' ? 'URL' : 'path');
|
|
15210
15262
|
}
|
|
15211
15263
|
|
|
15212
15264
|
function closePaneMenu(restore) {
|
|
@@ -15373,29 +15425,31 @@ function openPaneMenu(x, y, id) {
|
|
|
15373
15425
|
if (!pane) return false;
|
|
15374
15426
|
const url = pane.kind === 'url';
|
|
15375
15427
|
const message = pane.kind === 'message';
|
|
15376
|
-
const
|
|
15428
|
+
const shell = pane.kind === 'shell';
|
|
15377
15429
|
showPaneMenu(
|
|
15378
15430
|
x,
|
|
15379
15431
|
y,
|
|
15380
15432
|
pane.id,
|
|
15381
15433
|
'Pane actions',
|
|
15382
|
-
paneMenuLabel(pane,
|
|
15383
|
-
(message ? '' : paneMenuItem('copy', url ? 'Copy URL' : 'Copy path')) +
|
|
15384
|
-
|
|
15385
|
-
'
|
|
15386
|
-
|
|
15387
|
-
|
|
15388
|
-
|
|
15389
|
-
|
|
15390
|
-
|
|
15391
|
-
|
|
15392
|
-
|
|
15393
|
-
|
|
15394
|
-
|
|
15434
|
+
paneMenuLabel(pane, paneLabel(pane)) +
|
|
15435
|
+
(message ? '' : paneMenuItem('copy', url ? 'Copy URL' : shell ? 'Copy folder path' : 'Copy path')) +
|
|
15436
|
+
(shell
|
|
15437
|
+
? ''
|
|
15438
|
+
: paneMenuItem(
|
|
15439
|
+
'open',
|
|
15440
|
+
url
|
|
15441
|
+
? 'Open in new tab'
|
|
15442
|
+
: message
|
|
15443
|
+
? 'Open in message dialog'
|
|
15444
|
+
: pane.kind === 'scratchpad'
|
|
15445
|
+
? 'Open in scratch viewer'
|
|
15446
|
+
: 'Open in preview',
|
|
15447
|
+
)) +
|
|
15448
|
+
(message || shell
|
|
15395
15449
|
? ''
|
|
15396
15450
|
: paneMenuItem('link', paneIsLinked(pane) ? 'Remove from linked documents' : 'Add to linked documents')) +
|
|
15397
15451
|
paneMenuItem('rename', 'Rename') +
|
|
15398
|
-
paneMenuItem('reload', 'Reload') +
|
|
15452
|
+
paneMenuItem('reload', shell ? 'Restart shell' : 'Reload') +
|
|
15399
15453
|
(url ? paneMenuItem('dock', pane.dock ? 'Remove from the dock' : 'Dock beside the terminal') : '') +
|
|
15400
15454
|
paneGroupMenuItems(pane.id) +
|
|
15401
15455
|
paneMenuItem('close', 'Close pane'),
|
|
@@ -15644,8 +15698,13 @@ function movePanePopHighlight(step) {
|
|
|
15644
15698
|
}
|
|
15645
15699
|
|
|
15646
15700
|
function openPanePop() {
|
|
15647
|
-
|
|
15701
|
+
const sid = paneSessionId();
|
|
15702
|
+
if (!sid) return;
|
|
15648
15703
|
panePopInput.value = '';
|
|
15704
|
+
const shellBtn = document.getElementById('pane-pop-shell');
|
|
15705
|
+
const folder = getSessionBaseDir(sid);
|
|
15706
|
+
shellBtn.hidden = !terminalAvailable() || !folder;
|
|
15707
|
+
shellBtn.querySelector('.pane-pop-shell-dir').textContent = folder ? pathBasename(folder) : '';
|
|
15649
15708
|
renderPanePopDocs();
|
|
15650
15709
|
panePop.classList.add('visible');
|
|
15651
15710
|
panePopInput.focus();
|
|
@@ -15941,7 +16000,10 @@ panePop.addEventListener('keydown', (e) => {
|
|
|
15941
16000
|
return;
|
|
15942
16001
|
}
|
|
15943
16002
|
if (e.target !== panePopInput) return;
|
|
15944
|
-
if (e.key === 'Enter') {
|
|
16003
|
+
if (e.key === 'Enter' && e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey) {
|
|
16004
|
+
e.preventDefault();
|
|
16005
|
+
if (!document.getElementById('pane-pop-shell').hidden) addShellPane();
|
|
16006
|
+
} else if (e.key === 'Enter') {
|
|
15945
16007
|
e.preventDefault();
|
|
15946
16008
|
addPane(panePopMatches[panePopIdx] ?? panePopInput.value);
|
|
15947
16009
|
} else if (matchKey(e, 'ArrowDown', 'ArrowUp')) {
|
|
@@ -16208,10 +16270,7 @@ function syncTerminal() {
|
|
|
16208
16270
|
if (view !== termState.syncedView) {
|
|
16209
16271
|
termState.syncedView = view;
|
|
16210
16272
|
// The terminal shows the same conversation, so the log panel only takes width; it comes back when the terminal goes.
|
|
16211
|
-
if (on &&
|
|
16212
|
-
setMessagePanelVisible(false);
|
|
16213
|
-
logAutoOpened = false;
|
|
16214
|
-
} else if (on && messagePanelOpen) {
|
|
16273
|
+
if (on && messagePanelOpen) {
|
|
16215
16274
|
toggleMessagePanel();
|
|
16216
16275
|
termState.panelHidden = true;
|
|
16217
16276
|
} else if (!on && arrived && termState.panelHidden) toggleMessagePanel();
|
|
@@ -16330,13 +16389,31 @@ function ensureTerminalFrame() {
|
|
|
16330
16389
|
return ready;
|
|
16331
16390
|
}
|
|
16332
16391
|
|
|
16333
|
-
function
|
|
16334
|
-
|
|
16392
|
+
function createTerminalFrame(
|
|
16393
|
+
className,
|
|
16394
|
+
title,
|
|
16395
|
+
origin = termFrame.sameOrigin ? location.origin : terminalFrameOrigin(),
|
|
16396
|
+
) {
|
|
16335
16397
|
const el = document.createElement('iframe');
|
|
16336
|
-
el.className =
|
|
16337
|
-
el.title =
|
|
16398
|
+
el.className = className;
|
|
16399
|
+
el.title = title;
|
|
16338
16400
|
el.allow = 'clipboard-read; clipboard-write';
|
|
16339
16401
|
el.src = `${origin}/terminal.html#p=${encodeURIComponent(location.origin)}`;
|
|
16402
|
+
return { el, origin };
|
|
16403
|
+
}
|
|
16404
|
+
|
|
16405
|
+
// The answer to a frame's `loaded`: the frame is new, so it gets everything again.
|
|
16406
|
+
function initTerminalFrame(frameState, post) {
|
|
16407
|
+
const themeOptions = terminalThemeOptions();
|
|
16408
|
+
frameState.inited = false;
|
|
16409
|
+
frameState.claims = null;
|
|
16410
|
+
frameState.theme = JSON.stringify(themeOptions);
|
|
16411
|
+
post('init', terminalInitOptions(themeOptions));
|
|
16412
|
+
}
|
|
16413
|
+
|
|
16414
|
+
function loadTerminalFrame(origin, timeoutMs) {
|
|
16415
|
+
termFrame.el?.remove();
|
|
16416
|
+
const { el } = createTerminalFrame('terminal-frame', 'Terminal', origin);
|
|
16340
16417
|
resetTerminalFrame({ el, origin });
|
|
16341
16418
|
return new Promise((resolve, reject) => {
|
|
16342
16419
|
const timer = setTimeout(() => {
|
|
@@ -16359,6 +16436,7 @@ function sendTerminalTheme() {
|
|
|
16359
16436
|
for (const [frame, post] of [
|
|
16360
16437
|
[termFrame, postToTerminalFrame],
|
|
16361
16438
|
[kanbotState, postToKanbotFrame],
|
|
16439
|
+
...[...shellFrames.values()].map((s) => [s, s.post]),
|
|
16362
16440
|
]) {
|
|
16363
16441
|
if (!frame.inited || key === frame.theme) continue;
|
|
16364
16442
|
frame.theme = key;
|
|
@@ -16551,7 +16629,15 @@ function pushTerminalClaims() {
|
|
|
16551
16629
|
const bridged = bridgedFrameEls();
|
|
16552
16630
|
const urlFrames = urlPaneFrames();
|
|
16553
16631
|
const dockEls = dockFrameEls();
|
|
16554
|
-
if (
|
|
16632
|
+
if (
|
|
16633
|
+
!termFrame.inited &&
|
|
16634
|
+
!kanbotState.inited &&
|
|
16635
|
+
!bridged.length &&
|
|
16636
|
+
!urlFrames.length &&
|
|
16637
|
+
!dockEls.length &&
|
|
16638
|
+
!shellFrames.size
|
|
16639
|
+
)
|
|
16640
|
+
return;
|
|
16555
16641
|
const claims = keyClaims();
|
|
16556
16642
|
const base = bridgeClaims(claims);
|
|
16557
16643
|
sendBridgeClaimsAll(bridged, base);
|
|
@@ -16560,6 +16646,10 @@ function pushTerminalClaims() {
|
|
|
16560
16646
|
const sig = JSON.stringify(claims);
|
|
16561
16647
|
sendFrameClaims(kanbotState, claims, sig, postToKanbotFrame);
|
|
16562
16648
|
sendFrameClaims(termFrame, claims, sig, terminalFrameSend);
|
|
16649
|
+
if (!shellFrames.size) return;
|
|
16650
|
+
const shellClaims = { ...claims, keys: [...claims.keys, ...SHELL_PANE_CLAIMS] };
|
|
16651
|
+
const shellSig = JSON.stringify(shellClaims);
|
|
16652
|
+
for (const s of shellFrames.values()) sendFrameClaims(s, shellClaims, shellSig, s.post);
|
|
16563
16653
|
});
|
|
16564
16654
|
}
|
|
16565
16655
|
|
|
@@ -16617,6 +16707,7 @@ function adjustTerminalFontSize(step) {
|
|
|
16617
16707
|
else store.setItem(TERMINAL_FONT_KEY, String(size));
|
|
16618
16708
|
termState.fontSize = size;
|
|
16619
16709
|
terminalFrameSend('font', { size });
|
|
16710
|
+
for (const s of shellFrames.values()) if (s.inited) s.post('font', { size });
|
|
16620
16711
|
layoutShow();
|
|
16621
16712
|
}
|
|
16622
16713
|
showToast(`Terminal ${size}px`);
|
|
@@ -17046,7 +17137,13 @@ async function renderTerminalManager() {
|
|
|
17046
17137
|
body.innerHTML = list
|
|
17047
17138
|
.map((t) => {
|
|
17048
17139
|
const session = sessions.find((s) => s.id === t.id);
|
|
17049
|
-
const name = t.kanbot
|
|
17140
|
+
const name = t.kanbot
|
|
17141
|
+
? 'Kanbot'
|
|
17142
|
+
: t.pane
|
|
17143
|
+
? `Shell pane · ${pathBasename(t.cwd)}`
|
|
17144
|
+
: session
|
|
17145
|
+
? sessionDisplayName(session)
|
|
17146
|
+
: t.id.slice(0, 8);
|
|
17050
17147
|
const here = t.id === termState.sessionId ? '<span class="terminal-manager-here">this tab</span>' : '';
|
|
17051
17148
|
const attached = t.clients ? `${t.clients} attached` : 'detached';
|
|
17052
17149
|
return `<div class="terminal-manager-row${t.clients ? ' attached' : ''}">
|
|
@@ -17062,7 +17159,7 @@ async function renderTerminalManager() {
|
|
|
17062
17159
|
</div>
|
|
17063
17160
|
</div>
|
|
17064
17161
|
<div class="terminal-manager-actions">
|
|
17065
|
-
|
|
17162
|
+
${t.pane ? '' : `<button type="button" class="btn btn-secondary" data-open="${escapeHtml(t.id)}"${t.kanbot ? ' data-kanbot' : ''}>Open</button>`}
|
|
17066
17163
|
<button type="button" class="btn btn-secondary terminal-manager-end" data-end="${escapeHtml(t.id)}" data-started="${escapeHtml(String(Number(t.startedAt) || 0))}">End</button>
|
|
17067
17164
|
</div>
|
|
17068
17165
|
</div>`;
|
|
@@ -17255,12 +17352,8 @@ function toggleKanbot(force) {
|
|
|
17255
17352
|
}
|
|
17256
17353
|
kanbotState.frame?.focus();
|
|
17257
17354
|
if (!kanbotState.frame) {
|
|
17258
|
-
const frame =
|
|
17259
|
-
|
|
17260
|
-
frame.title = 'Kanbot';
|
|
17261
|
-
frame.allow = 'clipboard-read; clipboard-write';
|
|
17262
|
-
kanbotState.origin = termFrame.sameOrigin ? location.origin : terminalFrameOrigin();
|
|
17263
|
-
frame.src = `${kanbotState.origin}/terminal.html#p=${encodeURIComponent(location.origin)}`;
|
|
17355
|
+
const { el: frame, origin } = createTerminalFrame('kanbot-frame', 'Kanbot');
|
|
17356
|
+
kanbotState.origin = origin;
|
|
17264
17357
|
kanbotState.frame = frame;
|
|
17265
17358
|
el.querySelector('.kanbot-body').appendChild(frame);
|
|
17266
17359
|
return;
|
|
@@ -17303,11 +17396,7 @@ window.addEventListener('message', (e) => {
|
|
|
17303
17396
|
if (typeof m?.type !== 'string' || !m.type.startsWith(TERMINAL_MSG)) return;
|
|
17304
17397
|
const t = m.type.slice(TERMINAL_MSG.length);
|
|
17305
17398
|
if (t === 'loaded') {
|
|
17306
|
-
|
|
17307
|
-
kanbotState.inited = false;
|
|
17308
|
-
kanbotState.claims = null;
|
|
17309
|
-
kanbotState.theme = JSON.stringify(themeOptions);
|
|
17310
|
-
postToKanbotFrame('init', terminalInitOptions(themeOptions));
|
|
17399
|
+
initTerminalFrame(kanbotState, postToKanbotFrame);
|
|
17311
17400
|
return;
|
|
17312
17401
|
}
|
|
17313
17402
|
if (t === 'term') {
|
|
@@ -17339,6 +17428,155 @@ window.addEventListener('message', (e) => {
|
|
|
17339
17428
|
|
|
17340
17429
|
//#endregion
|
|
17341
17430
|
|
|
17431
|
+
//#region SHELL_PANES
|
|
17432
|
+
// A plain shell in a pane (kind `shell`): its own terminal frame, like Kanbot's, on a PTY in shell mode
|
|
17433
|
+
// that belongs to no session. The PTY outlives the frame, so an evicted view attaches again and gets
|
|
17434
|
+
// its screen back; closing the pane ends it on the server.
|
|
17435
|
+
// Only keys a shell does not type: the pane switch and close keys and the session tab keys.
|
|
17436
|
+
const SHELL_PANE_CLAIMS = [
|
|
17437
|
+
...['BracketLeft', 'BracketRight', 'KeyW'].map((code) => ({ altKey: true, key: 'Unidentified', code })),
|
|
17438
|
+
...['BracketLeft', 'BracketRight', 'Backslash'].map((code) => ({
|
|
17439
|
+
altKey: true,
|
|
17440
|
+
shiftKey: true,
|
|
17441
|
+
key: 'Unidentified',
|
|
17442
|
+
code,
|
|
17443
|
+
})),
|
|
17444
|
+
...'123456789'.split('').map((n) => ({ ctrlKey: true, altKey: true, key: 'Unidentified', code: `Digit${n}` })),
|
|
17445
|
+
];
|
|
17446
|
+
const SHELL_RETRY_MS = 1000;
|
|
17447
|
+
const SHELL_RETRIES = 5;
|
|
17448
|
+
|
|
17449
|
+
function loadShellPaneView(pane, view) {
|
|
17450
|
+
if (!terminalAvailable()) {
|
|
17451
|
+
view.insertAdjacentHTML(
|
|
17452
|
+
'beforeend',
|
|
17453
|
+
paneCardHtml(
|
|
17454
|
+
'The terminal is off',
|
|
17455
|
+
'A shell pane runs in the embedded terminal, which this board does not have.',
|
|
17456
|
+
),
|
|
17457
|
+
);
|
|
17458
|
+
return;
|
|
17459
|
+
}
|
|
17460
|
+
const { el, origin } = createTerminalFrame('pane-frame pane-shell-frame', pane.title);
|
|
17461
|
+
const post = (t, data) => el.contentWindow?.postMessage({ ...data, type: TERMINAL_MSG + t }, origin);
|
|
17462
|
+
shellFrames.set(el, { el, origin, post, ptyId: pane.target, inited: false, socketId: 0, ended: false, retries: 0 });
|
|
17463
|
+
view.appendChild(el);
|
|
17464
|
+
}
|
|
17465
|
+
|
|
17466
|
+
function openShellFrame(s) {
|
|
17467
|
+
s.ended = false;
|
|
17468
|
+
setShellCard(s.el);
|
|
17469
|
+
s.post('open', { socketId: ++s.socketId, reset: true, hello: { token: terminalToken, id: s.ptyId, mode: 'shell' } });
|
|
17470
|
+
}
|
|
17471
|
+
|
|
17472
|
+
// No title takes the card away.
|
|
17473
|
+
function setShellCard(el, title, text, button) {
|
|
17474
|
+
const view = el.parentElement;
|
|
17475
|
+
view?.querySelector('.pane-shell-card')?.remove();
|
|
17476
|
+
el.hidden = !!title;
|
|
17477
|
+
if (!title || !view) return;
|
|
17478
|
+
view.insertAdjacentHTML('beforeend', paneCardHtml(title, text, button, { attr: 'data-shell-restart' }));
|
|
17479
|
+
view.lastElementChild.classList.add('pane-shell-card');
|
|
17480
|
+
}
|
|
17481
|
+
|
|
17482
|
+
async function restartShellPane(sid, pane) {
|
|
17483
|
+
await terminalFetch(apiPath`/api/terminals/${pane.target}`, 'DELETE').catch(() => {});
|
|
17484
|
+
unmountPane(sid, pane.id);
|
|
17485
|
+
syncPanes();
|
|
17486
|
+
focusActivePane();
|
|
17487
|
+
}
|
|
17488
|
+
|
|
17489
|
+
function addShellPane() {
|
|
17490
|
+
const sid = paneSessionId();
|
|
17491
|
+
if (!sid) return;
|
|
17492
|
+
const typed = panePopInput.value.trim();
|
|
17493
|
+
closePanePop();
|
|
17494
|
+
openShellForSession(sid, typed && !linkUrl(typed) ? typed : undefined);
|
|
17495
|
+
}
|
|
17496
|
+
|
|
17497
|
+
// Panes hide behind the Claude terminal, so the session leaves terminal mode to show the shell.
|
|
17498
|
+
// The server checks `folder`, so a typed path that is no folder ends in its error toast.
|
|
17499
|
+
async function openShellForSession(sid, folder = getSessionBaseDir(sid)) {
|
|
17500
|
+
if (!folder) {
|
|
17501
|
+
showToast('This session has no folder to start a shell in', 'error');
|
|
17502
|
+
return;
|
|
17503
|
+
}
|
|
17504
|
+
if (sid !== paneSessionId()) await openSession(sid);
|
|
17505
|
+
if (wantsTerminalFor(sid)) exitTerminalMode(sid);
|
|
17506
|
+
if (!(await postPane(sid, { kind: 'shell', target: folder }))) return;
|
|
17507
|
+
syncPanes();
|
|
17508
|
+
focusActivePane();
|
|
17509
|
+
}
|
|
17510
|
+
|
|
17511
|
+
window.addEventListener('message', (e) => {
|
|
17512
|
+
const m = e.data;
|
|
17513
|
+
if (!shellFrames.size || typeof m?.type !== 'string' || !m.type.startsWith(TERMINAL_MSG)) return;
|
|
17514
|
+
let s = null;
|
|
17515
|
+
for (const f of shellFrames.values()) if (f.el.contentWindow === e.source) s = f;
|
|
17516
|
+
if (!s || e.origin !== s.origin) return;
|
|
17517
|
+
const el = s.el;
|
|
17518
|
+
const t = m.type.slice(TERMINAL_MSG.length);
|
|
17519
|
+
if (t === 'loaded') {
|
|
17520
|
+
initTerminalFrame(s, s.post);
|
|
17521
|
+
return;
|
|
17522
|
+
}
|
|
17523
|
+
if (t === 'term') {
|
|
17524
|
+
s.inited = true;
|
|
17525
|
+
pushTerminalClaims();
|
|
17526
|
+
openShellFrame(s);
|
|
17527
|
+
if (document.activeElement === el) s.post('focus');
|
|
17528
|
+
return;
|
|
17529
|
+
}
|
|
17530
|
+
if (t === 'key') {
|
|
17531
|
+
replayKey(m, el);
|
|
17532
|
+
return;
|
|
17533
|
+
}
|
|
17534
|
+
if (t === 'link') {
|
|
17535
|
+
openTerminalLink(m.href);
|
|
17536
|
+
return;
|
|
17537
|
+
}
|
|
17538
|
+
if (t === 'focused') {
|
|
17539
|
+
focusSideOf(el.closest('.pane-view'));
|
|
17540
|
+
return;
|
|
17541
|
+
}
|
|
17542
|
+
if (m.socketId !== s.socketId) return;
|
|
17543
|
+
if (t === 'ws') {
|
|
17544
|
+
if (m.msg?.t === 'ready') s.retries = 0;
|
|
17545
|
+
else if (m.msg?.t === 'exit') {
|
|
17546
|
+
s.ended = true;
|
|
17547
|
+
const clean = m.msg.code === 0 || m.msg.ended;
|
|
17548
|
+
setShellCard(
|
|
17549
|
+
el,
|
|
17550
|
+
'The shell exited',
|
|
17551
|
+
clean ? 'Start a new shell in this pane.' : `Exit code ${m.msg.code}.`,
|
|
17552
|
+
'Restart',
|
|
17553
|
+
);
|
|
17554
|
+
} else if (m.msg?.t === 'error') {
|
|
17555
|
+
s.ended = true;
|
|
17556
|
+
if (m.msg.msg === STALE_TOKEN_MSG) {
|
|
17557
|
+
refreshTerminalToken().then((ok) => ok && el.isConnected && openShellFrame(s));
|
|
17558
|
+
return;
|
|
17559
|
+
}
|
|
17560
|
+
setShellCard(el, 'The shell did not start', m.msg.msg || 'Terminal error', 'Try again');
|
|
17561
|
+
}
|
|
17562
|
+
} else if (t === 'close' && !s.ended && el.isConnected) {
|
|
17563
|
+
if (s.retries++ < SHELL_RETRIES) setTimeout(() => el.isConnected && !s.ended && openShellFrame(s), SHELL_RETRY_MS);
|
|
17564
|
+
else setShellCard(el, 'Lost the connection to the shell', 'The shell may still run on the board.', 'Reconnect');
|
|
17565
|
+
}
|
|
17566
|
+
});
|
|
17567
|
+
|
|
17568
|
+
paneViews.addEventListener('click', (e) => {
|
|
17569
|
+
const view = e.target.closest('[data-shell-restart]')?.closest('.pane-view');
|
|
17570
|
+
const el = view?.querySelector('.pane-shell-frame');
|
|
17571
|
+
const s = el && shellFrames.get(el);
|
|
17572
|
+
if (!s?.inited) return;
|
|
17573
|
+
s.retries = 0;
|
|
17574
|
+
openShellFrame(s);
|
|
17575
|
+
focusPaneTarget(el);
|
|
17576
|
+
});
|
|
17577
|
+
|
|
17578
|
+
//#endregion
|
|
17579
|
+
|
|
17342
17580
|
//#region ASK
|
|
17343
17581
|
// The question the session in the embedded terminal asks with the ask tool; the tool call waits for
|
|
17344
17582
|
// the answer. Hiding keeps the frame, so a half-filled card comes back as it was. Only an answer, a
|
|
@@ -18134,7 +18372,7 @@ new MutationObserver(() => {
|
|
|
18134
18372
|
});
|
|
18135
18373
|
}).observe(document.body, { attributes: true, attributeFilter: ['class', 'data-color-theme', 'style'] });
|
|
18136
18374
|
|
|
18137
|
-
const PANE_SHOW_FRAMES = '.show-pane-frame, .themed-frame, .ask-frame, .dock-addon-frame';
|
|
18375
|
+
const PANE_SHOW_FRAMES = '.show-pane-frame, .themed-frame, .ask-frame, .dock-addon-frame, .pane-url-frame';
|
|
18138
18376
|
|
|
18139
18377
|
// Builds the message only when a frame is there, because showTokens forces a style recalc.
|
|
18140
18378
|
function postToShowFrames(makeMsg, frames = [showState.frame, ...document.querySelectorAll(PANE_SHOW_FRAMES)]) {
|
|
@@ -18365,7 +18603,8 @@ function renderDockAddon(pane) {
|
|
|
18365
18603
|
if (pane) {
|
|
18366
18604
|
if (!panel.firstChild) {
|
|
18367
18605
|
panel.innerHTML = `<header class="show-head dock-addon-head" tabindex="-1"><span class="show-nav"><span class="show-title"></span></span>
|
|
18368
|
-
<span class="show-actions">${showBtnHtml('dock', '
|
|
18606
|
+
<span class="show-actions">${showBtnHtml('dock', 'pane', 'pane', 'Open as a pane of the session')}
|
|
18607
|
+
${showBtnHtml('dock', 'open', 'external', 'Open in a new tab')}
|
|
18369
18608
|
${showBtnHtml('dock', 'expand', 'expand', 'Fill the terminal · Alt+Enter')}
|
|
18370
18609
|
${showBtnHtml('dock', 'reload', 'reload', 'Reload')}
|
|
18371
18610
|
${showBtnHtml('dock', 'remove', 'clear', 'Remove from the rail')}
|
|
@@ -18378,6 +18617,7 @@ function renderDockAddon(pane) {
|
|
|
18378
18617
|
const open = panel.querySelector('[data-dock="open"]');
|
|
18379
18618
|
open.title = `Open ${pane.target} in a new tab`;
|
|
18380
18619
|
open.setAttribute('aria-label', open.title);
|
|
18620
|
+
panel.querySelector('[data-dock="pane"]').hidden = !pane.addon;
|
|
18381
18621
|
panel.classList.toggle('expanded', dockExpanded);
|
|
18382
18622
|
panel.style.setProperty('--show-term-font', `${currentTerminalFontSize()}px`);
|
|
18383
18623
|
const expand = panel.querySelector('[data-dock="expand"]');
|
|
@@ -18421,11 +18661,6 @@ function createDockView(pane) {
|
|
|
18421
18661
|
if (pane.run && !dockAddonUp.has(pane.id)) return startDockAddon(pane);
|
|
18422
18662
|
const frame = paneUrlFrame(pane, 'dock-addon-frame');
|
|
18423
18663
|
frame.dataset.target = pane.target;
|
|
18424
|
-
frame.addEventListener('load', () => {
|
|
18425
|
-
postToShowFrames(() => ({ type: `${SHOW_MSG}tokens`, tokens: showTokens() }), [frame]);
|
|
18426
|
-
frame.hostKeysSig = null;
|
|
18427
|
-
pushTerminalClaims();
|
|
18428
|
-
});
|
|
18429
18664
|
if (pane.addon || paneFraming.get(pane.target)) return frame;
|
|
18430
18665
|
const sid = dockSid;
|
|
18431
18666
|
probePaneFraming(sid, pane).then((frameable) => {
|
|
@@ -18628,6 +18863,7 @@ function initDockRail() {
|
|
|
18628
18863
|
if (e.target.closest('[data-dock="close"]')) dockRailCommand(pane.id);
|
|
18629
18864
|
else if (e.target.closest('[data-dock="expand"]')) setDockExpanded(!dockExpanded);
|
|
18630
18865
|
else if (e.target.closest('[data-dock="remove"]')) removeDockItem(pane);
|
|
18866
|
+
else if (e.target.closest('[data-dock="pane"]')) addPaneToSession(dockSid, pane.target, pane.title);
|
|
18631
18867
|
else if (e.target.closest('[data-dock="reload"]')) {
|
|
18632
18868
|
dockAddonUp.delete(pane.id);
|
|
18633
18869
|
dropDockView(pane.id);
|
|
@@ -18835,6 +19071,12 @@ function placeholderSession(id, spec) {
|
|
|
18835
19071
|
prompted: !!(spec.prompted || spec.prompt),
|
|
18836
19072
|
name: spec.name || (spec.forkOf && forkLabel(spec.forkOf)) || PLACEHOLDER_NAMES[spec.mode] || PLACEHOLDER_NAMES.new,
|
|
18837
19073
|
dispatched: spec.mode === 'dispatch' ? { parent: spec.parent || null, child: !!spec.child } : undefined,
|
|
19074
|
+
nest:
|
|
19075
|
+
spec.mode === 'dispatch'
|
|
19076
|
+
? { parent: spec.parent || null, child: !!spec.child }
|
|
19077
|
+
: spec.forkOf
|
|
19078
|
+
? { parent: spec.forkOf, child: true }
|
|
19079
|
+
: undefined,
|
|
18838
19080
|
project: spec.cwd,
|
|
18839
19081
|
worktree: spec.worktree ? { repo: spec.cwd, name: spec.worktree === true ? 'new' : spec.worktree } : null,
|
|
18840
19082
|
modifiedAt: new Date(spec.startedAt).toISOString(),
|
|
@@ -19609,6 +19851,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
19609
19851
|
|
|
19610
19852
|
loadSidebarState();
|
|
19611
19853
|
for (const p of readStoredList(COLLAPSED_GROUPS_KEY)) collapsedProjectGroups.add(p);
|
|
19854
|
+
setZenScope(zenGroup, zenProject);
|
|
19612
19855
|
syncSessionGroups();
|
|
19613
19856
|
initSessionGroupsDnd();
|
|
19614
19857
|
initSessionPicker();
|
|
@@ -19814,6 +20057,7 @@ if (urlState.search) {
|
|
|
19814
20057
|
getJson('/api/config')
|
|
19815
20058
|
.then((c) => {
|
|
19816
20059
|
if (c) appConfig = c;
|
|
20060
|
+
syncTerminalHost();
|
|
19817
20061
|
if (appConfig.kanbot && footerState.version) renderSidebarFooter(footerState.rl);
|
|
19818
20062
|
})
|
|
19819
20063
|
.then(restorePendingSessions)
|
|
@@ -19851,7 +20095,6 @@ getJson('/api/config')
|
|
|
19851
20095
|
}
|
|
19852
20096
|
if (focusZoneBeforeReload === 'sidebar') setFocusZone('sidebar');
|
|
19853
20097
|
if (urlState.messages && currentSessionId) {
|
|
19854
|
-
if (logAutoOpened) setMessagePanelVisible(false);
|
|
19855
20098
|
toggleMessagePanel();
|
|
19856
20099
|
// Re-render after panel layout settles so scroll dimensions are correct
|
|
19857
20100
|
requestAnimationFrame(() => {
|