jupyterlab_ai_code_assistants_extension 1.2.73 → 1.2.83
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 +8 -43
- package/lib/core/panel.js +44 -229
- 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 +105 -248
- 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 +48 -272
- 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 +48 -36
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;
|
package/lib/core/terminals.d.ts
CHANGED
|
@@ -46,11 +46,6 @@ export declare class TerminalManager {
|
|
|
46
46
|
* Launch a terminal for one request and focus it. The returned widget is
|
|
47
47
|
* tagged with `tagSessionId` in the microcache, so a later click on the row
|
|
48
48
|
* that conversation now belongs to reuses this very terminal.
|
|
49
|
-
*
|
|
50
|
-
* For a project-scoped assistant the project's running terminal is the
|
|
51
|
-
* answer instead, whatever the request asked for: every caller - row click,
|
|
52
|
-
* `+`, fork, Launcher tile - lands here, so this one gate is what keeps a
|
|
53
|
-
* second server off the project.
|
|
54
49
|
*/
|
|
55
50
|
launch(request: ILaunchRequest, tagSessionId?: string): Promise<any>;
|
|
56
51
|
/**
|
|
@@ -68,28 +63,11 @@ export declare class TerminalManager {
|
|
|
68
63
|
* too, not only launches that carry an argv id. An id is globally unique to
|
|
69
64
|
* one conversation, so a terminal holding it IS the one to focus, whatever
|
|
70
65
|
* cwd it reports - a process that changed directory, or whose project dir
|
|
71
|
-
* was recreated, must still be reused rather than duplicated.
|
|
72
|
-
|
|
73
|
-
* For a project-scoped assistant the id is not what a terminal holds; the
|
|
74
|
-
* project's running terminal (see `_projectTerminal`) is the answer, so the
|
|
75
|
-
* caller passes the project path. */
|
|
76
|
-
findForSession(wantedSessionId: string | undefined, projectPath?: string): Promise<{
|
|
66
|
+
* was recreated, must still be reused rather than duplicated. */
|
|
67
|
+
findForSession(wantedSessionId: string | undefined): Promise<{
|
|
77
68
|
widget: any;
|
|
78
69
|
runningId: string | null;
|
|
79
70
|
} | null>;
|
|
80
|
-
/** The one terminal serving a project, for a project-scoped assistant, or
|
|
81
|
-
* null. The project's microcache entry whatever conversation it was tagged
|
|
82
|
-
* with, else the first live terminal the server confirms is running this
|
|
83
|
-
* assistant with its working directory inside the project - the same
|
|
84
|
-
* cwd-to-project rule the colour pass applies. The server's `running`
|
|
85
|
-
* answer is what keeps a plain shell opened at the project from matching.
|
|
86
|
-
*
|
|
87
|
-
* The cached terminal is asked too, so a server the user stopped in it does
|
|
88
|
-
* not hold every later open on a dead shell. Only a terminal the server has
|
|
89
|
-
* once confirmed is evicted on a `running: false` answer: a fresh launch
|
|
90
|
-
* answers that until its process is up, and evicting it then would start
|
|
91
|
-
* the second server this method exists to prevent. */
|
|
92
|
-
private _projectTerminal;
|
|
93
71
|
/** Ask the server what a terminal is running. Null when the widget has no
|
|
94
72
|
* session name yet, or the probe fails - a terminal can vanish between
|
|
95
73
|
* enumeration and probe, which is a retry, not an error. */
|
|
@@ -122,15 +100,6 @@ export declare class TerminalManager {
|
|
|
122
100
|
* the time - see `_pendingChoices`.
|
|
123
101
|
*/
|
|
124
102
|
reconcileColours(): Promise<void>;
|
|
125
|
-
/** Effective colour of one conversation as the cache currently reads it, for
|
|
126
|
-
* branch inheritance at the fork sites.
|
|
127
|
-
*
|
|
128
|
-
* A snapshot, not the last word: the cache holds only server-confirmed
|
|
129
|
-
* values, so a colour still being written is not in it. The fork path settles
|
|
130
|
-
* the store and re-reads before it copies anything, and keeps this answer as
|
|
131
|
-
* the fallback for a conversation the store holds nothing for - see
|
|
132
|
-
* `_inheritColour` (DEF-31). */
|
|
133
|
-
colourFor(session: ISession, sessionId?: string): string | null;
|
|
134
103
|
/** Drop the tint from this assistant's terminals. Only its own terminals are
|
|
135
104
|
* touched, so a tint the user set by hand on another tab survives.
|
|
136
105
|
*
|
package/lib/core/terminals.js
CHANGED
|
@@ -99,8 +99,7 @@ export class TerminalManager {
|
|
|
99
99
|
// terminal is not painted, because painting is what destroys the pick.
|
|
100
100
|
this._pendingChoices = new Map();
|
|
101
101
|
// Most recent terminal per project, tagged with the conversation it runs so
|
|
102
|
-
// reuse can tell a project's branches apart.
|
|
103
|
-
// server once answered `running: true` for it (project scope only).
|
|
102
|
+
// reuse can tell a project's branches apart.
|
|
104
103
|
this._byProject = new Map();
|
|
105
104
|
// In-flight launches keyed per CONVERSATION, so two branches of one project
|
|
106
105
|
// open independently and concurrently.
|
|
@@ -178,17 +177,6 @@ export class TerminalManager {
|
|
|
178
177
|
}
|
|
179
178
|
async _doOpenSession(session, mode, wanted) {
|
|
180
179
|
var _a;
|
|
181
|
-
// A project-scoped assistant has no per-conversation terminal to find:
|
|
182
|
-
// `launch` answers with the project's running one or starts it.
|
|
183
|
-
if (this._descriptor.terminalScope === 'project') {
|
|
184
|
-
await this.launch({
|
|
185
|
-
project_path: session.project_path,
|
|
186
|
-
encoded_path: session.encoded_path,
|
|
187
|
-
session_id: wanted,
|
|
188
|
-
mode
|
|
189
|
-
}, wanted);
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
180
|
// 1. Microcache - the most recent terminal of this project, reused only
|
|
193
181
|
// when it carries the wanted conversation.
|
|
194
182
|
const cached = this._byProject.get(session.project_path);
|
|
@@ -223,26 +211,8 @@ export class TerminalManager {
|
|
|
223
211
|
* Launch a terminal for one request and focus it. The returned widget is
|
|
224
212
|
* tagged with `tagSessionId` in the microcache, so a later click on the row
|
|
225
213
|
* that conversation now belongs to reuses this very terminal.
|
|
226
|
-
*
|
|
227
|
-
* For a project-scoped assistant the project's running terminal is the
|
|
228
|
-
* answer instead, whatever the request asked for: every caller - row click,
|
|
229
|
-
* `+`, fork, Launcher tile - lands here, so this one gate is what keeps a
|
|
230
|
-
* second server off the project.
|
|
231
214
|
*/
|
|
232
215
|
async launch(request, tagSessionId) {
|
|
233
|
-
if (this._descriptor.terminalScope === 'project') {
|
|
234
|
-
const running = await this._projectTerminal(request.project_path);
|
|
235
|
-
if (running) {
|
|
236
|
-
// A new conversation still settles the project's pin (DEF-9): the
|
|
237
|
-
// argv route runs the launch's validation and pin bookkeeping without
|
|
238
|
-
// spawning, and the argv it answers with is not needed here.
|
|
239
|
-
if (request.session_id === undefined && request.encoded_path) {
|
|
240
|
-
await requestProvider(this._descriptor.id, 'launch-argv', this._serverSettings, { method: 'POST', body: JSON.stringify(request) });
|
|
241
|
-
}
|
|
242
|
-
this.focus(running);
|
|
243
|
-
return running;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
216
|
const spinner = showLaunchSpinner(`Opening ${this._descriptor.label}`, this._trans);
|
|
247
217
|
try {
|
|
248
218
|
const launched = await requestProvider(this._descriptor.id, 'launch', this._serverSettings, { method: 'POST', body: JSON.stringify(request) });
|
|
@@ -292,18 +262,8 @@ export class TerminalManager {
|
|
|
292
262
|
* too, not only launches that carry an argv id. An id is globally unique to
|
|
293
263
|
* one conversation, so a terminal holding it IS the one to focus, whatever
|
|
294
264
|
* cwd it reports - a process that changed directory, or whose project dir
|
|
295
|
-
* was recreated, must still be reused rather than duplicated.
|
|
296
|
-
|
|
297
|
-
* For a project-scoped assistant the id is not what a terminal holds; the
|
|
298
|
-
* project's running terminal (see `_projectTerminal`) is the answer, so the
|
|
299
|
-
* caller passes the project path. */
|
|
300
|
-
async findForSession(wantedSessionId, projectPath) {
|
|
301
|
-
if (this._descriptor.terminalScope === 'project') {
|
|
302
|
-
const widget = projectPath
|
|
303
|
-
? await this._projectTerminal(projectPath)
|
|
304
|
-
: null;
|
|
305
|
-
return widget ? { widget, runningId: null } : null;
|
|
306
|
-
}
|
|
265
|
+
* was recreated, must still be reused rather than duplicated. */
|
|
266
|
+
async findForSession(wantedSessionId) {
|
|
307
267
|
if (!this._tracker || !wantedSessionId) {
|
|
308
268
|
return null;
|
|
309
269
|
}
|
|
@@ -315,50 +275,6 @@ export class TerminalManager {
|
|
|
315
275
|
}
|
|
316
276
|
return null;
|
|
317
277
|
}
|
|
318
|
-
/** The one terminal serving a project, for a project-scoped assistant, or
|
|
319
|
-
* null. The project's microcache entry whatever conversation it was tagged
|
|
320
|
-
* with, else the first live terminal the server confirms is running this
|
|
321
|
-
* assistant with its working directory inside the project - the same
|
|
322
|
-
* cwd-to-project rule the colour pass applies. The server's `running`
|
|
323
|
-
* answer is what keeps a plain shell opened at the project from matching.
|
|
324
|
-
*
|
|
325
|
-
* The cached terminal is asked too, so a server the user stopped in it does
|
|
326
|
-
* not hold every later open on a dead shell. Only a terminal the server has
|
|
327
|
-
* once confirmed is evicted on a `running: false` answer: a fresh launch
|
|
328
|
-
* answers that until its process is up, and evicting it then would start
|
|
329
|
-
* the second server this method exists to prevent. */
|
|
330
|
-
async _projectTerminal(projectPath) {
|
|
331
|
-
var _a, _b;
|
|
332
|
-
const cached = this._byProject.get(projectPath);
|
|
333
|
-
if (cached && !cached.widget.isDisposed) {
|
|
334
|
-
const info = await this.probe(cached.widget);
|
|
335
|
-
if (info === null || info === void 0 ? void 0 : info.running) {
|
|
336
|
-
cached.confirmed = true;
|
|
337
|
-
}
|
|
338
|
-
if ((info === null || info === void 0 ? void 0 : info.running) !== false || !cached.confirmed) {
|
|
339
|
-
return cached.widget;
|
|
340
|
-
}
|
|
341
|
-
this._byProject.delete(projectPath);
|
|
342
|
-
}
|
|
343
|
-
if (!this._tracker) {
|
|
344
|
-
return null;
|
|
345
|
-
}
|
|
346
|
-
for (const widget of this._liveTerminals()) {
|
|
347
|
-
const info = await this.probe(widget);
|
|
348
|
-
if ((info === null || info === void 0 ? void 0 : info.running) &&
|
|
349
|
-
((_b = sessionForCwds((_a = info.cwds) !== null && _a !== void 0 ? _a : [], this._sessions)) === null || _b === void 0 ? void 0 : _b.project_path) ===
|
|
350
|
-
projectPath) {
|
|
351
|
-
this._byProject.set(projectPath, {
|
|
352
|
-
widget,
|
|
353
|
-
sessionId: undefined,
|
|
354
|
-
confirmed: true
|
|
355
|
-
});
|
|
356
|
-
this._wireDisposal(projectPath, widget);
|
|
357
|
-
return widget;
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
return null;
|
|
361
|
-
}
|
|
362
278
|
/** Ask the server what a terminal is running. Null when the widget has no
|
|
363
279
|
* session name yet, or the probe fails - a terminal can vanish between
|
|
364
280
|
* enumeration and probe, which is a retry, not an error. */
|
|
@@ -488,6 +404,27 @@ export class TerminalManager {
|
|
|
488
404
|
}
|
|
489
405
|
}
|
|
490
406
|
const sessionId = (_e = (_b = info.session_id) !== null && _b !== void 0 ? _b : (_d = sessionForCwds((_c = info.cwds) !== null && _c !== void 0 ? _c : [], this._sessions)) === null || _d === void 0 ? void 0 : _d.session_id) !== null && _e !== void 0 ? _e : null;
|
|
407
|
+
// The server releases a stored colour that a later colour command of
|
|
408
|
+
// the assistant overtook (DEF-COLO-306), and the cache would go on
|
|
409
|
+
// painting it from the top of the ladder: only the panel's poll
|
|
410
|
+
// reloads it, and that poll stops while the panel is hidden. A probe
|
|
411
|
+
// naming this conversation answers its effective colour with every
|
|
412
|
+
// entry the server still holds on top, so a cached entry the probe
|
|
413
|
+
// disagrees with is no longer the server's - reload before painting.
|
|
414
|
+
// The reload queues behind every write of the store (DEF-30), so a
|
|
415
|
+
// pick confirmed after the probe answered survives it.
|
|
416
|
+
const cached = this._colours.get(sessionId);
|
|
417
|
+
if (cached !== null &&
|
|
418
|
+
info.session_id === sessionId &&
|
|
419
|
+
info.colour !== undefined &&
|
|
420
|
+
info.colour !== cached) {
|
|
421
|
+
await this._colours.load();
|
|
422
|
+
if (!this._colouredTabs ||
|
|
423
|
+
this._disposed ||
|
|
424
|
+
this._pass !== generation) {
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
491
428
|
const native = (_f = info.colour) !== null && _f !== void 0 ? _f : (sessionId
|
|
492
429
|
? ((_h = (_g = this._sessions.find(s => s.session_id === sessionId)) === null || _g === void 0 ? void 0 : _g.colour) !== null && _h !== void 0 ? _h : null)
|
|
493
430
|
: null);
|
|
@@ -516,19 +453,6 @@ export class TerminalManager {
|
|
|
516
453
|
this.startColourLoop();
|
|
517
454
|
}
|
|
518
455
|
}
|
|
519
|
-
/** Effective colour of one conversation as the cache currently reads it, for
|
|
520
|
-
* branch inheritance at the fork sites.
|
|
521
|
-
*
|
|
522
|
-
* A snapshot, not the last word: the cache holds only server-confirmed
|
|
523
|
-
* values, so a colour still being written is not in it. The fork path settles
|
|
524
|
-
* the store and re-reads before it copies anything, and keeps this answer as
|
|
525
|
-
* the fallback for a conversation the store holds nothing for - see
|
|
526
|
-
* `_inheritColour` (DEF-31). */
|
|
527
|
-
colourFor(session, sessionId) {
|
|
528
|
-
var _a;
|
|
529
|
-
const id = sessionId !== null && sessionId !== void 0 ? sessionId : session.session_id;
|
|
530
|
-
return effectiveColour(id, this._descriptor.colourSource, this._colours.get(id), (_a = session.colour) !== null && _a !== void 0 ? _a : null);
|
|
531
|
-
}
|
|
532
456
|
/** Drop the tint from this assistant's terminals. Only its own terminals are
|
|
533
457
|
* touched, so a tint the user set by hand on another tab survives.
|
|
534
458
|
*
|
package/lib/core/types.d.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
/** How a conversation is branched.
|
|
2
2
|
*
|
|
3
|
-
* - `native-flag` - the CLI forks in-process from a flag pair, and the new
|
|
4
|
-
* conversation id is minted by the frontend, so the launch carries it and
|
|
5
|
-
* the branch is watched for until its store entry materialises
|
|
6
|
-
* - `native-command` - the CLI owns the fork verb AND mints the id itself, so
|
|
7
|
-
* the id has to be discovered by diffing the branch list after launch
|
|
8
3
|
* - `server-copy` - the CLI has no fork at all; the server copies the store
|
|
9
4
|
* entry, answers with the new id, and the launch resumes that id
|
|
5
|
+
* - `server-native` - the store drives the CLI's own non-interactive fork
|
|
6
|
+
* path, so the fork exists with its id before any terminal opens and the
|
|
7
|
+
* launch resumes that id
|
|
10
8
|
*
|
|
11
9
|
* No `none` member. Python's `Capabilities` defaults `fork_strategy` to
|
|
12
10
|
* `"none"` and answers a fork against it with 400 `fork_unsupported`, but
|
|
@@ -14,11 +12,11 @@
|
|
|
14
12
|
* about it - and the flag never crosses the wire, so no TS code could produce
|
|
15
13
|
* or read that value.
|
|
16
14
|
*/
|
|
17
|
-
export type ForkStrategy = '
|
|
18
|
-
/** See `IProviderDescriptor.terminalScope`. */
|
|
19
|
-
export type TerminalScope = 'conversation' | 'project';
|
|
15
|
+
export type ForkStrategy = 'server-copy' | 'server-native';
|
|
20
16
|
/** Where a conversation's DEFAULT tab tint comes from. A user-set colour in
|
|
21
|
-
* the extension's own write-back store
|
|
17
|
+
* the extension's own write-back store wins over `derived` and `none`. Over
|
|
18
|
+
* `native` the newer choice wins: the server releases a stored entry older
|
|
19
|
+
* than the assistant's newest run of its own colour command (DEF-COLO-306). */
|
|
22
20
|
export type ColourSource = 'native' | 'derived' | 'none';
|
|
23
21
|
/** One launch-behaviour setting of an assistant, in that assistant's own
|
|
24
22
|
* terminology. A launch mode is a boolean skip-approval switch: it gets a
|
|
@@ -58,17 +56,6 @@ export interface IProviderDescriptor {
|
|
|
58
56
|
cliBinary: string;
|
|
59
57
|
forkStrategy: ForkStrategy;
|
|
60
58
|
colourSource: ColourSource;
|
|
61
|
-
/** What one terminal of this assistant holds. `conversation`: the process
|
|
62
|
-
* runs exactly one conversation, so a terminal is reused only when the
|
|
63
|
-
* server reads the wanted id off it. `project`: the process serves every
|
|
64
|
-
* conversation of the project (a web UI chosen in the browser), so the
|
|
65
|
-
* project's one running terminal is the answer to every open - a row click,
|
|
66
|
-
* `+`, a fork, a Launcher tile - and a second process on the same project
|
|
67
|
-
* is always a duplicate. */
|
|
68
|
-
terminalScope: TerminalScope;
|
|
69
|
-
/** Whether the branch flow asks the user to name the new conversation.
|
|
70
|
-
* Where that name then GOES is `forkStrategy`'s job. */
|
|
71
|
-
promptsForBranchName: boolean;
|
|
72
59
|
/** The assistant keeps a conversation name this extension can write where
|
|
73
60
|
* the assistant itself reads it back. False hides the rename action rather
|
|
74
61
|
* than offering one that cannot land - which is the honest answer for an
|
|
@@ -207,26 +194,19 @@ export interface IRenameResponse {
|
|
|
207
194
|
export interface ILaunchRequest {
|
|
208
195
|
project_path: string;
|
|
209
196
|
/** The project's store key. Carrying it arms the server's launch-time pin
|
|
210
|
-
* bookkeeping (a
|
|
211
|
-
*
|
|
212
|
-
*
|
|
197
|
+
* bookkeeping (a new session clears a stale pin) and the session_not_found
|
|
198
|
+
* pre-flight - without it both are silently skipped. Send it whenever the
|
|
199
|
+
* session row is in hand. */
|
|
213
200
|
encoded_path?: string;
|
|
214
201
|
/** Conversation to open. Omit to start a brand-new one. */
|
|
215
202
|
session_id?: string;
|
|
216
203
|
/** Frontend-minted id for a brand-new conversation, when the CLI accepts
|
|
217
204
|
* one, so the terminal is identifiable from its argv on the first poll. */
|
|
218
205
|
new_session_id?: string;
|
|
219
|
-
/** Frontend-minted id for the fork (`forkStrategy: 'native-flag'`). */
|
|
220
|
-
fork_session_id?: string;
|
|
221
|
-
/** Parent conversation to fork from (`forkStrategy: 'native-command'`). */
|
|
222
|
-
fork_from?: string;
|
|
223
|
-
/** Name to stamp on the new conversation (`promptsForBranchName: true`). */
|
|
224
|
-
name?: string;
|
|
225
206
|
/** The launch mode this action runs under, as one token in the assistant's
|
|
226
|
-
* own terminology:
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
* 400 `mode_unsupported`. */
|
|
207
|
+
* own terminology: the bare `ILaunchMode.id`. One token, not a set - the
|
|
208
|
+
* server maps a single mode to a single flag, and refuses any token the
|
|
209
|
+
* descriptor does not declare with 400 `mode_unsupported`. */
|
|
230
210
|
mode?: string;
|
|
231
211
|
}
|
|
232
212
|
export interface ILaunchResponse {
|
package/lib/providers/claude.js
CHANGED
|
@@ -33,20 +33,13 @@ export const descriptor = {
|
|
|
33
33
|
iconName: 'jupyterlab_ai_code_assistants_extension:claude',
|
|
34
34
|
iconSvg: claudeSvgStr,
|
|
35
35
|
cliBinary: 'claude',
|
|
36
|
-
//
|
|
37
|
-
|
|
38
|
-
// store entry is written lazily, on the first turn, which is what the core's
|
|
39
|
-
// branch watcher waits for.
|
|
40
|
-
forkStrategy: 'native-flag',
|
|
36
|
+
// The server forks with native /rename and /color before opening the CLI.
|
|
37
|
+
forkStrategy: 'server-native',
|
|
41
38
|
// `/color` is Claude's own surface for a conversation's colour, recorded in
|
|
42
39
|
// its transcript, so the assistant supplies the DEFAULT tint - a colour the
|
|
43
|
-
// user
|
|
40
|
+
// user sets on the tab overrides it and is remembered, until a later
|
|
41
|
+
// `/color` takes over (`colour_choice_ms` in providers/claude.py).
|
|
44
42
|
colourSource: 'native',
|
|
45
|
-
terminalScope: 'conversation',
|
|
46
|
-
// `-n <name>` at launch: Claude stamps the name itself and re-stamps it on
|
|
47
|
-
// every turn, which is the only way a fork's name survives - a title written
|
|
48
|
-
// after the fact loses to the parent title the fork inherits.
|
|
49
|
-
promptsForBranchName: true,
|
|
50
43
|
// `/rename` writes a `custom-title` record into the transcript, and the
|
|
51
44
|
// store writes the same record.
|
|
52
45
|
canRename: true,
|
package/lib/providers/codex.js
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
//
|
|
7
7
|
// The three divergences that matter are capability flags, not code:
|
|
8
8
|
//
|
|
9
|
-
// * `forkStrategy: 'native
|
|
10
|
-
//
|
|
11
|
-
//
|
|
9
|
+
// * `forkStrategy: 'server-native'` - the store forks through Codex's own
|
|
10
|
+
// app-server (`thread/fork` plus `thread/name/set`) before its terminal
|
|
11
|
+
// opens, so the panel resumes the id the server answered with
|
|
12
12
|
// * `colourSource: 'none'` - Codex has no colour concept at all, so a tab tint
|
|
13
13
|
// only ever comes from the extension's own write-back store
|
|
14
14
|
// * `hasLiveProcess: true` - a project row shows a dot when a `codex` process
|
|
@@ -34,17 +34,14 @@ export const descriptor = {
|
|
|
34
34
|
iconName: 'jupyterlab_ai_code_assistants_extension:codex',
|
|
35
35
|
iconSvg: codexSvgStr,
|
|
36
36
|
cliBinary: 'codex',
|
|
37
|
-
//
|
|
38
|
-
forkStrategy: 'native
|
|
37
|
+
// The native metadata API returns a named fork before its terminal opens.
|
|
38
|
+
forkStrategy: 'server-native',
|
|
39
39
|
// No `/color` equivalent, and nothing in the thread store records one.
|
|
40
40
|
colourSource: 'none',
|
|
41
|
-
|
|
42
|
-
//
|
|
43
|
-
//
|
|
44
|
-
|
|
45
|
-
// No writable name: a thread's name lives in the sqlite index the CLI
|
|
46
|
-
// owns, and Codex has no rename subcommand to shell to.
|
|
47
|
-
canRename: false,
|
|
41
|
+
// The server writes the name through the app-server method `thread/name/set`
|
|
42
|
+
// - the same experimental stdio channel its fork already speaks - and the
|
|
43
|
+
// sqlite index the CLI reads follows it.
|
|
44
|
+
canRename: true,
|
|
48
45
|
// A bare `codex` mints its own thread id; there is no `--session-id`.
|
|
49
46
|
mintsNewSessionId: false,
|
|
50
47
|
launchModes: [
|
|
@@ -1,41 +1,28 @@
|
|
|
1
1
|
// The DeepSeek provider - the DeepSeek Harness `dsh` CLI.
|
|
2
2
|
//
|
|
3
3
|
// New here: no standalone extension preceded it, so there is nothing to port
|
|
4
|
-
// and nothing to migrate. The
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
// core file knows it exists:
|
|
4
|
+
// and nothing to migrate. The interactive surface is the community TUI bundle
|
|
5
|
+
// `@deepseek-harness-tui/dsh-tui`, mounted as the `tui` profile: `dsh tui`
|
|
6
|
+
// runs a conversation in the terminal and `dsh tui --resume <id>` reopens the
|
|
7
|
+
// row's one. Everything that makes this assistant different is descriptor
|
|
8
|
+
// data, so no core file knows it exists:
|
|
10
9
|
//
|
|
11
10
|
// * `forkStrategy: 'server-copy'` - no fork verb at all, so the server copies
|
|
12
11
|
// the conversation log under a fresh id and answers with it
|
|
13
12
|
// * `colourSource: 'none'` - no colour command, and nothing in the log records
|
|
14
13
|
// one, so a tab tint only ever comes from the extension's own write-back
|
|
15
14
|
// store
|
|
16
|
-
// * `
|
|
17
|
-
//
|
|
18
|
-
// itself displays a conversation under
|
|
19
|
-
// * `mintsNewSessionId: false` - the web UI mints its own ids when a
|
|
20
|
-
// conversation is started in the browser; nothing on the command line takes
|
|
21
|
-
// one
|
|
22
|
-
// * `terminalScope: 'project'` - one `dsh --profile web` serves every
|
|
23
|
-
// conversation of the project, so every open of the project focuses the
|
|
24
|
-
// terminal already running it rather than starting a second server
|
|
15
|
+
// * `mintsNewSessionId: false` - a bare `dsh tui` starts a conversation whose
|
|
16
|
+
// id the TUI mints itself; nothing on the command line takes one
|
|
25
17
|
// * `sessionIdPrefix: 'session-'` - every id is `session-<uuid>`, so the short
|
|
26
18
|
// id shown in menus is sliced past the constant part
|
|
27
|
-
// * no launch modes: the
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
//
|
|
31
|
-
//
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
// head to the left, the fluke raised at the right, an eye cut out with the
|
|
35
|
-
// even-odd rule. `jp-icon3` so the theme drives the fill in both light and
|
|
36
|
-
// dark; the 16px box matches every other icon in the sidebar.
|
|
37
|
-
const deepseekSvgStr = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16">
|
|
38
|
-
<path class="jp-icon3" fill="#616161" fill-rule="evenodd" d="M2 12c0-3.6 3-6.5 6.6-6.5h3.2c3.3 0 6.1 2.1 7 5l2.4-2.5c.5-.5 1.4 0 1.2.7l-1.2 3.3 1.2 3.3c.2.7-.7 1.2-1.2.7l-2.4-2.5c-.9 2.9-3.7 5-7 5H8.6C5 18.5 2 15.6 2 12zm6-2.6a1.1 1.1 0 1 0 0 2.2 1.1 1.1 0 0 0 0-2.2z"/>
|
|
19
|
+
// * no launch modes: the TUI has no approval switch on its command line
|
|
20
|
+
// DeepSeek's own mark: the whale, head to the left, the fluke raised at the
|
|
21
|
+
// right. `jp-icon3` so the theme drives the fill in both light and dark. The
|
|
22
|
+
// viewBox is the mark's own and the box is 16px like every other icon in the
|
|
23
|
+
// sidebar, which fits the whale inside it at its drawn proportions.
|
|
24
|
+
const deepseekSvgStr = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0.163 1.75 26.634 19.6" width="16" height="16">
|
|
25
|
+
<path class="jp-icon3" fill="#616161" d="M26.5174 3.39471C26.235 3.2567 26.1137 3.52006 25.9487 3.65346C25.8923 3.69659 25.8446 3.75294 25.7969 3.80469C25.3846 4.24516 24.9027 4.53439 24.2737 4.49989C23.3536 4.44814 22.5682 4.73737 21.8735 5.44119C21.7258 4.57349 21.2353 4.0554 20.4889 3.72304C20.0985 3.55054 19.7034 3.37746 19.4297 3.00197C19.2388 2.73459 19.1865 2.43673 19.091 2.14289C19.0301 1.96579 18.9697 1.78466 18.7656 1.75418C18.5442 1.71968 18.4574 1.90541 18.3705 2.06067C18.0232 2.69549 17.8887 3.39471 17.9019 4.10313C17.9324 5.6965 18.6051 6.96556 19.9421 7.86834C20.0939 7.97184 20.133 8.07535 20.0852 8.22658C19.9938 8.53766 19.8857 8.83955 19.7903 9.15063C19.7293 9.34901 19.6384 9.39271 19.4257 9.30588C18.692 8.9994 18.0583 8.54571 17.4982 7.99772C16.5477 7.07827 15.6881 6.06336 14.6162 5.26869C14.3644 5.08296 14.1125 4.91045 13.8521 4.746C12.7584 3.68394 13.9952 2.81164 14.2816 2.70814C14.5812 2.60003 14.3857 2.22857 13.4179 2.23317C12.4502 2.2372 11.5646 2.56151 10.4359 2.99335C10.2708 3.05832 10.0972 3.10547 9.91951 3.14457C8.8954 2.95022 7.83162 2.90709 6.72069 3.03245C4.62877 3.26533 2.95777 4.25436 1.72954 5.94261C0.254043 7.97184 -0.0932678 10.2777 0.33167 12.6824C0.778458 15.2171 2.07225 17.3153 4.06008 18.9558C6.12152 20.6567 8.49577 21.4905 11.2047 21.3306C12.8498 21.2358 14.6812 21.0155 16.7473 19.2669C17.2682 19.5262 17.8151 19.6297 18.7219 19.7074C19.4205 19.7723 20.0933 19.6729 20.6143 19.5648C21.4302 19.3923 21.3739 18.6367 21.0789 18.4981C18.6874 17.3843 19.2124 17.8374 18.7351 17.4706C19.9501 16.033 21.8063 13.4776 22.379 9.99821C22.4353 9.61409 22.5072 9.073 22.4986 8.76192C22.494 8.57216 22.5377 8.49856 22.7545 8.47671C23.3536 8.40771 23.935 8.24383 24.4692 7.94999C26.0188 7.10357 26.6439 5.71318 26.7911 4.04678C26.8129 3.79204 26.7865 3.52869 26.5174 3.39471ZM13.0143 18.3946C10.6964 16.5724 9.5722 15.9726 9.10816 15.9985C8.67402 16.0244 8.75222 16.5212 8.84768 16.8449C8.94773 17.1646 9.07768 17.3849 9.25996 17.6655C9.38589 17.8512 9.47272 18.1272 9.13404 18.3348C8.38766 18.7965 7.08985 18.1796 7.0289 18.1491C5.51833 17.2595 4.25559 16.0853 3.36546 14.4793C2.50581 12.9337 2.0067 11.2753 1.92447 9.50542C1.90262 9.07818 2.02855 8.92695 2.45406 8.84932C3.01413 8.74582 3.59144 8.72397 4.15093 8.80619C6.51656 9.15178 8.53027 10.2092 10.2185 11.8848C11.1822 12.8388 11.9114 13.979 12.6623 15.0929C13.461 16.2757 14.3201 17.4027 15.4144 18.3268C15.8008 18.6505 16.109 18.8966 16.404 19.0783C15.5144 19.1778 14.0297 19.1991 13.0143 18.3958V18.3946ZM14.1252 11.2489C14.1252 11.0591 14.277 10.9079 14.4679 10.9079C14.511 10.9079 14.5501 10.9165 14.5852 10.9292C14.6329 10.9464 14.6766 10.9723 14.7111 11.0114C14.7721 11.0718 14.8066 11.158 14.8066 11.2489C14.8066 11.4386 14.6548 11.5899 14.4639 11.5899C14.273 11.5899 14.1252 11.4386 14.1252 11.2489ZM17.5759 13.0188C17.3545 13.1096 17.1331 13.1873 16.9203 13.1959C16.5903 13.2131 16.2303 13.0791 16.0348 12.9153C15.7312 12.6605 15.5139 12.5179 15.423 12.0734C15.3839 11.8837 15.4057 11.5899 15.4402 11.4214C15.5185 11.0585 15.4316 10.8257 15.1757 10.614C14.9676 10.4415 14.7025 10.3938 14.4115 10.3938C14.3029 10.3938 14.2034 10.3461 14.1292 10.3076C14.0079 10.2472 13.9078 10.096 14.0033 9.91023C14.0338 9.84985 14.1815 9.70322 14.216 9.67734C14.6111 9.45251 15.0665 9.52612 15.488 9.6946C15.8784 9.85445 16.174 10.1477 16.5989 10.5623C17.033 11.0631 17.1112 11.2011 17.3585 11.5772C17.554 11.871 17.7317 12.1729 17.8536 12.5185C17.9272 12.7341 17.8317 12.9107 17.5759 13.0188Z"/>
|
|
39
26
|
</svg>`;
|
|
40
27
|
export const descriptor = {
|
|
41
28
|
id: 'deepseek',
|
|
@@ -46,8 +33,6 @@ export const descriptor = {
|
|
|
46
33
|
cliBinary: 'dsh',
|
|
47
34
|
forkStrategy: 'server-copy',
|
|
48
35
|
colourSource: 'none',
|
|
49
|
-
terminalScope: 'project',
|
|
50
|
-
promptsForBranchName: true,
|
|
51
36
|
// The name is the newest `session/title` event of the log.
|
|
52
37
|
canRename: true,
|
|
53
38
|
mintsNewSessionId: false,
|
|
@@ -57,9 +42,3 @@ export const descriptor = {
|
|
|
57
42
|
hasBgAgents: false,
|
|
58
43
|
hasLiveProcess: false
|
|
59
44
|
};
|
|
60
|
-
export const hooks = {
|
|
61
|
-
// The terminal serves the web UI and prints its URL; the conversation is
|
|
62
|
-
// then chosen in the browser. Naming that here is what keeps a click from
|
|
63
|
-
// reading as a resume that silently opened something else.
|
|
64
|
-
resumeLabel: () => 'Open Web UI'
|
|
65
|
-
};
|