jupyterlab_ai_code_assistants_extension 1.2.73 → 1.2.99
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/README.md +6 -5
- package/lib/core/colour.d.ts +2 -10
- package/lib/core/colour.js +8 -18
- package/lib/core/modes.d.ts +2 -2
- package/lib/core/panel.d.ts +15 -43
- package/lib/core/panel.js +111 -226
- package/lib/core/popup.d.ts +1 -1
- package/lib/core/popup.js +52 -11
- package/lib/core/request.js +13 -6
- package/lib/core/terminals.d.ts +2 -33
- package/lib/core/terminals.js +24 -100
- package/lib/core/types.d.ts +13 -33
- package/lib/providers/claude.js +4 -11
- package/lib/providers/codex.js +9 -12
- package/lib/providers/deepseek.d.ts +1 -2
- package/lib/providers/deepseek.js +14 -35
- package/lib/providers/gemini.js +1 -9
- package/lib/providers/kimi.js +0 -6
- package/package.json +1 -1
- package/src/__tests__/colour.spec.ts +11 -19
- package/src/__tests__/launcher.spec.ts +1 -3
- package/src/__tests__/panel.spec.ts +252 -238
- package/src/__tests__/popup.spec.ts +105 -2
- package/src/__tests__/registry.spec.ts +1 -4
- package/src/__tests__/tab-colour-capture.spec.ts +48 -3
- package/src/__tests__/terminals.spec.ts +29 -143
- package/src/core/colour.ts +8 -23
- package/src/core/modes.ts +2 -2
- package/src/core/panel.ts +118 -270
- package/src/core/popup.ts +58 -12
- package/src/core/request.ts +13 -6
- package/src/core/terminals.ts +30 -118
- package/src/core/types.ts +13 -34
- package/src/index.ts +2 -2
- package/src/providers/claude.ts +4 -11
- package/src/providers/codex.ts +9 -12
- package/src/providers/deepseek.ts +15 -37
- package/src/providers/gemini.ts +1 -9
- package/src/providers/kimi.ts +0 -6
- package/style/base.css +76 -37
package/lib/core/panel.js
CHANGED
|
@@ -32,10 +32,6 @@ const MENU_STATE_BUDGET_MS = 800;
|
|
|
32
32
|
* without a floor the spinner shows for a frame and the click reads as
|
|
33
33
|
* "nothing happened". */
|
|
34
34
|
const REFRESH_SPIN_FLOOR_MS = 500;
|
|
35
|
-
// After a fork is requested, watch for its lazily-written store entry at this
|
|
36
|
-
// faster cadence (bounded) so a new branch surfaces in seconds.
|
|
37
|
-
const BRANCH_WATCH_INTERVAL_MS = 2000;
|
|
38
|
-
const BRANCH_WATCH_MAX_ATTEMPTS = 90; // ~3 minutes
|
|
39
35
|
/** Conversations listed inline in a branch submenu before the popup takes over. */
|
|
40
36
|
const INLINE_BRANCH_LIMIT = 5;
|
|
41
37
|
/** Command id of the sibling extension that spawns a shell-less terminal on a
|
|
@@ -116,6 +112,9 @@ export class AssistantSessionsPanel extends Widget {
|
|
|
116
112
|
this._deleteToTrash = true;
|
|
117
113
|
this._removingPaths = new Set();
|
|
118
114
|
this._loadingEl = null;
|
|
115
|
+
this._busyEl = null;
|
|
116
|
+
this._busyTextEl = null;
|
|
117
|
+
this._busyCount = 0;
|
|
119
118
|
this._errorEl = null;
|
|
120
119
|
this._refreshBtn = null;
|
|
121
120
|
this._filterBtn = null;
|
|
@@ -393,6 +392,28 @@ export class AssistantSessionsPanel extends Widget {
|
|
|
393
392
|
loadingSpinner.className =
|
|
394
393
|
'jp-aiAssistants-spinner jp-AiAssistantsPanel-loadingSpinner';
|
|
395
394
|
loading.appendChild(loadingSpinner);
|
|
395
|
+
// Click-time busy overlay: raised synchronously when a row is opened or
|
|
396
|
+
// branched, before the terminal probe or the branch request, so the click
|
|
397
|
+
// never reads as ignored (DEF-PANE-318). Unlike the refresh veil it takes
|
|
398
|
+
// no pointer events and no focus: the context menu that launched a branch
|
|
399
|
+
// stays open until its command runs, and a focus change would close it.
|
|
400
|
+
const busy = document.createElement('div');
|
|
401
|
+
busy.className = 'jp-AiAssistantsPanel-busyOverlay';
|
|
402
|
+
busy.hidden = true;
|
|
403
|
+
const busySpinner = document.createElement('div');
|
|
404
|
+
busySpinner.className =
|
|
405
|
+
'jp-aiAssistants-spinner jp-AiAssistantsPanel-busySpinner';
|
|
406
|
+
busySpinner.setAttribute('aria-hidden', 'true');
|
|
407
|
+
busy.appendChild(busySpinner);
|
|
408
|
+
// The spinner is decoration; a screen-reader user hears the action
|
|
409
|
+
// instead. The region sits on the root, always rendered and outside the
|
|
410
|
+
// overlay and the aria-busy body: a live region created inside a
|
|
411
|
+
// display:none container, or one whose update lands in an aria-busy
|
|
412
|
+
// subtree, can be withheld by assistive technology.
|
|
413
|
+
const busyText = document.createElement('div');
|
|
414
|
+
busyText.className = 'jp-AiAssistantsPanel-srOnly';
|
|
415
|
+
busyText.setAttribute('role', 'status');
|
|
416
|
+
busyText.setAttribute('aria-live', 'polite');
|
|
396
417
|
// Inline error strip - a failed poll reports here and keeps retrying,
|
|
397
418
|
// rather than tearing the panel down or raising a modal that would also
|
|
398
419
|
// interrupt the other providers' panels.
|
|
@@ -407,10 +428,42 @@ export class AssistantSessionsPanel extends Widget {
|
|
|
407
428
|
root.appendChild(error);
|
|
408
429
|
root.appendChild(body);
|
|
409
430
|
root.appendChild(loading);
|
|
431
|
+
root.appendChild(busy);
|
|
432
|
+
root.appendChild(busyText);
|
|
410
433
|
this._bodyEl = body;
|
|
411
434
|
this._loadingEl = loading;
|
|
435
|
+
this._busyEl = busy;
|
|
436
|
+
this._busyTextEl = busyText;
|
|
412
437
|
this._errorEl = error;
|
|
413
438
|
}
|
|
439
|
+
/** Raise the click-time busy overlay. Counted, because an open and a branch
|
|
440
|
+
* can overlap; the overlay clears when the last one ends. */
|
|
441
|
+
_beginBusy(message) {
|
|
442
|
+
this._busyCount += 1;
|
|
443
|
+
if (this._busyEl) {
|
|
444
|
+
this._busyEl.hidden = false;
|
|
445
|
+
if (this._busyTextEl) {
|
|
446
|
+
this._busyTextEl.textContent = message;
|
|
447
|
+
}
|
|
448
|
+
// The body is what the action changes; the root stays outside the
|
|
449
|
+
// busy subtree so the live region above is not withheld.
|
|
450
|
+
if (this._bodyEl) {
|
|
451
|
+
this._bodyEl.setAttribute('aria-busy', 'true');
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
_endBusy() {
|
|
456
|
+
this._busyCount = Math.max(0, this._busyCount - 1);
|
|
457
|
+
if (this._busyCount === 0 && this._busyEl) {
|
|
458
|
+
this._busyEl.hidden = true;
|
|
459
|
+
if (this._busyTextEl) {
|
|
460
|
+
this._busyTextEl.textContent = '';
|
|
461
|
+
}
|
|
462
|
+
if (this._bodyEl) {
|
|
463
|
+
this._bodyEl.removeAttribute('aria-busy');
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
}
|
|
414
467
|
/** Show / hide the filter input. Hiding also clears the active filter, so
|
|
415
468
|
* the user never returns to an "invisible" filter narrowing the rows. */
|
|
416
469
|
_toggleFilterBar() {
|
|
@@ -750,6 +803,9 @@ export class AssistantSessionsPanel extends Widget {
|
|
|
750
803
|
return resolveLaunchMode(this._descriptor.launchModes, this._modes, force);
|
|
751
804
|
}
|
|
752
805
|
async _openSession(session, force, sessionId) {
|
|
806
|
+
// The click's own feedback, raised before the terminal walk and the
|
|
807
|
+
// launch - both can take seconds (DEF-PANE-318).
|
|
808
|
+
this._beginBusy(this._trans.__('Opening conversation'));
|
|
753
809
|
try {
|
|
754
810
|
await this._terminals.openSession(session, this._launchMode(force), sessionId);
|
|
755
811
|
// Not awaited: the open has succeeded, and the sync is not part of it.
|
|
@@ -764,6 +820,7 @@ export class AssistantSessionsPanel extends Widget {
|
|
|
764
820
|
}
|
|
765
821
|
}
|
|
766
822
|
finally {
|
|
823
|
+
this._endBusy();
|
|
767
824
|
// Reuse or fresh launch, either way the picture changed. Pull fresh
|
|
768
825
|
// state; a poll tick retries if this one fails.
|
|
769
826
|
void this._fetch().catch(() => undefined);
|
|
@@ -898,7 +955,7 @@ export class AssistantSessionsPanel extends Widget {
|
|
|
898
955
|
if (row) {
|
|
899
956
|
// A terminal already holding that conversation IS the answer: a second
|
|
900
957
|
// process on one history is never what the click meant (ACC-LNCH-152).
|
|
901
|
-
const found = await this._terminals.findForSession(row.session_id
|
|
958
|
+
const found = await this._terminals.findForSession(row.session_id);
|
|
902
959
|
if (found) {
|
|
903
960
|
this._terminals.focus(found.widget);
|
|
904
961
|
return found.widget;
|
|
@@ -982,126 +1039,56 @@ export class AssistantSessionsPanel extends Widget {
|
|
|
982
1039
|
void this._fetch().catch(() => undefined);
|
|
983
1040
|
}
|
|
984
1041
|
}
|
|
985
|
-
/**
|
|
986
|
-
*
|
|
987
|
-
* `forkStrategy`.
|
|
988
|
-
*
|
|
989
|
-
* The three strategies differ only in who mints the new id and when it
|
|
990
|
-
* becomes knowable - so the shared part (ask for a name, launch a terminal
|
|
991
|
-
* on the fork, inherit the parent's tint, surface the branch) lives here
|
|
992
|
-
* once, and the strategy decides the payload and the discovery.
|
|
993
|
-
*/
|
|
1042
|
+
/** Branch the active row's current conversation. Every `forkStrategy` has
|
|
1043
|
+
* the server mint the fork, so this is the one path. */
|
|
994
1044
|
async _branchSession(force) {
|
|
995
|
-
var _a;
|
|
996
1045
|
const session = this._activeSession;
|
|
997
1046
|
if (!session) {
|
|
998
1047
|
return;
|
|
999
1048
|
}
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
title: 'Branch Session',
|
|
1005
|
-
label: 'Name for the new session',
|
|
1006
|
-
placeholder: this._lookupName(session)
|
|
1007
|
-
});
|
|
1008
|
-
if (!named.button.accept) {
|
|
1009
|
-
return;
|
|
1010
|
-
}
|
|
1011
|
-
name = ((_a = named.value) !== null && _a !== void 0 ? _a : '').trim();
|
|
1012
|
-
if (!name) {
|
|
1013
|
-
// Reported, not swallowed. The placeholder shows the parent's name,
|
|
1014
|
-
// which reads as the "press Ok for the default" idiom, so Ok on an
|
|
1015
|
-
// empty field was a closed dialog with no POST and no word (DEF-43).
|
|
1016
|
-
// A notification rather than a disabled Ok because that is how this
|
|
1017
|
-
// panel refuses everywhere else - Open Terminal and Show in File
|
|
1018
|
-
// Browser on a folder outside the root - and `InputDialog.getText`
|
|
1019
|
-
// offers no hook to disable Ok while the field is empty; getting one
|
|
1020
|
-
// means replacing the dialog with a hand-built body widget.
|
|
1021
|
-
Notification.warning('Enter a name for the new session - nothing was branched.', { autoClose: 4000 });
|
|
1022
|
-
return;
|
|
1023
|
-
}
|
|
1024
|
-
}
|
|
1025
|
-
if (this._descriptor.forkStrategy === 'server-copy') {
|
|
1026
|
-
await this._branchByServerCopy(session, name, force);
|
|
1027
|
-
return;
|
|
1028
|
-
}
|
|
1029
|
-
if (this._descriptor.forkStrategy === 'native-command') {
|
|
1030
|
-
await this._branchByNativeCommand(session, force, parentColour);
|
|
1031
|
-
return;
|
|
1032
|
-
}
|
|
1033
|
-
await this._branchByNativeFlag(session, name, force, parentColour);
|
|
1034
|
-
}
|
|
1035
|
-
/** The CLI forks from a flag pair and takes the new id from us, so the fork
|
|
1036
|
-
* is known before it exists. Its store entry is written lazily, on the first
|
|
1037
|
-
* turn, so the branch is watched for rather than expected at once. */
|
|
1038
|
-
async _branchByNativeFlag(session, name, force, parentColour) {
|
|
1039
|
-
const forkId = UUID.uuid4();
|
|
1040
|
-
const request = {
|
|
1041
|
-
project_path: session.project_path,
|
|
1042
|
-
// Arms the server's fork pin - without it the fork never becomes the
|
|
1043
|
-
// row's current conversation and recency drags the row back (DEF-9).
|
|
1044
|
-
encoded_path: session.encoded_path,
|
|
1045
|
-
session_id: session.session_id,
|
|
1046
|
-
fork_session_id: forkId,
|
|
1047
|
-
name,
|
|
1048
|
-
mode: this._launchMode(force)
|
|
1049
|
-
};
|
|
1050
|
-
try {
|
|
1051
|
-
await this._terminals.launch(request, forkId);
|
|
1052
|
-
}
|
|
1053
|
-
catch (err) {
|
|
1054
|
-
this._showActionError('Could not branch this session - try again.', err);
|
|
1055
|
-
return;
|
|
1056
|
-
}
|
|
1057
|
-
await this._inheritColour(parentColour, forkId, session.session_id);
|
|
1058
|
-
this._watchForBranch(session.encoded_path, forkId);
|
|
1059
|
-
}
|
|
1060
|
-
/** The CLI owns both the fork verb and the id, so the id has to be
|
|
1061
|
-
* discovered: snapshot the branch ids first, then diff after launch. */
|
|
1062
|
-
async _branchByNativeCommand(session, force, parentColour) {
|
|
1063
|
-
var _a, _b;
|
|
1064
|
-
const known = new Set((_b = (_a = (await this._fetchBranches(session).catch(() => null))) === null || _a === void 0 ? void 0 : _a.branches.map(b => b.session_id)) !== null && _b !== void 0 ? _b : []);
|
|
1065
|
-
known.add(session.session_id);
|
|
1049
|
+
// Raised on the click: the branch POST mints the fork server-side (for
|
|
1050
|
+
// Claude and Codex by running their own CLI) and can take seconds
|
|
1051
|
+
// (DEF-PANE-318).
|
|
1052
|
+
this._beginBusy(this._trans.__('Branching conversation'));
|
|
1066
1053
|
try {
|
|
1067
|
-
await this.
|
|
1068
|
-
project_path: session.project_path,
|
|
1069
|
-
fork_from: session.session_id,
|
|
1070
|
-
mode: this._launchMode(force)
|
|
1071
|
-
});
|
|
1054
|
+
await this._branchByServerCopy(session, undefined, force);
|
|
1072
1055
|
}
|
|
1073
|
-
|
|
1074
|
-
this.
|
|
1075
|
-
return;
|
|
1056
|
+
finally {
|
|
1057
|
+
this._endBusy();
|
|
1076
1058
|
}
|
|
1077
|
-
this._watchForNewBranch(session, known, parentColour);
|
|
1078
|
-
void this._fetch().catch(() => undefined);
|
|
1079
1059
|
}
|
|
1080
|
-
/** The
|
|
1081
|
-
*
|
|
1082
|
-
*
|
|
1060
|
+
/** The server mints the new id and answers with it before the terminal
|
|
1061
|
+
* opens - `server-copy` copies the store entry, `server-native` drives the
|
|
1062
|
+
* assistant's own non-interactive fork path - so one refresh surfaces the
|
|
1063
|
+
* branch. */
|
|
1083
1064
|
async _branchByServerCopy(session, name, force) {
|
|
1084
1065
|
// Let the parent's colour settle before the server reads it (DEF-74). The
|
|
1085
1066
|
// server copies the store entry while minting the fork, so a colour picked
|
|
1086
1067
|
// on the parent's tab moments earlier - still queued in this store's
|
|
1087
1068
|
// request chain, unsent - is not in the server's store yet and the branch
|
|
1088
|
-
// is born wearing the PREVIOUS tint.
|
|
1089
|
-
// (DEF-
|
|
1090
|
-
//
|
|
1091
|
-
//
|
|
1092
|
-
//
|
|
1069
|
+
// is born wearing the PREVIOUS tint. A reload is a queued request like
|
|
1070
|
+
// every other of this store's (DEF-30), so it is not sent until the
|
|
1071
|
+
// capture ahead of it has been answered, and awaiting it is what makes the
|
|
1072
|
+
// server's read fresh. Only inside the capture window, so an ordinary fork
|
|
1073
|
+
// still costs no request.
|
|
1093
1074
|
if (this._colours.isPending(session.session_id)) {
|
|
1094
1075
|
await this._colours.load();
|
|
1095
1076
|
}
|
|
1077
|
+
// Whether the POST below returned the minted fork. Past that point the
|
|
1078
|
+
// branch exists server-side - row, pin and colour - and only the launch
|
|
1079
|
+
// of its terminal can still fail, which is a different thing to report.
|
|
1080
|
+
let minted = false;
|
|
1096
1081
|
try {
|
|
1097
1082
|
const fork = await requestProvider(this._descriptor.id, 'branch', this._serverSettings, {
|
|
1098
1083
|
method: 'POST',
|
|
1099
1084
|
body: JSON.stringify({
|
|
1100
1085
|
encoded_path: session.encoded_path,
|
|
1101
1086
|
session_id: session.session_id,
|
|
1102
|
-
name
|
|
1087
|
+
name,
|
|
1088
|
+
base_name: session.name
|
|
1103
1089
|
})
|
|
1104
1090
|
});
|
|
1091
|
+
minted = true;
|
|
1105
1092
|
// No colour write here. `BranchHandler` already inherited it while
|
|
1106
1093
|
// minting this fork, from a read taken server-side at request time -
|
|
1107
1094
|
// strictly fresher than the click-time read this would repeat, and the
|
|
@@ -1117,6 +1104,19 @@ export class AssistantSessionsPanel extends Widget {
|
|
|
1117
1104
|
if (isResponseStatus(err, 400)) {
|
|
1118
1105
|
Notification.error(`${this._descriptor.label} cannot branch this conversation.`, { autoClose: 4000 });
|
|
1119
1106
|
}
|
|
1107
|
+
else if (minted) {
|
|
1108
|
+
// The branch was created and only its terminal was refused - the
|
|
1109
|
+
// launch preflight's 409 carries words for the user. "Could not
|
|
1110
|
+
// branch this session" would be false, and the early return would
|
|
1111
|
+
// skip the refresh that surfaces the new row, so the refusal keeps
|
|
1112
|
+
// its own message and the list is re-read all the same.
|
|
1113
|
+
// Kept to 41 characters for the TOAST, not for taste: ": " plus the
|
|
1114
|
+
// longest message a store may raise (97, the DeepSeek refusal's
|
|
1115
|
+
// bound in tests/test_provider_stores.py) is 41 + 2 + 97 = 140 -
|
|
1116
|
+
// exactly the window before JupyterLab clips the rest.
|
|
1117
|
+
this._notifyLaunchError('Branch created; its terminal did not open', err);
|
|
1118
|
+
await this._fetch().catch(() => undefined);
|
|
1119
|
+
}
|
|
1120
1120
|
else {
|
|
1121
1121
|
this._showActionError('Could not branch this session - try again.', err);
|
|
1122
1122
|
}
|
|
@@ -1149,108 +1149,6 @@ export class AssistantSessionsPanel extends Widget {
|
|
|
1149
1149
|
await this._terminals.reconcileColours();
|
|
1150
1150
|
await this._fetch().catch(() => undefined);
|
|
1151
1151
|
}
|
|
1152
|
-
/** Copy the parent's tint onto a fresh branch.
|
|
1153
|
-
*
|
|
1154
|
-
* A native-colour assistant hands every conversation its own colour, so a
|
|
1155
|
-
* fork already arrives correctly tinted: only what this extension's own
|
|
1156
|
-
* store holds for the parent is inherited there - an entry the parent itself
|
|
1157
|
-
* inherited counts, which is what makes a branch of a branch take what its
|
|
1158
|
-
* parent actually shows. Copying the parent's native tint instead would pin
|
|
1159
|
-
* the fork to it and shadow the fork's own `/color` for good.
|
|
1160
|
-
* Every other assistant inherits the parent's effective colour, which is the
|
|
1161
|
-
* only tint it has. */
|
|
1162
|
-
async _inheritColour(parentColour, childId, parentId) {
|
|
1163
|
-
// The project gained a conversation, so a listing kept from before it is
|
|
1164
|
-
// short by one.
|
|
1165
|
-
this._branchCache = null;
|
|
1166
|
-
// Let the parent's colour settle before copying it (DEF-31). The store
|
|
1167
|
-
// holds only server-confirmed values, so a colour picked on the parent's
|
|
1168
|
-
// tab moments earlier is not in it yet, and a fork started in that window
|
|
1169
|
-
// was born wearing the PREVIOUS tint - stored as inherited, so never
|
|
1170
|
-
// offered for release and corrected by no later pass.
|
|
1171
|
-
//
|
|
1172
|
-
// A reload is a queued request like every other of this store's (DEF-30):
|
|
1173
|
-
// it is not sent until the capture ahead of it has been answered, which is
|
|
1174
|
-
// what makes the re-read below current. It runs only inside the capture
|
|
1175
|
-
// window, so an ordinary fork still costs no request, and the wait is
|
|
1176
|
-
// bounded - every request is capped at REQUEST_TIMEOUT_MS (DEF-72). A
|
|
1177
|
-
// reload that fails keeps the cache, which by then holds whatever the
|
|
1178
|
-
// capture confirmed, so the re-read is current either way.
|
|
1179
|
-
if (this._colours.isPending(parentId)) {
|
|
1180
|
-
await this._colours.load();
|
|
1181
|
-
}
|
|
1182
|
-
// Re-read rather than trust `parentColour`, which was taken at click time -
|
|
1183
|
-
// before the name dialog. A capture in flight at click time may well have
|
|
1184
|
-
// landed while that dialog was open, which leaves nothing pending and the
|
|
1185
|
-
// snapshot stale all the same. It stays as the fallback everywhere but a
|
|
1186
|
-
// `native` provider - it is the only value here in which the derived hash
|
|
1187
|
-
// is resolved, so a parent this store holds no colour for still hands its
|
|
1188
|
-
// fork the tint it actually shows. `native` takes no fallback at all, for
|
|
1189
|
-
// the reason above.
|
|
1190
|
-
const stored = this._colours.get(parentId);
|
|
1191
|
-
const inherited = this._descriptor.colourSource === 'native'
|
|
1192
|
-
? stored
|
|
1193
|
-
: (stored !== null && stored !== void 0 ? stored : parentColour);
|
|
1194
|
-
await this._colours.inherit(inherited, childId);
|
|
1195
|
-
}
|
|
1196
|
-
/** Poll fast for a fork whose id we already know, then refresh once. The
|
|
1197
|
-
* panel is never updated before the branch genuinely exists - it cannot list
|
|
1198
|
-
* a store entry that has not been written. */
|
|
1199
|
-
_watchForBranch(encodedPath, forkId) {
|
|
1200
|
-
let attempts = 0;
|
|
1201
|
-
const tick = async () => {
|
|
1202
|
-
// dispose() can land between an await and this callback; the widget must
|
|
1203
|
-
// not keep polling off a dead object.
|
|
1204
|
-
if (this.isDisposed) {
|
|
1205
|
-
return;
|
|
1206
|
-
}
|
|
1207
|
-
attempts += 1;
|
|
1208
|
-
try {
|
|
1209
|
-
const data = await requestProvider(this._descriptor.id, withQuery('branches', { encoded_path: encodedPath }), this._serverSettings, { cache: 'no-store' });
|
|
1210
|
-
if (data.current === forkId ||
|
|
1211
|
-
data.branches.some(b => b.session_id === forkId)) {
|
|
1212
|
-
await this._fetch();
|
|
1213
|
-
return;
|
|
1214
|
-
}
|
|
1215
|
-
}
|
|
1216
|
-
catch (_a) {
|
|
1217
|
-
// Transient - keep watching until the attempt budget runs out.
|
|
1218
|
-
}
|
|
1219
|
-
if (attempts < BRANCH_WATCH_MAX_ATTEMPTS) {
|
|
1220
|
-
window.setTimeout(() => void tick(), BRANCH_WATCH_INTERVAL_MS);
|
|
1221
|
-
}
|
|
1222
|
-
};
|
|
1223
|
-
window.setTimeout(() => void tick(), BRANCH_WATCH_INTERVAL_MS);
|
|
1224
|
-
}
|
|
1225
|
-
/** Poll fast for a fork whose id the CLI minted: whichever conversation the
|
|
1226
|
-
* snapshot did not hold is the fork. It is then pinned as current (recency
|
|
1227
|
-
* alone would not - the actively written parent overtakes it) and inherits
|
|
1228
|
-
* the parent's tint. */
|
|
1229
|
-
_watchForNewBranch(session, known, parentColour) {
|
|
1230
|
-
let attempts = 0;
|
|
1231
|
-
const tick = async () => {
|
|
1232
|
-
if (this.isDisposed) {
|
|
1233
|
-
return;
|
|
1234
|
-
}
|
|
1235
|
-
attempts += 1;
|
|
1236
|
-
try {
|
|
1237
|
-
const data = await this._fetchBranches(session);
|
|
1238
|
-
const fresh = data.branches.find(b => !known.has(b.session_id));
|
|
1239
|
-
if (fresh) {
|
|
1240
|
-
await this._inheritColour(parentColour, fresh.session_id, session.session_id);
|
|
1241
|
-
await this._switchBranch(session, fresh.session_id);
|
|
1242
|
-
return;
|
|
1243
|
-
}
|
|
1244
|
-
}
|
|
1245
|
-
catch (_a) {
|
|
1246
|
-
// Transient - keep watching.
|
|
1247
|
-
}
|
|
1248
|
-
if (attempts < BRANCH_WATCH_MAX_ATTEMPTS) {
|
|
1249
|
-
window.setTimeout(() => void tick(), BRANCH_WATCH_INTERVAL_MS);
|
|
1250
|
-
}
|
|
1251
|
-
};
|
|
1252
|
-
window.setTimeout(() => void tick(), BRANCH_WATCH_INTERVAL_MS);
|
|
1253
|
-
}
|
|
1254
1152
|
/** Name the row's current conversation, in the assistant's own store.
|
|
1255
1153
|
*
|
|
1256
1154
|
* Only ever offered where the descriptor says the assistant keeps a name
|
|
@@ -1273,9 +1171,8 @@ export class AssistantSessionsPanel extends Widget {
|
|
|
1273
1171
|
}
|
|
1274
1172
|
const name = ((_a = named.value) !== null && _a !== void 0 ? _a : '').trim();
|
|
1275
1173
|
if (!name) {
|
|
1276
|
-
//
|
|
1277
|
-
//
|
|
1278
|
-
// default", so an empty Ok has to say that nothing happened.
|
|
1174
|
+
// The placeholder shows the current name, which reads as "press Ok for
|
|
1175
|
+
// the default", so an empty Ok has to say that nothing happened.
|
|
1279
1176
|
Notification.warning('Enter a name - nothing was renamed.', {
|
|
1280
1177
|
autoClose: 4000
|
|
1281
1178
|
});
|
|
@@ -1945,9 +1842,7 @@ export class AssistantSessionsPanel extends Widget {
|
|
|
1945
1842
|
}
|
|
1946
1843
|
/** Whether a forced variant would build the launch the plain item already
|
|
1947
1844
|
* builds - a mode left on in settings makes the plain item carry it, so the
|
|
1948
|
-
* variant beside it would be a second entry for one outcome.
|
|
1949
|
-
* variant can match: a forced token is the bare mode id, so an enum sitting
|
|
1950
|
-
* on a widening value is a launch no variant duplicates. */
|
|
1845
|
+
* variant beside it would be a second entry for one outcome. */
|
|
1951
1846
|
_buildsSameLaunch(mode) {
|
|
1952
1847
|
const forced = resolveLaunchMode(this._descriptor.launchModes, this._modes, mode.id);
|
|
1953
1848
|
return !!forced && forced === this._launchMode();
|
|
@@ -2093,8 +1988,8 @@ export class AssistantSessionsPanel extends Widget {
|
|
|
2093
1988
|
// colourful-tab extension as a choice with no colour and does drop the
|
|
2094
1989
|
// override, but only for the conversation that terminal is running - so
|
|
2095
1990
|
// without this item an override on a branch with no tab open would be
|
|
2096
|
-
// permanent, and on a native
|
|
2097
|
-
//
|
|
1991
|
+
// permanent on an assistant with no colour command, and on a native one
|
|
1992
|
+
// would hold until the next `/color` run in that conversation.
|
|
2098
1993
|
//
|
|
2099
1994
|
// It covers every conversation of the row, not just the current one: a
|
|
2100
1995
|
// terminal opened on a branch files its colour under THAT branch, and this
|
|
@@ -2325,14 +2220,10 @@ export class AssistantSessionsPanel extends Widget {
|
|
|
2325
2220
|
add('reset-colour');
|
|
2326
2221
|
this._contextMenu.addItem({ type: 'separator' });
|
|
2327
2222
|
if (withBranches) {
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
type: 'submenu',
|
|
2333
|
-
submenu: this._openBranchSubmenu
|
|
2334
|
-
});
|
|
2335
|
-
}
|
|
2223
|
+
this._contextMenu.addItem({
|
|
2224
|
+
type: 'submenu',
|
|
2225
|
+
submenu: this._openBranchSubmenu
|
|
2226
|
+
});
|
|
2336
2227
|
this._contextMenu.addItem({
|
|
2337
2228
|
type: 'submenu',
|
|
2338
2229
|
submenu: this._switchSubmenu
|
|
@@ -2501,7 +2392,7 @@ export class AssistantSessionsPanel extends Widget {
|
|
|
2501
2392
|
branchName: b => this._branchDisplayName(b),
|
|
2502
2393
|
formatTime: ms => this._formatRelativeTime(ms),
|
|
2503
2394
|
branchBadge: b => this._bgBadgeFor(b),
|
|
2504
|
-
openTitle: () => this._openBranchTitle(
|
|
2395
|
+
openTitle: () => this._openBranchTitle(),
|
|
2505
2396
|
onSwitch: id => void this._switchBranch(session, id),
|
|
2506
2397
|
onOpen: id => void this._openSession(session, undefined, id),
|
|
2507
2398
|
onDelete: ids => this._deleteBranches(session, ids),
|
|
@@ -2514,13 +2405,7 @@ export class AssistantSessionsPanel extends Widget {
|
|
|
2514
2405
|
/** Tooltip for one Open button in the Manage Sessions popup. Same rule as the
|
|
2515
2406
|
* Open Branched Conversation submenu: the button launches a terminal, so it
|
|
2516
2407
|
* names the mode that launch carries. */
|
|
2517
|
-
_openBranchTitle(
|
|
2518
|
-
var _a, _b, _c;
|
|
2519
|
-
// One terminal serves a project-scoped assistant, so the button focuses
|
|
2520
|
-
// or starts it, under the provider's own verb for that.
|
|
2521
|
-
if (this._descriptor.terminalScope === 'project') {
|
|
2522
|
-
return ((_c = (_b = (_a = this._hooks).resumeLabel) === null || _b === void 0 ? void 0 : _b.call(_a, session)) !== null && _c !== void 0 ? _c : "Open the project's terminal");
|
|
2523
|
-
}
|
|
2408
|
+
_openBranchTitle() {
|
|
2524
2409
|
const base = 'Open this conversation in its own terminal';
|
|
2525
2410
|
const variant = this._resolvedVariant();
|
|
2526
2411
|
return variant ? `${base} (${variant.label})` : base;
|
package/lib/core/popup.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export declare namespace ManageSessionsPopup {
|
|
|
32
32
|
/** Tooltip for one row's Open button. The panel owns it because the launch
|
|
33
33
|
* mode in force is panel state, and every other surface that opens a
|
|
34
34
|
* conversation names it. */
|
|
35
|
-
openTitle: (
|
|
35
|
+
openTitle: () => string;
|
|
36
36
|
/** Make a conversation the row's current one. */
|
|
37
37
|
onSwitch: (sessionId: string) => void;
|
|
38
38
|
/** Open a conversation in its own terminal. */
|
package/lib/core/popup.js
CHANGED
|
@@ -17,6 +17,26 @@ function copyButton(sessionId, trans) {
|
|
|
17
17
|
});
|
|
18
18
|
return btn;
|
|
19
19
|
}
|
|
20
|
+
/** The default dialog renderer with one extra node leading the footer.
|
|
21
|
+
* JupyterLab builds the footer in the Dialog constructor through
|
|
22
|
+
* `renderer.createFooter`, and `IOptions.renderer` is the public hook for
|
|
23
|
+
* changing it; its only built-in extra, `checkbox`, renders a checkbox, not a
|
|
24
|
+
* button. Leading the footer puts the node before Close in tab order, so the
|
|
25
|
+
* keyboard reaches the list, then Delete, then Close - and the Dialog's own Tab
|
|
26
|
+
* wrap, keyed on its last button, still wraps from Close. */
|
|
27
|
+
class FooterRenderer extends Dialog.Renderer {
|
|
28
|
+
constructor(_lead) {
|
|
29
|
+
super();
|
|
30
|
+
this._lead = _lead;
|
|
31
|
+
}
|
|
32
|
+
createFooter(buttons, checkbox) {
|
|
33
|
+
const footer = super.createFooter(buttons, checkbox);
|
|
34
|
+
// After super: its `Styling.styleNode` pass has run, so the lead keeps its
|
|
35
|
+
// own look instead of taking the `jp-mod-styled` dialog-button styling.
|
|
36
|
+
footer.node.prepend(this._lead);
|
|
37
|
+
return footer;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
20
40
|
export function showManageSessionsPopup(options) {
|
|
21
41
|
var _a;
|
|
22
42
|
const trans = (_a = options.trans) !== null && _a !== void 0 ? _a : nullTranslator.load('jupyterlab_ai_code_assistants_extension');
|
|
@@ -57,14 +77,12 @@ export function showManageSessionsPopup(options) {
|
|
|
57
77
|
list.setAttribute('role', 'group');
|
|
58
78
|
list.setAttribute('aria-label', trans.__('Conversations'));
|
|
59
79
|
body.appendChild(list);
|
|
80
|
+
// Delete and its counter live in the dialog's own action row, not the body:
|
|
81
|
+
// a secondary destructive action sits on the left edge of the row that holds
|
|
82
|
+
// Close, as JupyterLab dialogs place one (DEF-PANE-307). It stays a plain
|
|
83
|
+
// button - a Dialog button resolves, and so closes, the dialog on click.
|
|
60
84
|
const footer = document.createElement('div');
|
|
61
85
|
footer.className = 'jp-AiAssistantsPanel-branchFooter';
|
|
62
|
-
// Plain visual counter (selection, or the last action). The screen-reader
|
|
63
|
-
// announcement lives in its own live region so per-checkbox ticks are not
|
|
64
|
-
// announced on top of the native checkbox.
|
|
65
|
-
const selCount = document.createElement('span');
|
|
66
|
-
selCount.className = 'jp-AiAssistantsPanel-branchSelCount';
|
|
67
|
-
footer.appendChild(selCount);
|
|
68
86
|
const deleteBtn = document.createElement('button');
|
|
69
87
|
deleteBtn.type = 'button';
|
|
70
88
|
deleteBtn.className = 'jp-AiAssistantsPanel-branchDelete';
|
|
@@ -72,7 +90,13 @@ export function showManageSessionsPopup(options) {
|
|
|
72
90
|
? 'Deleted conversations move to the trash (recoverable)'
|
|
73
91
|
: 'Deleted conversations are removed permanently';
|
|
74
92
|
footer.appendChild(deleteBtn);
|
|
75
|
-
|
|
93
|
+
// Plain visual counter (selection, or the last action), beside the button
|
|
94
|
+
// whose count and result it reports. The screen-reader announcement lives in
|
|
95
|
+
// its own live region so per-checkbox ticks are not announced on top of the
|
|
96
|
+
// native checkbox.
|
|
97
|
+
const selCount = document.createElement('span');
|
|
98
|
+
selCount.className = 'jp-AiAssistantsPanel-branchSelCount';
|
|
99
|
+
footer.appendChild(selCount);
|
|
76
100
|
// Visually hidden polite live region, announced only on delete.
|
|
77
101
|
const srLive = document.createElement('div');
|
|
78
102
|
srLive.className = 'jp-AiAssistantsPanel-srOnly';
|
|
@@ -86,8 +110,11 @@ export function showManageSessionsPopup(options) {
|
|
|
86
110
|
// `Close`, not `Cancel`: deletions here are committed as they happen, so
|
|
87
111
|
// the only exit must not read as an offer to undo them. The cleanup dialog
|
|
88
112
|
// in the panel already says Close for the same reason.
|
|
89
|
-
buttons: [Dialog.okButton({ label: trans.__('Close') })]
|
|
113
|
+
buttons: [Dialog.okButton({ label: trans.__('Close') })],
|
|
114
|
+
renderer: new FooterRenderer(footer)
|
|
90
115
|
});
|
|
116
|
+
// Scopes the action-row layout in base.css to this one dialog.
|
|
117
|
+
dialog.addClass('jp-AiAssistantsPanel-branchDialog');
|
|
91
118
|
// Per-row "Open" launches that conversation in its own terminal and closes
|
|
92
119
|
// the popup. stopPropagation keeps the click from toggling selection or
|
|
93
120
|
// switching the row.
|
|
@@ -96,7 +123,7 @@ export function showManageSessionsPopup(options) {
|
|
|
96
123
|
btn.type = 'button';
|
|
97
124
|
btn.className = 'jp-AiAssistantsPanel-branchOpen';
|
|
98
125
|
btn.textContent = 'Open';
|
|
99
|
-
btn.title = options.openTitle(
|
|
126
|
+
btn.title = options.openTitle();
|
|
100
127
|
btn.addEventListener('click', e => {
|
|
101
128
|
e.stopPropagation();
|
|
102
129
|
dialog.dispose();
|
|
@@ -292,7 +319,8 @@ export function showManageSessionsPopup(options) {
|
|
|
292
319
|
// Busy-lock the whole body during the async delete, so a slow backend cannot
|
|
293
320
|
// be double-clicked into deleting the same set twice and a mid-flight
|
|
294
321
|
// selection cannot be silently discarded. The Dialog's Close button sits
|
|
295
|
-
// outside the body and stays usable
|
|
322
|
+
// outside the body and stays usable; Delete sits outside it too, and is held
|
|
323
|
+
// by its own `disabled` while `deleting` is set.
|
|
296
324
|
const setDeleting = (on) => {
|
|
297
325
|
deleting = on;
|
|
298
326
|
body.classList.toggle('jp-mod-busy', on);
|
|
@@ -382,6 +410,15 @@ export function showManageSessionsPopup(options) {
|
|
|
382
410
|
}
|
|
383
411
|
});
|
|
384
412
|
});
|
|
413
|
+
// Leaving the armed button disarms it, as the device bridge's two-step
|
|
414
|
+
// buttons do: the second click must follow the first, not come back to it
|
|
415
|
+
// after the focus has been somewhere else.
|
|
416
|
+
deleteBtn.addEventListener('blur', () => {
|
|
417
|
+
if (armed) {
|
|
418
|
+
disarm();
|
|
419
|
+
updateControls();
|
|
420
|
+
}
|
|
421
|
+
});
|
|
385
422
|
search.addEventListener('input', () => {
|
|
386
423
|
if (deleting) {
|
|
387
424
|
return;
|
|
@@ -394,5 +431,9 @@ export function showManageSessionsPopup(options) {
|
|
|
394
431
|
// dialog.dispose() (on open/switch) rejects this promise with `undefined`;
|
|
395
432
|
// catch it so the teardown never surfaces as an unhandled rejection.
|
|
396
433
|
dialog.launch().catch(() => undefined);
|
|
397
|
-
|
|
434
|
+
// The Dialog focuses its primary button once attached; the filter takes the
|
|
435
|
+
// focus after that, so typing filters the list. Close stays the primary, so
|
|
436
|
+
// focus that leaves the dialog (Shift+Tab from the filter) returns to Close
|
|
437
|
+
// (DEF-PANE-314).
|
|
438
|
+
void dialog.ready.then(() => search.focus());
|
|
398
439
|
}
|
package/lib/core/request.js
CHANGED
|
@@ -133,12 +133,19 @@ export async function requestAPI(endPoint, serverSettings, init = {}) {
|
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
if (!response.ok) {
|
|
136
|
-
// `
|
|
137
|
-
//
|
|
138
|
-
//
|
|
139
|
-
//
|
|
140
|
-
//
|
|
141
|
-
//
|
|
136
|
+
// `message`, then `error`, then `data`, because the server authors two
|
|
137
|
+
// refusal shapes. Every refusal in `core/routes.py` but one is
|
|
138
|
+
// `{"error": "<code>"}` - the `bad_request` helper plus its inline writes
|
|
139
|
+
// - and a code is a handle, not copy: the panel holds the words for the
|
|
140
|
+
// codes it knows (`cli_not_found`, `rename_failed`) and its own copy
|
|
141
|
+
// around the rest, so the chain's job there is only to keep `data` itself
|
|
142
|
+
// from being picked - falling to it stringified the object into the
|
|
143
|
+
// literal `[object Object]`. The holdout carries words: the launch
|
|
144
|
+
// preflight's 409 (`LaunchRefused`, the DeepSeek harness with no `tui`
|
|
145
|
+
// profile) answers `{"message": <the refusal in words for the user>}`
|
|
146
|
+
// with no code, and the panel prints it verbatim because it is already
|
|
147
|
+
// the sentence. Hence `message` outranks `error`; jupyter_server's own
|
|
148
|
+
// error bodies carry `message` too and need the same read.
|
|
142
149
|
throw new ServerConnection.ResponseError(response, (_b = (_a = data === null || data === void 0 ? void 0 : data.message) !== null && _a !== void 0 ? _a : data === null || data === void 0 ? void 0 : data.error) !== null && _b !== void 0 ? _b : data);
|
|
143
150
|
}
|
|
144
151
|
return data;
|