@causyne/agent 1.20.117 → 1.20.120

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.
Files changed (82) hide show
  1. package/package.json +7 -2
  2. package/src/agentLoop.js +29 -12
  3. package/src/agentLoop.ts +29 -16
  4. package/src/browser/causyneBrowser.js +231 -136
  5. package/src/browser/causyneBrowser.ts +229 -140
  6. package/src/browser/searchProviders.js +41 -30
  7. package/src/browser/searchProviders.ts +24 -14
  8. package/src/browser/workspacePathSafety.js +50 -0
  9. package/src/browser/workspacePathSafety.ts +50 -0
  10. package/src/browser/workspacePreview.js +27 -4
  11. package/src/browser/workspacePreview.ts +28 -4
  12. package/src/cliMode.js +20 -4
  13. package/src/commands.js +12 -14
  14. package/src/creative/liveBridge.js +34 -1
  15. package/src/creative/liveBridge.ts +28 -1
  16. package/src/observer/evidence.js +23 -0
  17. package/src/observer/evidence.ts +21 -0
  18. package/src/plugins/pluginManager.js +74 -0
  19. package/src/providers/anthropic.js +33 -17
  20. package/src/providers/base.js +14 -0
  21. package/src/providers/dashscope-byok.js +13 -7
  22. package/src/providers/deepseek.js +13 -18
  23. package/src/providers/gemini.js +33 -25
  24. package/src/providers/moonshot.js +13 -12
  25. package/src/providers/ollama.js +21 -21
  26. package/src/providers/openai-compatible.js +12 -19
  27. package/src/providers/openrouter.js +20 -90
  28. package/src/providers/openrouter.ts +31 -94
  29. package/src/providers/qwen-byok.js +13 -7
  30. package/src/providers/toolContracts.js +9 -3
  31. package/src/providers/toolContracts.ts +9 -3
  32. package/src/providers/wireNormalizer.js +238 -0
  33. package/src/providers/wireNormalizer.ts +279 -0
  34. package/src/providers/xai.js +13 -12
  35. package/src/reporting.js +12 -4
  36. package/src/skillsManager.js +3 -2
  37. package/src/skillsManager.ts +3 -2
  38. package/src/tools/browserAutomator.js +13 -1
  39. package/src/tools/browserAutomator.ts +13 -0
  40. package/src/tools/creativeApps.js +2 -1
  41. package/src/tools/creativeApps.ts +2 -1
  42. package/src/tools/gameAssetFetcher.js +130 -26
  43. package/src/tools/gameAssetHarvester.js +80 -58
  44. package/src/tools/nativeEngine.js +1 -1
  45. package/src/tools/nativeEngine.ts +1 -1
  46. package/src/tools/pluginManager.js +17 -2
  47. package/src/tools/registry.js +13 -0
  48. package/src/tools/toolScanner.js +596 -140
  49. package/src/tools/toolScanner.ts +665 -147
  50. package/src/tools/toolSelfRepair.js +243 -114
  51. package/src/tools/toolSelfRepair.ts +262 -111
  52. package/src/tools/webFetch.js +161 -24
  53. package/src/tools/webFetch.ts +157 -22
  54. package/src/tools/webSearch.js +33 -4
  55. package/src/tools/webSearch.ts +27 -4
  56. package/src/tui/composerControls.js +16 -3
  57. package/src/tui/composerControls.ts +14 -3
  58. package/src/tui/prompt.js +122 -16
  59. package/src/tui/sessionPicker.js +132 -35
  60. package/src/tui/sessionPicker.ts +153 -32
  61. package/src/tui/sessionPickerView.js +277 -34
  62. package/src/tui/sessionPickerView.ts +328 -34
  63. package/src/tui/statusLine.js +3 -0
  64. package/src/tui/statusLine.ts +5 -0
  65. package/src/tui/usageCard.js +119 -47
  66. package/src/tui/usageCard.ts +133 -49
  67. package/src/tui/workspaceIdentity.js +133 -0
  68. package/src/tui/workspaceIdentity.ts +146 -0
  69. package/src/tui/workspaceSwitch.js +2 -0
  70. package/src/tui/workspaceSwitch.ts +1 -0
  71. package/src/verification/boundedExplorer.js +119 -0
  72. package/src/verification/cliProbe.js +116 -0
  73. package/src/verification/featureMap.js +78 -0
  74. package/src/verification/interactivePty.js +188 -0
  75. package/src/verification/propertyProbe.js +121 -0
  76. package/src/verification/ptyProbe.js +125 -0
  77. package/src/verification/skillCatalog.d.ts +1 -0
  78. package/src/verification/skillCatalog.js +60 -0
  79. package/src/verification/statechart.js +143 -0
  80. package/src/verification/uiRuntime.js +57 -0
  81. package/src/verificationPlan.js +1 -1
  82. package/src/verificationPlan.ts +1 -1
@@ -1,29 +1,25 @@
1
1
  /**
2
- * Causyne Agent /sessions: session-specific presentation on the existing modal stack.
3
- * No changes to the session store, approval policy or the shared SelectList.
2
+ * Causyne Agent /sessions: workspace-aware session presentation on the existing modal stack.
3
+ * Preserves the date-grouped placement algorithm while elevating the active workspace's
4
+ * sessions (or an explicit Empty state) above deduplicated All Sessions.
4
5
  */
5
- import path from 'node:path';
6
6
  // @ts-expect-error The existing dialog component is authored in JavaScript.
7
7
  import { SelectLayer } from './dialogs.js';
8
8
  // @ts-expect-error The theme is authored in JavaScript.
9
9
  import { bold, dim, paint, GLYPHS } from './theme.js';
10
10
  import { safeDisplay, truncate, visibleWidth } from './text.js';
11
+ import { sameWorkspace, workspaceDisplayName, shortenWorkspacePath, formatWorkspaceSectionTitle } from './workspaceIdentity.js';
11
12
  const INNER_HEADER_ROWS = 3; // scope, search, divider
12
13
  const INNER_DETAIL_ROWS = 3; // divider, selected title, metadata
13
14
  const MAX_PANEL_HEIGHT = 28;
14
15
  function clean(value) {
15
16
  return safeDisplay(typeof value === 'string' ? value : String(value ?? '')).replace(/[\r\n]+/g, ' ');
16
17
  }
17
- function sameWorkspace(first, second) {
18
- if (!first || !second)
19
- return false;
20
- const a = path.resolve(first);
21
- const b = path.resolve(second);
22
- return process.platform === 'win32' ? a.toLowerCase() === b.toLowerCase() : a === b;
23
- }
24
18
  function rowPair(left, right, width) {
25
19
  const room = Number.isFinite(width) ? Math.max(0, Math.floor(width)) : 60;
26
20
  const rightWidth = visibleWidth(right);
21
+ if (rightWidth === 0)
22
+ return truncate(left, room, '…');
27
23
  if (rightWidth >= room - 5)
28
24
  return truncate(left, room, '…');
29
25
  const safeLeft = truncate(left, Math.max(0, room - rightWidth - 2), '…');
@@ -70,62 +66,293 @@ function actionOrSessionText(item, selected, width) {
70
66
  const styledName = selected ? bold(paint('ink', name)) : paint('ink', name);
71
67
  return rowPair(leftPrefix + styledName, usableRight, width);
72
68
  }
69
+ function resolveItemSection(item, currentWorkspace, cache) {
70
+ if (item.value.type !== 'switch')
71
+ return 'actions';
72
+ if (item.section === 'workspace' || item.section === 'all') {
73
+ if (!currentWorkspace || item.value.workspace === undefined)
74
+ return item.section;
75
+ }
76
+ if (currentWorkspace && sameWorkspace(item.value.workspace, currentWorkspace, cache)) {
77
+ return 'workspace';
78
+ }
79
+ return 'all';
80
+ }
81
+ /**
82
+ * Partition picker items into:
83
+ * 1. Pinned actions
84
+ * 2. Current workspace sessions (preserving date-sorted order)
85
+ * 3. All other sessions (preserving date-sorted order, strictly deduplicated)
86
+ */
87
+ export function partitionSessionPickerItems(items, currentWorkspace, cache) {
88
+ const actions = [];
89
+ const workspace = [];
90
+ const other = [];
91
+ const seenIds = new Set();
92
+ for (const raw of Array.isArray(items) ? items : []) {
93
+ if (!raw || !raw.value)
94
+ continue;
95
+ const key = typeof raw.id === 'string' && raw.id ? raw.id : '';
96
+ if (key && seenIds.has(key))
97
+ continue;
98
+ if (key)
99
+ seenIds.add(key);
100
+ if (raw.value.type !== 'switch') {
101
+ actions.push(raw.section === 'actions' ? raw : { ...raw, section: 'actions' });
102
+ continue;
103
+ }
104
+ const inWorkspace = sameWorkspace(raw.value.workspace, currentWorkspace, cache);
105
+ if (inWorkspace) {
106
+ workspace.push(raw.section === 'workspace' ? raw : { ...raw, section: 'workspace' });
107
+ }
108
+ else {
109
+ other.push(raw.section === 'all' ? raw : { ...raw, section: 'all' });
110
+ }
111
+ }
112
+ return {
113
+ ordered: [...actions, ...workspace, ...other],
114
+ workspaceCount: workspace.length,
115
+ otherCount: other.length
116
+ };
117
+ }
73
118
  /**
74
- * Category headers are terminal rows, not selectable items. This window is
75
- * measured in *actual rows*, preventing selection disappearing at group edges.
119
+ * Section and date headers are terminal rows, not selectable items. This window is
120
+ * measured in *actual rows*, preventing orphaned headers or hidden selections at
121
+ * section and group boundaries.
76
122
  */
77
- export function renderSessionRows(entries, start, selected, width, budget) {
123
+ export function renderSessionRows(entries, start, selected, width, budget, options) {
78
124
  const rows = [];
79
125
  const safeStart = Number.isFinite(start) ? Math.max(0, Math.floor(start)) : 0;
80
126
  const safeWidth = Number.isFinite(width) ? Math.max(4, Math.floor(width)) : 60;
81
127
  const safeBudget = budget === Number.POSITIVE_INFINITY
82
- ? entries.length
128
+ ? Math.max(entries.length * 4 + 6, 16)
83
129
  : (Number.isFinite(budget) ? Math.max(0, Math.floor(budget)) : 0);
130
+ if (safeBudget === 0) {
131
+ return { rows, lastIndex: safeStart - 1 };
132
+ }
133
+ const useSections = Boolean(options?.currentWorkspace
134
+ || entries.some((entry) => entry?.item?.section !== undefined));
135
+ // Legacy 5-argument direct rendering without workspace sections.
136
+ if (!useSections) {
137
+ let lastIndex = safeStart - 1;
138
+ let previousCategory = null;
139
+ for (let i = safeStart; i < entries.length && rows.length < safeBudget; i++) {
140
+ const item = entries[i].item;
141
+ const category = clean(item.category || 'Sessions');
142
+ const isNewGroup = category !== previousCategory;
143
+ // Avoid leaving an orphaned header in the final available row.
144
+ if (isNewGroup && safeBudget - rows.length >= 2) {
145
+ rows.push(dim(` ${truncate(category.toUpperCase(), Math.max(1, safeWidth - 4), '…')}`));
146
+ }
147
+ else if (isNewGroup && rows.length > 0) {
148
+ break;
149
+ }
150
+ if (rows.length >= safeBudget)
151
+ break;
152
+ rows.push(actionOrSessionText(item, i === selected, safeWidth));
153
+ lastIndex = i;
154
+ previousCategory = category;
155
+ }
156
+ return { rows, lastIndex };
157
+ }
158
+ const currentWorkspace = options?.currentWorkspace;
159
+ const cache = options?.canonicalCache;
160
+ const isSearching = Boolean(options?.isSearching);
161
+ const wsCount = typeof options?.workspaceCount === 'number' && Number.isFinite(options.workspaceCount)
162
+ ? Math.max(0, Math.floor(options.workspaceCount))
163
+ : entries.filter((entry) => resolveItemSection(entry.item, currentWorkspace, cache) === 'workspace').length;
164
+ const otherCount = typeof options?.otherCount === 'number' && Number.isFinite(options.otherCount)
165
+ ? Math.max(0, Math.floor(options.otherCount))
166
+ : entries.filter((entry) => resolveItemSection(entry.item, currentWorkspace, cache) === 'all').length;
167
+ const wsDisplayName = workspaceDisplayName(currentWorkspace, cache);
168
+ const wsShortPath = currentWorkspace ? shortenWorkspacePath(currentWorkspace) : '';
169
+ const actionsHeaderRow = () => dim(` ${truncate('ACTIONS', Math.max(1, safeWidth - 4), '…')}`);
170
+ const workspaceSectionRow = () => {
171
+ const title = formatWorkspaceSectionTitle(currentWorkspace, wsCount, cache);
172
+ const styledLeft = ` ${bold(paint('accent', title))}`;
173
+ const leftWidth = visibleWidth(styledLeft);
174
+ const remainingForPath = safeWidth - leftWidth - 3;
175
+ let rightPath = '';
176
+ if (safeWidth >= 52
177
+ && remainingForPath >= 12
178
+ && wsShortPath
179
+ && wsShortPath !== wsDisplayName
180
+ && wsShortPath !== '(default)') {
181
+ let shownPath = wsShortPath;
182
+ if (visibleWidth(shownPath) > remainingForPath) {
183
+ const runes = Array.from(shownPath);
184
+ const budget = Math.max(1, remainingForPath - 1);
185
+ while (runes.length > 0 && visibleWidth(runes.join('')) > budget)
186
+ runes.shift();
187
+ shownPath = `…${runes.join('')}`;
188
+ }
189
+ rightPath = dim(shownPath);
190
+ }
191
+ return rowPair(styledLeft, rightPath, safeWidth);
192
+ };
193
+ const workspaceEmptyRow = () => {
194
+ const label = safeWidth >= 46
195
+ ? 'Empty — no sessions in this workspace yet'
196
+ : 'Empty';
197
+ return dim(` ${truncate(label, Math.max(1, safeWidth - 4), '…')}`);
198
+ };
199
+ const allSessionsSectionRow = () => {
200
+ const title = `ALL SESSIONS (${otherCount})`;
201
+ return truncate(` ${bold(paint('ink', title))}`, safeWidth, '…');
202
+ };
203
+ const dateSubHeaderRow = (category) => dim(` ${truncate(category.toUpperCase(), Math.max(1, safeWidth - 6), '…')}`);
204
+ const searchGroupHeaderRow = (section, category) => {
205
+ if (section === 'actions')
206
+ return actionsHeaderRow();
207
+ if (section === 'workspace') {
208
+ const text = `${wsDisplayName} ${GLYPHS.dot} ${category.toUpperCase()}`;
209
+ return truncate(` ${paint('accent', text)}`, safeWidth, '…');
210
+ }
211
+ const text = `ALL SESSIONS ${GLYPHS.dot} ${category.toUpperCase()}`;
212
+ return dim(` ${truncate(text, Math.max(1, safeWidth - 4), '…')}`);
213
+ };
214
+ const shouldShowEmptyWorkspace = !isSearching && wsCount === 0;
215
+ let emptyWorkspaceEmitted = false;
84
216
  let lastIndex = safeStart - 1;
217
+ let previousSection = null;
85
218
  let previousCategory = null;
86
219
  for (let i = safeStart; i < entries.length && rows.length < safeBudget; i++) {
87
220
  const item = entries[i].item;
88
221
  const category = clean(item.category || 'Sessions');
89
- const isNewGroup = category !== previousCategory;
90
- // Avoid leaving an orphaned header in the final available row.
91
- if (isNewGroup && safeBudget - rows.length >= 2) {
92
- rows.push(dim(` ${truncate(category.toUpperCase(), Math.max(1, safeWidth - 4), '…')}`));
222
+ const section = resolveItemSection(item, currentWorkspace, cache);
223
+ // Emit the Empty workspace block directly after Actions (or at index 0 when
224
+ // there are no Actions) before transitioning into ALL SESSIONS.
225
+ const needsEmptyWorkspaceBefore = shouldShowEmptyWorkspace
226
+ && !emptyWorkspaceEmitted
227
+ && section === 'all'
228
+ && (previousSection === 'actions' || (safeStart === 0 && i === 0));
229
+ if (needsEmptyWorkspaceBefore) {
230
+ const remainingBeforeEmpty = safeBudget - rows.length;
231
+ if (rows.length === 0 && i === selected && remainingBeforeEmpty < 3) {
232
+ // Ultra-short viewport targeting this item: never let the empty notice starve selection.
233
+ emptyWorkspaceEmitted = true;
234
+ }
235
+ else if (remainingBeforeEmpty >= 2) {
236
+ rows.push(workspaceSectionRow());
237
+ rows.push(workspaceEmptyRow());
238
+ emptyWorkspaceEmitted = true;
239
+ }
240
+ else if (rows.length > 0) {
241
+ break;
242
+ }
93
243
  }
94
- else if (isNewGroup && rows.length > 0) {
95
- break;
244
+ const pendingHeaders = [];
245
+ if (isSearching) {
246
+ if (section !== previousSection || category !== previousCategory) {
247
+ pendingHeaders.push(searchGroupHeaderRow(section, category));
248
+ }
249
+ }
250
+ else {
251
+ const sectionChanged = section !== previousSection;
252
+ if (sectionChanged) {
253
+ // Reset date tracking on section change so TODAY renders cleanly under ALL SESSIONS
254
+ // even when the preceding workspace section also ended on TODAY.
255
+ previousCategory = null;
256
+ if (section === 'actions') {
257
+ pendingHeaders.push(actionsHeaderRow());
258
+ }
259
+ else if (section === 'workspace') {
260
+ pendingHeaders.push(workspaceSectionRow());
261
+ }
262
+ else {
263
+ pendingHeaders.push(allSessionsSectionRow());
264
+ }
265
+ }
266
+ if (section !== 'actions' && category !== previousCategory) {
267
+ pendingHeaders.push(dateSubHeaderRow(category));
268
+ }
269
+ }
270
+ const remaining = safeBudget - rows.length;
271
+ if (pendingHeaders.length + 1 <= remaining) {
272
+ rows.push(...pendingHeaders);
273
+ rows.push(actionOrSessionText(item, i === selected, safeWidth));
274
+ }
275
+ else if (rows.length === 0) {
276
+ // First item in window on a very tight viewport: keep selection visible without orphaned headers.
277
+ if (remaining >= 2 && pendingHeaders.length > 0) {
278
+ rows.push(pendingHeaders[0]);
279
+ rows.push(actionOrSessionText(item, i === selected, safeWidth));
280
+ }
281
+ else if (remaining >= 1) {
282
+ rows.push(actionOrSessionText(item, i === selected, safeWidth));
283
+ }
284
+ else {
285
+ break;
286
+ }
96
287
  }
97
- if (rows.length >= safeBudget)
288
+ else {
98
289
  break;
99
- rows.push(actionOrSessionText(item, i === selected, safeWidth));
290
+ }
100
291
  lastIndex = i;
292
+ previousSection = section;
101
293
  previousCategory = category;
102
294
  }
295
+ // When the current workspace has 0 sessions and no other sessions followed Actions
296
+ // (for example: brand-new install or Tab-scoped THIS WORKSPACE view), show the
297
+ // workspace section header + Empty notice directly beneath Actions.
298
+ const reachedEnd = entries.length === 0 || lastIndex === entries.length - 1;
299
+ if (shouldShowEmptyWorkspace && !emptyWorkspaceEmitted && reachedEnd && safeBudget - rows.length >= 2) {
300
+ rows.push(workspaceSectionRow());
301
+ rows.push(workspaceEmptyRow());
302
+ }
103
303
  return { rows, lastIndex };
104
304
  }
105
305
  export class SessionPickerLayer extends SelectLayer {
106
306
  currentWorkspace;
107
307
  activeId;
108
308
  allItems;
309
+ canonicalCache;
310
+ lastWidth = 80;
109
311
  scope = 'all';
110
312
  constructor(options) {
313
+ const canonicalCache = new Map();
314
+ const partitioned = partitionSessionPickerItems(options.items, options.currentWorkspace, canonicalCache);
315
+ const totalSwitchCount = partitioned.workspaceCount + partitioned.otherCount;
111
316
  super({
112
- title: `Sessions ${options.items.filter(i => i.value.type === 'switch').length}`,
317
+ title: `Sessions ${totalSwitchCount}`,
113
318
  width: 100,
114
319
  height: MAX_PANEL_HEIGHT,
115
- items: options.items,
320
+ items: partitioned.ordered,
116
321
  placeholder: 'Search sessions by title, ID or workspace',
117
322
  emptyText: 'No matching sessions',
118
323
  footer: `↑↓ navigate ${GLYPHS.dot} enter open ${GLYPHS.dot} tab workspace ${GLYPHS.dot} esc close`,
119
324
  onPick: options.onPick
120
325
  });
121
- this.allItems = options.items;
326
+ this.canonicalCache = canonicalCache;
327
+ this.allItems = partitioned.ordered;
122
328
  this.currentWorkspace = options.currentWorkspace;
123
329
  this.activeId = options.activeId;
124
330
  }
331
+ renderOptions(entries) {
332
+ const isSearching = Boolean(clean(this.list.query || '').trim());
333
+ let workspaceCount = 0;
334
+ let otherCount = 0;
335
+ for (const entry of entries) {
336
+ const section = resolveItemSection(entry.item, this.currentWorkspace, this.canonicalCache);
337
+ if (section === 'workspace')
338
+ workspaceCount++;
339
+ else if (section === 'all')
340
+ otherCount++;
341
+ }
342
+ return {
343
+ currentWorkspace: this.currentWorkspace,
344
+ workspaceCount,
345
+ otherCount,
346
+ scope: this.scope,
347
+ isSearching,
348
+ canonicalCache: this.canonicalCache
349
+ };
350
+ }
125
351
  preferredHeight() {
126
352
  // Modals with a few sessions do not retain a large blank area.
127
- const distinctGroups = new Set(this.list.filtered.map((entry) => entry.item.category));
128
- const content = this.list.filtered.length + distinctGroups.size;
353
+ const entries = this.list.filtered;
354
+ const rendered = renderSessionRows(entries, 0, 0, this.lastWidth, MAX_PANEL_HEIGHT, this.renderOptions(entries));
355
+ const content = Math.max(1, rendered.rows.length);
129
356
  return Math.min(MAX_PANEL_HEIGHT, Math.max(12, content + INNER_HEADER_ROWS + INNER_DETAIL_ROWS + 2));
130
357
  }
131
358
  countSessions() {
@@ -137,11 +364,11 @@ export class SessionPickerLayer extends SelectLayer {
137
364
  const scoped = this.scope === 'all'
138
365
  ? this.allItems
139
366
  : this.allItems.filter(item => item.value.type !== 'switch' ||
140
- sameWorkspace(item.value.workspace, this.currentWorkspace));
367
+ sameWorkspace(item.value.workspace, this.currentWorkspace, this.canonicalCache));
141
368
  this.list.setItems(scoped);
142
369
  const next = this.list.filtered.findIndex((entry) => entry.item.id === oldId);
143
- const firstSession = this.list.filtered.findIndex((entry) => entry.item.value.type === 'switch');
144
- this.list.selected = next >= 0 ? next : Math.max(0, firstSession);
370
+ const firstWorkspace = this.list.filtered.findIndex((entry) => entry.item.section === 'workspace');
371
+ this.list.selected = next >= 0 ? next : Math.max(0, firstWorkspace);
145
372
  this.list.offset = 0;
146
373
  }
147
374
  key(event) {
@@ -149,6 +376,18 @@ export class SessionPickerLayer extends SelectLayer {
149
376
  this.toggleWorkspace();
150
377
  return 'handled';
151
378
  }
379
+ if (event?.name === 'pageup' || event?.name === 'pagedown') {
380
+ const entries = this.list.filtered;
381
+ if (entries.length === 0)
382
+ return 'handled';
383
+ const available = Math.max(1, this.list.lastItemRows || 12);
384
+ const offset = Math.max(0, Math.min(Math.floor(this.list.offset || 0), entries.length - 1));
385
+ const selected = Math.max(0, Math.min(Math.floor(this.list.selected || 0), entries.length - 1));
386
+ const window = renderSessionRows(entries, offset, selected, this.lastWidth, available, this.renderOptions(entries));
387
+ const page = Math.max(1, window.lastIndex - offset + 1);
388
+ this.list.move(event.name === 'pageup' ? -page : page, available);
389
+ return 'handled';
390
+ }
152
391
  const previousQuery = this.list.query;
153
392
  const result = super.key(event);
154
393
  if (this.list.query !== previousQuery) {
@@ -160,11 +399,14 @@ export class SessionPickerLayer extends SelectLayer {
160
399
  body(width, height) {
161
400
  const w = Math.max(12, Number.isFinite(width) ? Math.floor(width) : 60);
162
401
  const h = Math.max(1, Number.isFinite(height) ? Math.floor(height) : 20);
402
+ this.lastWidth = w;
163
403
  const rows = [];
164
404
  const scopeLabel = this.scope === 'all' ? 'ALL WORKSPACES' : 'THIS WORKSPACE';
405
+ const wsName = workspaceDisplayName(this.currentWorkspace, this.canonicalCache);
165
406
  const total = this.allItems.filter(item => item.value.type === 'switch').length;
166
407
  const count = this.countSessions();
167
- rows.push(rowPair(` ${paint('accent', scopeLabel)}`, w >= 52 ? dim(`${count} / ${total} sessions`) : '', w));
408
+ const leftScope = ` ${paint('accent', scopeLabel)} ${dim(`${GLYPHS.dot} ${wsName}`)}`;
409
+ rows.push(rowPair(leftScope, w >= 52 ? dim(`${count} / ${total} sessions`) : '', w));
168
410
  const query = clean(this.list.query || '');
169
411
  const lead = ` ${paint('accent', GLYPHS.arrow)} `;
170
412
  const maxInput = Math.max(1, w - visibleWidth(lead) - 1);
@@ -193,10 +435,11 @@ export class SessionPickerLayer extends SelectLayer {
193
435
  const selected = Math.max(0, Math.min(rawSel, entries.length - 1));
194
436
  this.list.selected = selected;
195
437
  let start = Math.max(0, Math.min(rawOff, selected));
196
- let output = renderSessionRows(entries, start, selected, w, available);
438
+ const renderOpts = this.renderOptions(entries);
439
+ let output = renderSessionRows(entries, start, selected, w, available, renderOpts);
197
440
  while (output.lastIndex < selected && start < selected) {
198
441
  start++;
199
- output = renderSessionRows(entries, start, selected, w, available);
442
+ output = renderSessionRows(entries, start, selected, w, available, renderOpts);
200
443
  }
201
444
  this.list.offset = start;
202
445
  this.list.lastItemRows = available;
@@ -214,7 +457,7 @@ export class SessionPickerLayer extends SelectLayer {
214
457
  rows.push(rowPair(` ${truncate(title, Math.max(1, w - 19), '…')}`, state, w));
215
458
  const description = chosen.value.type === 'switch'
216
459
  ? chosen.description
217
- : chosen.value.type === 'new' ? 'Start with an empty conversation in this workspace'
460
+ : chosen.value.type === 'new' ? `Start with an empty conversation in ${wsName}`
218
461
  : 'Duplicate conversation history; authorization is reset';
219
462
  rows.push(dim(` ${truncate(clean(description), Math.max(1, w - 3), '…')}`));
220
463
  }