dsh-agent-enhancer 0.3.0 → 0.3.1

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 (90) hide show
  1. package/README.en.md +22 -10
  2. package/README.md +22 -10
  3. package/lib/client/context/open-tab.d.ts +5 -0
  4. package/lib/client/context/open-tab.d.ts.map +1 -1
  5. package/lib/client/dsh/conversation.d.ts.map +1 -1
  6. package/lib/client/dsh/icons.d.ts +2 -0
  7. package/lib/client/dsh/icons.d.ts.map +1 -1
  8. package/lib/client/dsh/overlay.d.ts.map +1 -1
  9. package/lib/client/index.d.ts.map +1 -1
  10. package/lib/client/locales.d.ts +93 -9
  11. package/lib/client/locales.d.ts.map +1 -1
  12. package/lib/client/prompt/coordinator.d.ts +2 -0
  13. package/lib/client/prompt/coordinator.d.ts.map +1 -1
  14. package/lib/client/prompt/history.d.ts.map +1 -1
  15. package/lib/client/prompt/ledger-store.d.ts +8 -0
  16. package/lib/client/prompt/ledger-store.d.ts.map +1 -0
  17. package/lib/client/prompt/ledger.d.ts +15 -0
  18. package/lib/client/prompt/ledger.d.ts.map +1 -0
  19. package/lib/client/rollback/actions.d.ts +1 -0
  20. package/lib/client/rollback/actions.d.ts.map +1 -1
  21. package/lib/client/rollback/controller.d.ts +24 -2
  22. package/lib/client/rollback/controller.d.ts.map +1 -1
  23. package/lib/client/rollback/failure.d.ts +7 -0
  24. package/lib/client/rollback/failure.d.ts.map +1 -0
  25. package/lib/client/rollback/format.d.ts +23 -0
  26. package/lib/client/rollback/format.d.ts.map +1 -0
  27. package/lib/client/rollback/input-actions-cache.d.ts +6 -0
  28. package/lib/client/rollback/input-actions-cache.d.ts.map +1 -0
  29. package/lib/client/rollback/modal-host.d.ts +13 -0
  30. package/lib/client/rollback/modal-host.d.ts.map +1 -1
  31. package/lib/client/rollback/preview.d.ts +3 -2
  32. package/lib/client/rollback/preview.d.ts.map +1 -1
  33. package/lib/client/rollback/prompt-entries.d.ts +9 -0
  34. package/lib/client/rollback/prompt-entries.d.ts.map +1 -0
  35. package/lib/client/rollback/remote.d.ts +2 -1
  36. package/lib/client/rollback/remote.d.ts.map +1 -1
  37. package/lib/client/rollback/session-stats-dock.d.ts +10 -0
  38. package/lib/client/rollback/session-stats-dock.d.ts.map +1 -0
  39. package/lib/client/rollback/session-stats-filter.d.ts +18 -0
  40. package/lib/client/rollback/session-stats-filter.d.ts.map +1 -0
  41. package/lib/client/rollback/session-stats-meter.d.ts +18 -0
  42. package/lib/client/rollback/session-stats-meter.d.ts.map +1 -0
  43. package/lib/client/rollback/timeline-format.d.ts +23 -0
  44. package/lib/client/rollback/timeline-format.d.ts.map +1 -0
  45. package/lib/client/rollback/timeline-kind.d.ts +13 -0
  46. package/lib/client/rollback/timeline-kind.d.ts.map +1 -0
  47. package/lib/client/rollback/timeline-panel.d.ts +25 -0
  48. package/lib/client/rollback/timeline-panel.d.ts.map +1 -0
  49. package/lib/client/rollback/timeline-tab.d.ts +39 -0
  50. package/lib/client/rollback/timeline-tab.d.ts.map +1 -0
  51. package/lib/client/rollback/transcript-filter.d.ts +5 -0
  52. package/lib/client/rollback/transcript-filter.d.ts.map +1 -1
  53. package/lib/client/rollback/transcript.d.ts +45 -5
  54. package/lib/client/rollback/transcript.d.ts.map +1 -1
  55. package/lib/client/rollback/turn-outline-filter.d.ts.map +1 -1
  56. package/lib/client/rollback/types.d.ts +14 -1
  57. package/lib/client/rollback/types.d.ts.map +1 -1
  58. package/lib/client/rollback/user-node.d.ts +1 -0
  59. package/lib/client/rollback/user-node.d.ts.map +1 -1
  60. package/lib/client.js +1807 -236
  61. package/lib/client.js.map +1 -1
  62. package/lib/host/auto-route/session-hook.d.ts.map +1 -1
  63. package/lib/host/auto-route/session-selection.d.ts.map +1 -1
  64. package/lib/host/checkpoint/activity.d.ts +43 -0
  65. package/lib/host/checkpoint/activity.d.ts.map +1 -0
  66. package/lib/host/checkpoint/availability.d.ts +8 -1
  67. package/lib/host/checkpoint/availability.d.ts.map +1 -1
  68. package/lib/host/checkpoint/capture.d.ts +12 -4
  69. package/lib/host/checkpoint/capture.d.ts.map +1 -1
  70. package/lib/host/checkpoint/dsh.d.ts.map +1 -1
  71. package/lib/host/checkpoint/files.d.ts +3 -0
  72. package/lib/host/checkpoint/files.d.ts.map +1 -1
  73. package/lib/host/checkpoint/live.d.ts +8 -0
  74. package/lib/host/checkpoint/live.d.ts.map +1 -1
  75. package/lib/host/checkpoint/service.d.ts +82 -0
  76. package/lib/host/checkpoint/service.d.ts.map +1 -1
  77. package/lib/host/checkpoint/store.d.ts +7 -0
  78. package/lib/host/checkpoint/store.d.ts.map +1 -1
  79. package/lib/host/checkpoint/workspace-snapshot.d.ts +30 -0
  80. package/lib/host/checkpoint/workspace-snapshot.d.ts.map +1 -0
  81. package/lib/host/index.d.ts +2 -1
  82. package/lib/host/index.d.ts.map +1 -1
  83. package/lib/host/rpc.d.ts +3 -0
  84. package/lib/host/rpc.d.ts.map +1 -1
  85. package/lib/host/usage/source.d.ts.map +1 -1
  86. package/lib/identity.d.ts +1 -1
  87. package/lib/identity.d.ts.map +1 -1
  88. package/lib/index.js +1094 -138
  89. package/lib/index.js.map +4 -4
  90. package/package.json +61 -60
package/lib/client.js CHANGED
@@ -26,7 +26,7 @@ __export(index_exports, {
26
26
  inject: () => inject
27
27
  });
28
28
  module.exports = __toCommonJS(index_exports);
29
- var import_react15 = require("react");
29
+ var import_react18 = require("react");
30
30
 
31
31
  // src/host/auto-route/sentinel.ts
32
32
  var AUTO_PROVIDER = "agent-enhancer";
@@ -112,6 +112,52 @@ function resolveUiLocale(id) {
112
112
  var PROVIDER_BALANCE_ACCOUNT_KEY = "llm-deepseek-account";
113
113
  var PROVIDER_BALANCE_API_KEY_KEY = "llm-deepseek";
114
114
 
115
+ // src/client/prompt/ledger.ts
116
+ var PromptHistoryLedger = class {
117
+ /** Keyed by exact `text`; value is the newest seq for that string. */
118
+ byText = /* @__PURE__ */ new Map();
119
+ observe(incoming) {
120
+ for (const entry of incoming) {
121
+ if (entry.text.trim() === "") continue;
122
+ const previous = this.byText.get(entry.text);
123
+ if (previous !== void 0 && previous.seq > entry.seq) continue;
124
+ this.byText.set(entry.text, entry);
125
+ }
126
+ return this.list();
127
+ }
128
+ list() {
129
+ return [...this.byText.values()].sort((a, b) => a.seq - b.seq);
130
+ }
131
+ clear() {
132
+ this.byText.clear();
133
+ }
134
+ };
135
+
136
+ // src/client/prompt/ledger-store.ts
137
+ var ledgers = /* @__PURE__ */ new Map();
138
+ var invalidators = /* @__PURE__ */ new Set();
139
+ function promptLedgerFor(sessionId) {
140
+ const key = String(sessionId);
141
+ let ledger = ledgers.get(key);
142
+ if (ledger === void 0) {
143
+ ledger = new PromptHistoryLedger();
144
+ ledgers.set(key, ledger);
145
+ }
146
+ return ledger;
147
+ }
148
+ function disposePromptLedger(sessionId) {
149
+ ledgers.delete(String(sessionId));
150
+ }
151
+ function subscribePromptLedgerInvalidation(listener) {
152
+ invalidators.add(listener);
153
+ return () => {
154
+ invalidators.delete(listener);
155
+ };
156
+ }
157
+ function invalidatePromptHistory(sessionId) {
158
+ for (const listener of invalidators) listener(sessionId);
159
+ }
160
+
115
161
  // src/errors.ts
116
162
  var AUXILIARY_ERROR_CODES = [
117
163
  "MODEL_UNAVAILABLE",
@@ -209,12 +255,17 @@ function replaceAroundOccurrences(actions, source, occurrences, optimizedSegment
209
255
  var PromptHistory = class {
210
256
  constructor(entries) {
211
257
  this.entries = entries;
212
- const seen = /* @__PURE__ */ new Set();
213
- this.entries = entries.filter((entry) => {
214
- if (seen.has(entry.seq)) return false;
215
- seen.add(entry.seq);
258
+ const bySeq = /* @__PURE__ */ new Map();
259
+ for (const entry of entries) {
260
+ if (!bySeq.has(entry.seq)) bySeq.set(entry.seq, entry);
261
+ }
262
+ const newestFirst = [...bySeq.values()].sort((a, b) => b.seq - a.seq);
263
+ const seenText = /* @__PURE__ */ new Set();
264
+ this.entries = newestFirst.filter((entry) => {
265
+ if (seenText.has(entry.text)) return false;
266
+ seenText.add(entry.text);
216
267
  return true;
217
- }).sort((a, b) => b.seq - a.seq);
268
+ });
218
269
  }
219
270
  entries;
220
271
  previous(index) {
@@ -297,6 +348,13 @@ var Coordinator = class {
297
348
  this.historyPending.clear();
298
349
  };
299
350
  }
351
+ /** Drop cached ↑↓ / search entries without leaving history mode. */
352
+ invalidateHistoryCache(sessionId) {
353
+ if (this.disposed) return;
354
+ if (sessionId === void 0) this.historyCache.clear();
355
+ else this.historyCache.delete(sessionId);
356
+ this.historyPending.clear();
357
+ }
300
358
  refreshSettings() {
301
359
  if (this.disposed || this.switches.history()) return;
302
360
  if (this.mode.kind !== "history" && this.mode.kind !== "search") return;
@@ -355,39 +413,52 @@ var Coordinator = class {
355
413
  this.updateLocalDraft(draft, this.optimizedEnd);
356
414
  return true;
357
415
  }
358
- undoOptimization(cache) {
359
- if (this.disposed || this.input === null || this.input.sessionId !== cache.selection.sessionId) return false;
360
- const end = cache.selection.start + cache.optimized.length;
361
- if (this.input.draft.slice(cache.selection.start, end) !== cache.optimized) return false;
362
- const structured = cache.selection.structured === true;
363
- if (structured && (cache.sourceSegments === void 0 || cache.optimizedSegments === void 0 || cache.optimizedSegments.length !== this.input.occurrences.length + 1 || !sameOptimizedOccurrences(
364
- cache.selection.occurrences,
416
+ undoOptimization(cache2) {
417
+ if (this.disposed || this.input === null || this.input.sessionId !== cache2.selection.sessionId) return false;
418
+ const end = cache2.selection.start + cache2.optimized.length;
419
+ if (this.input.draft.slice(cache2.selection.start, end) !== cache2.optimized) return false;
420
+ const structured = cache2.selection.structured === true;
421
+ if (structured && (cache2.sourceSegments === void 0 || cache2.optimizedSegments === void 0 || cache2.optimizedSegments.length !== this.input.occurrences.length + 1 || !sameOptimizedOccurrences(
422
+ cache2.selection.occurrences,
365
423
  this.input.occurrences,
366
- cache.sourceSegments,
367
- cache.optimizedSegments
368
- ) || !sameSegments(textSegments(this.input.draft, this.input.occurrences), cache.optimizedSegments))) return false;
424
+ cache2.sourceSegments,
425
+ cache2.optimizedSegments
426
+ ) || !sameSegments(textSegments(this.input.draft, this.input.occurrences), cache2.optimizedSegments))) return false;
369
427
  const selection = {
370
428
  sessionId: this.input.sessionId,
371
429
  draftRev: this.input.draftRev,
372
- start: cache.selection.start,
430
+ start: cache2.selection.start,
373
431
  end,
374
432
  ...this.input.occurrences.length > 0 ? { occurrences: this.input.occurrences } : {},
375
433
  ...structured ? { structured: true } : {}
376
434
  };
377
- if (!this.writer.replace(cache.source, selection, cache.sourceSegments, this.input.draft)) return false;
378
- const restored = this.input.draft.slice(0, selection.start) + cache.source + this.input.draft.slice(end);
435
+ if (!this.writer.replace(cache2.source, selection, cache2.sourceSegments, this.input.draft)) return false;
436
+ const restored = this.input.draft.slice(0, selection.start) + cache2.source + this.input.draft.slice(end);
379
437
  this.generation += 1;
380
438
  this.resetTransient();
381
- this.updateLocalDraft(restored, selection.start + cache.source.length);
439
+ this.updateLocalDraft(restored, selection.start + cache2.source.length);
382
440
  return true;
383
441
  }
384
442
  updateSearch(query) {
385
443
  if (this.disposed || this.mode.kind !== "search" || this.input === null) return false;
386
- const entries = this.historyCache.get(this.input.sessionId)?.entries ?? [];
387
- this.searchEntries = new PromptHistory(entries).search(query);
388
- this.searchIndex = this.searchEntries.length > 0 ? 0 : -1;
444
+ const generation = this.generation;
445
+ const guard = guardOf(this.input);
446
+ const entries = this.loadHistory(this.input.sessionId);
447
+ if (Array.isArray(entries)) {
448
+ this.searchEntries = new PromptHistory(entries).search(query);
449
+ this.searchIndex = this.searchEntries.length > 0 ? 0 : -1;
450
+ this.mode = { ...this.mode, query };
451
+ this.emit();
452
+ return true;
453
+ }
389
454
  this.mode = { ...this.mode, query };
390
455
  this.emit();
456
+ void Promise.resolve(entries).then((loaded) => {
457
+ if (this.disposed || generation !== this.generation || !this.current(guard) || this.mode.kind !== "search") return;
458
+ this.searchEntries = new PromptHistory(loaded).search(this.mode.query);
459
+ this.searchIndex = this.searchEntries.length > 0 ? 0 : -1;
460
+ this.emit();
461
+ });
391
462
  return true;
392
463
  }
393
464
  handleKey(key, context) {
@@ -560,14 +631,29 @@ var Coordinator = class {
560
631
  return true;
561
632
  }
562
633
  if (this.mode.kind !== "history") return false;
563
- const entries = this.historyCache.get(this.input.sessionId)?.entries ?? [];
564
- const selected = new PromptHistory(entries).next(this.mode.index);
565
- if (selected === null) return true;
566
- if (selected.index === null) {
567
- this.restoreOriginal(this.mode.original);
568
- return true;
634
+ const original = this.mode.original;
635
+ const index = this.mode.index;
636
+ const generation = this.generation;
637
+ const guard = guardOf(this.input);
638
+ const entries = this.loadHistory(this.input.sessionId);
639
+ const apply2 = (loaded) => {
640
+ const selected = new PromptHistory(loaded).next(index);
641
+ if (selected === null) return;
642
+ if (selected.index === null) {
643
+ this.restoreOriginal(original);
644
+ return;
645
+ }
646
+ this.selectHistory(selected, original);
647
+ };
648
+ if (Array.isArray(entries)) {
649
+ apply2(entries);
650
+ } else {
651
+ void Promise.resolve(entries).then((loaded) => {
652
+ if (this.disposed || generation !== this.generation || !this.current(guard)) return;
653
+ if (this.mode.kind !== "history") return;
654
+ apply2(loaded);
655
+ });
569
656
  }
570
- this.selectHistory(selected, this.mode.original);
571
657
  return true;
572
658
  }
573
659
  selectHistory(selected, original) {
@@ -647,8 +733,8 @@ var OptimizationStore = class {
647
733
  read(source) {
648
734
  return this.value?.source === source ? this.value : null;
649
735
  }
650
- write(cache) {
651
- this.value = cache;
736
+ write(cache2) {
737
+ this.value = cache2;
652
738
  }
653
739
  invalidate() {
654
740
  this.value = null;
@@ -692,10 +778,10 @@ var OptimizationController = class {
692
778
  }
693
779
  const textChanged = this.current !== null && (this.current.sessionId !== snapshot.sessionId || this.current.text !== snapshot.text);
694
780
  this.current = { ...snapshot };
695
- const cache = this.readCache();
696
- if (cache !== null) {
697
- const optimizedVisible = cache.selection.sessionId === snapshot.sessionId && snapshot.text === this.cacheOptimizedDraft;
698
- const sourceVisible = cache.selection.sessionId === snapshot.sessionId && snapshot.text === this.cacheSourceDraft;
781
+ const cache2 = this.readCache();
782
+ if (cache2 !== null) {
783
+ const optimizedVisible = cache2.selection.sessionId === snapshot.sessionId && snapshot.text === this.cacheOptimizedDraft;
784
+ const sourceVisible = cache2.selection.sessionId === snapshot.sessionId && snapshot.text === this.cacheSourceDraft;
699
785
  if (!optimizedVisible && !sourceVisible) this.invalidate();
700
786
  else if (this.pending === null) this.setView(optimizedVisible ? "undo" : "optimize", textChanged ? null : this.view.error);
701
787
  } else if (this.pending === null && this.view.status === "undo") {
@@ -802,10 +888,10 @@ var OptimizationController = class {
802
888
  }
803
889
  undo() {
804
890
  if (this.disposed || !this.enabled || this.pending !== null) return false;
805
- const cache = this.readCache();
806
- if (cache === null) return false;
891
+ const cache2 = this.readCache();
892
+ if (cache2 === null) return false;
807
893
  try {
808
- const restored = this.coordinator.undoOptimization(cache);
894
+ const restored = this.coordinator.undoOptimization(cache2);
809
895
  if (restored) this.setView("optimize", null);
810
896
  return restored;
811
897
  } catch (error) {
@@ -1118,6 +1204,31 @@ var styles_default = {
1118
1204
  rollbackDialog: "styles_rollbackDialog",
1119
1205
  rollbackContent: "styles_rollbackContent",
1120
1206
  rollbackPreview: "styles_rollbackPreview",
1207
+ rollbackSummaryRow: "styles_rollbackSummaryRow",
1208
+ rollbackSummary: "styles_rollbackSummary",
1209
+ rollbackAlready: "styles_rollbackAlready",
1210
+ rollbackTimelineLink: "styles_rollbackTimelineLink",
1211
+ timelineRightPane: "styles_timelineRightPane",
1212
+ timelinePanel: "styles_timelinePanel",
1213
+ timelineLead: "styles_timelineLead",
1214
+ timelineStatus: "styles_timelineStatus",
1215
+ timelineList: "styles_timelineList",
1216
+ timelineItem: "styles_timelineItem",
1217
+ timelineRow: "styles_timelineRow",
1218
+ timelineHead: "styles_timelineHead",
1219
+ timelineTurn: "styles_timelineTurn",
1220
+ timelineRolledBack: "styles_timelineRolledBack",
1221
+ timelineCoverage: "styles_timelineCoverage",
1222
+ timelineMeta: "styles_timelineMeta",
1223
+ timelineTime: "styles_timelineTime",
1224
+ timelinePromptPreview: "styles_timelinePromptPreview",
1225
+ timelineDetail: "styles_timelineDetail",
1226
+ timelinePrompt: "styles_timelinePrompt",
1227
+ timelinePromptEmpty: "styles_timelinePromptEmpty",
1228
+ timelineFilesEmpty: "styles_timelineFilesEmpty",
1229
+ timelineFiles: "styles_timelineFiles",
1230
+ timelineGaps: "styles_timelineGaps",
1231
+ timelineFileChange: "styles_timelineFileChange",
1121
1232
  rollbackSection: "styles_rollbackSection",
1122
1233
  rollbackList: "styles_rollbackList",
1123
1234
  rollbackMessage: "styles_rollbackMessage",
@@ -1130,7 +1241,9 @@ var styles_default = {
1130
1241
  contextMeterRow: "styles_contextMeterRow",
1131
1242
  contextMeterChevron: "styles_contextMeterChevron",
1132
1243
  usageMeterTitleRow: "styles_usageMeterTitleRow",
1244
+ sessionStatsCheckpointRow: "styles_sessionStatsCheckpointRow",
1133
1245
  usageMeterLinkChevron: "styles_usageMeterLinkChevron",
1246
+ sessionStatsCheckpointChevron: "styles_sessionStatsCheckpointChevron",
1134
1247
  contextRightPanel: "styles_contextRightPanel",
1135
1248
  contextRightHeader: "styles_contextRightHeader",
1136
1249
  contextRightTitleRow: "styles_contextRightTitleRow",
@@ -1280,7 +1393,7 @@ var styles_default = {
1280
1393
  usageRecentTokens: "styles_usageRecentTokens"
1281
1394
  };
1282
1395
  var css_module_default = styles_default;
1283
- var cssText = '/* src/client/styles.module.css */\n.styles_root {\n position: relative;\n}\n.styles_toolbarIcon {\n width: 28px;\n padding: 0;\n}\n.styles_settings {\n display: grid;\n gap: 16px;\n max-width: 640px;\n color: var(--dsw-alias-label-primary);\n font: var(--dsw-font-sm-14);\n}\n.styles_settings h2,\n.styles_settings h3,\n.styles_settings p {\n margin: 0;\n}\n.styles_settingsHeader {\n display: grid;\n gap: 4px;\n}\n.styles_settingsHeader p,\n.styles_settingDescription,\n.styles_privacy p {\n color: var(--dsw-alias-label-secondary);\n}\n.styles_settingRow {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 16px;\n}\n.styles_settingText {\n display: grid;\n gap: 4px;\n min-width: 0;\n}\n.styles_settingText h3,\n.styles_privacy h3 {\n font: inherit;\n font-weight: 600;\n}\n.styles_settingControls {\n display: flex;\n align-items: center;\n gap: 8px;\n flex-shrink: 0;\n}\n.styles_settingsBack {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n margin: 0;\n padding: 0;\n border: 0;\n background: transparent;\n color: var(--dsw-alias-label-secondary);\n font: inherit;\n cursor: pointer;\n}\n.styles_settingsBack:hover {\n color: var(--dsw-alias-label-primary);\n}\n.styles_settingsConfigure,\n.styles_settingsActionPrimary {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n margin: 0;\n min-height: 28px;\n padding: 0 10px;\n border: 0;\n border-radius: var(--dsw-radius-sm);\n font: inherit;\n font-weight: 600;\n line-height: 16px;\n cursor: pointer;\n white-space: nowrap;\n}\n.styles_settingsConfigure {\n color: var(--dsw-alias-label-primary);\n background: var(--dsw-alias-bg-layer-2);\n box-shadow: 0 0 0 1px var(--dsw-alias-border-primary);\n}\n.styles_settingsConfigure:hover:not(:disabled) {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n.styles_settingsConfigure:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n.styles_settingsActionPrimary {\n color: #fff;\n background: #3b7ded;\n box-shadow: 0 0 0 1px color-mix(in srgb, #3b7ded 55%, transparent);\n}\n.styles_settingsActionPrimary:hover:not(:disabled) {\n background: #2f6fe0;\n}\n.styles_settingsActionPrimary:focus-visible {\n outline: 2px solid color-mix(in srgb, #3b7ded 70%, white);\n outline-offset: 2px;\n}\n.styles_settingsActionPrimary:disabled {\n opacity: 0.55;\n cursor: not-allowed;\n}\n.styles_modelPill {\n max-width: 168px;\n}\n.styles_modelPillLabel {\n display: block;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.styles_privacy {\n display: grid;\n gap: 8px;\n padding: 12px;\n background: var(--dsw-alias-bg-layer-2);\n border-radius: var(--dsw-radius-sm);\n}\n.styles_settingsUpdate {\n display: grid;\n gap: 8px;\n}\n.styles_settingsUpdateStatus {\n margin: 0;\n color: var(--dsw-alias-label-secondary);\n}\n.styles_updateCommand {\n margin: 0;\n padding: 8px;\n border-radius: var(--dsw-radius-sm);\n background: var(--dsw-alias-bg-layer-2);\n color: var(--dsw-alias-label-primary);\n font: var(--dsw-font-sm-12, var(--dsw-font-sm-14));\n font-family:\n ui-monospace,\n SFMono-Regular,\n Menlo,\n Monaco,\n Consolas,\n monospace;\n word-break: break-all;\n white-space: pre-wrap;\n}\n.styles_autoMappingSection {\n display: grid;\n gap: 12px;\n padding: 12px;\n background: var(--dsw-alias-bg-layer-2);\n border-radius: var(--dsw-radius-sm);\n}\n.styles_autoMappingSection h3 {\n font: inherit;\n font-weight: 600;\n}\n.styles_prediction {\n position: absolute;\n left: 0;\n right: 0;\n bottom: calc(100% + 8px);\n box-sizing: border-box;\n width: auto;\n max-width: none;\n padding: 8px 12px;\n color: var(--dsw-alias-label-secondary);\n font: var(--dsw-font-sm-14);\n white-space: pre-wrap;\n pointer-events: none;\n user-select: none;\n background: var(--dsw-alias-bg-layer-2);\n border-radius: var(--dsw-radius-sm);\n}\n.styles_prediction kbd {\n margin-left: 8px;\n}\n.styles_historyDialog {\n position: absolute;\n z-index: 20;\n left: 0;\n right: 0;\n bottom: calc(100% + 8px);\n display: grid;\n gap: 8px;\n box-sizing: border-box;\n width: auto;\n max-width: none;\n padding: 12px;\n color: var(--dsw-alias-label-primary);\n}\n.styles_historyHeader {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n font: var(--dsw-font-sm-14);\n}\n.styles_historyResults {\n max-height: 240px;\n margin: 0;\n padding: 0;\n overflow-y: auto;\n list-style: none;\n}\n.styles_historyResult {\n padding: 8px;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n cursor: pointer;\n border-radius: var(--dsw-radius-sm);\n}\n.styles_historyResult[aria-selected=true] {\n background: var(--dsw-alias-bg-layer-2);\n}\n.styles_hints {\n position: absolute;\n z-index: 21;\n left: 0;\n right: 0;\n bottom: calc(100% + 8px);\n display: grid;\n gap: 8px;\n box-sizing: border-box;\n width: auto;\n max-width: none;\n}\n.styles_hint {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n padding: 8px 12px;\n color: var(--dsw-alias-label-primary);\n font: var(--dsw-font-sm-14);\n background: var(--dsw-alias-bg-layer-2);\n border-radius: var(--dsw-radius-sm);\n}\n.styles_rollbackDialog {\n width: min(680px, 100%);\n max-height: 100%;\n min-height: 0;\n}\n.styles_rollbackContent {\n flex: 1 1 auto;\n min-height: 0;\n overflow-y: auto;\n}\n.styles_rollbackPreview {\n display: grid;\n gap: 20px;\n box-sizing: border-box;\n max-width: 72ch;\n padding: 16px;\n color: var(--dsw-alias-label-primary);\n font: var(--dsw-font-sm-14);\n}\n.styles_rollbackSection {\n display: grid;\n gap: 8px;\n min-width: 0;\n}\n.styles_rollbackSection h3,\n.styles_rollbackSection p {\n margin: 0;\n}\n.styles_rollbackSection h3 {\n font: inherit;\n font-weight: 600;\n}\n.styles_rollbackList {\n display: grid;\n gap: 8px;\n margin: 0;\n padding: 0;\n list-style: none;\n}\n.styles_rollbackList li {\n min-width: 0;\n overflow-wrap: anywhere;\n}\n.styles_rollbackMessage,\n.styles_rollbackFile {\n display: grid;\n gap: 4px;\n}\n.styles_rollbackFile {\n grid-template-columns: minmax(0, 1fr) auto;\n align-items: baseline;\n gap: 12px;\n}\n.styles_rollbackMeta {\n color: var(--dsw-alias-label-secondary);\n font-size: 0.92em;\n}\n.styles_rollbackConflict {\n display: block;\n color: var(--dsw-alias-label-secondary);\n}\n.styles_userMessageRow {\n display: flex;\n flex-direction: column;\n align-items: flex-end;\n gap: 6px;\n min-width: 0;\n}\n.styles_userMessageActions {\n display: inline-flex;\n align-items: center;\n justify-content: flex-end;\n gap: 4px;\n}\n.styles_userMessageAction {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: calc(28px + var(--dsh-content-font-delta, 0px));\n height: calc(28px + var(--dsh-content-font-delta, 0px));\n padding: 6px;\n color: var(--dsw-alias-label-tertiary);\n background: transparent;\n border: 0;\n border-radius: var(--dsw-radius-sm);\n cursor: pointer;\n}\n.styles_userMessageAction svg {\n width: calc(15px + var(--dsh-content-font-delta, 0px));\n height: calc(15px + var(--dsh-content-font-delta, 0px));\n}\n.styles_userMessageAction:hover {\n color: var(--dsw-alias-label-secondary);\n background: var(--dsw-alias-interactive-bg-hover);\n}\n.styles_userMessageAction:disabled,\n.styles_userMessageAction[data-unavailable] {\n cursor: default;\n opacity: 0.4;\n}\n.styles_userMessageAction:disabled:hover,\n.styles_userMessageAction[data-unavailable]:hover {\n color: var(--dsw-alias-label-tertiary);\n background: transparent;\n}\n.styles_contextMeterRow {\n cursor: pointer;\n position: relative;\n padding-right: 18px;\n}\n.styles_contextMeterRow:hover {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n.styles_contextMeterRow[data-agent-enhancer-loading="1"] {\n opacity: 0.65;\n}\n.styles_contextMeterChevron {\n position: absolute;\n right: 4px;\n top: 50%;\n transform: translateY(-50%);\n color: var(--dsw-alias-label-tertiary);\n font-size: 14px;\n line-height: 1;\n}\n.styles_usageMeterTitleRow {\n cursor: pointer;\n position: relative;\n padding-right: 18px;\n}\n.styles_usageMeterTitleRow:hover {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n.styles_usageMeterTitleRow:focus-visible {\n outline: 2px solid var(--dsw-alias-label-secondary);\n outline-offset: 2px;\n}\n.styles_usageMeterLinkChevron {\n position: absolute;\n right: 4px;\n top: 50%;\n transform: translateY(-50%);\n color: var(--dsw-alias-label-tertiary);\n font-size: 14px;\n line-height: 1;\n pointer-events: none;\n}\n.styles_contextRightPanel {\n box-sizing: border-box;\n height: 100%;\n min-height: 0;\n display: flex;\n flex-direction: column;\n gap: 12px;\n padding: 12px 14px 14px;\n color: var(--dsw-alias-label-primary);\n font: var(--dsw-font-sm-13);\n}\n.styles_contextRightHeader {\n display: flex;\n flex-direction: column;\n gap: 10px;\n flex: none;\n}\n.styles_contextRightTitleRow {\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n gap: 12px;\n}\n.styles_contextRightTitle {\n margin: 0;\n font: var(--dsw-font-sm-14);\n font-weight: 600;\n}\n.styles_contextRightMeta {\n color: var(--dsw-alias-label-tertiary);\n white-space: nowrap;\n font-variant-numeric: tabular-nums;\n}\n.styles_contextRightSegments {\n display: flex;\n gap: 2px;\n flex-wrap: wrap;\n padding: 2px;\n border-radius: var(--dsw-radius-sm);\n background: var(--dsw-alias-bg-layer-2);\n}\n.styles_contextRightSegment,\n.styles_contextRightSegmentActive {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n border: 0;\n background: transparent;\n color: var(--dsw-alias-label-secondary);\n border-radius: var(--dsw-radius-sm);\n padding: 5px 9px;\n cursor: pointer;\n font: inherit;\n}\n.styles_contextRightSegment:hover {\n color: var(--dsw-alias-label-primary);\n}\n.styles_contextRightSegmentActive {\n background: var(--dsw-alias-interactive-bg-hover);\n color: var(--dsw-alias-label-primary);\n box-shadow: 0 0 0 1px var(--dsw-alias-border-primary);\n}\n.styles_contextRightStatus {\n margin: 0;\n color: var(--dsw-alias-label-tertiary);\n}\n.styles_contextChart {\n flex: none;\n display: grid;\n gap: 10px;\n padding: 10px 12px;\n border-radius: var(--dsw-radius-sm);\n background: var(--dsw-alias-bg-layer-2);\n}\n.styles_contextChartHeading {\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n gap: 10px;\n}\n.styles_contextChartTitle {\n font-weight: 600;\n color: var(--dsw-alias-label-primary);\n}\n.styles_contextChartTotal {\n color: var(--dsw-alias-label-primary);\n font-variant-numeric: tabular-nums;\n white-space: nowrap;\n}\n.styles_contextChartTotalHint {\n color: var(--dsw-alias-label-tertiary);\n font-weight: 400;\n}\n.styles_contextStackWrap {\n position: relative;\n display: grid;\n gap: 0;\n}\n.styles_contextStack {\n display: flex;\n width: 100%;\n height: 12px;\n border-radius: 999px;\n overflow: hidden;\n background: var(--dsw-alias-border-primary);\n}\n.styles_contextStackSegment,\n.styles_contextStackSegmentDim {\n display: block;\n height: 100%;\n min-width: 2px;\n cursor: default;\n transition: opacity 120ms ease, filter 120ms ease;\n}\n.styles_contextStackSegment {\n opacity: 1;\n filter: saturate(1.08);\n}\n.styles_contextStackSegmentDim {\n opacity: 0.28;\n filter: saturate(0.55);\n}\n.styles_contextChartTip {\n position: absolute;\n left: 50%;\n bottom: calc(100% + 6px);\n transform: translateX(-50%);\n z-index: 2;\n display: inline-flex;\n align-items: center;\n gap: 6px;\n max-width: min(100%, 280px);\n padding: 5px 8px;\n border-radius: var(--dsw-radius-sm);\n background: var(--dsw-alias-bg-layer-1);\n box-shadow: 0 0 0 1px var(--dsw-alias-border-primary);\n color: var(--dsw-alias-label-primary);\n font-size: 12px;\n line-height: 16px;\n white-space: nowrap;\n pointer-events: none;\n}\n.styles_contextChartTipSwatch {\n flex: none;\n width: 8px;\n height: 8px;\n border-radius: 999px;\n}\n.styles_contextChartLegend {\n list-style: none;\n margin: 0;\n padding: 0;\n min-width: 0;\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n.styles_contextChartLegendItem,\n.styles_contextChartLegendItemDim {\n display: grid;\n grid-template-columns: 8px minmax(0, 1fr);\n gap: 8px;\n align-items: start;\n font-size: 12px;\n border-radius: var(--dsw-radius-sm);\n padding: 2px 4px;\n margin: 0 -4px;\n transition: opacity 120ms ease, background 120ms ease;\n}\n.styles_contextChartLegendItem {\n opacity: 1;\n background: transparent;\n}\n.styles_contextChartLegendItem:hover {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n.styles_contextChartLegendItemDim {\n opacity: 0.4;\n}\n.styles_contextChartSwatch {\n width: 8px;\n height: 8px;\n margin-top: 4px;\n border-radius: 999px;\n}\n.styles_contextChartLegendMain {\n min-width: 0;\n display: grid;\n gap: 4px;\n}\n.styles_contextChartLegendTop {\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n gap: 8px;\n}\n.styles_contextChartLegendLabel {\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n color: var(--dsw-alias-label-primary);\n}\n.styles_contextChartLegendMeta {\n color: var(--dsw-alias-label-tertiary);\n font-variant-numeric: tabular-nums;\n white-space: nowrap;\n}\n.styles_contextChartLegendTrack {\n height: 3px;\n border-radius: 999px;\n background: var(--dsw-alias-border-primary);\n overflow: hidden;\n}\n.styles_contextChartLegendFill {\n height: 100%;\n border-radius: inherit;\n opacity: 0.9;\n}\n.styles_contextHeadroom {\n display: grid;\n gap: 4px;\n padding-top: 2px;\n border-top: 1px solid var(--dsw-alias-border-primary);\n}\n.styles_contextHeadroomMeta {\n display: flex;\n justify-content: space-between;\n gap: 8px;\n color: var(--dsw-alias-label-secondary);\n font-size: 12px;\n}\n.styles_contextHeadroomValue {\n color: var(--dsw-alias-label-primary);\n font-variant-numeric: tabular-nums;\n}\n.styles_contextHeadroomTrack {\n height: 5px;\n border-radius: 999px;\n background: var(--dsw-alias-border-primary);\n overflow: hidden;\n}\n.styles_contextHeadroomFill {\n height: 100%;\n border-radius: inherit;\n background: #4c8bf5;\n opacity: 0.85;\n}\n.styles_contextHeadroomHint {\n color: var(--dsw-alias-label-tertiary);\n font-size: 11px;\n}\n.styles_contextCompactBar {\n display: flex;\n align-items: flex-start;\n gap: 8px;\n flex: none;\n}\n.styles_contextCompactButton {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 6px;\n flex: none;\n min-height: 30px;\n padding: 0 10px 0 8px;\n border: 0;\n border-radius: var(--dsw-radius-sm);\n cursor: pointer;\n color: #fff;\n background: #3b7ded;\n font-size: 12px;\n font-weight: 600;\n line-height: 16px;\n box-shadow: 0 0 0 1px color-mix(in srgb, #3b7ded 55%, transparent);\n}\n.styles_contextCompactButton:hover:not(:disabled) {\n color: #fff;\n background: #2f6fe0;\n}\n.styles_contextCompactButton:focus-visible {\n outline: 2px solid color-mix(in srgb, #3b7ded 70%, white);\n outline-offset: 2px;\n}\n.styles_contextCompactButton:disabled {\n cursor: default;\n opacity: 0.55;\n}\n.styles_contextCompactButtonLabel {\n max-width: 9em;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.styles_contextCompactHint,\n.styles_contextCompactNote {\n margin: 0;\n min-width: 0;\n flex: 1;\n color: var(--dsw-alias-label-tertiary);\n font-size: 12px;\n line-height: 18px;\n padding-top: 5px;\n}\n.styles_contextCompactNote {\n color: var(--dsw-alias-label-secondary);\n}\n.styles_contextEventRow {\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n flex: none;\n}\n.styles_contextEventChip,\n.styles_contextEventChipCompact,\n.styles_contextEventChipPrune {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n padding: 2px 7px;\n border-radius: var(--dsw-radius-sm);\n background: var(--dsw-alias-bg-layer-2);\n color: var(--dsw-alias-label-secondary);\n font-size: 11px;\n line-height: 16px;\n}\n.styles_contextEventChipCompact {\n color: var(--dsw-alias-label-primary);\n}\n.styles_contextEventChipPrune {\n color: var(--dsw-alias-label-primary);\n}\n.styles_contextRightScroll,\n.styles_contextRightListFill {\n min-height: 0;\n flex: 1;\n display: flex;\n flex-direction: column;\n gap: 2px;\n}\n.styles_contextRightScroll {\n overflow: auto;\n}\n.styles_contextRightListFill {\n overflow: hidden;\n}\n.styles_contextRightItem,\n.styles_contextRightItemActive,\n.styles_contextRightItemActiveFill {\n border: 0;\n border-radius: var(--dsw-radius-sm);\n background: transparent;\n}\n.styles_contextRightItem:hover {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n.styles_contextRightItemActive,\n.styles_contextRightItemActiveFill {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n.styles_contextRightItemActiveFill {\n flex: 1;\n min-height: 0;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n}\n.styles_contextRightRow {\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n gap: 10px;\n width: 100%;\n text-align: left;\n border: 0;\n background: transparent;\n color: inherit;\n border-radius: var(--dsw-radius-sm);\n padding: 8px 8px 7px;\n cursor: pointer;\n font: inherit;\n}\n.styles_contextRightItemDot {\n width: 7px;\n height: 7px;\n border-radius: 999px;\n flex: none;\n margin-top: 5px;\n}\n.styles_contextRightRowMain {\n min-width: 0;\n flex: 1;\n display: grid;\n gap: 4px;\n}\n.styles_contextRightRowTitle {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 6px;\n font-weight: 500;\n}\n.styles_contextRightBadge,\n.styles_contextRightBadgeMuted {\n display: inline-flex;\n align-items: center;\n padding: 0 5px;\n border-radius: var(--dsw-radius-sm);\n font-size: 10px;\n font-weight: 500;\n line-height: 16px;\n color: var(--dsw-alias-label-secondary);\n background: var(--dsw-alias-bg-layer-2);\n}\n.styles_contextRightBadgeMuted {\n opacity: 0.9;\n}\n.styles_contextRightRowPreview {\n color: var(--dsw-alias-label-secondary);\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.styles_contextRightBarTrack {\n height: 2px;\n border-radius: 999px;\n background: var(--dsw-alias-border-primary);\n overflow: hidden;\n}\n.styles_contextRightBarFill {\n height: 100%;\n background: var(--dsw-alias-label-secondary);\n}\n.styles_contextRightRowTokens {\n flex: none;\n color: var(--dsw-alias-label-tertiary);\n font-variant-numeric: tabular-nums;\n text-align: right;\n padding-top: 1px;\n}\n.styles_contextRightShare {\n opacity: 0.85;\n}\n.styles_contextRightDetail {\n margin: 0 8px 8px 22px;\n min-height: 0;\n padding: 8px 10px;\n border-radius: var(--dsw-radius-sm);\n background: var(--dsw-alias-bg-layer-2);\n}\n.styles_contextRightItemActiveFill .styles_contextRightDetail {\n flex: 1;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n}\n.styles_contextRightDetailBody {\n margin: 0;\n white-space: pre-wrap;\n word-break: break-word;\n font: inherit;\n color: var(--dsw-alias-label-secondary);\n}\n.styles_contextRightItemActiveFill .styles_contextRightDetailBody {\n flex: 1;\n min-height: 0;\n overflow: auto;\n}\n.styles_contextRightNote {\n flex: none;\n color: var(--dsw-alias-label-tertiary);\n font-size: 12px;\n line-height: 18px;\n}\n.styles_usageRightPane {\n box-sizing: border-box;\n height: 100%;\n min-height: 0;\n display: flex;\n flex-direction: column;\n padding: 0;\n color: var(--dsw-alias-label-primary);\n font: var(--dsw-font-sm-13);\n background:\n linear-gradient(\n 180deg,\n color-mix(in srgb, #3d7cf5 10%, var(--dsw-alias-bg-layer-1)) 0,\n var(--dsw-alias-bg-layer-1) 120px);\n}\n.styles_usagePanel {\n box-sizing: border-box;\n flex: 1;\n min-height: 0;\n display: flex;\n flex-direction: column;\n gap: 14px;\n overflow: auto;\n padding: 14px 14px 16px;\n}\n.styles_usagePanel h2,\n.styles_usagePanel h3,\n.styles_usagePanel p {\n margin: 0;\n}\n.styles_usageHeader,\n.styles_usageHero {\n display: grid;\n gap: 6px;\n flex: none;\n}\n.styles_usageHero {\n grid-template-columns: minmax(0, 1fr) auto;\n align-items: end;\n gap: 12px;\n padding: 10px 12px;\n border-radius: var(--dsw-radius-md, 10px);\n background:\n linear-gradient(\n 135deg,\n color-mix(in srgb, #3d7cf5 16%, transparent),\n color-mix(in srgb, #1f9a6a 8%, transparent));\n border: 1px solid color-mix(in srgb, #3d7cf5 22%, var(--dsw-alias-bg-layer-2));\n}\n.styles_usageHeroCopy {\n display: grid;\n gap: 4px;\n min-width: 0;\n}\n.styles_usageHeroTotal {\n display: grid;\n justify-items: end;\n gap: 2px;\n}\n.styles_usageHeroTotalValue {\n font: var(--dsw-font-sm-16, var(--dsw-font-sm-14));\n font-weight: 700;\n font-variant-numeric: tabular-nums;\n letter-spacing: -0.02em;\n color: var(--dsw-alias-label-primary);\n}\n.styles_usageHeroTotalLabel {\n color: var(--dsw-alias-label-tertiary);\n font-size: 11px;\n line-height: 14px;\n}\n.styles_usageMoneyBlock {\n display: grid;\n gap: 2px;\n margin-top: 4px;\n}\n.styles_usageEstimate {\n font-weight: 650;\n font-variant-numeric: tabular-nums;\n letter-spacing: -0.01em;\n}\n.styles_usageEstimateHint,\n.styles_usageUnpriced,\n.styles_usageBalanceDetail,\n.styles_usageBalanceStale,\n.styles_usageBalanceHint {\n color: var(--dsw-alias-label-tertiary);\n font-size: 11px;\n line-height: 15px;\n}\n.styles_usageBalance {\n display: grid;\n gap: 2px;\n margin-top: 4px;\n font-variant-numeric: tabular-nums;\n}\n.styles_providerBalanceChip {\n display: grid;\n gap: 2px;\n justify-items: start;\n margin: 0;\n padding: 0;\n border: 0;\n background: transparent;\n color: var(--dsw-alias-label-secondary);\n font: inherit;\n font-size: 12px;\n line-height: 18px;\n font-variant-numeric: tabular-nums;\n text-align: left;\n cursor: pointer;\n}\n.styles_providerBalanceChip:hover .styles_providerBalancePrimary {\n color: var(--dsw-alias-label-primary);\n}\n.styles_providerBalancePrimary {\n color: var(--dsw-alias-label-secondary);\n}\n.styles_providerBalanceDetail {\n color: var(--dsw-alias-label-tertiary);\n font-size: 11px;\n line-height: 15px;\n}\n.styles_usageTitle {\n font: var(--dsw-font-sm-14);\n font-weight: 650;\n letter-spacing: -0.01em;\n}\n.styles_usageBack {\n justify-self: start;\n margin: 0 0 2px;\n padding: 0;\n border: 0;\n background: transparent;\n color: var(--dsw-alias-label-secondary);\n font: inherit;\n cursor: pointer;\n}\n.styles_usageBack:hover {\n color: var(--dsw-alias-label-primary);\n}\n.styles_usageNote,\n.styles_usageRetention,\n.styles_usageEmpty,\n.styles_usageEmptyInline,\n.styles_usageBucketMeta {\n color: var(--dsw-alias-label-tertiary);\n font-size: 12px;\n line-height: 18px;\n}\n.styles_usageToolbar,\n.styles_usageRecordsToolbar {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n flex: none;\n}\n.styles_usageRanges {\n display: flex;\n flex-wrap: wrap;\n gap: 4px;\n width: fit-content;\n max-width: 100%;\n padding: 4px;\n background: var(--dsw-alias-bg-layer-2);\n border-radius: var(--dsw-radius-sm);\n flex: none;\n}\n.styles_usageRefresh {\n margin: 0;\n min-height: 28px;\n padding: 0 12px;\n border: 1px solid color-mix(in srgb, var(--dsw-alias-label-primary) 12%, transparent);\n border-radius: var(--dsw-radius-sm);\n background: var(--dsw-alias-bg-layer-2);\n color: var(--dsw-alias-label-primary);\n font: inherit;\n cursor: pointer;\n}\n.styles_usageRefresh:hover:not(:disabled) {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n.styles_usageRefresh:focus-visible {\n outline: 2px solid var(--dsw-alias-label-secondary);\n outline-offset: 2px;\n}\n.styles_usageRefresh:disabled {\n cursor: not-allowed;\n opacity: 0.55;\n}\n.styles_usageRange {\n margin: 0;\n min-height: 28px;\n padding: 0 10px;\n border: 0;\n border-radius: var(--dsw-radius-sm);\n background: transparent;\n color: var(--dsw-alias-label-secondary);\n font: inherit;\n cursor: pointer;\n}\n.styles_usageRange[aria-pressed=true] {\n background: var(--dsw-alias-interactive-bg-hover);\n color: var(--dsw-alias-label-primary);\n font-weight: 600;\n}\n.styles_usageRange:hover:not(:disabled):not([aria-pressed=true]) {\n color: var(--dsw-alias-label-primary);\n}\n.styles_usageRange:focus-visible,\n.styles_usageBack:focus-visible,\n.styles_usageLink:focus-visible,\n.styles_usageRecordsEntry:focus-visible {\n outline: 2px solid var(--dsw-alias-label-secondary);\n outline-offset: 2px;\n}\n.styles_usageRange:disabled,\n.styles_usageRecordsEntry:disabled {\n cursor: not-allowed;\n opacity: 0.55;\n}\n.styles_usageCharts {\n display: grid;\n gap: 16px;\n flex: none;\n}\n.styles_usageBuckets {\n display: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n gap: 8px;\n}\n.styles_usageBucket {\n display: grid;\n gap: 4px;\n min-width: 0;\n padding: 10px 12px;\n border-radius: var(--dsw-radius-sm);\n background: var(--dsw-alias-bg-layer-2);\n border: 1px solid color-mix(in srgb, var(--dsw-alias-label-primary) 6%, transparent);\n}\n.styles_usageBucketLabel {\n color: var(--dsw-alias-label-tertiary);\n font-size: 11px;\n line-height: 14px;\n}\n.styles_usageBucketValue {\n color: var(--dsw-alias-label-primary);\n font: var(--dsw-font-sm-14);\n font-weight: 650;\n font-variant-numeric: tabular-nums;\n}\n.styles_usageSectionTitle {\n margin: 0;\n font: var(--dsw-font-sm-13);\n font-weight: 650;\n color: var(--dsw-alias-label-primary);\n}\n.styles_usageChart {\n display: grid;\n gap: 10px;\n}\n.styles_usageChartHead {\n display: grid;\n gap: 4px;\n}\n.styles_usageChartHint {\n margin: 0;\n color: var(--dsw-alias-label-tertiary);\n font-size: 11px;\n line-height: 15px;\n}\n.styles_usageHeatBody {\n display: grid;\n gap: 10px;\n}\n.styles_usageHeatGrid {\n display: grid;\n gap: 4px;\n}\n.styles_usageHeatGridHour {\n grid-template-columns: repeat(6, minmax(0, 1fr));\n}\n.styles_usageHeatGridDay {\n grid-template-columns: repeat(auto-fill, minmax(28px, 1fr));\n}\n.styles_usageHeatCell,\n.styles_usageHeatCellDim {\n box-sizing: border-box;\n display: grid;\n place-items: end start;\n min-height: 36px;\n margin: 0;\n padding: 4px;\n border: 1px solid color-mix(in srgb, var(--dsw-alias-label-primary) 8%, transparent);\n border-radius: 6px;\n background: var(--dsw-alias-bg-layer-2);\n color: var(--dsw-alias-label-secondary);\n cursor: pointer;\n transition: opacity 120ms ease, transform 120ms ease;\n}\n.styles_usageHeatCell:hover,\n.styles_usageHeatCell:focus-visible {\n transform: translateY(-1px);\n outline: none;\n}\n.styles_usageHeatCell:focus-visible {\n box-shadow: 0 0 0 2px color-mix(in srgb, #3d7cf5 55%, transparent);\n}\n.styles_usageHeatCellDim {\n opacity: 0.35;\n}\n.styles_usageHeatCell[data-level="0"],\n.styles_usageHeatCellDim[data-level="0"],\n.styles_usageHeatScale span[data-level="0"] {\n background: var(--dsw-alias-bg-layer-2);\n}\n.styles_usageHeatCell[data-level="1"],\n.styles_usageHeatCellDim[data-level="1"],\n.styles_usageHeatScale span[data-level="1"] {\n background: color-mix(in srgb, #3d7cf5 22%, var(--dsw-alias-bg-layer-2));\n}\n.styles_usageHeatCell[data-level="2"],\n.styles_usageHeatCellDim[data-level="2"],\n.styles_usageHeatScale span[data-level="2"] {\n background: color-mix(in srgb, #3d7cf5 40%, var(--dsw-alias-bg-layer-2));\n}\n.styles_usageHeatCell[data-level="3"],\n.styles_usageHeatCellDim[data-level="3"],\n.styles_usageHeatScale span[data-level="3"] {\n background: color-mix(in srgb, #3d7cf5 62%, var(--dsw-alias-bg-layer-2));\n color: #f4f7ff;\n}\n.styles_usageHeatCell[data-level="4"],\n.styles_usageHeatCellDim[data-level="4"],\n.styles_usageHeatScale span[data-level="4"] {\n background: color-mix(in srgb, #245fd4 88%, #0b1c3a);\n color: #f4f7ff;\n}\n.styles_usageHeatLabel {\n font-size: 10px;\n line-height: 12px;\n font-variant-numeric: tabular-nums;\n}\n.styles_usageHeatLegend {\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n gap: 12px;\n min-height: 20px;\n}\n.styles_usageHeatTipValue {\n font-weight: 650;\n font-variant-numeric: tabular-nums;\n}\n.styles_usageHeatTipMeta {\n color: var(--dsw-alias-label-tertiary);\n font-size: 12px;\n}\n.styles_usageHeatScale {\n display: inline-flex;\n gap: 3px;\n margin-left: auto;\n}\n.styles_usageHeatScale span {\n width: 12px;\n height: 12px;\n border-radius: 3px;\n border: 1px solid color-mix(in srgb, var(--dsw-alias-label-primary) 8%, transparent);\n}\n.styles_usageShareBody {\n display: grid;\n gap: 10px;\n}\n.styles_usageShareTrack {\n display: flex;\n width: 100%;\n height: 12px;\n overflow: hidden;\n border-radius: 999px;\n background: var(--dsw-alias-bg-layer-2);\n}\n.styles_usageShareSegment,\n.styles_usageShareSegmentDim {\n height: 100%;\n min-width: 2px;\n transition: opacity 120ms ease;\n}\n.styles_usageShareSegmentDim {\n opacity: 0.28;\n}\n.styles_usageLegend,\n.styles_usageRankList,\n.styles_usageRecentList {\n display: grid;\n gap: 8px;\n width: 100%;\n margin: 0;\n padding: 0;\n list-style: none;\n}\n.styles_usageLegendItem,\n.styles_usageLegendItemDim {\n display: grid;\n grid-template-columns: 8px minmax(0, 1fr) auto;\n gap: 8px;\n align-items: center;\n}\n.styles_usageLegendItemDim {\n opacity: 0.45;\n}\n.styles_usageLegendSwatch {\n width: 8px;\n height: 8px;\n border-radius: 999px;\n}\n.styles_usageLegendLabel {\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.styles_usageLegendMeta,\n.styles_usageRankMeta {\n color: var(--dsw-alias-label-secondary);\n font-variant-numeric: tabular-nums;\n white-space: nowrap;\n}\n.styles_usageLegendShare {\n margin-left: 6px;\n color: var(--dsw-alias-label-tertiary);\n}\n.styles_usageRankItem {\n display: grid;\n gap: 4px;\n}\n.styles_usageRankTop {\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n gap: 12px;\n}\n.styles_usageRankLabel {\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.styles_usageRankTrack {\n height: 6px;\n overflow: hidden;\n border-radius: 999px;\n background: var(--dsw-alias-bg-layer-2);\n}\n.styles_usageRankFill {\n height: 100%;\n border-radius: inherit;\n}\n.styles_usageFooter {\n margin-top: auto;\n flex: none;\n display: grid;\n gap: 8px;\n padding-top: 4px;\n}\n.styles_usageRecentPreview {\n display: grid;\n gap: 8px;\n}\n.styles_usageRecentHead {\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n gap: 12px;\n}\n.styles_usageLink {\n margin: 0;\n padding: 0;\n border: 0;\n background: transparent;\n color: var(--dsw-alias-label-secondary);\n font: inherit;\n cursor: pointer;\n}\n.styles_usageLink:hover {\n color: var(--dsw-alias-label-primary);\n}\n.styles_usageRecordsEntry {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n width: 100%;\n margin: 0;\n padding: 10px 0;\n border: 0;\n border-top: 1px solid var(--dsw-alias-border-subtle, var(--dsw-alias-bg-layer-2));\n background: transparent;\n color: var(--dsw-alias-label-primary);\n font: inherit;\n text-align: start;\n cursor: pointer;\n}\n.styles_usageRecordsEntry:hover:not(:disabled) {\n color: var(--dsw-alias-label-primary);\n}\n.styles_usageRecordsEntryMeta {\n color: var(--dsw-alias-label-tertiary);\n font-variant-numeric: tabular-nums;\n white-space: nowrap;\n}\n.styles_usageRecentItem {\n display: grid;\n gap: 6px;\n padding: 10px 0;\n}\n.styles_usageRecentItem + .styles_usageRecentItem {\n border-top: 1px solid var(--dsw-alias-border-subtle, var(--dsw-alias-bg-layer-2));\n}\n.styles_usageRecentMain {\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n gap: 12px;\n}\n.styles_usageRecentSource {\n font-weight: 650;\n}\n.styles_usageRecentRoute {\n display: flex;\n flex-wrap: wrap;\n gap: 6px 10px;\n color: var(--dsw-alias-label-secondary);\n font-size: 12px;\n line-height: 16px;\n}\n.styles_usageRecentProvider {\n color: var(--dsw-alias-label-tertiary);\n}\n.styles_usageRecentWhen {\n color: var(--dsw-alias-label-tertiary);\n font-size: 12px;\n white-space: nowrap;\n}\n.styles_usageRecentTokens {\n display: flex;\n flex-wrap: wrap;\n gap: 6px 10px;\n color: var(--dsw-alias-label-secondary);\n font-size: 12px;\n line-height: 16px;\n font-variant-numeric: tabular-nums;\n}\n';
1396
+ var cssText = '/* src/client/styles.module.css */\n.styles_root {\n position: relative;\n}\n.styles_toolbarIcon {\n width: 28px;\n padding: 0;\n}\n.styles_settings {\n display: grid;\n gap: 16px;\n max-width: 640px;\n color: var(--dsw-alias-label-primary);\n font: var(--dsw-font-sm-14);\n}\n.styles_settings h2,\n.styles_settings h3,\n.styles_settings p {\n margin: 0;\n}\n.styles_settingsHeader {\n display: grid;\n gap: 4px;\n}\n.styles_settingsHeader p,\n.styles_settingDescription,\n.styles_privacy p {\n color: var(--dsw-alias-label-secondary);\n}\n.styles_settingRow {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 16px;\n}\n.styles_settingText {\n display: grid;\n gap: 4px;\n min-width: 0;\n}\n.styles_settingText h3,\n.styles_privacy h3 {\n font: inherit;\n font-weight: 600;\n}\n.styles_settingControls {\n display: flex;\n align-items: center;\n gap: 8px;\n flex-shrink: 0;\n}\n.styles_settingsBack {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n margin: 0;\n padding: 0;\n border: 0;\n background: transparent;\n color: var(--dsw-alias-label-secondary);\n font: inherit;\n cursor: pointer;\n}\n.styles_settingsBack:hover {\n color: var(--dsw-alias-label-primary);\n}\n.styles_settingsConfigure,\n.styles_settingsActionPrimary {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n margin: 0;\n min-height: 28px;\n padding: 0 10px;\n border: 0;\n border-radius: var(--dsw-radius-sm);\n font: inherit;\n font-weight: 600;\n line-height: 16px;\n cursor: pointer;\n white-space: nowrap;\n}\n.styles_settingsConfigure {\n color: var(--dsw-alias-label-primary);\n background: var(--dsw-alias-bg-layer-2);\n box-shadow: 0 0 0 1px var(--dsw-alias-border-primary);\n}\n.styles_settingsConfigure:hover:not(:disabled) {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n.styles_settingsConfigure:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n.styles_settingsActionPrimary {\n color: #fff;\n background: #3b7ded;\n box-shadow: 0 0 0 1px color-mix(in srgb, #3b7ded 55%, transparent);\n}\n.styles_settingsActionPrimary:hover:not(:disabled) {\n background: #2f6fe0;\n}\n.styles_settingsActionPrimary:focus-visible {\n outline: 2px solid color-mix(in srgb, #3b7ded 70%, white);\n outline-offset: 2px;\n}\n.styles_settingsActionPrimary:disabled {\n opacity: 0.55;\n cursor: not-allowed;\n}\n.styles_modelPill {\n max-width: 168px;\n}\n.styles_modelPillLabel {\n display: block;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.styles_privacy {\n display: grid;\n gap: 8px;\n padding: 12px;\n background: var(--dsw-alias-bg-layer-2);\n border-radius: var(--dsw-radius-sm);\n}\n.styles_settingsUpdate {\n display: grid;\n gap: 8px;\n}\n.styles_settingsUpdateStatus {\n margin: 0;\n color: var(--dsw-alias-label-secondary);\n}\n.styles_updateCommand {\n margin: 0;\n padding: 8px;\n border-radius: var(--dsw-radius-sm);\n background: var(--dsw-alias-bg-layer-2);\n color: var(--dsw-alias-label-primary);\n font: var(--dsw-font-sm-12, var(--dsw-font-sm-14));\n font-family:\n ui-monospace,\n SFMono-Regular,\n Menlo,\n Monaco,\n Consolas,\n monospace;\n word-break: break-all;\n white-space: pre-wrap;\n}\n.styles_autoMappingSection {\n display: grid;\n gap: 12px;\n padding: 12px;\n background: var(--dsw-alias-bg-layer-2);\n border-radius: var(--dsw-radius-sm);\n}\n.styles_autoMappingSection h3 {\n font: inherit;\n font-weight: 600;\n}\n.styles_prediction {\n position: absolute;\n left: 0;\n right: 0;\n bottom: calc(100% + 8px);\n box-sizing: border-box;\n width: auto;\n max-width: none;\n padding: 8px 12px;\n color: var(--dsw-alias-label-secondary);\n font: var(--dsw-font-sm-14);\n white-space: pre-wrap;\n pointer-events: none;\n user-select: none;\n background: var(--dsw-alias-bg-layer-2);\n border-radius: var(--dsw-radius-sm);\n}\n.styles_prediction kbd {\n margin-left: 8px;\n}\n.styles_historyDialog {\n position: absolute;\n z-index: 20;\n left: 0;\n right: 0;\n bottom: calc(100% + 8px);\n display: grid;\n gap: 8px;\n box-sizing: border-box;\n width: auto;\n max-width: none;\n padding: 12px;\n color: var(--dsw-alias-label-primary);\n}\n.styles_historyHeader {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n font: var(--dsw-font-sm-14);\n}\n.styles_historyResults {\n max-height: 240px;\n margin: 0;\n padding: 0;\n overflow-y: auto;\n list-style: none;\n}\n.styles_historyResult {\n padding: 8px;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n cursor: pointer;\n border-radius: var(--dsw-radius-sm);\n}\n.styles_historyResult[aria-selected=true] {\n background: var(--dsw-alias-bg-layer-2);\n}\n.styles_hints {\n position: absolute;\n z-index: 21;\n left: 0;\n right: 0;\n bottom: calc(100% + 8px);\n display: grid;\n gap: 8px;\n box-sizing: border-box;\n width: auto;\n max-width: none;\n}\n.styles_hint {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n padding: 8px 12px;\n color: var(--dsw-alias-label-primary);\n font: var(--dsw-font-sm-14);\n background: var(--dsw-alias-bg-layer-2);\n border-radius: var(--dsw-radius-sm);\n}\n.styles_rollbackDialog {\n width: min(680px, 100%);\n max-height: 100%;\n min-height: 0;\n}\n.styles_rollbackContent {\n flex: 1 1 auto;\n min-height: 0;\n overflow-y: auto;\n}\n.styles_rollbackPreview {\n display: grid;\n gap: 20px;\n box-sizing: border-box;\n max-width: 72ch;\n padding: 16px;\n color: var(--dsw-alias-label-primary);\n font: var(--dsw-font-sm-14);\n}\n.styles_rollbackSummaryRow {\n display: flex;\n flex-wrap: wrap;\n align-items: baseline;\n justify-content: space-between;\n gap: 8px 16px;\n}\n.styles_rollbackSummary {\n margin: 0;\n color: var(--dsw-alias-label-secondary);\n font: inherit;\n}\n.styles_rollbackAlready {\n margin: 0;\n padding: 10px 12px;\n color: var(--dsw-alias-label-primary);\n font: inherit;\n line-height: 1.45;\n background: var(--dsw-alias-fill-secondary, color-mix(in srgb, var(--dsw-alias-label-secondary) 12%, transparent));\n border-radius: 6px;\n}\n.styles_rollbackTimelineLink {\n margin: 0;\n padding: 0;\n color: var(--dsw-alias-label-secondary);\n font: inherit;\n text-decoration: underline;\n text-underline-offset: 2px;\n background: transparent;\n border: 0;\n cursor: pointer;\n}\n.styles_rollbackTimelineLink:hover {\n color: var(--dsw-alias-label-primary);\n}\n.styles_timelineRightPane {\n display: flex;\n flex-direction: column;\n min-height: 0;\n height: 100%;\n overflow: auto;\n padding: 12px 14px 20px;\n color: var(--dsw-alias-label-primary);\n font: var(--dsw-font-sm-14);\n}\n.styles_timelinePanel {\n display: grid;\n gap: 12px;\n min-width: 0;\n}\n.styles_timelineLead,\n.styles_timelineStatus {\n margin: 0;\n color: var(--dsw-alias-label-secondary);\n}\n.styles_timelineStatus {\n display: grid;\n gap: 10px;\n justify-items: start;\n}\n.styles_timelineList {\n display: grid;\n gap: 8px;\n margin: 0;\n padding: 0;\n list-style: none;\n}\n.styles_timelineItem {\n --timeline-accent: color-mix(in srgb, var(--dsw-alias-label-tertiary, #94a3b8) 80%, transparent);\n --timeline-wash: color-mix(in srgb, var(--dsw-alias-label-tertiary, #94a3b8) 10%, transparent);\n min-width: 0;\n overflow: hidden;\n border: 1px solid color-mix(in srgb, var(--timeline-accent) 55%, transparent);\n border-left-width: 3px;\n border-left-color: var(--timeline-accent);\n border-radius: var(--dsw-radius-sm);\n background: var(--timeline-wash);\n}\n.styles_timelineItem[data-coverage=files] {\n --timeline-accent: color-mix(in srgb, #0f766e 75%, var(--dsw-alias-label-primary, #0f172a));\n --timeline-wash: color-mix(in srgb, #14b8a6 12%, transparent);\n}\n.styles_timelineItem[data-coverage=partial] {\n --timeline-accent: color-mix(in srgb, #b45309 75%, var(--dsw-alias-label-primary, #0f172a));\n --timeline-wash: color-mix(in srgb, #f59e0b 14%, transparent);\n}\n.styles_timelineItem[data-coverage=conversation] {\n --timeline-accent: color-mix(in srgb, #475569 75%, var(--dsw-alias-label-primary, #0f172a));\n --timeline-wash: color-mix(in srgb, #64748b 12%, transparent);\n}\n.styles_timelineItem[data-coverage=unknown] {\n --timeline-accent: color-mix(in srgb, var(--dsw-alias-label-tertiary, #94a3b8) 80%, transparent);\n --timeline-wash: color-mix(in srgb, var(--dsw-alias-label-tertiary, #94a3b8) 8%, transparent);\n}\n.styles_timelineItem[data-rolled-back] {\n opacity: 0.72;\n}\n.styles_timelineRow {\n display: grid;\n gap: 6px;\n width: 100%;\n margin: 0;\n padding: 9px 10px 9px 12px;\n color: inherit;\n text-align: start;\n background: transparent;\n border: 0;\n cursor: pointer;\n}\n.styles_timelineRow:hover,\n.styles_timelineItem[data-expanded] > .styles_timelineRow {\n background: color-mix(in srgb, var(--dsw-alias-interactive-bg-hover, rgba(0, 0, 0, 0.06)) 70%, transparent);\n}\n.styles_timelineHead {\n display: flex;\n flex-wrap: wrap;\n gap: 8px 10px;\n align-items: center;\n min-width: 0;\n}\n.styles_timelineTurn {\n font-weight: 600;\n}\n.styles_timelineRolledBack {\n padding: 1px 7px;\n color: color-mix(in srgb, #be123c 70%, var(--dsw-alias-label-primary, #0f172a));\n font-size: 0.82em;\n font-weight: 700;\n line-height: 1.35;\n white-space: nowrap;\n border-radius: 999px;\n background: color-mix(in srgb, #fb7185 16%, transparent);\n box-shadow: inset 0 0 0 1px color-mix(in srgb, #e11d48 28%, transparent);\n}\n.styles_timelineCoverage {\n max-width: 100%;\n padding: 2px 8px;\n overflow: hidden;\n color: inherit;\n font-size: 0.88em;\n font-weight: 600;\n line-height: 1.35;\n white-space: nowrap;\n text-overflow: ellipsis;\n border-radius: 999px;\n background: color-mix(in srgb, var(--timeline-accent) 18%, transparent);\n box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--timeline-accent) 35%, transparent);\n}\n.styles_timelineCoverage[data-coverage=files] {\n color: color-mix(in srgb, #0f766e 70%, var(--dsw-alias-label-primary, #0f172a));\n}\n.styles_timelineCoverage[data-coverage=partial] {\n color: color-mix(in srgb, #b45309 72%, var(--dsw-alias-label-primary, #0f172a));\n}\n.styles_timelineCoverage[data-coverage=conversation] {\n color: color-mix(in srgb, #334155 65%, var(--dsw-alias-label-primary, #0f172a));\n}\n.styles_timelineCoverage[data-coverage=unknown] {\n color: var(--dsw-alias-label-secondary);\n}\n.styles_timelineMeta,\n.styles_timelineTime {\n margin-left: auto;\n color: var(--dsw-alias-label-secondary);\n font-size: 0.92em;\n}\n.styles_timelinePromptPreview {\n display: -webkit-box;\n margin: 0;\n overflow: hidden;\n color: var(--dsw-alias-label-primary, inherit);\n font-size: 0.92em;\n line-height: 1.4;\n -webkit-box-orient: vertical;\n -webkit-line-clamp: 2;\n}\n.styles_timelineDetail {\n display: grid;\n gap: 10px;\n margin: 0;\n padding: 10px 12px 12px;\n background: color-mix(in srgb, var(--dsw-alias-bg-layer-2, #fff) 88%, transparent);\n border-top: 1px solid color-mix(in srgb, var(--timeline-accent) 28%, transparent);\n}\n.styles_timelinePrompt,\n.styles_timelinePromptEmpty,\n.styles_timelineFilesEmpty {\n margin: 0;\n}\n.styles_timelinePromptEmpty,\n.styles_timelineFilesEmpty {\n color: var(--dsw-alias-label-secondary);\n}\n.styles_timelineRow > .styles_timelinePromptEmpty {\n font-size: 0.92em;\n line-height: 1.4;\n}\n.styles_timelineFiles,\n.styles_timelineGaps {\n display: grid;\n gap: 6px;\n margin: 0;\n padding: 0;\n list-style: none;\n}\n.styles_timelineFiles li {\n display: grid;\n grid-template-columns: minmax(0, 1fr) auto;\n gap: 8px 12px;\n align-items: baseline;\n padding: 4px 8px;\n overflow-wrap: anywhere;\n border-radius: var(--dsw-radius-sm);\n background: color-mix(in srgb, var(--dsw-alias-bg-layer-1, transparent) 40%, transparent);\n}\n.styles_timelineFiles li[data-change=create] {\n box-shadow: inset 2px 0 0 color-mix(in srgb, #0f766e 70%, transparent);\n}\n.styles_timelineFiles li[data-change=modify] {\n box-shadow: inset 2px 0 0 color-mix(in srgb, #0369a1 70%, transparent);\n}\n.styles_timelineFiles li[data-change=delete] {\n box-shadow: inset 2px 0 0 color-mix(in srgb, #be123c 70%, transparent);\n}\n.styles_timelineFileChange {\n font-size: 0.88em;\n font-weight: 600;\n}\n.styles_timelineFileChange[data-change=create] {\n color: color-mix(in srgb, #0f766e 75%, var(--dsw-alias-label-primary, #0f172a));\n}\n.styles_timelineFileChange[data-change=modify] {\n color: color-mix(in srgb, #0369a1 75%, var(--dsw-alias-label-primary, #0f172a));\n}\n.styles_timelineFileChange[data-change=delete] {\n color: color-mix(in srgb, #be123c 75%, var(--dsw-alias-label-primary, #0f172a));\n}\n.styles_timelineGaps li {\n padding: 4px 8px;\n color: color-mix(in srgb, #b45309 70%, var(--dsw-alias-label-primary, #0f172a));\n font-size: 0.92em;\n border-radius: var(--dsw-radius-sm);\n background: color-mix(in srgb, #f59e0b 12%, transparent);\n box-shadow: inset 2px 0 0 color-mix(in srgb, #d97706 65%, transparent);\n}\n.styles_rollbackSection {\n display: grid;\n gap: 8px;\n min-width: 0;\n}\n.styles_rollbackSection h3,\n.styles_rollbackSection p {\n margin: 0;\n}\n.styles_rollbackSection h3 {\n font: inherit;\n font-weight: 600;\n}\n.styles_rollbackList {\n display: grid;\n gap: 8px;\n margin: 0;\n padding: 0;\n list-style: none;\n}\n.styles_rollbackList li {\n min-width: 0;\n overflow-wrap: anywhere;\n}\n.styles_rollbackMessage,\n.styles_rollbackFile {\n display: grid;\n gap: 4px;\n}\n.styles_rollbackFile {\n grid-template-columns: minmax(0, 1fr) auto;\n align-items: baseline;\n gap: 12px;\n}\n.styles_rollbackMeta {\n color: var(--dsw-alias-label-secondary);\n font-size: 0.92em;\n}\n.styles_rollbackConflict {\n display: block;\n color: var(--dsw-alias-label-secondary);\n}\n.styles_userMessageRow {\n display: flex;\n flex-direction: column;\n align-items: flex-end;\n gap: 6px;\n min-width: 0;\n}\n.styles_userMessageActions {\n display: inline-flex;\n align-items: center;\n justify-content: flex-end;\n gap: 4px;\n}\n.styles_userMessageAction {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: calc(28px + var(--dsh-content-font-delta, 0px));\n height: calc(28px + var(--dsh-content-font-delta, 0px));\n padding: 6px;\n color: var(--dsw-alias-label-tertiary);\n background: transparent;\n border: 0;\n border-radius: var(--dsw-radius-sm);\n cursor: pointer;\n}\n.styles_userMessageAction svg {\n width: calc(15px + var(--dsh-content-font-delta, 0px));\n height: calc(15px + var(--dsh-content-font-delta, 0px));\n}\n.styles_userMessageAction:hover {\n color: var(--dsw-alias-label-secondary);\n background: var(--dsw-alias-interactive-bg-hover);\n}\n.styles_userMessageAction[data-coverage=files],\n.styles_userMessageAction[data-coverage=partial] {\n color: var(--dsw-alias-label-secondary);\n}\n.styles_userMessageAction:disabled,\n.styles_userMessageAction[data-unavailable] {\n cursor: default;\n opacity: 0.4;\n}\n.styles_userMessageAction:disabled:hover,\n.styles_userMessageAction[data-unavailable]:hover {\n color: var(--dsw-alias-label-tertiary);\n background: transparent;\n}\n.styles_contextMeterRow {\n cursor: pointer;\n position: relative;\n padding-right: 18px;\n}\n.styles_contextMeterRow:hover {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n.styles_contextMeterRow[data-agent-enhancer-loading="1"] {\n opacity: 0.65;\n}\n.styles_contextMeterChevron {\n position: absolute;\n right: 4px;\n top: 50%;\n transform: translateY(-50%);\n color: var(--dsw-alias-label-tertiary);\n font-size: 14px;\n line-height: 1;\n}\n.styles_usageMeterTitleRow,\n.styles_sessionStatsCheckpointRow {\n cursor: pointer;\n position: relative;\n padding-right: 18px;\n}\n.styles_usageMeterTitleRow:hover,\n.styles_sessionStatsCheckpointRow:hover {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n.styles_usageMeterTitleRow:focus-visible,\n.styles_sessionStatsCheckpointRow:focus-visible {\n outline: 2px solid var(--dsw-alias-label-secondary);\n outline-offset: 2px;\n}\n.styles_usageMeterLinkChevron,\n.styles_sessionStatsCheckpointChevron {\n position: absolute;\n right: 4px;\n top: 50%;\n transform: translateY(-50%);\n color: var(--dsw-alias-label-tertiary);\n font-size: 14px;\n line-height: 1;\n pointer-events: none;\n}\n.styles_contextRightPanel {\n box-sizing: border-box;\n height: 100%;\n min-height: 0;\n display: flex;\n flex-direction: column;\n gap: 12px;\n padding: 12px 14px 14px;\n color: var(--dsw-alias-label-primary);\n font: var(--dsw-font-sm-13);\n}\n.styles_contextRightHeader {\n display: flex;\n flex-direction: column;\n gap: 10px;\n flex: none;\n}\n.styles_contextRightTitleRow {\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n gap: 12px;\n}\n.styles_contextRightTitle {\n margin: 0;\n font: var(--dsw-font-sm-14);\n font-weight: 600;\n}\n.styles_contextRightMeta {\n color: var(--dsw-alias-label-tertiary);\n white-space: nowrap;\n font-variant-numeric: tabular-nums;\n}\n.styles_contextRightSegments {\n display: flex;\n gap: 2px;\n flex-wrap: wrap;\n padding: 2px;\n border-radius: var(--dsw-radius-sm);\n background: var(--dsw-alias-bg-layer-2);\n}\n.styles_contextRightSegment,\n.styles_contextRightSegmentActive {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n border: 0;\n background: transparent;\n color: var(--dsw-alias-label-secondary);\n border-radius: var(--dsw-radius-sm);\n padding: 5px 9px;\n cursor: pointer;\n font: inherit;\n}\n.styles_contextRightSegment:hover {\n color: var(--dsw-alias-label-primary);\n}\n.styles_contextRightSegmentActive {\n background: var(--dsw-alias-interactive-bg-hover);\n color: var(--dsw-alias-label-primary);\n box-shadow: 0 0 0 1px var(--dsw-alias-border-primary);\n}\n.styles_contextRightStatus {\n margin: 0;\n color: var(--dsw-alias-label-tertiary);\n}\n.styles_contextChart {\n flex: none;\n display: grid;\n gap: 10px;\n padding: 10px 12px;\n border-radius: var(--dsw-radius-sm);\n background: var(--dsw-alias-bg-layer-2);\n}\n.styles_contextChartHeading {\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n gap: 10px;\n}\n.styles_contextChartTitle {\n font-weight: 600;\n color: var(--dsw-alias-label-primary);\n}\n.styles_contextChartTotal {\n color: var(--dsw-alias-label-primary);\n font-variant-numeric: tabular-nums;\n white-space: nowrap;\n}\n.styles_contextChartTotalHint {\n color: var(--dsw-alias-label-tertiary);\n font-weight: 400;\n}\n.styles_contextStackWrap {\n position: relative;\n display: grid;\n gap: 0;\n}\n.styles_contextStack {\n display: flex;\n width: 100%;\n height: 12px;\n border-radius: 999px;\n overflow: hidden;\n background: var(--dsw-alias-border-primary);\n}\n.styles_contextStackSegment,\n.styles_contextStackSegmentDim {\n display: block;\n height: 100%;\n min-width: 2px;\n cursor: default;\n transition: opacity 120ms ease, filter 120ms ease;\n}\n.styles_contextStackSegment {\n opacity: 1;\n filter: saturate(1.08);\n}\n.styles_contextStackSegmentDim {\n opacity: 0.28;\n filter: saturate(0.55);\n}\n.styles_contextChartTip {\n position: absolute;\n left: 50%;\n bottom: calc(100% + 6px);\n transform: translateX(-50%);\n z-index: 2;\n display: inline-flex;\n align-items: center;\n gap: 6px;\n max-width: min(100%, 280px);\n padding: 5px 8px;\n border-radius: var(--dsw-radius-sm);\n background: var(--dsw-alias-bg-layer-1);\n box-shadow: 0 0 0 1px var(--dsw-alias-border-primary);\n color: var(--dsw-alias-label-primary);\n font-size: 12px;\n line-height: 16px;\n white-space: nowrap;\n pointer-events: none;\n}\n.styles_contextChartTipSwatch {\n flex: none;\n width: 8px;\n height: 8px;\n border-radius: 999px;\n}\n.styles_contextChartLegend {\n list-style: none;\n margin: 0;\n padding: 0;\n min-width: 0;\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n.styles_contextChartLegendItem,\n.styles_contextChartLegendItemDim {\n display: grid;\n grid-template-columns: 8px minmax(0, 1fr);\n gap: 8px;\n align-items: start;\n font-size: 12px;\n border-radius: var(--dsw-radius-sm);\n padding: 2px 4px;\n margin: 0 -4px;\n transition: opacity 120ms ease, background 120ms ease;\n}\n.styles_contextChartLegendItem {\n opacity: 1;\n background: transparent;\n}\n.styles_contextChartLegendItem:hover {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n.styles_contextChartLegendItemDim {\n opacity: 0.4;\n}\n.styles_contextChartSwatch {\n width: 8px;\n height: 8px;\n margin-top: 4px;\n border-radius: 999px;\n}\n.styles_contextChartLegendMain {\n min-width: 0;\n display: grid;\n gap: 4px;\n}\n.styles_contextChartLegendTop {\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n gap: 8px;\n}\n.styles_contextChartLegendLabel {\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n color: var(--dsw-alias-label-primary);\n}\n.styles_contextChartLegendMeta {\n color: var(--dsw-alias-label-tertiary);\n font-variant-numeric: tabular-nums;\n white-space: nowrap;\n}\n.styles_contextChartLegendTrack {\n height: 3px;\n border-radius: 999px;\n background: var(--dsw-alias-border-primary);\n overflow: hidden;\n}\n.styles_contextChartLegendFill {\n height: 100%;\n border-radius: inherit;\n opacity: 0.9;\n}\n.styles_contextHeadroom {\n display: grid;\n gap: 4px;\n padding-top: 2px;\n border-top: 1px solid var(--dsw-alias-border-primary);\n}\n.styles_contextHeadroomMeta {\n display: flex;\n justify-content: space-between;\n gap: 8px;\n color: var(--dsw-alias-label-secondary);\n font-size: 12px;\n}\n.styles_contextHeadroomValue {\n color: var(--dsw-alias-label-primary);\n font-variant-numeric: tabular-nums;\n}\n.styles_contextHeadroomTrack {\n height: 5px;\n border-radius: 999px;\n background: var(--dsw-alias-border-primary);\n overflow: hidden;\n}\n.styles_contextHeadroomFill {\n height: 100%;\n border-radius: inherit;\n background: #4c8bf5;\n opacity: 0.85;\n}\n.styles_contextHeadroomHint {\n color: var(--dsw-alias-label-tertiary);\n font-size: 11px;\n}\n.styles_contextCompactBar {\n display: flex;\n align-items: flex-start;\n gap: 8px;\n flex: none;\n}\n.styles_contextCompactButton {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 6px;\n flex: none;\n min-height: 30px;\n padding: 0 10px 0 8px;\n border: 0;\n border-radius: var(--dsw-radius-sm);\n cursor: pointer;\n color: #fff;\n background: #3b7ded;\n font-size: 12px;\n font-weight: 600;\n line-height: 16px;\n box-shadow: 0 0 0 1px color-mix(in srgb, #3b7ded 55%, transparent);\n}\n.styles_contextCompactButton:hover:not(:disabled) {\n color: #fff;\n background: #2f6fe0;\n}\n.styles_contextCompactButton:focus-visible {\n outline: 2px solid color-mix(in srgb, #3b7ded 70%, white);\n outline-offset: 2px;\n}\n.styles_contextCompactButton:disabled {\n cursor: default;\n opacity: 0.55;\n}\n.styles_contextCompactButtonLabel {\n max-width: 9em;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.styles_contextCompactHint,\n.styles_contextCompactNote {\n margin: 0;\n min-width: 0;\n flex: 1;\n color: var(--dsw-alias-label-tertiary);\n font-size: 12px;\n line-height: 18px;\n padding-top: 5px;\n}\n.styles_contextCompactNote {\n color: var(--dsw-alias-label-secondary);\n}\n.styles_contextEventRow {\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n flex: none;\n}\n.styles_contextEventChip,\n.styles_contextEventChipCompact,\n.styles_contextEventChipPrune {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n padding: 2px 7px;\n border-radius: var(--dsw-radius-sm);\n background: var(--dsw-alias-bg-layer-2);\n color: var(--dsw-alias-label-secondary);\n font-size: 11px;\n line-height: 16px;\n}\n.styles_contextEventChipCompact {\n color: var(--dsw-alias-label-primary);\n}\n.styles_contextEventChipPrune {\n color: var(--dsw-alias-label-primary);\n}\n.styles_contextRightScroll,\n.styles_contextRightListFill {\n min-height: 0;\n flex: 1;\n display: flex;\n flex-direction: column;\n gap: 2px;\n}\n.styles_contextRightScroll {\n overflow: auto;\n}\n.styles_contextRightListFill {\n overflow: hidden;\n}\n.styles_contextRightItem,\n.styles_contextRightItemActive,\n.styles_contextRightItemActiveFill {\n border: 0;\n border-radius: var(--dsw-radius-sm);\n background: transparent;\n}\n.styles_contextRightItem:hover {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n.styles_contextRightItemActive,\n.styles_contextRightItemActiveFill {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n.styles_contextRightItemActiveFill {\n flex: 1;\n min-height: 0;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n}\n.styles_contextRightRow {\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n gap: 10px;\n width: 100%;\n text-align: left;\n border: 0;\n background: transparent;\n color: inherit;\n border-radius: var(--dsw-radius-sm);\n padding: 8px 8px 7px;\n cursor: pointer;\n font: inherit;\n}\n.styles_contextRightItemDot {\n width: 7px;\n height: 7px;\n border-radius: 999px;\n flex: none;\n margin-top: 5px;\n}\n.styles_contextRightRowMain {\n min-width: 0;\n flex: 1;\n display: grid;\n gap: 4px;\n}\n.styles_contextRightRowTitle {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 6px;\n font-weight: 500;\n}\n.styles_contextRightBadge,\n.styles_contextRightBadgeMuted {\n display: inline-flex;\n align-items: center;\n padding: 0 5px;\n border-radius: var(--dsw-radius-sm);\n font-size: 10px;\n font-weight: 500;\n line-height: 16px;\n color: var(--dsw-alias-label-secondary);\n background: var(--dsw-alias-bg-layer-2);\n}\n.styles_contextRightBadgeMuted {\n opacity: 0.9;\n}\n.styles_contextRightRowPreview {\n color: var(--dsw-alias-label-secondary);\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.styles_contextRightBarTrack {\n height: 2px;\n border-radius: 999px;\n background: var(--dsw-alias-border-primary);\n overflow: hidden;\n}\n.styles_contextRightBarFill {\n height: 100%;\n background: var(--dsw-alias-label-secondary);\n}\n.styles_contextRightRowTokens {\n flex: none;\n color: var(--dsw-alias-label-tertiary);\n font-variant-numeric: tabular-nums;\n text-align: right;\n padding-top: 1px;\n}\n.styles_contextRightShare {\n opacity: 0.85;\n}\n.styles_contextRightDetail {\n margin: 0 8px 8px 22px;\n min-height: 0;\n padding: 8px 10px;\n border-radius: var(--dsw-radius-sm);\n background: var(--dsw-alias-bg-layer-2);\n}\n.styles_contextRightItemActiveFill .styles_contextRightDetail {\n flex: 1;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n}\n.styles_contextRightDetailBody {\n margin: 0;\n white-space: pre-wrap;\n word-break: break-word;\n font: inherit;\n color: var(--dsw-alias-label-secondary);\n}\n.styles_contextRightItemActiveFill .styles_contextRightDetailBody {\n flex: 1;\n min-height: 0;\n overflow: auto;\n}\n.styles_contextRightNote {\n flex: none;\n color: var(--dsw-alias-label-tertiary);\n font-size: 12px;\n line-height: 18px;\n}\n.styles_usageRightPane {\n box-sizing: border-box;\n height: 100%;\n min-height: 0;\n display: flex;\n flex-direction: column;\n padding: 0;\n color: var(--dsw-alias-label-primary);\n font: var(--dsw-font-sm-13);\n background:\n linear-gradient(\n 180deg,\n color-mix(in srgb, #3d7cf5 10%, var(--dsw-alias-bg-layer-1)) 0,\n var(--dsw-alias-bg-layer-1) 120px);\n}\n.styles_usagePanel {\n box-sizing: border-box;\n flex: 1;\n min-height: 0;\n display: flex;\n flex-direction: column;\n gap: 14px;\n overflow: auto;\n padding: 14px 14px 16px;\n}\n.styles_usagePanel h2,\n.styles_usagePanel h3,\n.styles_usagePanel p {\n margin: 0;\n}\n.styles_usageHeader,\n.styles_usageHero {\n display: grid;\n gap: 6px;\n flex: none;\n}\n.styles_usageHero {\n grid-template-columns: minmax(0, 1fr) auto;\n align-items: end;\n gap: 12px;\n padding: 10px 12px;\n border-radius: var(--dsw-radius-md, 10px);\n background:\n linear-gradient(\n 135deg,\n color-mix(in srgb, #3d7cf5 16%, transparent),\n color-mix(in srgb, #1f9a6a 8%, transparent));\n border: 1px solid color-mix(in srgb, #3d7cf5 22%, var(--dsw-alias-bg-layer-2));\n}\n.styles_usageHeroCopy {\n display: grid;\n gap: 4px;\n min-width: 0;\n}\n.styles_usageHeroTotal {\n display: grid;\n justify-items: end;\n gap: 2px;\n}\n.styles_usageHeroTotalValue {\n font: var(--dsw-font-sm-16, var(--dsw-font-sm-14));\n font-weight: 700;\n font-variant-numeric: tabular-nums;\n letter-spacing: -0.02em;\n color: var(--dsw-alias-label-primary);\n}\n.styles_usageHeroTotalLabel {\n color: var(--dsw-alias-label-tertiary);\n font-size: 11px;\n line-height: 14px;\n}\n.styles_usageMoneyBlock {\n display: grid;\n gap: 2px;\n margin-top: 4px;\n}\n.styles_usageEstimate {\n font-weight: 650;\n font-variant-numeric: tabular-nums;\n letter-spacing: -0.01em;\n}\n.styles_usageEstimateHint,\n.styles_usageUnpriced,\n.styles_usageBalanceDetail,\n.styles_usageBalanceStale,\n.styles_usageBalanceHint {\n color: var(--dsw-alias-label-tertiary);\n font-size: 11px;\n line-height: 15px;\n}\n.styles_usageBalance {\n display: grid;\n gap: 2px;\n margin-top: 4px;\n font-variant-numeric: tabular-nums;\n}\n.styles_providerBalanceChip {\n display: grid;\n gap: 2px;\n justify-items: start;\n margin: 0;\n padding: 0;\n border: 0;\n background: transparent;\n color: var(--dsw-alias-label-secondary);\n font: inherit;\n font-size: 12px;\n line-height: 18px;\n font-variant-numeric: tabular-nums;\n text-align: left;\n cursor: pointer;\n}\n.styles_providerBalanceChip:hover .styles_providerBalancePrimary {\n color: var(--dsw-alias-label-primary);\n}\n.styles_providerBalancePrimary {\n color: var(--dsw-alias-label-secondary);\n}\n.styles_providerBalanceDetail {\n color: var(--dsw-alias-label-tertiary);\n font-size: 11px;\n line-height: 15px;\n}\n.styles_usageTitle {\n font: var(--dsw-font-sm-14);\n font-weight: 650;\n letter-spacing: -0.01em;\n}\n.styles_usageBack {\n justify-self: start;\n margin: 0 0 2px;\n padding: 0;\n border: 0;\n background: transparent;\n color: var(--dsw-alias-label-secondary);\n font: inherit;\n cursor: pointer;\n}\n.styles_usageBack:hover {\n color: var(--dsw-alias-label-primary);\n}\n.styles_usageNote,\n.styles_usageRetention,\n.styles_usageEmpty,\n.styles_usageEmptyInline,\n.styles_usageBucketMeta {\n color: var(--dsw-alias-label-tertiary);\n font-size: 12px;\n line-height: 18px;\n}\n.styles_usageToolbar,\n.styles_usageRecordsToolbar {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n flex: none;\n}\n.styles_usageRanges {\n display: flex;\n flex-wrap: wrap;\n gap: 4px;\n width: fit-content;\n max-width: 100%;\n padding: 4px;\n background: var(--dsw-alias-bg-layer-2);\n border-radius: var(--dsw-radius-sm);\n flex: none;\n}\n.styles_usageRefresh {\n margin: 0;\n min-height: 28px;\n padding: 0 12px;\n border: 1px solid color-mix(in srgb, var(--dsw-alias-label-primary) 12%, transparent);\n border-radius: var(--dsw-radius-sm);\n background: var(--dsw-alias-bg-layer-2);\n color: var(--dsw-alias-label-primary);\n font: inherit;\n cursor: pointer;\n}\n.styles_usageRefresh:hover:not(:disabled) {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n.styles_usageRefresh:focus-visible {\n outline: 2px solid var(--dsw-alias-label-secondary);\n outline-offset: 2px;\n}\n.styles_usageRefresh:disabled {\n cursor: not-allowed;\n opacity: 0.55;\n}\n.styles_usageRange {\n margin: 0;\n min-height: 28px;\n padding: 0 10px;\n border: 0;\n border-radius: var(--dsw-radius-sm);\n background: transparent;\n color: var(--dsw-alias-label-secondary);\n font: inherit;\n cursor: pointer;\n}\n.styles_usageRange[aria-pressed=true] {\n background: var(--dsw-alias-interactive-bg-hover);\n color: var(--dsw-alias-label-primary);\n font-weight: 600;\n}\n.styles_usageRange:hover:not(:disabled):not([aria-pressed=true]) {\n color: var(--dsw-alias-label-primary);\n}\n.styles_usageRange:focus-visible,\n.styles_usageBack:focus-visible,\n.styles_usageLink:focus-visible,\n.styles_usageRecordsEntry:focus-visible {\n outline: 2px solid var(--dsw-alias-label-secondary);\n outline-offset: 2px;\n}\n.styles_usageRange:disabled,\n.styles_usageRecordsEntry:disabled {\n cursor: not-allowed;\n opacity: 0.55;\n}\n.styles_usageCharts {\n display: grid;\n gap: 16px;\n flex: none;\n}\n.styles_usageBuckets {\n display: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n gap: 8px;\n}\n.styles_usageBucket {\n display: grid;\n gap: 4px;\n min-width: 0;\n padding: 10px 12px;\n border-radius: var(--dsw-radius-sm);\n background: var(--dsw-alias-bg-layer-2);\n border: 1px solid color-mix(in srgb, var(--dsw-alias-label-primary) 6%, transparent);\n}\n.styles_usageBucketLabel {\n color: var(--dsw-alias-label-tertiary);\n font-size: 11px;\n line-height: 14px;\n}\n.styles_usageBucketValue {\n color: var(--dsw-alias-label-primary);\n font: var(--dsw-font-sm-14);\n font-weight: 650;\n font-variant-numeric: tabular-nums;\n}\n.styles_usageSectionTitle {\n margin: 0;\n font: var(--dsw-font-sm-13);\n font-weight: 650;\n color: var(--dsw-alias-label-primary);\n}\n.styles_usageChart {\n display: grid;\n gap: 10px;\n}\n.styles_usageChartHead {\n display: grid;\n gap: 4px;\n}\n.styles_usageChartHint {\n margin: 0;\n color: var(--dsw-alias-label-tertiary);\n font-size: 11px;\n line-height: 15px;\n}\n.styles_usageHeatBody {\n display: grid;\n gap: 10px;\n}\n.styles_usageHeatGrid {\n display: grid;\n gap: 4px;\n}\n.styles_usageHeatGridHour {\n grid-template-columns: repeat(6, minmax(0, 1fr));\n}\n.styles_usageHeatGridDay {\n grid-template-columns: repeat(auto-fill, minmax(28px, 1fr));\n}\n.styles_usageHeatCell,\n.styles_usageHeatCellDim {\n box-sizing: border-box;\n display: grid;\n place-items: end start;\n min-height: 36px;\n margin: 0;\n padding: 4px;\n border: 1px solid color-mix(in srgb, var(--dsw-alias-label-primary) 8%, transparent);\n border-radius: 6px;\n background: var(--dsw-alias-bg-layer-2);\n color: var(--dsw-alias-label-secondary);\n cursor: pointer;\n transition: opacity 120ms ease, transform 120ms ease;\n}\n.styles_usageHeatCell:hover,\n.styles_usageHeatCell:focus-visible {\n transform: translateY(-1px);\n outline: none;\n}\n.styles_usageHeatCell:focus-visible {\n box-shadow: 0 0 0 2px color-mix(in srgb, #3d7cf5 55%, transparent);\n}\n.styles_usageHeatCellDim {\n opacity: 0.35;\n}\n.styles_usageHeatCell[data-level="0"],\n.styles_usageHeatCellDim[data-level="0"],\n.styles_usageHeatScale span[data-level="0"] {\n background: var(--dsw-alias-bg-layer-2);\n}\n.styles_usageHeatCell[data-level="1"],\n.styles_usageHeatCellDim[data-level="1"],\n.styles_usageHeatScale span[data-level="1"] {\n background: color-mix(in srgb, #3d7cf5 22%, var(--dsw-alias-bg-layer-2));\n}\n.styles_usageHeatCell[data-level="2"],\n.styles_usageHeatCellDim[data-level="2"],\n.styles_usageHeatScale span[data-level="2"] {\n background: color-mix(in srgb, #3d7cf5 40%, var(--dsw-alias-bg-layer-2));\n}\n.styles_usageHeatCell[data-level="3"],\n.styles_usageHeatCellDim[data-level="3"],\n.styles_usageHeatScale span[data-level="3"] {\n background: color-mix(in srgb, #3d7cf5 62%, var(--dsw-alias-bg-layer-2));\n color: #f4f7ff;\n}\n.styles_usageHeatCell[data-level="4"],\n.styles_usageHeatCellDim[data-level="4"],\n.styles_usageHeatScale span[data-level="4"] {\n background: color-mix(in srgb, #245fd4 88%, #0b1c3a);\n color: #f4f7ff;\n}\n.styles_usageHeatLabel {\n font-size: 10px;\n line-height: 12px;\n font-variant-numeric: tabular-nums;\n}\n.styles_usageHeatLegend {\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n gap: 12px;\n min-height: 20px;\n}\n.styles_usageHeatTipValue {\n font-weight: 650;\n font-variant-numeric: tabular-nums;\n}\n.styles_usageHeatTipMeta {\n color: var(--dsw-alias-label-tertiary);\n font-size: 12px;\n}\n.styles_usageHeatScale {\n display: inline-flex;\n gap: 3px;\n margin-left: auto;\n}\n.styles_usageHeatScale span {\n width: 12px;\n height: 12px;\n border-radius: 3px;\n border: 1px solid color-mix(in srgb, var(--dsw-alias-label-primary) 8%, transparent);\n}\n.styles_usageShareBody {\n display: grid;\n gap: 10px;\n}\n.styles_usageShareTrack {\n display: flex;\n width: 100%;\n height: 12px;\n overflow: hidden;\n border-radius: 999px;\n background: var(--dsw-alias-bg-layer-2);\n}\n.styles_usageShareSegment,\n.styles_usageShareSegmentDim {\n height: 100%;\n min-width: 2px;\n transition: opacity 120ms ease;\n}\n.styles_usageShareSegmentDim {\n opacity: 0.28;\n}\n.styles_usageLegend,\n.styles_usageRankList,\n.styles_usageRecentList {\n display: grid;\n gap: 8px;\n width: 100%;\n margin: 0;\n padding: 0;\n list-style: none;\n}\n.styles_usageLegendItem,\n.styles_usageLegendItemDim {\n display: grid;\n grid-template-columns: 8px minmax(0, 1fr) auto;\n gap: 8px;\n align-items: center;\n}\n.styles_usageLegendItemDim {\n opacity: 0.45;\n}\n.styles_usageLegendSwatch {\n width: 8px;\n height: 8px;\n border-radius: 999px;\n}\n.styles_usageLegendLabel {\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.styles_usageLegendMeta,\n.styles_usageRankMeta {\n color: var(--dsw-alias-label-secondary);\n font-variant-numeric: tabular-nums;\n white-space: nowrap;\n}\n.styles_usageLegendShare {\n margin-left: 6px;\n color: var(--dsw-alias-label-tertiary);\n}\n.styles_usageRankItem {\n display: grid;\n gap: 4px;\n}\n.styles_usageRankTop {\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n gap: 12px;\n}\n.styles_usageRankLabel {\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.styles_usageRankTrack {\n height: 6px;\n overflow: hidden;\n border-radius: 999px;\n background: var(--dsw-alias-bg-layer-2);\n}\n.styles_usageRankFill {\n height: 100%;\n border-radius: inherit;\n}\n.styles_usageFooter {\n margin-top: auto;\n flex: none;\n display: grid;\n gap: 8px;\n padding-top: 4px;\n}\n.styles_usageRecentPreview {\n display: grid;\n gap: 8px;\n}\n.styles_usageRecentHead {\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n gap: 12px;\n}\n.styles_usageLink {\n margin: 0;\n padding: 0;\n border: 0;\n background: transparent;\n color: var(--dsw-alias-label-secondary);\n font: inherit;\n cursor: pointer;\n}\n.styles_usageLink:hover {\n color: var(--dsw-alias-label-primary);\n}\n.styles_usageRecordsEntry {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n width: 100%;\n margin: 0;\n padding: 10px 0;\n border: 0;\n border-top: 1px solid var(--dsw-alias-border-subtle, var(--dsw-alias-bg-layer-2));\n background: transparent;\n color: var(--dsw-alias-label-primary);\n font: inherit;\n text-align: start;\n cursor: pointer;\n}\n.styles_usageRecordsEntry:hover:not(:disabled) {\n color: var(--dsw-alias-label-primary);\n}\n.styles_usageRecordsEntryMeta {\n color: var(--dsw-alias-label-tertiary);\n font-variant-numeric: tabular-nums;\n white-space: nowrap;\n}\n.styles_usageRecentItem {\n display: grid;\n gap: 6px;\n padding: 10px 0;\n}\n.styles_usageRecentItem + .styles_usageRecentItem {\n border-top: 1px solid var(--dsw-alias-border-subtle, var(--dsw-alias-bg-layer-2));\n}\n.styles_usageRecentMain {\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n gap: 12px;\n}\n.styles_usageRecentSource {\n font-weight: 650;\n}\n.styles_usageRecentRoute {\n display: flex;\n flex-wrap: wrap;\n gap: 6px 10px;\n color: var(--dsw-alias-label-secondary);\n font-size: 12px;\n line-height: 16px;\n}\n.styles_usageRecentProvider {\n color: var(--dsw-alias-label-tertiary);\n}\n.styles_usageRecentWhen {\n color: var(--dsw-alias-label-tertiary);\n font-size: 12px;\n white-space: nowrap;\n}\n.styles_usageRecentTokens {\n display: flex;\n flex-wrap: wrap;\n gap: 6px 10px;\n color: var(--dsw-alias-label-secondary);\n font-size: 12px;\n line-height: 16px;\n font-variant-numeric: tabular-nums;\n}\n';
1284
1397
  function installCss() {
1285
1398
  const style = document.createElement("style");
1286
1399
  style.setAttribute("data-dsh-agent-enhancer", "");
@@ -1328,6 +1441,29 @@ function UndoIcon() {
1328
1441
  }
1329
1442
  );
1330
1443
  }
1444
+ function TimelineIcon() {
1445
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
1446
+ "svg",
1447
+ {
1448
+ width: "16",
1449
+ height: "16",
1450
+ viewBox: "0 0 16 16",
1451
+ fill: "none",
1452
+ stroke: "currentColor",
1453
+ strokeWidth: "1.5",
1454
+ strokeLinecap: "round",
1455
+ strokeLinejoin: "round",
1456
+ "aria-hidden": "true",
1457
+ children: [
1458
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M4 2.5v11" }),
1459
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "4", cy: "4", r: "1.4", fill: "currentColor", stroke: "none" }),
1460
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "4", cy: "8", r: "1.4", fill: "currentColor", stroke: "none" }),
1461
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "4", cy: "12", r: "1.4", fill: "currentColor", stroke: "none" }),
1462
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M7 4h5M7 8h5M7 12h3.5" })
1463
+ ]
1464
+ }
1465
+ );
1466
+ }
1331
1467
 
1332
1468
  // src/client/dsh/controls.tsx
1333
1469
  var import_jsx_runtime2 = require("react/jsx-runtime");
@@ -1382,13 +1518,19 @@ function textOf(node) {
1382
1518
  function turnOf(node) {
1383
1519
  return node.location.kind === "turn" || node.location.kind === "step" ? node.location.turn.turn : void 0;
1384
1520
  }
1521
+ function isDirectUserPrompt(data) {
1522
+ const source = data.source;
1523
+ return source?.kind === "user";
1524
+ }
1385
1525
  function sentPrompts(chat) {
1386
1526
  if (chat === void 0) return [];
1387
1527
  return chat.order.flatMap((key) => {
1388
1528
  const node = chat.nodes.get(key);
1389
1529
  if (node?.kind !== "user") return [];
1390
- const text2 = textOf(node.data);
1391
- return text2.trim() === "" ? [] : [{ seq: node.data.seq, text: text2 }];
1530
+ const data = node.data;
1531
+ if (!isDirectUserPrompt(data)) return [];
1532
+ const text2 = textOf(data);
1533
+ return text2.trim() === "" ? [] : [{ seq: data.seq, text: text2 }];
1392
1534
  });
1393
1535
  }
1394
1536
  function latestCompletedTurn(chat, session) {
@@ -1608,14 +1750,19 @@ function AgentOverlay(props) {
1608
1750
  setSearch(coordinator.searchSnapshot());
1609
1751
  setPrediction(coordinator.predictionSnapshot());
1610
1752
  });
1611
- let unregisterHistory = () => {
1612
- };
1613
- const refreshHistory = () => {
1614
- unregisterHistory();
1615
- unregisterHistory = coordinator.registerHistory({
1616
- load: (requested) => requested === props.sessionId ? sentPrompts(latestRef.current.chat) : []
1617
- });
1753
+ const unregisterHistory = coordinator.registerHistory({
1754
+ load: (requested) => {
1755
+ if (requested !== props.sessionId) return [];
1756
+ return promptLedgerFor(props.sessionId).observe(sentPrompts(latestRef.current.chat));
1757
+ }
1758
+ });
1759
+ const warmHistory = () => {
1760
+ promptLedgerFor(props.sessionId).observe(sentPrompts(latestRef.current.chat));
1761
+ coordinator.invalidateHistoryCache(props.sessionId);
1618
1762
  };
1763
+ const unsubscribeLedger = subscribePromptLedgerInvalidation((sessionId) => {
1764
+ if (sessionId === props.sessionId) coordinator.invalidateHistoryCache(sessionId);
1765
+ });
1619
1766
  let selection = { start: latestRef.current.input.draft.length, end: latestRef.current.input.draft.length };
1620
1767
  const sync = () => {
1621
1768
  selection = readSelection(root) ?? selection;
@@ -1675,7 +1822,7 @@ function AgentOverlay(props) {
1675
1822
  root.ownerDocument.addEventListener("click", onOfficialMenuPointer);
1676
1823
  const active = {
1677
1824
  sync,
1678
- refreshHistory,
1825
+ refreshHistory: warmHistory,
1679
1826
  dispose() {
1680
1827
  root.removeEventListener("keydown", onKeyDown);
1681
1828
  root.removeEventListener("input", onInput);
@@ -1685,12 +1832,14 @@ function AgentOverlay(props) {
1685
1832
  root.ownerDocument.removeEventListener("pointerdown", onOfficialMenuPointer);
1686
1833
  root.ownerDocument.removeEventListener("click", onOfficialMenuPointer);
1687
1834
  unregisterHistory();
1835
+ unsubscribeLedger();
1688
1836
  unsubscribe();
1689
1837
  detach();
1690
1838
  }
1691
1839
  };
1692
1840
  activeRef.current = active;
1693
1841
  sync();
1842
+ warmHistory();
1694
1843
  return () => {
1695
1844
  active.dispose();
1696
1845
  if (activeRef.current === active) activeRef.current = null;
@@ -2880,6 +3029,10 @@ function ContextInspectDock(props) {
2880
3029
  var USAGE_TAB_ID = "dsh-agent-enhancer/usage";
2881
3030
  var USAGE_TAB_KIND = "agentEnhancerUsage";
2882
3031
 
3032
+ // src/client/rollback/timeline-kind.ts
3033
+ var CHECKPOINT_TIMELINE_TAB_ID = "dsh-agent-enhancer/checkpointTimeline";
3034
+ var CHECKPOINT_TIMELINE_TAB_KIND = "agentEnhancerCheckpointTimeline";
3035
+
2883
3036
  // src/client/context/tab.ts
2884
3037
  var CONTEXT_INSPECT_TAB_ID = "dsh-agent-enhancer/contextInspect";
2885
3038
  var CONTEXT_INSPECT_TAB_KIND = "agentEnhancerContextInspect";
@@ -2925,6 +3078,9 @@ function openContextInspectTab(sidebarRight, params) {
2925
3078
  function openUsageTab(sidebarRight) {
2926
3079
  return openRightTab(sidebarRight, USAGE_TAB_KIND, {});
2927
3080
  }
3081
+ function openCheckpointTimelineTab(sidebarRight, params) {
3082
+ return openRightTab(sidebarRight, CHECKPOINT_TIMELINE_TAB_KIND, params);
3083
+ }
2928
3084
 
2929
3085
  // src/client/context/right-tab.tsx
2930
3086
  var import_react7 = require("react");
@@ -4424,53 +4580,95 @@ var agentLocales = {
4424
4580
  rollbackTitle: "\u6062\u590D\u5230\u7B2C {turn} \u8F6E\u4E4B\u524D",
4425
4581
  rollbackUndoTitle: "\u64A4\u9500\u7B2C {turn} \u8F6E\u6062\u590D",
4426
4582
  rollbackScope: "\u53EF\u9009\u62E9\u4EC5\u6062\u590D\u5BF9\u8BDD\uFF0C\u6216\u540C\u65F6\u6062\u590D\u5DF2\u8DDF\u8E2A\u6587\u4EF6\u3002\u8FDB\u7A0B\u3001\u7EC8\u7AEF\u3001\u540E\u53F0\u4EFB\u52A1\u3001\u6570\u636E\u5E93\u3001\u7F51\u7EDC\u3001\u90E8\u7F72\u3001\u7B2C\u4E09\u65B9\u670D\u52A1\u548C\u672A\u8DDF\u8E2A\u6587\u4EF6\u4E0D\u4F1A\u6062\u590D\u3002\u65E0\u6587\u4EF6\u53D8\u66F4\u6216\u4EC5\u6709\u6355\u83B7\u7F3A\u53E3\u65F6\u4ECD\u53EF\u786E\u8BA4\uFF1B\u6709\u6587\u4EF6\u51B2\u7A81\u65F6\u4ECD\u53EF\u4EC5\u6062\u590D\u5BF9\u8BDD\u3002",
4583
+ rollbackScopeAlready: "\u5BF9\u8BDD\u5DF2\u505C\u5728\u6B64\u68C0\u67E5\u70B9\u3002\u786E\u8BA4\u53EA\u4F1A\u91CD\u65B0\u586B\u5165\u8BE5\u8F6E\u8349\u7A3F\uFF1B\u82E5\u8981\u91CD\u65B0\u663E\u793A\u88AB\u64A4\u56DE\u7684\u6D88\u606F\uFF0C\u8BF7\u7528\u300C\u64A4\u9500\u6062\u590D\u300D\u3002\u8FDB\u7A0B\u3001\u7EC8\u7AEF\u3001\u540E\u53F0\u4EFB\u52A1\u3001\u6570\u636E\u5E93\u3001\u7F51\u7EDC\u3001\u90E8\u7F72\u3001\u7B2C\u4E09\u65B9\u670D\u52A1\u548C\u672A\u8DDF\u8E2A\u6587\u4EF6\u4E0D\u4F1A\u6062\u590D\u3002",
4584
+ rollbackScopeCovered: "\u5F53\u524D\u5DF2\u6062\u590D\u5230\u66F4\u65E9\u7684\u68C0\u67E5\u70B9\uFF0C\u6B64\u5904\u88AB\u8986\u76D6\u3002\u8BF7\u5148\u300C\u64A4\u9500\u6062\u590D\u300D\u56DE\u5230\u5B8C\u6574\u5BF9\u8BDD\uFF0C\u518D\u9009\u62E9\u6062\u590D\u5230\u8FD9\u4E00\u8F6E\u3002",
4427
4585
  rollbackUndoScope: "\u5C06\u64A4\u56DE\u672C\u6B21\u6062\u590D\u6807\u8BB0\uFF0C\u5E76\u8FD8\u539F\u6062\u590D\u524D\u7684\u5BF9\u8BDD\u4E0E\u5DF2\u8DDF\u8E2A\u6587\u4EF6\u9884\u89C8\u3002\u8FDB\u7A0B\u3001\u7EC8\u7AEF\u3001\u540E\u53F0\u4EFB\u52A1\u3001\u6570\u636E\u5E93\u3001\u7F51\u7EDC\u3001\u90E8\u7F72\u3001\u7B2C\u4E09\u65B9\u670D\u52A1\u548C\u672A\u8DDF\u8E2A\u6587\u4EF6\u4E0D\u4F1A\u6062\u590D\u3002",
4428
4586
  rollbackUndoScopeConversation: "\u5C06\u64A4\u56DE\u672C\u6B21\u4EC5\u5BF9\u8BDD\u6062\u590D\u6807\u8BB0\uFF0C\u5E76\u8FD8\u539F\u6062\u590D\u524D\u7684\u5BF9\u8BDD\u9884\u89C8\u3002\u5DF2\u8DDF\u8E2A\u6587\u4EF6\u4FDD\u6301\u5F53\u524D\u72B6\u6001\u3002",
4429
4587
  rollbackClose: "\u5173\u95ED\u6062\u590D\u9884\u89C8",
4430
4588
  rollbackConfirm: "\u6062\u590D\u5BF9\u8BDD\u4E0E\u5DF2\u8DDF\u8E2A\u6587\u4EF6",
4431
4589
  rollbackConfirmConversation: "\u4EC5\u6062\u590D\u5BF9\u8BDD",
4590
+ rollbackConfirmAlready: "\u91CD\u65B0\u586B\u5165\u8349\u7A3F\uFF08\u542B\u6587\u4EF6\uFF09",
4591
+ rollbackConfirmConversationAlready: "\u91CD\u65B0\u586B\u5165\u8349\u7A3F",
4432
4592
  rollbackUndoConfirm: "\u64A4\u9500\u6062\u590D\u5E76\u8FD8\u539F\u9884\u89C8\u5185\u5BB9",
4433
4593
  rollbackUndoConfirmConversation: "\u64A4\u9500\u6062\u590D\u5E76\u8FD8\u539F\u5BF9\u8BDD",
4434
4594
  rollbackCancel: "\u53D6\u6D88",
4595
+ rollbackAlreadyRestored: "\u5F53\u524D\u5DF2\u6062\u590D\u5230\u6B64\u68C0\u67E5\u70B9\uFF0C\u6CA1\u6709\u65B0\u7684\u5BF9\u8BDD\u53EF\u64A4\u56DE\u3002\u786E\u8BA4\u540E\u5173\u95ED\u9884\u89C8\u5E76\u586B\u5165\u8BE5\u8F6E\u63D0\u793A\u8BCD\u8349\u7A3F\uFF1B\u9700\u8981\u627E\u56DE\u88AB\u64A4\u56DE\u7684\u6D88\u606F\u65F6\uFF0C\u8BF7\u6539\u7528\u300C\u64A4\u9500\u6062\u590D\u300D\u3002",
4596
+ rollbackCoveredByEarlier: "\u66F4\u65E9\u7684\u6062\u590D\uFF08\u7B2C {tipTurn} \u8F6E\uFF09\u5DF2\u8986\u76D6\u6B64\u68C0\u67E5\u70B9\u3002\u8BF7\u5148\u64A4\u9500\u5F53\u524D\u6062\u590D\uFF0C\u518D\u6062\u590D\u5230\u8FD9\u4E00\u8F6E\u3002",
4435
4597
  rollbackLoading: "\u6B63\u5728\u91CD\u65B0\u68C0\u67E5\u5BF9\u8BDD\u548C\u6587\u4EF6\u72B6\u6001\u2026",
4436
4598
  rollbackRestoring: "\u6B63\u5728\u6062\u590D\u5BF9\u8BDD\u4E0E\u5DF2\u8DDF\u8E2A\u6587\u4EF6\u2026",
4437
4599
  rollbackRestoringConversation: "\u6B63\u5728\u6062\u590D\u5BF9\u8BDD\u2026",
4438
4600
  rollbackUndoRestoring: "\u6B63\u5728\u64A4\u9500\u6062\u590D\u5E76\u8FD8\u539F\u5BF9\u8BDD\u4E0E\u5DF2\u8DDF\u8E2A\u6587\u4EF6\u2026",
4439
4601
  rollbackUndoRestoringConversation: "\u6B63\u5728\u64A4\u9500\u6062\u590D\u5E76\u8FD8\u539F\u5BF9\u8BDD\u2026",
4440
4602
  rollbackFailed: "\u6062\u590D\u672A\u5B8C\u6210\uFF0C\u8BF7\u5173\u95ED\u9884\u89C8\u540E\u91CD\u8BD5\u3002",
4603
+ rollbackFailedUnavailable: "\u5F53\u524D\u65E0\u6CD5\u6062\u590D\uFF08\u4F1A\u8BDD\u5DF2\u53D8\u5316\u3001\u4ECD\u5728\u8FD0\u884C\u6216\u7ED3\u6784\u4E0D\u517C\u5BB9\uFF09\u3002\u8BF7\u5173\u95ED\u9884\u89C8\u540E\u91CD\u8BD5\u3002",
4604
+ rollbackFailedConflict: "\u6587\u4EF6\u5728\u9884\u89C8\u540E\u53D1\u751F\u4E86\u53D8\u5316\uFF0C\u5B8C\u6574\u6062\u590D\u5DF2\u53D6\u6D88\u3002\u53EF\u6539\u4E3A\u4EC5\u6062\u590D\u5BF9\u8BDD\uFF0C\u6216\u5173\u95ED\u540E\u91CD\u65B0\u9884\u89C8\u3002",
4605
+ rollbackFailedRecovery: "\u4E0A\u6B21\u6062\u590D\u5C1A\u672A\u6536\u5C3E\uFF08\u4F1A\u8BDD\u6B63\u5FD9\u6216\u5D29\u6E83\u6062\u590D\u672A\u5B8C\u6210\uFF09\u3002\u8BF7\u7B49\u4F1A\u8BDD\u7A7A\u95F2\u540E\u70B9\u300C\u91CD\u65B0\u68C0\u67E5\u300D\uFF0C\u6216\u5173\u95ED\u9884\u89C8\u518D\u8BD5\u3002",
4606
+ rollbackRetry: "\u91CD\u65B0\u68C0\u67E5",
4441
4607
  rollbackTurnOpen: "\u672C\u8F6E\u5C1A\u672A\u7ED3\u675F",
4442
4608
  rollbackTurnStartMissing: "\u672C\u8F6E\u5F00\u59CB\u4E8B\u4EF6\u5C1A\u672A\u52A0\u8F7D",
4609
+ rollbackSummary: "{messages} \u6761\u6D88\u606F \xB7 {files} \u4E2A\u6587\u4EF6",
4610
+ rollbackSummaryLabel: "\u6062\u590D\u8303\u56F4\u6458\u8981",
4611
+ rollbackMessageEmpty: "\uFF08\u65E0\u6587\u672C\uFF09",
4612
+ rollbackRole_user: "\u7528\u6237",
4613
+ rollbackRole_assistant: "\u52A9\u624B",
4614
+ rollbackRole_tool: "\u5DE5\u5177",
4615
+ rollbackRole_system: "\u7CFB\u7EDF",
4616
+ rollbackRole_other: "\u5176\u4ED6",
4617
+ rollbackCoverageFiles: "\u6062\u590D\u5230\u8FD9\u91CC \xB7 {count} \u4E2A\u5DF2\u8DDF\u8E2A\u6587\u4EF6",
4618
+ rollbackCoveragePartial: "\u6062\u590D\u5230\u8FD9\u91CC \xB7 \u90E8\u5206\u6587\u4EF6\u5FEB\u7167\uFF08{count}\uFF09",
4619
+ rollbackCoverageConversation: "\u6062\u590D\u5230\u8FD9\u91CC \xB7 \u4EC5\u5BF9\u8BDD\u5FEB\u7167",
4620
+ rollbackTimelineTitle: "\u68C0\u67E5\u70B9",
4621
+ rollbackTimelineOpen: "\u68C0\u67E5\u70B9\u65F6\u95F4\u7EBF",
4622
+ rollbackTimelineLead: "\u5F53\u524D\u5BF9\u8BDD {turns} \u8F6E / {steps} \u6B65 \xB7 \u68C0\u67E5\u70B9 {liveCheckpoints}/{checkpoints}\uFF08\u4E0D\u542B\u64A4\u9500\u58F3\uFF09\u3002\u6309\u5BF9\u8BDD\u987A\u5E8F\u6392\u5217\uFF1B\u5C55\u5F00\u53EF\u770B\u63D0\u793A\u8BCD\u3001\u6587\u4EF6\u4E0E\u7F3A\u53E3\u3002",
4623
+ rollbackTimelineLoading: "\u6B63\u5728\u52A0\u8F7D\u68C0\u67E5\u70B9\u2026",
4624
+ rollbackTimelineFailed: "\u68C0\u67E5\u70B9\u5217\u8868\u52A0\u8F7D\u5931\u8D25\u3002\u8BF7\u91CD\u8BD5\u3002",
4625
+ rollbackTimelineEmpty: "\u6B64\u4F1A\u8BDD\u8FD8\u6CA1\u6709\u53EF\u5C55\u793A\u7684\u68C0\u67E5\u70B9\u3002\u5B8C\u6210\u4E00\u8F6E\u540E\u4F1A\u51FA\u73B0\u5728\u8FD9\u91CC\u3002",
4626
+ rollbackTimelineNoSession: "\u8BF7\u4ECE\u4F1A\u8BDD\u4E2D\u7684\u6062\u590D\u5165\u53E3\u6253\u5F00\u68C0\u67E5\u70B9\u65F6\u95F4\u7EBF\u3002",
4627
+ rollbackTimelineTurn: "\u7B2C {turn} \u8F6E",
4628
+ rollbackTimelineRolledBack: "\u5DF2\u56DE\u6EDA",
4629
+ rollbackTimelineTip: "\u5F53\u524D\u6062\u590D\u70B9",
4630
+ rollbackTimelineOpening: "\u6B63\u5728\u6253\u5F00\u9884\u89C8\u2026",
4631
+ rollbackTimelineCoveredHint: "\u5DF2\u88AB\u66F4\u65E9\u7684\u6062\u590D\u70B9\u8986\u76D6\u3002\u8981\u56DE\u5230\u8FD9\u4E00\u8F6E\uFF0C\u8BF7\u5148\u64A4\u9500\u5F53\u524D\u6062\u590D\u3002",
4632
+ rollbackTimelineNoPrompt: "\u65E0\u53EF\u7528\u63D0\u793A\u8BCD\u6458\u8981",
4633
+ rollbackTimelineFileFallback: "{path}",
4634
+ rollbackTimelineFilesFallback: "{path} \u7B49 {count} \u4E2A\u6587\u4EF6",
4635
+ rollbackTimelineCoverageFiles: "{count} \u4E2A\u5DF2\u8DDF\u8E2A\u6587\u4EF6",
4636
+ rollbackTimelineCoveragePartial: "\u90E8\u5206\u5FEB\u7167 \xB7 {count} \u4E2A\u6587\u4EF6",
4637
+ rollbackTimelineCoverageConversation: "\u4EC5\u5BF9\u8BDD",
4638
+ rollbackTimelineCoverageUnknown: "\u672A\u77E5\u8986\u76D6",
4443
4639
  rollbackMessages: "\u5C06\u64A4\u56DE\u7684\u5BF9\u8BDD",
4444
4640
  rollbackFiles: "\u5C06\u6062\u590D\u7684\u5DF2\u8DDF\u8E2A\u6587\u4EF6",
4445
4641
  rollbackGaps: "\u65E0\u6CD5\u6062\u590D\u7684\u539F\u56E0",
4446
4642
  rollbackFilesLimited: "\u5B8C\u6574\u6062\u590D\u53D7\u9650",
4447
- rollbackFilesLimitedHint: "\u4ECD\u53EF\u53EA\u6062\u590D\u5BF9\u8BDD\uFF1B\u5DE5\u4F5C\u533A\u6355\u83B7\u4E0D\u5B8C\u6574\u6216\u6587\u4EF6\u6709\u51B2\u7A81\u65F6\uFF0C\u4E0D\u5EFA\u8BAE\u6062\u590D\u6587\u4EF6\u3002",
4643
+ rollbackFilesLimitedHint: "\u5DF2\u8DDF\u8E2A\u7684\u6587\u4EF6\u53D8\u66F4\u4ECD\u53EF\u6062\u590D\uFF1B\u82E5\u6587\u4EF6\u51B2\u7A81\u6216\u6355\u83B7\u7F3A\u53E3\u6321\u4F4F\u5176\u4F59\u90E8\u5206\uFF0C\u4ECD\u53EF\u53EA\u6062\u590D\u5BF9\u8BDD\u3002",
4448
4644
  rollbackConflicts: "\u6587\u4EF6\u51B2\u7A81",
4449
4645
  rollbackNoMessages: "\u6CA1\u6709\u53EF\u9884\u89C8\u7684\u5BF9\u8BDD\u6D88\u606F\u3002",
4450
4646
  rollbackNoFiles: "\u6B64\u68C0\u67E5\u70B9\u6CA1\u6709\u5DF2\u8DDF\u8E2A\u6587\u4EF6\u3002",
4451
4647
  rollbackFile_create: "\u5220\u9664\u672C\u8F6E\u521B\u5EFA\u7684\u6587\u4EF6",
4452
4648
  rollbackFile_modify: "\u6062\u590D\u4FEE\u6539\u524D\u5185\u5BB9",
4453
4649
  rollbackFile_delete: "\u6062\u590D\u5DF2\u5220\u9664\u6587\u4EF6",
4454
- rollbackGapWorkspace: "\u5DE5\u4F5C\u533A\u6355\u83B7\u4E0D\u5B8C\u6574",
4650
+ rollbackGapWorkspace: "\u5DE5\u4F5C\u533A\u6355\u83B7\u4E0D\u5B8C\u6574\uFF08\u90E8\u5206\u547D\u4EE4\u884C\u526F\u4F5C\u7528\u53EF\u80FD\u672A\u6536\u5F55\uFF09",
4455
4651
  rollbackGapPrompt: "\u539F\u63D0\u793A\u8BCD\u4E0D\u662F\u7EAF\u6587\u672C",
4456
4652
  rollbackUnavailableCheckpoint: "\u627E\u4E0D\u5230\u6B64\u8F6E\u68C0\u67E5\u70B9",
4457
- rollbackUnavailableIncomplete: "\u68C0\u67E5\u70B9\u4E0D\u5B8C\u6574\uFF1B\u4ECD\u53EF\u53EA\u6062\u590D\u5BF9\u8BDD",
4653
+ rollbackUnavailableIncomplete: "\u68C0\u67E5\u70B9\u4E0D\u5B8C\u6574\uFF1B\u5DF2\u8DDF\u8E2A\u6587\u4EF6\u4E0E\u5BF9\u8BDD\u4ECD\u53EF\u6062\u590D\uFF1B\u90E8\u5206\u547D\u4EE4\u884C\u526F\u4F5C\u7528\u53EF\u80FD\u672A\u6536\u5F55",
4458
4654
  rollbackUnavailableSessionChanged: "\u4F1A\u8BDD\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u9884\u89C8",
4459
4655
  rollbackUnavailableRunning: "\u4F1A\u8BDD\u4ECD\u5728\u8FD0\u884C",
4460
4656
  rollbackUnavailablePermission: "\u5F53\u524D\u6CA1\u6709\u6062\u590D\u6743\u9650",
4461
4657
  rollbackUnavailableDisabled: "\u56DE\u6EDA\u529F\u80FD\u5DF2\u5173\u95ED",
4462
- rollbackUnavailableFirstTurn: "\u9996\u8F6E\u8FB9\u754C\u8F83\u7279\u6B8A\uFF1B\u4ECD\u53EF\u5C1D\u8BD5\u53EA\u6062\u590D\u5BF9\u8BDD",
4463
4658
  rollbackUnavailableIncompatible: "\u68C0\u67E5\u70B9\u4E0E\u5F53\u524D\u4F1A\u8BDD\u6216\u63D2\u4EF6\u7248\u672C\u4E0D\u517C\u5BB9",
4464
4659
  rollbackUnavailableCompacted: "\u5BF9\u8BDD\u66FE\u88AB\u538B\u7F29\uFF1B\u5B8C\u6574\u6587\u4EF6\u6062\u590D\u53EF\u80FD\u4E0D\u53EF\u7528\uFF0C\u4ECD\u53EF\u53EA\u6062\u590D\u5BF9\u8BDD",
4465
4660
  rollbackUnavailableSubagent: "\u5B50 Agent \u4F1A\u8BDD\u4E0D\u652F\u6301\u56DE\u6EDA",
4466
4661
  rollbackUnavailableUnknown: "\u5BF9\u8BDD\u7ED3\u6784\u65E0\u6CD5\u5B89\u5168\u8BC6\u522B",
4662
+ rollbackUnavailableAlready: "\u5BF9\u8BDD\u5DF2\u505C\u5728\u6B64\u68C0\u67E5\u70B9",
4663
+ rollbackUnavailableCovered: "\u5DF2\u88AB\u66F4\u65E9\u7684\u6062\u590D\u70B9\u8986\u76D6",
4467
4664
  rollbackConflictUnsafe: "\u6587\u4EF6\u8DEF\u5F84\u4E0D\u5B89\u5168",
4468
4665
  rollbackConflictSymlink: "\u6587\u4EF6\u8DEF\u5F84\u5305\u542B\u7B26\u53F7\u94FE\u63A5",
4469
4666
  rollbackConflictRegular: "\u5F53\u524D\u8DEF\u5F84\u4E0D\u662F\u666E\u901A\u6587\u4EF6",
4470
4667
  rollbackConflictBinary: "\u4E8C\u8FDB\u5236\u6587\u4EF6\u4E0D\u652F\u6301\u6062\u590D",
4471
4668
  rollbackConflictLarge: "\u6587\u4EF6\u8D85\u8FC7\u6062\u590D\u5927\u5C0F\u9650\u5236",
4472
4669
  rollbackConflictBefore: "\u68C0\u67E5\u70B9\u6587\u4EF6\u5185\u5BB9\u65E0\u6548",
4473
- rollbackConflictHash: "\u6587\u4EF6\u5728\u68C0\u67E5\u70B9\u540E\u53D1\u751F\u4E86\u53D8\u5316"
4670
+ rollbackConflictHash: "\u6587\u4EF6\u5728\u68C0\u67E5\u70B9\u540E\u53D1\u751F\u4E86\u53D8\u5316",
4671
+ rollbackConflictHashHint: "\u53EF\u6539\u56DE\u68C0\u67E5\u70B9\u5185\u5BB9\u540E\u91CD\u8BD5\uFF0C\u6216\u5148\u4EC5\u6062\u590D\u5BF9\u8BDD"
4474
4672
  },
4475
4673
  en: {
4476
4674
  historyTitle: "Prompt history",
@@ -4656,53 +4854,95 @@ var agentLocales = {
4656
4854
  rollbackTitle: "Restore before turn {turn}",
4657
4855
  rollbackUndoTitle: "Undo restore before turn {turn}",
4658
4856
  rollbackScope: "Choose conversation-only restore, or restore conversation and tracked files. Processes, terminals, background jobs, databases, network activity, deployments, third-party state, and untracked files are not restored. Soft capture gaps do not block restore when there are no tracked files; conversation-only remains available when files conflict.",
4857
+ rollbackScopeAlready: "The conversation is already at this checkpoint. Confirm only prefills that turn\u2019s draft; use Undo restore to bring withdrawn messages back. Processes, terminals, background jobs, databases, network activity, deployments, third-party state, and untracked files are not restored.",
4858
+ rollbackScopeCovered: "A more recent restore already sits at an earlier checkpoint. Undo that restore first, then restore to this turn.",
4659
4859
  rollbackUndoScope: "Withdraw the restore marker and bring back the conversation and tracked files shown in preview. Processes, terminals, background jobs, databases, network activity, deployments, third-party state, and untracked files are not restored.",
4660
4860
  rollbackUndoScopeConversation: "Withdraw the conversation-only restore marker and bring back the conversation shown in preview. Tracked files stay as they are.",
4661
4861
  rollbackClose: "Close restore preview",
4662
4862
  rollbackConfirm: "Restore conversation and tracked files",
4663
4863
  rollbackConfirmConversation: "Restore conversation only",
4864
+ rollbackConfirmAlready: "Prefill draft (with files)",
4865
+ rollbackConfirmConversationAlready: "Prefill draft",
4664
4866
  rollbackUndoConfirm: "Undo restore and bring back preview",
4665
4867
  rollbackUndoConfirmConversation: "Undo restore and bring back conversation",
4666
4868
  rollbackCancel: "Cancel",
4869
+ rollbackAlreadyRestored: "Already restored to this checkpoint \u2014 nothing new to withdraw. Confirm closes the preview and prefills that turn\u2019s prompt. Use Undo restore if you want the withdrawn messages back.",
4870
+ rollbackCoveredByEarlier: "An earlier restore (before turn {tipTurn}) already covers this checkpoint. Undo the current restore first, then restore to this turn.",
4667
4871
  rollbackLoading: "Rechecking conversation and file state\u2026",
4668
4872
  rollbackRestoring: "Restoring conversation and tracked files\u2026",
4669
4873
  rollbackRestoringConversation: "Restoring conversation\u2026",
4670
4874
  rollbackUndoRestoring: "Undoing restore and bringing back conversation and tracked files\u2026",
4671
4875
  rollbackUndoRestoringConversation: "Undoing restore and bringing back conversation\u2026",
4672
4876
  rollbackFailed: "Restore did not complete. Close the preview and try again.",
4877
+ rollbackFailedUnavailable: "Restore is unavailable (session changed, still running, or structure incompatible). Close the preview and try again.",
4878
+ rollbackFailedConflict: "Files changed after preview, so full restore was cancelled. Use conversation-only restore, or close and preview again.",
4879
+ rollbackFailedRecovery: "A previous restore is still finishing (session busy or crash recovery pending). Wait until the session is idle, then tap Check again, or close the preview and retry.",
4880
+ rollbackRetry: "Check again",
4673
4881
  rollbackTurnOpen: "The turn is not closed",
4674
4882
  rollbackTurnStartMissing: "The turn start is not loaded",
4883
+ rollbackSummary: "{messages} messages \xB7 {files} files",
4884
+ rollbackSummaryLabel: "Restore scope summary",
4885
+ rollbackMessageEmpty: "(no text)",
4886
+ rollbackRole_user: "User",
4887
+ rollbackRole_assistant: "Assistant",
4888
+ rollbackRole_tool: "Tool",
4889
+ rollbackRole_system: "System",
4890
+ rollbackRole_other: "Other",
4891
+ rollbackCoverageFiles: "Restore to here \xB7 {count} tracked files",
4892
+ rollbackCoveragePartial: "Restore to here \xB7 partial file snapshot ({count})",
4893
+ rollbackCoverageConversation: "Restore to here \xB7 conversation snapshot",
4894
+ rollbackTimelineTitle: "Checkpoints",
4895
+ rollbackTimelineOpen: "Checkpoint timeline",
4896
+ rollbackTimelineLead: "Live chat {turns} turns / {steps} steps \xB7 checkpoints {liveCheckpoints}/{checkpoints} (undo shells excluded). Listed in conversation order; expand a row for prompt, files, and gaps.",
4897
+ rollbackTimelineLoading: "Loading checkpoints\u2026",
4898
+ rollbackTimelineFailed: "Could not load checkpoints. Try again.",
4899
+ rollbackTimelineEmpty: "No checkpoints for this session yet. They appear after a completed turn.",
4900
+ rollbackTimelineNoSession: "Open the checkpoint timeline from a restore entry in a conversation.",
4901
+ rollbackTimelineTurn: "Turn {turn}",
4902
+ rollbackTimelineRolledBack: "Rolled back",
4903
+ rollbackTimelineTip: "Current restore point",
4904
+ rollbackTimelineOpening: "Opening preview\u2026",
4905
+ rollbackTimelineCoveredHint: "Covered by an earlier restore. Undo the current restore before restoring to this turn.",
4906
+ rollbackTimelineNoPrompt: "No prompt summary available",
4907
+ rollbackTimelineFileFallback: "{path}",
4908
+ rollbackTimelineFilesFallback: "{path} \xB7 {count} files",
4909
+ rollbackTimelineCoverageFiles: "{count} tracked files",
4910
+ rollbackTimelineCoveragePartial: "Partial \xB7 {count} files",
4911
+ rollbackTimelineCoverageConversation: "Conversation only",
4912
+ rollbackTimelineCoverageUnknown: "Unknown coverage",
4675
4913
  rollbackMessages: "Conversation to withdraw",
4676
4914
  rollbackFiles: "Tracked files to restore",
4677
4915
  rollbackGaps: "Why restore is unavailable",
4678
4916
  rollbackFilesLimited: "Full restore is limited",
4679
- rollbackFilesLimitedHint: "Conversation-only restore is still available. Skip file restore when workspace capture is incomplete or files conflict.",
4917
+ rollbackFilesLimitedHint: "Tracked file changes can still be restored. Conversation-only restore remains available if files conflict or capture gaps block the rest.",
4680
4918
  rollbackConflicts: "File conflicts",
4681
4919
  rollbackNoMessages: "No conversation messages are available for preview.",
4682
4920
  rollbackNoFiles: "This checkpoint has no tracked files.",
4683
4921
  rollbackFile_create: "Remove file created in this turn",
4684
4922
  rollbackFile_modify: "Restore previous content",
4685
4923
  rollbackFile_delete: "Restore deleted file",
4686
- rollbackGapWorkspace: "Workspace capture is incomplete",
4924
+ rollbackGapWorkspace: "Workspace capture is incomplete (some shell side effects may be missing)",
4687
4925
  rollbackGapPrompt: "The original prompt was not plain text",
4688
4926
  rollbackUnavailableCheckpoint: "No checkpoint was found for this turn",
4689
- rollbackUnavailableIncomplete: "The checkpoint is incomplete; conversation-only restore is still available",
4927
+ rollbackUnavailableIncomplete: "The checkpoint is incomplete; tracked files and conversation restore are still available; some shell side effects may be missing",
4690
4928
  rollbackUnavailableSessionChanged: "The session changed. Preview again.",
4691
4929
  rollbackUnavailableRunning: "The session is still running",
4692
4930
  rollbackUnavailablePermission: "Restore permission is unavailable",
4693
4931
  rollbackUnavailableDisabled: "Rollback is disabled",
4694
- rollbackUnavailableFirstTurn: "The first-turn boundary is unusual; conversation-only restore may still work",
4695
4932
  rollbackUnavailableIncompatible: "The checkpoint is incompatible with this session or plugin version",
4696
4933
  rollbackUnavailableCompacted: "The conversation was compacted; full file restore may be unavailable, conversation-only restore still works",
4697
4934
  rollbackUnavailableSubagent: "Subagent sessions do not support rollback",
4698
4935
  rollbackUnavailableUnknown: "The conversation structure cannot be verified safely",
4936
+ rollbackUnavailableAlready: "Already at this checkpoint",
4937
+ rollbackUnavailableCovered: "Covered by an earlier restore",
4699
4938
  rollbackConflictUnsafe: "The file path is unsafe",
4700
4939
  rollbackConflictSymlink: "The file path contains a symbolic link",
4701
4940
  rollbackConflictRegular: "The current path is not a regular file",
4702
4941
  rollbackConflictBinary: "Binary files cannot be restored",
4703
4942
  rollbackConflictLarge: "The file exceeds the restore size limit",
4704
4943
  rollbackConflictBefore: "The checkpoint file content is invalid",
4705
- rollbackConflictHash: "File changed after this checkpoint"
4944
+ rollbackConflictHash: "File changed after this checkpoint",
4945
+ rollbackConflictHashHint: "Revert the file to the checkpoint contents, or restore conversation only"
4706
4946
  }
4707
4947
  };
4708
4948
 
@@ -4717,6 +4957,7 @@ function codec(typeSymbol) {
4717
4957
  };
4718
4958
  }
4719
4959
  var requestCodec = codec("dsh-agent-enhancer#CheckpointRollbackRequest");
4960
+ var summariesRequestCodec = codec("dsh-agent-enhancer#CheckpointSummariesRequest");
4720
4961
  var checkpointClientRemoteInfo = {
4721
4962
  package: "dsh-agent-enhancer",
4722
4963
  descriptors: [{
@@ -4739,6 +4980,16 @@ var checkpointClientRemoteInfo = {
4739
4980
  parameters: [{ name: "request", wire: "request", source: "json", codec: requestCodec }],
4740
4981
  cancellation: { parameter: "signal" },
4741
4982
  result: codec("dsh-agent-enhancer#CheckpointRollbackResult")
4983
+ }, {
4984
+ id: "dsh-agent-enhancer#checkpointRollback/summaries",
4985
+ service: "checkpointRollback",
4986
+ namespace: "checkpointRollback",
4987
+ method: "summaries",
4988
+ implementation: "summaries",
4989
+ invocation: { kind: "direct" },
4990
+ parameters: [{ name: "request", wire: "request", source: "json", codec: summariesRequestCodec }],
4991
+ cancellation: { parameter: "signal" },
4992
+ result: codec("dsh-agent-enhancer#CheckpointSummariesResult")
4742
4993
  }]
4743
4994
  };
4744
4995
  var CheckpointRollbackClientError = class extends Error {
@@ -4771,6 +5022,9 @@ var checkpointRollbackRemote = {
4771
5022
  },
4772
5023
  execute(remote, request, signal) {
4773
5024
  return invoke(remote, "execute", request, signal);
5025
+ },
5026
+ summaries(remote, request, signal) {
5027
+ return invoke(remote, "summaries", request, signal);
4774
5028
  }
4775
5029
  };
4776
5030
 
@@ -5139,6 +5393,28 @@ function ProviderBalanceChip(props) {
5139
5393
  );
5140
5394
  }
5141
5395
 
5396
+ // src/client/rollback/failure.ts
5397
+ function rollbackErrorCodeOf(error) {
5398
+ return error instanceof CheckpointRollbackClientError ? error.code : void 0;
5399
+ }
5400
+ function rollbackFailureMessageKey(code) {
5401
+ switch (code) {
5402
+ case "ROLLBACK_UNAVAILABLE":
5403
+ return "rollbackFailedUnavailable";
5404
+ case "ROLLBACK_CONFLICT":
5405
+ return "rollbackFailedConflict";
5406
+ case "ROLLBACK_RECOVERY_FAILED":
5407
+ return "rollbackFailedRecovery";
5408
+ case "ROLLBACK_FAILED":
5409
+ case void 0:
5410
+ return "rollbackFailed";
5411
+ default: {
5412
+ const _exhaustive = code;
5413
+ return _exhaustive;
5414
+ }
5415
+ }
5416
+ }
5417
+
5142
5418
  // src/host/checkpoint/availability.ts
5143
5419
  var CONVERSATION_SOFT = /* @__PURE__ */ new Set([
5144
5420
  "incomplete-checkpoint",
@@ -5149,21 +5425,31 @@ var CONVERSATION_SOFT = /* @__PURE__ */ new Set([
5149
5425
  "compacted-surface",
5150
5426
  // Conversation restore does not need a workspace cwd.
5151
5427
  "permission-denied",
5152
- // Turn 1 is restorable; keep this soft for older previews that still emit it.
5153
- "first-turn"
5154
5428
  // Non-contiguous logs are unusual but still restorable when a surface was built.
5155
5429
  // Only emit unknown-surface when surface is missing — that case stays hard.
5430
+ // Re-confirming the active tip is a soft no-op (draft prefill / optional files).
5431
+ "already-restored",
5432
+ // Covered cuts need undo-first — UI replaces confirms with Undo, not a fatal gap list.
5433
+ "covered-by-earlier-restore"
5156
5434
  ]);
5157
5435
  var EMPTY_FILES_SOFT = /* @__PURE__ */ new Set([
5158
5436
  "incomplete-checkpoint",
5159
5437
  "workspace-capture-failed",
5160
5438
  "prompt-non-text-content",
5161
- "compacted-surface"
5439
+ "compacted-surface",
5440
+ "already-restored",
5441
+ "covered-by-earlier-restore"
5442
+ ]);
5443
+ var TRACKED_FILES_SOFT = /* @__PURE__ */ new Set([
5444
+ "incomplete-checkpoint",
5445
+ "workspace-capture-failed",
5446
+ "prompt-non-text-content",
5447
+ "already-restored",
5448
+ "covered-by-earlier-restore"
5162
5449
  ]);
5163
5450
  function blockingUnavailable(unavailable, scope, options = {}) {
5164
- const trackedFiles = options.trackedFiles;
5165
- const soft = scope === "conversation" || trackedFiles === 0 ? scope === "conversation" ? CONVERSATION_SOFT : EMPTY_FILES_SOFT : null;
5166
- if (soft === null) return unavailable;
5451
+ const trackedFiles = options.trackedFiles ?? 0;
5452
+ const soft = scope === "conversation" ? CONVERSATION_SOFT : trackedFiles === 0 ? EMPTY_FILES_SOFT : TRACKED_FILES_SOFT;
5167
5453
  return unavailable.filter((reason) => !soft.has(reason));
5168
5454
  }
5169
5455
 
@@ -5180,14 +5466,30 @@ function scopeLabel(scope) {
5180
5466
  var RollbackController = class {
5181
5467
  constructor(options) {
5182
5468
  this.options = options;
5183
- this.snapshot = { enabled: options.enabled(), active: null };
5469
+ this.snapshot = { enabled: options.enabled(), active: null, coverageByTurn: {} };
5470
+ if (options.enabled()) this.refreshCoverage();
5184
5471
  }
5185
5472
  options;
5186
5473
  listeners = /* @__PURE__ */ new Set();
5474
+ surfaces = /* @__PURE__ */ new Set();
5187
5475
  operation = null;
5476
+ coverageByTurn = {};
5477
+ coverageController = null;
5188
5478
  snapshot;
5189
5479
  version = 0;
5190
5480
  disposed = false;
5481
+ /** Last agent running bit from the composer overlay; drives stale-modal refresh. */
5482
+ lastKnownRunning;
5483
+ /**
5484
+ * Modal hosts register so `open` can fall back to any mounted surface — a
5485
+ * timeline click must never leave `active` with no host willing to render it.
5486
+ */
5487
+ registerSurface(surface) {
5488
+ this.surfaces.add(surface);
5489
+ return () => {
5490
+ this.surfaces.delete(surface);
5491
+ };
5492
+ }
5191
5493
  subscribe = (listener) => {
5192
5494
  if (this.disposed) return () => {
5193
5495
  };
@@ -5202,27 +5504,54 @@ var RollbackController = class {
5202
5504
  const enabled = this.options.enabled();
5203
5505
  if (!enabled) {
5204
5506
  this.cancelOperation();
5507
+ this.clearCoverage();
5205
5508
  this.publish();
5206
5509
  return;
5207
5510
  }
5208
5511
  if (this.snapshot.enabled) return;
5209
5512
  this.publish();
5513
+ this.refreshCoverage();
5210
5514
  }
5211
- open(turn, operation = "rollback") {
5515
+ /**
5516
+ * Refresh an open ready/error modal when the session run cycle flips
5517
+ * (running→idle clears session-running / recovery waits; idle→running refreshes gates).
5518
+ */
5519
+ notifySessionRunning(running) {
5520
+ if (this.disposed) return;
5521
+ const previous = this.lastKnownRunning;
5522
+ this.lastKnownRunning = running;
5523
+ if (!this.options.enabled() || previous === void 0 || previous === running) return;
5524
+ const active = this.operation;
5525
+ if (active === null || active.status === "executing" || active.status === "loading") return;
5526
+ this.open(active.turn, active.operation, { surface: active.surface });
5527
+ }
5528
+ open(turn, operation = "rollback", options = {}) {
5212
5529
  if (this.disposed || !this.options.enabled() || this.operation?.status === "executing") return;
5213
5530
  this.cancelOperation();
5214
5531
  const version = ++this.version;
5215
5532
  const controller = new AbortController();
5216
- this.operation = { turn, operation, status: "loading", version, controller };
5533
+ const surface = this.resolveSurface(options.surface ?? "composer");
5534
+ this.operation = { turn, operation, status: "loading", version, controller, surface };
5217
5535
  this.publish();
5218
5536
  const request = { sessionId: this.options.sessionId, turn, operation };
5219
5537
  void this.options.remote.preview(request, controller.signal).then((result) => {
5220
5538
  if (!this.current(version, request, result)) return;
5221
- this.operation = { ...this.operation, status: "ready", preview: result };
5539
+ this.rememberPreviewCoverage(result);
5540
+ this.operation = {
5541
+ ...this.operation,
5542
+ turn: result.turn,
5543
+ status: "ready",
5544
+ preview: result
5545
+ };
5222
5546
  this.publish();
5223
- }).catch(() => {
5547
+ }).catch((error) => {
5224
5548
  if (!this.current(version, request)) return;
5225
- this.operation = { ...this.operation, status: "error", error: "preview" };
5549
+ this.operation = {
5550
+ ...this.operation,
5551
+ status: "error",
5552
+ error: "preview",
5553
+ ...errorFields(error)
5554
+ };
5226
5555
  this.publish();
5227
5556
  });
5228
5557
  }
@@ -5251,7 +5580,13 @@ var RollbackController = class {
5251
5580
  scope: effectiveScope
5252
5581
  };
5253
5582
  const controller = new AbortController();
5254
- this.operation = { ...active, status: "executing", scope: effectiveScope, controller };
5583
+ this.operation = {
5584
+ ...active,
5585
+ status: "executing",
5586
+ scope: effectiveScope,
5587
+ controller,
5588
+ surface: active.surface
5589
+ };
5255
5590
  this.publish();
5256
5591
  let result;
5257
5592
  try {
@@ -5259,63 +5594,105 @@ var RollbackController = class {
5259
5594
  } catch (error) {
5260
5595
  if (this.disposed || !this.options.enabled()) return;
5261
5596
  if ((controller.signal.aborted || error instanceof Error && error.name === "AbortError") && !this.options.enabled()) return;
5262
- this.operation = {
5263
- turn,
5264
- operation,
5265
- status: "error",
5266
- error: "execute",
5267
- version: this.version,
5268
- controller: new AbortController(),
5269
- preview,
5270
- scope: effectiveScope
5271
- };
5272
- this.publish();
5597
+ this.failExecute(turn, operation, preview, effectiveScope, error);
5273
5598
  return;
5274
5599
  }
5275
5600
  if (this.disposed || !this.options.enabled()) return;
5276
5601
  if (result === null || typeof result !== "object" || result.sessionId !== request.sessionId || result.turn !== request.turn || typeof result.draft !== "string") {
5277
- this.operation = {
5278
- turn,
5279
- operation,
5280
- status: "error",
5281
- error: "execute",
5282
- version: this.version,
5283
- controller: new AbortController(),
5284
- preview,
5285
- scope: effectiveScope
5286
- };
5287
- this.publish();
5602
+ this.failExecute(turn, operation, preview, effectiveScope);
5288
5603
  return;
5289
5604
  }
5290
5605
  try {
5291
5606
  actions.setDraft(result.draft);
5292
5607
  actions.persistDraft();
5293
5608
  } catch {
5294
- this.operation = {
5295
- turn,
5296
- operation,
5297
- status: "error",
5298
- error: "execute",
5299
- version: this.version,
5300
- controller: new AbortController(),
5301
- preview,
5302
- scope: effectiveScope
5303
- };
5304
- this.publish();
5609
+ this.failExecute(turn, operation, preview, effectiveScope);
5305
5610
  return;
5306
5611
  }
5307
5612
  this.operation = null;
5308
5613
  this.publish();
5614
+ this.refreshCoverage();
5309
5615
  }
5310
5616
  dispose() {
5311
5617
  if (this.disposed) return;
5312
5618
  this.disposed = true;
5313
5619
  this.cancelOperation();
5620
+ this.clearCoverage();
5314
5621
  this.listeners.clear();
5315
5622
  }
5623
+ refreshCoverage() {
5624
+ const summaries = this.options.remote.summaries;
5625
+ if (summaries === void 0 || this.disposed || !this.options.enabled()) return;
5626
+ this.coverageController?.abort();
5627
+ const controller = new AbortController();
5628
+ this.coverageController = controller;
5629
+ void summaries({ sessionId: this.options.sessionId }, controller.signal).then((result) => {
5630
+ if (this.disposed || controller.signal.aborted || !this.options.enabled()) return;
5631
+ if (result.sessionId !== this.options.sessionId) return;
5632
+ const next = {};
5633
+ for (const turn of result.turns) next[turn.turn] = turn;
5634
+ this.coverageByTurn = next;
5635
+ this.publish();
5636
+ }).catch(() => {
5637
+ });
5638
+ }
5639
+ rememberPreviewCoverage(preview) {
5640
+ if (preview.operation === "undo") return;
5641
+ const incomplete = preview.unavailable.includes("incomplete-checkpoint") || preview.unavailable.includes("workspace-capture-failed");
5642
+ const previous = this.coverageByTurn[preview.turn];
5643
+ this.coverageByTurn = {
5644
+ ...this.coverageByTurn,
5645
+ [preview.turn]: {
5646
+ turn: preview.turn,
5647
+ coverage: incomplete ? "partial" : "complete",
5648
+ fileCount: preview.files.length,
5649
+ createdAt: previous?.createdAt ?? Date.now(),
5650
+ atSeq: previous?.atSeq ?? 0,
5651
+ prompt: previous?.prompt ?? "",
5652
+ promptPreview: previous?.promptPreview ?? "",
5653
+ files: preview.files.map((file) => ({ path: file.path, change: file.change })),
5654
+ gaps: previous?.gaps ?? [],
5655
+ rolledBack: previous?.rolledBack ?? false,
5656
+ tip: previous?.tip ?? false
5657
+ }
5658
+ };
5659
+ }
5660
+ clearCoverage() {
5661
+ this.coverageController?.abort();
5662
+ this.coverageController = null;
5663
+ this.coverageByTurn = {};
5664
+ }
5665
+ resolveSurface(preferred) {
5666
+ if (this.surfaces.has(preferred)) return preferred;
5667
+ if (this.surfaces.has("composer")) return "composer";
5668
+ if (this.surfaces.has("timeline")) return "timeline";
5669
+ return preferred;
5670
+ }
5316
5671
  current(version, request, response) {
5317
5672
  const operation = request.operation ?? "rollback";
5318
- return !this.disposed && this.options.enabled() && this.version === version && this.operation?.version === version && this.operation.turn === request.turn && this.operation.operation === operation && (response === void 0 || response.sessionId === request.sessionId && response.turn === request.turn);
5673
+ if (this.disposed || !this.options.enabled() || this.version !== version) return false;
5674
+ if (this.operation?.version !== version || this.operation.operation !== operation) return false;
5675
+ if (response === void 0) {
5676
+ return this.operation.turn === request.turn || operation === "undo";
5677
+ }
5678
+ if (response.sessionId !== request.sessionId) return false;
5679
+ if (operation === "undo") return true;
5680
+ return response.turn === request.turn;
5681
+ }
5682
+ failExecute(turn, operation, preview, scope, error) {
5683
+ this.operation = {
5684
+ turn,
5685
+ operation,
5686
+ status: "error",
5687
+ error: "execute",
5688
+ version: this.version,
5689
+ controller: new AbortController(),
5690
+ preview,
5691
+ scope,
5692
+ surface: this.operation?.surface ?? "composer",
5693
+ ...errorFields(error)
5694
+ };
5695
+ this.publish();
5319
5696
  }
5320
5697
  cancelOperation() {
5321
5698
  this.version += 1;
@@ -5325,26 +5702,87 @@ var RollbackController = class {
5325
5702
  publish() {
5326
5703
  this.snapshot = {
5327
5704
  enabled: !this.disposed && this.options.enabled(),
5705
+ coverageByTurn: this.coverageByTurn,
5328
5706
  active: this.operation === null ? null : {
5329
5707
  turn: this.operation.turn,
5330
5708
  operation: this.operation.operation,
5331
5709
  status: this.operation.status,
5332
5710
  version: this.operation.version,
5711
+ surface: this.operation.surface,
5333
5712
  ...this.operation.preview === void 0 ? {} : { preview: this.operation.preview },
5334
5713
  ...this.operation.scope === void 0 ? {} : { scope: this.operation.scope },
5335
- ...this.operation.error === void 0 ? {} : { error: this.operation.error }
5714
+ ...this.operation.error === void 0 ? {} : { error: this.operation.error },
5715
+ ...this.operation.errorCode === void 0 ? {} : { errorCode: this.operation.errorCode }
5336
5716
  }
5337
5717
  };
5338
5718
  for (const listener of this.listeners) listener();
5339
5719
  }
5340
5720
  };
5721
+ function errorFields(error) {
5722
+ const errorCode = rollbackErrorCodeOf(error);
5723
+ return errorCode === void 0 ? {} : { errorCode };
5724
+ }
5341
5725
 
5342
5726
  // src/client/rollback/modal-host.tsx
5343
5727
  var import_dsh_client_ui_primitives6 = require("@deepseek-ai/dsh-client-ui-primitives");
5344
5728
  var import_react12 = require("react");
5345
5729
 
5730
+ // src/client/rollback/input-actions-cache.ts
5731
+ var cache = /* @__PURE__ */ new Map();
5732
+ var stubActions = {
5733
+ insertQuote: () => false,
5734
+ captureInsertion: () => ({ start: 0, end: 0, draftRev: 0 }),
5735
+ insertText: () => false,
5736
+ setDraft: () => {
5737
+ },
5738
+ persistDraft: () => {
5739
+ },
5740
+ addAttachments: () => false,
5741
+ removeAttachment: () => {
5742
+ },
5743
+ pruneAttachments: () => {
5744
+ },
5745
+ submit: () => {
5746
+ }
5747
+ };
5748
+ function rememberRollbackInputActions(sessionId, actions) {
5749
+ if (sessionId === void 0 || actions === void 0) return;
5750
+ cache.set(sessionId, actions);
5751
+ }
5752
+ function rollbackInputActionsFor(sessionId) {
5753
+ return cache.get(sessionId) ?? stubActions;
5754
+ }
5755
+
5346
5756
  // src/client/rollback/preview.tsx
5347
5757
  var import_dsh_client_ui_primitives5 = require("@deepseek-ai/dsh-client-ui-primitives");
5758
+
5759
+ // src/client/rollback/format.ts
5760
+ var PREVIEW_TEXT_MAX = 140;
5761
+ function truncatePreviewText(text2, max = PREVIEW_TEXT_MAX) {
5762
+ const normalized = text2.replace(/\s+/g, " ").trim();
5763
+ if (normalized.length <= max) return normalized;
5764
+ return `${normalized.slice(0, Math.max(0, max - 1)).trimEnd()}\u2026`;
5765
+ }
5766
+ function previewMessageRole(type) {
5767
+ if (type.startsWith("user/")) return "user";
5768
+ if (type.startsWith("assistant/")) return "assistant";
5769
+ if (type.startsWith("tool/")) return "tool";
5770
+ if (type.startsWith("system/") || type.startsWith("developer/")) return "system";
5771
+ return "other";
5772
+ }
5773
+ function coverageAffordance(summary) {
5774
+ if (summary === void 0) return "unknown";
5775
+ if (summary.fileCount > 0) {
5776
+ return summary.coverage === "partial" ? "partial" : "files";
5777
+ }
5778
+ return summary.coverage === "partial" ? "partial" : "conversation";
5779
+ }
5780
+ function checkpointPrimaryAction(summary) {
5781
+ if (summary?.tip === true) return "undo";
5782
+ return "restore";
5783
+ }
5784
+
5785
+ // src/client/rollback/preview.tsx
5348
5786
  var import_jsx_runtime13 = require("react/jsx-runtime");
5349
5787
  var UNAVAILABLE_KEYS = {
5350
5788
  "checkpoint-not-found": "rollbackUnavailableCheckpoint",
@@ -5355,11 +5793,12 @@ var UNAVAILABLE_KEYS = {
5355
5793
  "session-running": "rollbackUnavailableRunning",
5356
5794
  "permission-denied": "rollbackUnavailablePermission",
5357
5795
  "rollback-disabled": "rollbackUnavailableDisabled",
5358
- "first-turn": "rollbackUnavailableFirstTurn",
5359
5796
  "incompatible-session": "rollbackUnavailableIncompatible",
5360
5797
  "compacted-surface": "rollbackUnavailableCompacted",
5361
5798
  "subagent-session": "rollbackUnavailableSubagent",
5362
- "unknown-surface": "rollbackUnavailableUnknown"
5799
+ "unknown-surface": "rollbackUnavailableUnknown",
5800
+ "already-restored": "rollbackUnavailableAlready",
5801
+ "covered-by-earlier-restore": "rollbackUnavailableCovered"
5363
5802
  };
5364
5803
  var CONFLICT_KEYS = {
5365
5804
  "unsafe-path": "rollbackConflictUnsafe",
@@ -5371,12 +5810,21 @@ var CONFLICT_KEYS = {
5371
5810
  "invalid-after-image": "rollbackConflictBefore",
5372
5811
  "hash-mismatch": "rollbackConflictHash"
5373
5812
  };
5374
- function RollbackPreview({ active, t }) {
5813
+ var ROLE_KEYS = {
5814
+ user: "rollbackRole_user",
5815
+ assistant: "rollbackRole_assistant",
5816
+ tool: "rollbackRole_tool",
5817
+ system: "rollbackRole_system",
5818
+ other: "rollbackRole_other"
5819
+ };
5820
+ function RollbackPreview({ active, t, onOpenTimeline }) {
5375
5821
  if (active.status === "loading" || active.status === "executing") {
5376
5822
  const loadingKey = active.status === "loading" ? "rollbackLoading" : active.operation === "undo" ? "rollbackUndoRestoring" : "rollbackRestoring";
5377
5823
  return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { role: "status", children: t(loadingKey) });
5378
5824
  }
5379
- if (active.status === "error") return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { role: "alert", children: t("rollbackFailed") });
5825
+ if (active.status === "error") {
5826
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { role: "alert", children: t(rollbackFailureMessageKey(active.errorCode)) });
5827
+ }
5380
5828
  const preview = active.preview;
5381
5829
  if (preview === void 0) return null;
5382
5830
  const hardUnavailable = blockingUnavailable(preview.unavailable, "conversation", {
@@ -5385,17 +5833,36 @@ function RollbackPreview({ active, t }) {
5385
5833
  const filesLimited = active.operation !== "undo" && blockingUnavailable(preview.unavailable, "conversation-and-files", {
5386
5834
  trackedFiles: preview.files.length
5387
5835
  }).length > hardUnavailable.length;
5836
+ const alreadyRestored = active.operation !== "undo" && preview.unavailable.includes("already-restored");
5837
+ const coveredByEarlier = active.operation !== "undo" && preview.unavailable.includes("covered-by-earlier-restore");
5838
+ const tipTurn = preview.tipTurn;
5388
5839
  return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_dsh_client_ui_primitives5.MenuSurface, { className: css_module_default.rollbackPreview, children: [
5840
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: css_module_default.rollbackSummaryRow, children: [
5841
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: css_module_default.rollbackSummary, "aria-label": t("rollbackSummaryLabel"), children: t("rollbackSummary", { messages: preview.messages.length, files: preview.files.length }) }),
5842
+ onOpenTimeline === void 0 || active.operation === "undo" ? null : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
5843
+ "button",
5844
+ {
5845
+ type: "button",
5846
+ className: css_module_default.rollbackTimelineLink,
5847
+ onClick: () => {
5848
+ onOpenTimeline(active.turn);
5849
+ },
5850
+ children: t("rollbackTimelineOpen")
5851
+ }
5852
+ )
5853
+ ] }),
5854
+ alreadyRestored ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: css_module_default.rollbackAlready, role: "status", children: t("rollbackAlreadyRestored") }) : null,
5855
+ coveredByEarlier ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: css_module_default.rollbackAlready, role: "status", children: t("rollbackCoveredByEarlier", { tipTurn: tipTurn ?? active.turn }) }) : null,
5389
5856
  /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("section", { className: css_module_default.rollbackSection, "aria-label": t("rollbackMessages"), children: [
5390
5857
  /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("h3", { children: t("rollbackMessages") }),
5391
- preview.messages.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { children: t("rollbackNoMessages") }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("ul", { className: css_module_default.rollbackList, children: preview.messages.map((message) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("li", { className: css_module_default.rollbackMessage, children: [
5392
- /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: css_module_default.rollbackMeta, children: [
5393
- message.type,
5394
- " \xB7 ",
5395
- message.seq
5396
- ] }),
5397
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: message.text })
5398
- ] }, message.seq)) })
5858
+ preview.messages.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { children: t("rollbackNoMessages") }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("ul", { className: css_module_default.rollbackList, children: preview.messages.map((message) => {
5859
+ const role = previewMessageRole(message.type);
5860
+ const text2 = truncatePreviewText(message.text);
5861
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("li", { className: css_module_default.rollbackMessage, children: [
5862
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: css_module_default.rollbackMeta, children: t(ROLE_KEYS[role]) }),
5863
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: text2.length === 0 ? t("rollbackMessageEmpty") : text2 })
5864
+ ] }, message.seq);
5865
+ }) })
5399
5866
  ] }),
5400
5867
  /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("section", { className: css_module_default.rollbackSection, "aria-label": t("rollbackFiles"), children: [
5401
5868
  /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("h3", { children: t("rollbackFiles") }),
@@ -5416,12 +5883,15 @@ function RollbackPreview({ active, t }) {
5416
5883
  /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("h3", { children: t("rollbackConflicts") }),
5417
5884
  /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("ul", { className: css_module_default.rollbackList, children: preview.conflicts.map((conflict) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("li", { children: [
5418
5885
  /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: conflict.path }),
5419
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: css_module_default.rollbackConflict, children: t(CONFLICT_KEYS[conflict.reason]) })
5886
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: css_module_default.rollbackConflict, children: [
5887
+ t(CONFLICT_KEYS[conflict.reason]),
5888
+ conflict.reason === "hash-mismatch" ? ` \xB7 ${t("rollbackConflictHashHint")}` : null
5889
+ ] })
5420
5890
  ] }, `${conflict.path}:${conflict.reason}`)) })
5421
5891
  ] })
5422
5892
  ] });
5423
5893
  }
5424
- function rollbackModalCopy(operation, t, turn, scope) {
5894
+ function rollbackModalCopy(operation, t, turn, scope, alreadyRestored = false, coveredByEarlier = false) {
5425
5895
  if (operation === "undo") {
5426
5896
  const conversationOnly = scope === "conversation";
5427
5897
  return {
@@ -5433,11 +5903,21 @@ function rollbackModalCopy(operation, t, turn, scope) {
5433
5903
  executingConversation: t("rollbackUndoRestoringConversation")
5434
5904
  };
5435
5905
  }
5906
+ if (coveredByEarlier) {
5907
+ return {
5908
+ title: t("rollbackTitle", { turn }),
5909
+ description: t("rollbackScopeCovered"),
5910
+ confirm: t("rollbackConfirm"),
5911
+ confirmConversation: t("rollbackConfirmConversation"),
5912
+ executing: t("rollbackRestoring"),
5913
+ executingConversation: t("rollbackRestoringConversation")
5914
+ };
5915
+ }
5436
5916
  return {
5437
5917
  title: t("rollbackTitle", { turn }),
5438
- description: t("rollbackScope"),
5439
- confirm: t("rollbackConfirm"),
5440
- confirmConversation: t("rollbackConfirmConversation"),
5918
+ description: t(alreadyRestored ? "rollbackScopeAlready" : "rollbackScope"),
5919
+ confirm: t(alreadyRestored ? "rollbackConfirmAlready" : "rollbackConfirm"),
5920
+ confirmConversation: t(alreadyRestored ? "rollbackConfirmConversationAlready" : "rollbackConfirmConversation"),
5441
5921
  executing: t("rollbackRestoring"),
5442
5922
  executingConversation: t("rollbackRestoringConversation")
5443
5923
  };
@@ -5446,23 +5926,39 @@ function rollbackModalCopy(operation, t, turn, scope) {
5446
5926
  // src/client/rollback/modal-host.tsx
5447
5927
  var import_jsx_runtime14 = require("react/jsx-runtime");
5448
5928
  function RollbackModalHost(props) {
5929
+ const surface = props.surface ?? "composer";
5449
5930
  const snapshot = (0, import_react12.useSyncExternalStore)(props.rollback.subscribe, props.rollback.getSnapshot);
5450
5931
  const active = snapshot.active;
5932
+ const owned = active !== null && active.surface === surface;
5933
+ const running = props.useSession === void 0 ? false : props.useSession((state) => state.running);
5451
5934
  const trackedFiles = active?.preview?.files.length ?? 0;
5452
5935
  const undoScope = scopeLabel(active?.scope ?? active?.preview?.scope);
5453
5936
  const conversationBlocked = active?.preview === void 0 || confirmBlocked(active.preview.unavailable, active.preview.conflicts, "conversation", trackedFiles);
5454
5937
  const filesBlocked = active?.preview === void 0 || confirmBlocked(active.preview.unavailable, active.preview.conflicts, "conversation-and-files", trackedFiles);
5455
5938
  const undoBlocked = active?.preview === void 0 || confirmBlocked(active.preview.unavailable, active.preview.conflicts, undoScope, trackedFiles);
5456
- const modal = active === null ? null : rollbackModalCopy(
5939
+ const alreadyRestored = owned && active?.operation === "rollback" && active.preview?.unavailable.includes("already-restored") === true;
5940
+ const coveredByEarlier = owned && active?.operation === "rollback" && active.preview?.unavailable.includes("covered-by-earlier-restore") === true;
5941
+ const modal = !owned || active === null ? null : rollbackModalCopy(
5457
5942
  active.operation,
5458
5943
  props.t,
5459
5944
  active.turn,
5460
- active.operation === "undo" ? undoScope : void 0
5945
+ active.operation === "undo" ? undoScope : void 0,
5946
+ alreadyRestored,
5947
+ coveredByEarlier
5461
5948
  );
5462
5949
  const ready = active?.status === "ready";
5463
5950
  const executing = active?.status === "executing";
5951
+ const errored = active?.status === "error";
5952
+ (0, import_react12.useEffect)(() => {
5953
+ rememberRollbackInputActions(props.sessionId, props.inputActions);
5954
+ }, [props.sessionId, props.inputActions]);
5955
+ (0, import_react12.useEffect)(() => props.rollback.registerSurface(surface), [props.rollback, surface]);
5956
+ (0, import_react12.useEffect)(() => {
5957
+ if (!owned) return;
5958
+ props.rollback.notifySessionRunning(running);
5959
+ }, [props.rollback, running, owned]);
5464
5960
  (0, import_react12.useEffect)(() => {
5465
- if (active === null) return;
5961
+ if (!owned || active === null) return;
5466
5962
  const dialog = document.querySelector(`.${css_module_default.rollbackDialog}`);
5467
5963
  const parent = dialog?.parentElement;
5468
5964
  const byAria = parent?.querySelector('[aria-hidden="true"]');
@@ -5481,8 +5977,8 @@ function RollbackModalHost(props) {
5481
5977
  mask.removeEventListener(type, stop, true);
5482
5978
  }
5483
5979
  };
5484
- }, [active]);
5485
- if (!snapshot.enabled || active === null || modal === null) return null;
5980
+ }, [active, owned]);
5981
+ if (!snapshot.enabled || !owned || active === null || modal === null) return null;
5486
5982
  const requestClose = () => {
5487
5983
  if (active.status === "executing") return;
5488
5984
  props.rollback.close(active.turn);
@@ -5491,6 +5987,15 @@ function RollbackModalHost(props) {
5491
5987
  if (active.status !== "ready" || executing) return;
5492
5988
  void props.rollback.confirm(props.inputActions, scope);
5493
5989
  };
5990
+ const runUndoInstead = () => {
5991
+ if (active.status === "executing") return;
5992
+ const tipTurn = active.preview?.tipTurn ?? active.turn;
5993
+ props.rollback.open(tipTurn, "undo", { surface: active.surface });
5994
+ };
5995
+ const runRetry = () => {
5996
+ if (active.status !== "error") return;
5997
+ props.rollback.open(active.turn, active.operation, { surface: active.surface });
5998
+ };
5494
5999
  return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
5495
6000
  import_dsh_client_ui_primitives6.Modal,
5496
6001
  {
@@ -5511,7 +6016,7 @@ function RollbackModalHost(props) {
5511
6016
  children: props.t("rollbackCancel")
5512
6017
  }
5513
6018
  ),
5514
- active.operation === "undo" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
6019
+ errored ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_dsh_client_ui_primitives6.Button, { type: "button", "data-modal-autofocus": true, onClick: runRetry, children: props.t("rollbackRetry") }) : active.operation === "undo" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
5515
6020
  import_dsh_client_ui_primitives6.Button,
5516
6021
  {
5517
6022
  type: "button",
@@ -5522,7 +6027,25 @@ function RollbackModalHost(props) {
5522
6027
  },
5523
6028
  children: executing ? modal.executing : modal.confirm
5524
6029
  }
5525
- ) : executing ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_dsh_client_ui_primitives6.Button, { type: "button", disabled: true, children: active.scope === "conversation" ? modal.executingConversation : modal.executing }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
6030
+ ) : executing ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_dsh_client_ui_primitives6.Button, { type: "button", disabled: true, children: active.scope === "conversation" ? modal.executingConversation : modal.executing }) : coveredByEarlier ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
6031
+ import_dsh_client_ui_primitives6.Button,
6032
+ {
6033
+ type: "button",
6034
+ "data-modal-autofocus": true,
6035
+ disabled: !ready,
6036
+ onClick: runUndoInstead,
6037
+ children: props.t("rollbackUndoAction")
6038
+ }
6039
+ ) : /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
6040
+ alreadyRestored ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
6041
+ import_dsh_client_ui_primitives6.Button,
6042
+ {
6043
+ type: "button",
6044
+ disabled: !ready,
6045
+ onClick: runUndoInstead,
6046
+ children: props.t("rollbackUndoAction")
6047
+ }
6048
+ ) : null,
5526
6049
  /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
5527
6050
  import_dsh_client_ui_primitives6.Button,
5528
6051
  {
@@ -5548,7 +6071,7 @@ function RollbackModalHost(props) {
5548
6071
  )
5549
6072
  ] })
5550
6073
  ] }),
5551
- children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(RollbackPreview, { active, t: props.t })
6074
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(RollbackPreview, { active, t: props.t, onOpenTimeline: props.onOpenTimeline })
5552
6075
  }
5553
6076
  );
5554
6077
  }
@@ -5583,6 +6106,21 @@ function installRollbackUndoCommand(options) {
5583
6106
  };
5584
6107
  }
5585
6108
 
6109
+ // src/client/rollback/prompt-entries.ts
6110
+ function promptsFromSessionEntries(entries) {
6111
+ const out = [];
6112
+ for (const entry of entries) {
6113
+ if (entry.type !== "event") continue;
6114
+ const event = entry.event;
6115
+ if (event.type !== "user/message") continue;
6116
+ if (event.data.source.kind !== "user") continue;
6117
+ const text2 = event.data.content.flatMap((block2) => block2.type === "text" ? [block2.text] : []).join("");
6118
+ if (text2.trim() === "") continue;
6119
+ out.push({ seq: Number(event.seq), text: text2 });
6120
+ }
6121
+ return out;
6122
+ }
6123
+
5586
6124
  // src/identity.ts
5587
6125
  var PACKAGE_NAME = "dsh-agent-enhancer";
5588
6126
  var LEGACY_PACKAGE_NAME = "dsh-composer-enhancer";
@@ -5596,18 +6134,91 @@ function isRollbackId(id) {
5596
6134
  function isUndoId(id) {
5597
6135
  return id.startsWith(UNDO_PREFIX) || id.startsWith(LEGACY_UNDO_PREFIX);
5598
6136
  }
6137
+ function indexOfRollbackPrefix(id) {
6138
+ const current = id.indexOf(ROLLBACK_PREFIX);
6139
+ if (current >= 0) return current;
6140
+ return id.indexOf(LEGACY_ROLLBACK_PREFIX);
6141
+ }
5599
6142
  function turnFromRollbackId(id) {
5600
6143
  for (const prefix of [ROLLBACK_PREFIX, LEGACY_ROLLBACK_PREFIX]) {
5601
6144
  if (!id.startsWith(prefix)) continue;
5602
6145
  const match = new RegExp(`^${escapeRegExp(prefix)}(\\d+):`).exec(id);
5603
6146
  if (match !== null) return Number(match[1]);
5604
6147
  }
6148
+ const embedded = indexOfRollbackPrefix(id);
6149
+ if (embedded > 0) return turnFromRollbackId(id.slice(embedded));
5605
6150
  return void 0;
5606
6151
  }
5607
6152
  function escapeRegExp(value) {
5608
6153
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
5609
6154
  }
5610
6155
 
6156
+ // src/host/checkpoint/activity.ts
6157
+ function surfaceMessageId(event) {
6158
+ switch (event.type) {
6159
+ case "user/message":
6160
+ return event.data.id;
6161
+ case "system/message":
6162
+ case "developer/message":
6163
+ case "assistant/message":
6164
+ case "tool/result":
6165
+ return event.data.message.id;
6166
+ default:
6167
+ return null;
6168
+ }
6169
+ }
6170
+ function isUndoCopyEvent(event) {
6171
+ const id = surfaceMessageId(event);
6172
+ return id !== null && isUndoId(id);
6173
+ }
6174
+ function isRollbackScaffoldEvent(event) {
6175
+ if (event.type !== "user/message") return false;
6176
+ if (isRollbackId(event.data.id)) return true;
6177
+ return event.data.source.kind === "checkpoint-rollback";
6178
+ }
6179
+ function undoShellRanges(events) {
6180
+ const ranges = [];
6181
+ let turn;
6182
+ let startSeq = 0;
6183
+ let sawUndo = false;
6184
+ let sawReal = false;
6185
+ let lastSeq = 0;
6186
+ const flush = () => {
6187
+ if (turn !== void 0 && sawUndo && !sawReal) {
6188
+ ranges.push({ turn, startSeq, endSeq: lastSeq });
6189
+ }
6190
+ sawUndo = false;
6191
+ sawReal = false;
6192
+ };
6193
+ for (const event of events) {
6194
+ lastSeq = Number(event.seq);
6195
+ if (event.type === "turn/start") {
6196
+ flush();
6197
+ turn = event.data.turn;
6198
+ startSeq = lastSeq;
6199
+ continue;
6200
+ }
6201
+ if (event.type === "turn/end" && turn !== void 0 && event.data.turn === turn) {
6202
+ flush();
6203
+ turn = void 0;
6204
+ continue;
6205
+ }
6206
+ if (turn === void 0 || isRollbackScaffoldEvent(event)) continue;
6207
+ if (isUndoCopyEvent(event)) {
6208
+ sawUndo = true;
6209
+ continue;
6210
+ }
6211
+ if (event.type === "user/message" || event.type === "assistant/message" || event.type === "tool/result" || event.type === "system/message" || event.type === "developer/message") {
6212
+ sawReal = true;
6213
+ }
6214
+ }
6215
+ flush();
6216
+ return ranges;
6217
+ }
6218
+ function inUndoShellRange(seq, ranges) {
6219
+ return ranges.some((range) => seq >= range.startSeq && seq <= range.endSeq);
6220
+ }
6221
+
5611
6222
  // src/client/rollback/marker.ts
5612
6223
  function isRollbackMarkerSource(source) {
5613
6224
  return source?.kind === "checkpoint-rollback";
@@ -5635,18 +6246,8 @@ function isRollbackMarkerEvent(event) {
5635
6246
  if (event.type !== "user/message") return false;
5636
6247
  return isRollbackMarkerMessage(event.data.source, event.data.id);
5637
6248
  }
5638
- function isUndoCopyEvent(event) {
5639
- switch (event.type) {
5640
- case "user/message":
5641
- return isUndoId(event.data.id);
5642
- case "system/message":
5643
- case "developer/message":
5644
- case "assistant/message":
5645
- case "tool/result":
5646
- return isUndoId(event.data.message.id);
5647
- default:
5648
- return false;
5649
- }
6249
+ function isUndoCopyEvent2(event) {
6250
+ return isUndoCopyEvent(event);
5650
6251
  }
5651
6252
  function markerStillActive(marker, events) {
5652
6253
  return !events.some((event) => {
@@ -5658,6 +6259,24 @@ function markerStillActive(marker, events) {
5658
6259
  function asAppend(event) {
5659
6260
  return { ...event, surfaceOp: "append" };
5660
6261
  }
6262
+ function asBookkeepingTip(event) {
6263
+ if (event.type !== "user/message") return asAppend(event);
6264
+ const source = event.data.source;
6265
+ const alreadyHidden = surfaceOpOf(event) === "append" && source.kind === "checkpoint-rollback";
6266
+ if (alreadyHidden) return event;
6267
+ return {
6268
+ ...event,
6269
+ surfaceOp: "append",
6270
+ data: {
6271
+ ...event.data,
6272
+ source: {
6273
+ kind: "checkpoint-rollback",
6274
+ form: "notice",
6275
+ ...typeof source.summary === "string" ? { summary: source.summary } : {}
6276
+ }
6277
+ }
6278
+ };
6279
+ }
5661
6280
  function turnOfEvent(event) {
5662
6281
  if (event.type === "turn/start" || event.type === "turn/end" || event.type === "step/start" || event.type === "step/end") {
5663
6282
  return event.data.turn;
@@ -5665,50 +6284,220 @@ function turnOfEvent(event) {
5665
6284
  const data = event.data;
5666
6285
  return typeof data.turn === "number" ? data.turn : void 0;
5667
6286
  }
5668
- function activeMarkersOf(events) {
5669
- return events.filter((event) => isRollbackMarkerEvent(event) && markerStillActive(event, events));
6287
+ function activeTipMarkers(events) {
6288
+ const markers = [];
6289
+ for (const event of events) {
6290
+ if (!isRollbackMarkerEvent(event) || !markerStillActive(event, events)) continue;
6291
+ markers.push(event);
6292
+ }
6293
+ if (markers.length === 0) return markers;
6294
+ const latestSeq = Math.max(...markers.map((event) => Number(event.seq)));
6295
+ if (events.some((event) => Number(event.seq) > latestSeq && isUndoCopyEvent2(event))) {
6296
+ return [];
6297
+ }
6298
+ return markers;
6299
+ }
6300
+ function liveTipMarker(events) {
6301
+ const markers = activeTipMarkers(events);
6302
+ if (markers.length === 0) return void 0;
6303
+ return markers.reduce((latest, event) => Number(event.seq) >= Number(latest.seq) ? event : latest);
5670
6304
  }
5671
6305
  function activeRollbackHideTurnsFrom(entries) {
5672
- const events = entries.flatMap((entry) => entry.type === "event" ? [entry.event] : []);
5673
6306
  let hideTurnsFrom;
5674
- for (const event of activeMarkersOf(events)) {
5675
- const turn = event.type === "user/message" ? turnFromRollbackMarkerId(event.data.id) : void 0;
5676
- if (turn !== void 0) {
5677
- hideTurnsFrom = hideTurnsFrom === void 0 ? turn : Math.min(hideTurnsFrom, turn);
5678
- }
6307
+ for (const tip of activeTipMarkers(entries.flatMap((entry) => entry.type === "event" ? [entry.event] : []))) {
6308
+ if (tip.type !== "user/message") continue;
6309
+ const turn = turnFromRollbackMarkerId(tip.data.id);
6310
+ if (turn === void 0) continue;
6311
+ hideTurnsFrom = hideTurnsFrom === void 0 ? turn : Math.min(hideTurnsFrom, turn);
5679
6312
  }
5680
6313
  return hideTurnsFrom;
5681
6314
  }
5682
6315
  function activeRollbackContinueAfterSeq(entries) {
5683
- const markers = activeMarkersOf(entries.flatMap((entry) => entry.type === "event" ? [entry.event] : []));
6316
+ const tip = liveTipMarker(entries.flatMap((entry) => entry.type === "event" ? [entry.event] : []));
6317
+ return tip === void 0 ? void 0 : Number(tip.seq);
6318
+ }
6319
+ function keepPrefixLoadThroughSeq(entries) {
6320
+ const markers = activeTipMarkers(entries.flatMap((entry) => entry.type === "event" ? [entry.event] : []));
5684
6321
  if (markers.length === 0) return void 0;
5685
- return Math.max(...markers.map((event) => Number(event.seq)));
6322
+ let minShadowed;
6323
+ for (const marker of markers) {
6324
+ for (const seq of marker.sourceEventSeqs ?? []) {
6325
+ const value = Number(seq);
6326
+ if (!Number.isFinite(value)) continue;
6327
+ minShadowed = minShadowed === void 0 ? value : Math.min(minShadowed, value);
6328
+ }
6329
+ }
6330
+ if (minShadowed === void 0) return void 0;
6331
+ return Math.max(0, minShadowed - 1);
6332
+ }
6333
+ function hasKeepPrefixConversation(entries) {
6334
+ return entries.some((entry) => {
6335
+ if (entry.type !== "event") return false;
6336
+ const event = entry.event;
6337
+ if (event.type !== "user/message" && event.type !== "assistant/message") return false;
6338
+ return !isRollbackMarkerEvent(event) && !isUndoCopyEvent2(event);
6339
+ });
6340
+ }
6341
+ function needsKeepPrefixHistory(entries, hasMore) {
6342
+ if (!hasMore) return false;
6343
+ if (keepPrefixLoadThroughSeq(entries) === void 0) return false;
6344
+ return !hasKeepPrefixConversation(entries);
5686
6345
  }
5687
6346
  function activeRollbackUndoTip(entries) {
5688
6347
  const events = entries.flatMap((entry) => entry.type === "event" ? [entry.event] : []);
5689
- let tip;
5690
- for (const event of events) {
5691
- if (!isRollbackMarkerEvent(event) || !markerStillActive(event, events)) continue;
5692
- if (event.type !== "user/message") continue;
5693
- const turn = turnFromRollbackMarkerId(event.data.id);
5694
- if (turn === void 0) continue;
5695
- if (tip === void 0 || Number(event.seq) >= tip.seq) tip = { turn, seq: Number(event.seq) };
6348
+ const tip = liveTipMarker(events);
6349
+ if (tip === void 0 || tip.type !== "user/message") return void 0;
6350
+ const turn = turnFromRollbackMarkerId(tip.data.id);
6351
+ if (turn === void 0) return void 0;
6352
+ const later = events.some((event) => Number(event.seq) > Number(tip.seq) && !isRollbackMarkerEvent(event) && !isUndoCopyEvent2(event));
6353
+ return later ? void 0 : { turn };
6354
+ }
6355
+ function undoShellRangesFromEntries(entries) {
6356
+ return undoShellRanges(entries.flatMap((entry) => entry.type === "event" ? [entry.event] : []));
6357
+ }
6358
+ function undoSourceSeqOf(id) {
6359
+ const match = /:(\d+)(?::(?:dsh-agent-enhancer|dsh-composer-enhancer):rollback:.*)?$/.exec(id);
6360
+ if (match === null) return void 0;
6361
+ const seq = Number(match[1]);
6362
+ return Number.isFinite(seq) ? seq : void 0;
6363
+ }
6364
+ function surfaceMessageIdOf(event) {
6365
+ switch (event.type) {
6366
+ case "user/message":
6367
+ return event.data.id;
6368
+ case "system/message":
6369
+ case "developer/message":
6370
+ case "assistant/message":
6371
+ case "tool/result":
6372
+ return event.data.message.id;
6373
+ default:
6374
+ return null;
5696
6375
  }
5697
- if (tip === void 0) return void 0;
5698
- const later = events.some((event) => Number(event.seq) > tip.seq && !isRollbackMarkerEvent(event) && !isUndoCopyEvent(event));
5699
- return later ? void 0 : { turn: tip.turn };
5700
6376
  }
5701
- function filterTurnOutline(outline, hideTurnsFrom, continueAfterSeq) {
5702
- if (hideTurnsFrom === void 0 || !Array.isArray(outline)) return outline;
5703
- const next = outline.filter((entry) => {
5704
- if (!isRecord(entry) || typeof entry.turn !== "number") return true;
5705
- if (entry.turn < hideTurnsFrom) return true;
5706
- return continueAfterSeq !== void 0 && typeof entry.seq === "number" && entry.seq > continueAfterSeq;
5707
- });
5708
- return next.length === outline.length ? outline : next;
6377
+ function asUnmaskedUndoCopy(event, bySeq) {
6378
+ const append = surfaceOpOf(event) === "append" ? event : asAppend(event);
6379
+ const id = surfaceMessageIdOf(event);
6380
+ if (id === null) return append;
6381
+ const sourceSeq = undoSourceSeqOf(id);
6382
+ const original = sourceSeq === void 0 ? void 0 : bySeq.get(sourceSeq);
6383
+ if (original === void 0) return append;
6384
+ const originalTurn = turnOfEvent(original);
6385
+ const originalStep = original.data.step;
6386
+ const data = append.data;
6387
+ const needsTurn = typeof originalTurn === "number" && data.turn !== originalTurn;
6388
+ const needsStep = typeof originalStep === "number" && data.step !== originalStep;
6389
+ if (!needsTurn && !needsStep && append === event) return event;
6390
+ if (!needsTurn && !needsStep) return append;
6391
+ return {
6392
+ ...append,
6393
+ data: {
6394
+ ...append.data,
6395
+ ...typeof originalTurn === "number" ? { turn: originalTurn } : {},
6396
+ ...typeof originalStep === "number" ? { step: originalStep } : {}
6397
+ }
6398
+ };
5709
6399
  }
5710
- function renumberCollidingTurns(entries) {
5711
- const starts = [];
6400
+ function activityStatsFromEvents(events) {
6401
+ const closed = /* @__PURE__ */ new Set();
6402
+ const turns = /* @__PURE__ */ new Set();
6403
+ for (const event of events) {
6404
+ if (event.type !== "step/end") continue;
6405
+ const key = `${event.data.turn}:${event.data.step}`;
6406
+ if (closed.has(key)) continue;
6407
+ closed.add(key);
6408
+ turns.add(event.data.turn);
6409
+ }
6410
+ if (closed.size > 0) return { turns: turns.size, steps: closed.size };
6411
+ let steps = 0;
6412
+ for (const event of events) {
6413
+ if (event.type === "turn/start") {
6414
+ turns.add(event.data.turn);
6415
+ continue;
6416
+ }
6417
+ if (event.type !== "assistant/message" || isRollbackMarkerEvent(event)) continue;
6418
+ steps += 1;
6419
+ const turn = turnOfEvent(event);
6420
+ if (turn !== void 0) turns.add(turn);
6421
+ }
6422
+ return { turns: turns.size, steps };
6423
+ }
6424
+ function sourceTurnStepOf(event, bySeq) {
6425
+ const id = surfaceMessageIdOf(event);
6426
+ if (id === null) return void 0;
6427
+ const sourceSeq = undoSourceSeqOf(id);
6428
+ const original = sourceSeq === void 0 ? void 0 : bySeq.get(sourceSeq);
6429
+ if (original !== void 0) {
6430
+ const turn2 = turnOfEvent(original);
6431
+ const step2 = original.data.step;
6432
+ if (typeof turn2 === "number" && typeof step2 === "number") return { turn: turn2, step: step2 };
6433
+ }
6434
+ const turn = turnOfEvent(event);
6435
+ const step = event.data.step;
6436
+ if (typeof turn === "number" && typeof step === "number") return { turn, step };
6437
+ return void 0;
6438
+ }
6439
+ function stepKey(turn, step) {
6440
+ return `${turn}:${step}`;
6441
+ }
6442
+ function collectStepChromeKeys(entries) {
6443
+ const starts = /* @__PURE__ */ new Set();
6444
+ const ends = /* @__PURE__ */ new Set();
6445
+ for (const entry of entries) {
6446
+ if (entry.type !== "event") continue;
6447
+ const event = entry.event;
6448
+ if (event.type === "step/start") starts.add(stepKey(event.data.turn, event.data.step));
6449
+ if (event.type === "step/end") ends.add(stepKey(event.data.turn, event.data.step));
6450
+ }
6451
+ return { starts, ends };
6452
+ }
6453
+ function remapUndoShellStep(event, range, events, bySeq, present) {
6454
+ if (event.type !== "step/start" && event.type !== "step/end") return null;
6455
+ let coords;
6456
+ for (const candidate of events) {
6457
+ const seq = Number(candidate.seq);
6458
+ if (seq < range.startSeq || seq > range.endSeq) continue;
6459
+ if (!isUndoCopyEvent2(candidate)) continue;
6460
+ coords = sourceTurnStepOf(candidate, bySeq);
6461
+ if (coords !== void 0) break;
6462
+ }
6463
+ if (coords === void 0) {
6464
+ const turn = event.data.turn;
6465
+ const step = event.data.step;
6466
+ coords = { turn, step };
6467
+ }
6468
+ const key = stepKey(coords.turn, coords.step);
6469
+ if (event.type === "step/start" && present.starts.has(key)) return null;
6470
+ if (event.type === "step/end" && present.ends.has(key)) return null;
6471
+ if (event.type === "step/start") present.starts.add(key);
6472
+ else present.ends.add(key);
6473
+ if (event.data.turn === coords.turn && event.data.step === coords.step && surfaceOpOf(event) === "append") {
6474
+ return event;
6475
+ }
6476
+ return {
6477
+ ...asAppend(event),
6478
+ data: { ...event.data, turn: coords.turn, step: coords.step }
6479
+ };
6480
+ }
6481
+ function activityStatsFromEntries(entries) {
6482
+ const presented = presentRollbackTranscript(entries);
6483
+ return activityStatsFromEvents(
6484
+ presented.flatMap((entry) => entry.type === "event" ? [entry.event] : [])
6485
+ );
6486
+ }
6487
+ function filterTurnOutline(outline, hideTurnsFrom, continueAfterSeq, omitShellRanges) {
6488
+ if (!Array.isArray(outline)) return outline;
6489
+ if (hideTurnsFrom === void 0 && (omitShellRanges === void 0 || omitShellRanges.length === 0)) return outline;
6490
+ const next = outline.filter((entry) => {
6491
+ if (!isRecord(entry) || typeof entry.turn !== "number") return true;
6492
+ if (typeof entry.seq === "number" && omitShellRanges !== void 0 && inUndoShellRange(entry.seq, omitShellRanges)) return false;
6493
+ if (hideTurnsFrom === void 0) return true;
6494
+ if (entry.turn < hideTurnsFrom) return true;
6495
+ return continueAfterSeq !== void 0 && typeof entry.seq === "number" && entry.seq > continueAfterSeq;
6496
+ });
6497
+ return next.length === outline.length ? outline : next;
6498
+ }
6499
+ function renumberCollidingTurns(entries) {
6500
+ const starts = [];
5712
6501
  const seen = /* @__PURE__ */ new Map();
5713
6502
  let collided = false;
5714
6503
  for (const entry of entries) {
@@ -5761,32 +6550,21 @@ function renumberCollidingTurns(entries) {
5761
6550
  }
5762
6551
  function presentRollbackTranscript(entries) {
5763
6552
  const events = entries.flatMap((entry) => entry.type === "event" ? [entry.event] : []);
6553
+ const bySeq = new Map(events.map((event) => [Number(event.seq), event]));
5764
6554
  const everShadowed = /* @__PURE__ */ new Set();
5765
- const activeMarkers = /* @__PURE__ */ new Set();
6555
+ const liveTip = liveTipMarker(events);
6556
+ const liveTipSeq = liveTip === void 0 ? void 0 : Number(liveTip.seq);
5766
6557
  const hideTurnsFrom = activeRollbackHideTurnsFrom(entries);
5767
6558
  const continueAfterSeq = activeRollbackContinueAfterSeq(entries);
5768
- const undoneTurnCuts = /* @__PURE__ */ new Map();
6559
+ const undoRanges = undoShellRanges(events);
5769
6560
  for (const event of events) {
5770
6561
  if (!isRollbackMarkerEvent(event)) continue;
5771
6562
  for (const seq of event.sourceEventSeqs ?? []) everShadowed.add(Number(seq));
5772
- if (markerStillActive(event, events)) {
5773
- activeMarkers.add(Number(event.seq));
5774
- continue;
5775
- }
5776
- const replaced = events.some((candidate) => {
5777
- if (candidate.seq <= event.seq || !isUndoCopyEvent(candidate)) return false;
5778
- const op = surfaceOpOf(candidate);
5779
- return op !== void 0 && op !== "append" && op.startSeq <= Number(event.seq) && op.endSeq >= Number(event.seq);
5780
- });
5781
- if (!replaced || event.type !== "user/message") continue;
5782
- const turn = turnFromRollbackMarkerId(event.data.id);
5783
- if (turn === void 0) continue;
5784
- const prior = undoneTurnCuts.get(turn);
5785
- undoneTurnCuts.set(turn, prior === void 0 ? Number(event.seq) : Math.min(prior, Number(event.seq)));
5786
6563
  }
5787
- if (everShadowed.size === 0 && activeMarkers.size === 0 && !events.some(isUndoCopyEvent)) return renumberCollidingTurns(entries);
6564
+ if (everShadowed.size === 0 && liveTipSeq === void 0 && undoRanges.length === 0 && !events.some(isUndoCopyEvent2)) return renumberCollidingTurns(entries);
5788
6565
  let changed = false;
5789
6566
  const next = [];
6567
+ const presentSteps = collectStepChromeKeys([]);
5790
6568
  for (const entry of entries) {
5791
6569
  if (entry.type !== "event") {
5792
6570
  next.push(entry);
@@ -5798,31 +6576,52 @@ function presentRollbackTranscript(entries) {
5798
6576
  continue;
5799
6577
  }
5800
6578
  const ownedTurn = turnOfEvent(event);
5801
- const undoneCut = ownedTurn === void 0 ? void 0 : undoneTurnCuts.get(ownedTurn);
5802
- if (undoneCut !== void 0 && (event.type === "turn/start" || event.type === "turn/end" || event.type === "step/start" || event.type === "step/end") && Number(event.seq) < undoneCut) {
5803
- changed = true;
5804
- continue;
6579
+ const seq = Number(event.seq);
6580
+ const shell = undoRanges.find((range) => seq >= range.startSeq && seq <= range.endSeq);
6581
+ if (shell !== void 0) {
6582
+ if (event.type === "turn/start" || event.type === "turn/end" || event.type === "tool/call") {
6583
+ changed = true;
6584
+ continue;
6585
+ }
6586
+ if (event.type === "step/start" || event.type === "step/end") {
6587
+ const remapped = remapUndoShellStep(event, shell, events, bySeq, presentSteps);
6588
+ changed = true;
6589
+ if (remapped === null) continue;
6590
+ next.push({ type: "event", event: remapped });
6591
+ continue;
6592
+ }
5805
6593
  }
5806
- const beforeTip = continueAfterSeq === void 0 || Number(event.seq) <= continueAfterSeq;
5807
- if (hideTurnsFrom !== void 0 && ownedTurn !== void 0 && ownedTurn >= hideTurnsFrom && beforeTip && !isRollbackMarkerEvent(event) && !isUndoCopyEvent(event)) {
6594
+ const beforeTip = continueAfterSeq === void 0 || seq <= continueAfterSeq;
6595
+ if (hideTurnsFrom !== void 0 && ownedTurn !== void 0 && ownedTurn >= hideTurnsFrom && beforeTip && !isRollbackMarkerEvent(event) && !isUndoCopyEvent2(event)) {
5808
6596
  changed = true;
5809
6597
  continue;
5810
6598
  }
6599
+ if (event.type === "step/start") {
6600
+ presentSteps.starts.add(stepKey(event.data.turn, event.data.step));
6601
+ } else if (event.type === "step/end") {
6602
+ presentSteps.ends.add(stepKey(event.data.turn, event.data.step));
6603
+ }
5811
6604
  if (isRollbackMarkerEvent(event)) {
5812
- if (!activeMarkers.has(Number(event.seq))) {
6605
+ if (liveTipSeq === void 0 || Number(event.seq) !== liveTipSeq) {
5813
6606
  changed = true;
5814
6607
  continue;
5815
6608
  }
5816
- if (surfaceOpOf(event) === "append") {
6609
+ const tip = asBookkeepingTip(event);
6610
+ if (tip === event && surfaceOpOf(event) === "append") {
5817
6611
  next.push(entry);
5818
6612
  continue;
5819
6613
  }
5820
- next.push({ type: "event", event: asAppend(event) });
6614
+ next.push({ type: "event", event: tip });
5821
6615
  changed = true;
5822
6616
  continue;
5823
6617
  }
5824
- if (isUndoCopyEvent(event) && surfaceOpOf(event) !== "append") {
5825
- next.push({ type: "event", event: asAppend(event) });
6618
+ if (isUndoCopyEvent2(event)) {
6619
+ const displayed = asUnmaskedUndoCopy(event, bySeq);
6620
+ if (displayed === event) {
6621
+ next.push(entry);
6622
+ continue;
6623
+ }
6624
+ next.push({ type: "event", event: displayed });
5826
6625
  changed = true;
5827
6626
  continue;
5828
6627
  }
@@ -5832,11 +6631,63 @@ function presentRollbackTranscript(entries) {
5832
6631
  }
5833
6632
 
5834
6633
  // src/client/rollback/transcript-filter.ts
6634
+ var KEEP_PREFIX_MAX_PAGES = 12;
5835
6635
  function installRollbackTranscriptFilter(ctx, tips) {
5836
6636
  const sessions = ctx.get("sessions");
5837
6637
  if (sessions?.list === void 0 || typeof sessions.binding !== "function") return () => {
5838
6638
  };
5839
6639
  const watched = /* @__PURE__ */ new Map();
6640
+ const keepPrefixAttempted = /* @__PURE__ */ new Map();
6641
+ const loadingKeepPrefix = /* @__PURE__ */ new Set();
6642
+ const sessionOpen = (session) => session.openState === void 0 || session.openState === "open";
6643
+ const requestKeepPrefix = (sessionId, binding, entries) => {
6644
+ if (loadingKeepPrefix.has(sessionId)) return;
6645
+ const tipSeq = activeRollbackContinueAfterSeq(entries);
6646
+ if (tipSeq === void 0) return;
6647
+ if (keepPrefixAttempted.get(sessionId) === tipSeq) return;
6648
+ const session = binding.session;
6649
+ const source = binding.eventSource;
6650
+ if (session === void 0 || source.replace === void 0) return;
6651
+ if (!sessionOpen(session) || session.loadingOlder === true) return;
6652
+ const target = keepPrefixLoadThroughSeq(entries);
6653
+ if (session.hasMore === false) {
6654
+ keepPrefixAttempted.set(sessionId, tipSeq);
6655
+ return;
6656
+ }
6657
+ if (target === void 0) {
6658
+ keepPrefixAttempted.set(sessionId, tipSeq);
6659
+ return;
6660
+ }
6661
+ if (typeof session.baseSeq === "number" && session.baseSeq <= target && !needsKeepPrefixHistory(entries, true)) {
6662
+ keepPrefixAttempted.set(sessionId, tipSeq);
6663
+ return;
6664
+ }
6665
+ if (typeof session.loadThrough !== "function" && typeof session.loadOlder !== "function") {
6666
+ keepPrefixAttempted.set(sessionId, tipSeq);
6667
+ return;
6668
+ }
6669
+ loadingKeepPrefix.add(sessionId);
6670
+ void (async () => {
6671
+ try {
6672
+ if (typeof session.loadThrough === "function") {
6673
+ await session.loadThrough(target);
6674
+ }
6675
+ if (typeof session.loadOlder === "function") {
6676
+ for (let page = 0; page < KEEP_PREFIX_MAX_PAGES; page += 1) {
6677
+ const snap = source.getSnapshot();
6678
+ const presented = presentRollbackTranscript(snap.entries);
6679
+ if (!needsKeepPrefixHistory(presented, snap.hasMore || session.hasMore !== false)) break;
6680
+ if (session.hasMore === false || session.loadingOlder === true) break;
6681
+ await session.loadOlder();
6682
+ }
6683
+ }
6684
+ } finally {
6685
+ keepPrefixAttempted.set(sessionId, tipSeq);
6686
+ loadingKeepPrefix.delete(sessionId);
6687
+ syncSession(sessionId);
6688
+ }
6689
+ })();
6690
+ };
5840
6691
  const syncSession = (sessionId) => {
5841
6692
  const binding = sessions.binding(sessionId);
5842
6693
  const source = binding?.eventSource;
@@ -5845,9 +6696,19 @@ function installRollbackTranscriptFilter(ctx, tips) {
5845
6696
  return;
5846
6697
  }
5847
6698
  const window2 = source.getSnapshot();
6699
+ const before = promptLedgerFor(sessionId).list().length;
6700
+ promptLedgerFor(sessionId).observe(promptsFromSessionEntries(window2.entries));
6701
+ if (promptLedgerFor(sessionId).list().length !== before) {
6702
+ invalidatePromptHistory(sessionId);
6703
+ }
5848
6704
  const presented = presentRollbackTranscript(window2.entries);
5849
6705
  tips?.set(sessionId, activeRollbackUndoTip(presented)?.turn);
6706
+ const tipSeq = activeRollbackContinueAfterSeq(presented);
6707
+ if (tipSeq === void 0) keepPrefixAttempted.delete(sessionId);
5850
6708
  if (presented !== window2.entries) source.replace(presented, window2.hasMore);
6709
+ if (needsKeepPrefixHistory(presented, window2.hasMore) && binding !== void 0) {
6710
+ requestKeepPrefix(sessionId, binding, presented);
6711
+ }
5851
6712
  };
5852
6713
  const watch = (sessionId) => {
5853
6714
  if (watched.has(sessionId)) return;
@@ -5858,17 +6719,26 @@ function installRollbackTranscriptFilter(ctx, tips) {
5858
6719
  const unsubSource = source.subscribe(() => {
5859
6720
  syncSession(sessionId);
5860
6721
  });
6722
+ const unsubSession = binding.session?.subscribe?.(() => {
6723
+ syncSession(sessionId);
6724
+ }) ?? (() => {
6725
+ });
5861
6726
  const unsubRetention = retention?.subscribe(() => {
5862
6727
  if (sessions.binding(sessionId) === void 0) {
5863
6728
  watched.get(sessionId)?.();
5864
6729
  watched.delete(sessionId);
6730
+ loadingKeepPrefix.delete(sessionId);
6731
+ keepPrefixAttempted.delete(sessionId);
5865
6732
  tips?.set(sessionId, void 0);
5866
6733
  }
5867
6734
  }) ?? (() => {
5868
6735
  });
5869
6736
  watched.set(sessionId, () => {
5870
6737
  unsubSource();
6738
+ unsubSession();
5871
6739
  unsubRetention();
6740
+ loadingKeepPrefix.delete(sessionId);
6741
+ keepPrefixAttempted.delete(sessionId);
5872
6742
  tips?.set(sessionId, void 0);
5873
6743
  });
5874
6744
  syncSession(sessionId);
@@ -5882,6 +6752,8 @@ function installRollbackTranscriptFilter(ctx, tips) {
5882
6752
  unsubList();
5883
6753
  for (const dispose of watched.values()) dispose();
5884
6754
  watched.clear();
6755
+ loadingKeepPrefix.clear();
6756
+ keepPrefixAttempted.clear();
5885
6757
  };
5886
6758
  }
5887
6759
 
@@ -5900,8 +6772,9 @@ function installRollbackTurnOutlineFilter(ctx) {
5900
6772
  const entries = source.getSnapshot().entries;
5901
6773
  const hideTurnsFrom = activeRollbackHideTurnsFrom(entries);
5902
6774
  const continueAfterSeq = activeRollbackContinueAfterSeq(entries);
6775
+ const omitShellRanges = undoShellRangesFromEntries(entries);
5903
6776
  const base = hostOutlines.has(sessionId) ? hostOutlines.get(sessionId) : projections.get("turnOutline");
5904
- const filtered = filterTurnOutline(base, hideTurnsFrom, continueAfterSeq);
6777
+ const filtered = filterTurnOutline(base, hideTurnsFrom, continueAfterSeq, omitShellRanges);
5905
6778
  if (Object.is(filtered, projections.get("turnOutline"))) return;
5906
6779
  const currentSeq = Number(projections.seqOf("turnOutline") ?? 0);
5907
6780
  const nextSeq = Number.isFinite(currentSeq) ? currentSeq + 1 : 1;
@@ -5965,6 +6838,100 @@ function installRollbackTurnOutlineFilter(ctx) {
5965
6838
  };
5966
6839
  }
5967
6840
 
6841
+ // src/client/rollback/session-stats-filter.ts
6842
+ function isRecord2(value) {
6843
+ return typeof value === "object" && value !== null;
6844
+ }
6845
+ function withActivityCounts(base, activity) {
6846
+ if (!isRecord2(base)) return base;
6847
+ if (base.turns === activity.turns && base.steps === activity.steps) return base;
6848
+ return { ...base, turns: activity.turns, steps: activity.steps };
6849
+ }
6850
+ function installRollbackSessionStatsFilter(ctx) {
6851
+ const sessions = ctx.get("sessions");
6852
+ if (sessions?.list === void 0 || typeof sessions.binding !== "function") return () => {
6853
+ };
6854
+ const watched = /* @__PURE__ */ new Map();
6855
+ const hostStats = /* @__PURE__ */ new Map();
6856
+ const published = /* @__PURE__ */ new Map();
6857
+ const publish = (sessionId) => {
6858
+ const binding = sessions.binding(sessionId);
6859
+ const projections = binding?.session.projections;
6860
+ const source = binding?.eventSource;
6861
+ if (projections?.get === void 0 || projections.apply === void 0 || source === void 0) return;
6862
+ const base = hostStats.get(sessionId);
6863
+ if (!isRecord2(base)) return;
6864
+ const entries = source.getSnapshot().entries;
6865
+ const next = withActivityCounts(base, activityStatsFromEntries(entries));
6866
+ if (Object.is(next, projections.get("sessionStats"))) return;
6867
+ const currentSeq = Number(projections.seqOf("sessionStats") ?? 0);
6868
+ projections.apply("sessionStats", next, Number.isFinite(currentSeq) ? currentSeq + 1 : 1);
6869
+ published.set(sessionId, next);
6870
+ };
6871
+ const watch = (sessionId) => {
6872
+ if (watched.has(sessionId)) return;
6873
+ const binding = sessions.binding(sessionId);
6874
+ if (binding === void 0) return;
6875
+ const projections = binding.session.projections;
6876
+ if (projections?.faceOf === void 0 || projections.get === void 0) return;
6877
+ let applying = false;
6878
+ const onStats = () => {
6879
+ if (applying) return;
6880
+ const current = projections.get("sessionStats");
6881
+ if (current === published.get(sessionId)) return;
6882
+ hostStats.set(sessionId, current);
6883
+ applying = true;
6884
+ try {
6885
+ publish(sessionId);
6886
+ } finally {
6887
+ applying = false;
6888
+ }
6889
+ };
6890
+ const onEvents = () => {
6891
+ applying = true;
6892
+ try {
6893
+ publish(sessionId);
6894
+ } finally {
6895
+ applying = false;
6896
+ }
6897
+ };
6898
+ const unsubSource = binding.eventSource.subscribe(onEvents);
6899
+ const unsubStats = projections.faceOf("sessionStats").subscribe(onStats);
6900
+ const retention = sessions.retainInfo?.(sessionId);
6901
+ const unsubRetention = retention?.subscribe(() => {
6902
+ if (sessions.binding(sessionId) === void 0) {
6903
+ watched.get(sessionId)?.();
6904
+ watched.delete(sessionId);
6905
+ hostStats.delete(sessionId);
6906
+ published.delete(sessionId);
6907
+ }
6908
+ }) ?? (() => {
6909
+ });
6910
+ watched.set(sessionId, () => {
6911
+ unsubSource();
6912
+ unsubStats();
6913
+ unsubRetention();
6914
+ hostStats.delete(sessionId);
6915
+ published.delete(sessionId);
6916
+ });
6917
+ const initial = projections.get("sessionStats");
6918
+ if (isRecord2(initial)) hostStats.set(sessionId, initial);
6919
+ onEvents();
6920
+ };
6921
+ const syncList = () => {
6922
+ for (const id of sessions.list.getSnapshot().ids ?? []) watch(id);
6923
+ };
6924
+ const unsubList = sessions.list.subscribe(syncList);
6925
+ syncList();
6926
+ return () => {
6927
+ unsubList();
6928
+ for (const dispose of watched.values()) dispose();
6929
+ watched.clear();
6930
+ hostStats.clear();
6931
+ published.clear();
6932
+ };
6933
+ }
6934
+
5968
6935
  // src/client/rollback/undo-tip.ts
5969
6936
  var RollbackUndoTipStore = class {
5970
6937
  tips = /* @__PURE__ */ new Map();
@@ -6003,23 +6970,53 @@ function RollbackMessageActions(props) {
6003
6970
  if (!snapshot.enabled) return null;
6004
6971
  const canExecute = props.useAccess("checkpointRollback/execute");
6005
6972
  const disabledReason = canExecute === false ? "rollbackUnavailablePermission" : session.running ? "rollbackUnavailableRunning" : turn.status !== "closed" ? "rollbackTurnOpen" : turn.start === void 0 ? "rollbackTurnStartMissing" : null;
6006
- const entryLabel = props.t("rollbackAction");
6007
- const entryTooltip = disabledReason === null ? entryLabel : props.t(disabledReason);
6008
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_dsh_client_ui_primitives8.Tooltip, { label: entryTooltip, side: "bottom", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
6009
- "button",
6010
- {
6011
- type: "button",
6012
- className: css_module_default.userMessageAction,
6013
- "aria-label": entryLabel,
6014
- title: entryTooltip,
6015
- disabled: disabledReason !== null,
6016
- "data-unavailable": disabledReason !== null || void 0,
6017
- onClick: () => {
6018
- if (disabledReason === null) props.rollback.open(turn.turn, "rollback");
6019
- },
6020
- children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(UndoIcon, {})
6021
- }
6022
- ) });
6973
+ const summary = snapshot.coverageByTurn[turn.turn];
6974
+ const affordance = coverageAffordance(summary);
6975
+ const primary = checkpointPrimaryAction(summary);
6976
+ const entryLabel = primary === "undo" ? props.t("rollbackUndoAction") : props.t("rollbackAction");
6977
+ const coverageLabel = disabledReason !== null || primary === "undo" ? null : affordance === "files" ? props.t("rollbackCoverageFiles", { count: summary.fileCount }) : affordance === "partial" ? props.t("rollbackCoveragePartial", {
6978
+ count: summary.fileCount
6979
+ }) : affordance === "conversation" ? props.t("rollbackCoverageConversation") : null;
6980
+ const entryTooltip = disabledReason !== null ? props.t(disabledReason) : coverageLabel ?? entryLabel;
6981
+ const timelineLabel = props.t("rollbackTimelineOpen");
6982
+ const actionDisabled = disabledReason !== null;
6983
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
6984
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_dsh_client_ui_primitives8.Tooltip, { label: entryTooltip, side: "bottom", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
6985
+ "button",
6986
+ {
6987
+ type: "button",
6988
+ className: css_module_default.userMessageAction,
6989
+ "aria-label": entryTooltip,
6990
+ title: entryTooltip,
6991
+ disabled: actionDisabled,
6992
+ "data-unavailable": actionDisabled || void 0,
6993
+ "data-coverage": primary === "restore" && affordance !== "unknown" ? affordance : void 0,
6994
+ "data-action": primary,
6995
+ onClick: () => {
6996
+ if (actionDisabled) return;
6997
+ if (primary === "undo") {
6998
+ props.rollback.open(turn.turn, "undo");
6999
+ return;
7000
+ }
7001
+ props.rollback.open(turn.turn, "rollback");
7002
+ },
7003
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(UndoIcon, {})
7004
+ }
7005
+ ) }),
7006
+ props.onOpenTimeline === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_dsh_client_ui_primitives8.Tooltip, { label: timelineLabel, side: "bottom", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
7007
+ "button",
7008
+ {
7009
+ type: "button",
7010
+ className: css_module_default.userMessageAction,
7011
+ "aria-label": timelineLabel,
7012
+ title: timelineLabel,
7013
+ onClick: () => {
7014
+ props.onOpenTimeline?.(turn.turn);
7015
+ },
7016
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(TimelineIcon, {})
7017
+ }
7018
+ ) })
7019
+ ] });
6023
7020
  }
6024
7021
 
6025
7022
  // src/client/rollback/content-parts.ts
@@ -6113,13 +7110,503 @@ function RollbackUserNode(props) {
6113
7110
  t: props.tEnhancer,
6114
7111
  turn,
6115
7112
  useSession: props.useSession,
6116
- useAccess: props.useAccess
7113
+ useAccess: props.useAccess,
7114
+ onOpenTimeline: props.onOpenTimeline
6117
7115
  }
6118
7116
  ) : null
6119
7117
  ] })
6120
7118
  ] });
6121
7119
  }
6122
7120
 
7121
+ // src/client/rollback/session-stats-dock.tsx
7122
+ var import_react15 = require("react");
7123
+
7124
+ // src/client/rollback/session-stats-meter.ts
7125
+ var CHECKPOINT_ATTR = "data-agent-enhancer-checkpoint";
7126
+ var TITLE_RE2 = /会话统计|Session\s*statistics|Session\s*stats/i;
7127
+ var STAT_RE = /TTFT|TPS|模型用时|工具调用|首\s*token|输出速度|tok\s*\/\s*s/i;
7128
+ function cls3(value) {
7129
+ return value ?? "";
7130
+ }
7131
+ function textOf3(node) {
7132
+ return (node.textContent ?? "").replace(/\s+/g, " ").trim();
7133
+ }
7134
+ function isContextCompositionPanel2(dialog) {
7135
+ return dialog.querySelectorAll(":scope > dl > div").length === 3;
7136
+ }
7137
+ function isTokenUsagePanel2(dialog) {
7138
+ const text2 = textOf3(dialog);
7139
+ return /Token\s*(?:用量|usage)/i.test(text2) && /\d[\d,]*\s*tok/i.test(text2);
7140
+ }
7141
+ function isSessionStatsPanel(dialog) {
7142
+ if (isContextCompositionPanel2(dialog) || isTokenUsagePanel2(dialog)) return false;
7143
+ const text2 = textOf3(dialog);
7144
+ if (!TITLE_RE2.test(text2)) return false;
7145
+ return STAT_RE.test(text2);
7146
+ }
7147
+ function findOpenSessionStatsPanel() {
7148
+ const dock = document.querySelector("[data-composer-dock]");
7149
+ if (!(dock instanceof HTMLElement)) return null;
7150
+ const triggers = dock.querySelectorAll('button[aria-haspopup="dialog"][aria-expanded="true"]');
7151
+ if (triggers.length === 0) return null;
7152
+ const dialogs = document.querySelectorAll('body > [role="dialog"]');
7153
+ for (let index = dialogs.length - 1; index >= 0; index -= 1) {
7154
+ const dialog = dialogs[index];
7155
+ if (dialog === void 0) continue;
7156
+ if (isSessionStatsPanel(dialog)) return dialog;
7157
+ }
7158
+ return null;
7159
+ }
7160
+ function findSessionStatsTitleRow(panel) {
7161
+ const candidates = [];
7162
+ for (const node of panel.querySelectorAll("*")) {
7163
+ if (!(node instanceof HTMLElement) || node === panel) continue;
7164
+ const text2 = textOf3(node);
7165
+ if (!TITLE_RE2.test(text2)) continue;
7166
+ if (STAT_RE.test(text2) && text2.length > 40) continue;
7167
+ candidates.push(node);
7168
+ }
7169
+ if (candidates.length === 0) return null;
7170
+ candidates.sort((left, right) => left.querySelectorAll("*").length - right.querySelectorAll("*").length);
7171
+ return candidates[0] ?? null;
7172
+ }
7173
+ function enhanceTitleRow2(row, options) {
7174
+ if (row.getAttribute(CHECKPOINT_ATTR) === "1") return;
7175
+ row.setAttribute(CHECKPOINT_ATTR, "1");
7176
+ row.classList.add(cls3(css_module_default.sessionStatsCheckpointRow));
7177
+ row.tabIndex = 0;
7178
+ row.setAttribute("role", "button");
7179
+ row.setAttribute("aria-label", options.label());
7180
+ if (!row.querySelector("[data-agent-enhancer-checkpoint-chevron]")) {
7181
+ const chevron = document.createElement("span");
7182
+ chevron.dataset.agentEnhancerCheckpointChevron = "1";
7183
+ chevron.className = cls3(css_module_default.sessionStatsCheckpointChevron);
7184
+ chevron.setAttribute("aria-hidden", "true");
7185
+ chevron.textContent = "\u203A";
7186
+ row.append(chevron);
7187
+ }
7188
+ const open = () => {
7189
+ if (!options.enabled()) return;
7190
+ const sessionId = options.sessionId();
7191
+ if (sessionId === void 0 || sessionId === "") return;
7192
+ options.open();
7193
+ };
7194
+ row.addEventListener("click", (event) => {
7195
+ event.preventDefault();
7196
+ event.stopPropagation();
7197
+ open();
7198
+ });
7199
+ row.addEventListener("keydown", (event) => {
7200
+ if (event.key !== "Enter" && event.key !== " ") return;
7201
+ event.preventDefault();
7202
+ event.stopPropagation();
7203
+ open();
7204
+ });
7205
+ }
7206
+ function installSessionStatsCheckpointLink(options) {
7207
+ const scan = () => {
7208
+ const panel = findOpenSessionStatsPanel();
7209
+ if (panel === null) return;
7210
+ const title = findSessionStatsTitleRow(panel);
7211
+ if (title !== null) enhanceTitleRow2(title, options);
7212
+ };
7213
+ const observer = new MutationObserver(scan);
7214
+ observer.observe(document.body, {
7215
+ childList: true,
7216
+ subtree: true,
7217
+ attributes: true,
7218
+ attributeFilter: ["aria-expanded"]
7219
+ });
7220
+ scan();
7221
+ return () => {
7222
+ observer.disconnect();
7223
+ };
7224
+ }
7225
+
7226
+ // src/client/rollback/session-stats-dock.tsx
7227
+ function SessionStatsCheckpointDock(props) {
7228
+ const sessionId = props.sessionId;
7229
+ (0, import_react15.useEffect)(() => installSessionStatsCheckpointLink({
7230
+ enabled: props.enabled,
7231
+ sessionId: () => sessionId,
7232
+ open: () => {
7233
+ if (sessionId === void 0) return;
7234
+ props.open(sessionId);
7235
+ },
7236
+ label: () => props.t("rollbackTimelineOpen")
7237
+ }), [sessionId, props.enabled, props.open, props.t]);
7238
+ return null;
7239
+ }
7240
+
7241
+ // src/client/rollback/timeline-tab.tsx
7242
+ var import_react17 = require("react");
7243
+
7244
+ // src/client/rollback/timeline-panel.tsx
7245
+ var import_dsh_client_ui_primitives10 = require("@deepseek-ai/dsh-client-ui-primitives");
7246
+ var import_react16 = require("react");
7247
+
7248
+ // src/client/rollback/timeline-format.ts
7249
+ function timelineCoverageLabel(summary, t) {
7250
+ const affordance = coverageAffordance(summary);
7251
+ switch (affordance) {
7252
+ case "files":
7253
+ return t("rollbackTimelineCoverageFiles", { count: summary.fileCount });
7254
+ case "partial":
7255
+ return t("rollbackTimelineCoveragePartial", { count: summary.fileCount });
7256
+ case "conversation":
7257
+ return t("rollbackTimelineCoverageConversation");
7258
+ case "unknown":
7259
+ return t("rollbackTimelineCoverageUnknown");
7260
+ default: {
7261
+ const _exhaustive = affordance;
7262
+ return _exhaustive;
7263
+ }
7264
+ }
7265
+ }
7266
+ function timelineGapLabel(gap, t) {
7267
+ switch (gap.type) {
7268
+ case "prompt":
7269
+ return t("rollbackGapPrompt");
7270
+ case "workspace":
7271
+ return t("rollbackGapWorkspace");
7272
+ default: {
7273
+ const _exhaustive = gap;
7274
+ return _exhaustive;
7275
+ }
7276
+ }
7277
+ }
7278
+ function sortTimelineByConversation(turns) {
7279
+ return [...turns].sort((left, right) => left.atSeq - right.atSeq || left.turn - right.turn || left.createdAt - right.createdAt);
7280
+ }
7281
+ function formatCheckpointTime(createdAt, locale) {
7282
+ try {
7283
+ return new Intl.DateTimeFormat(locale, {
7284
+ month: "short",
7285
+ day: "numeric",
7286
+ hour: "2-digit",
7287
+ minute: "2-digit"
7288
+ }).format(new Date(createdAt));
7289
+ } catch {
7290
+ return new Date(createdAt).toLocaleString();
7291
+ }
7292
+ }
7293
+ function timelinePromptLabel(summary, t) {
7294
+ if (summary.promptPreview.length > 0) {
7295
+ return { text: summary.promptPreview, empty: false };
7296
+ }
7297
+ const first = summary.files[0];
7298
+ if (first !== void 0) {
7299
+ return {
7300
+ text: summary.files.length === 1 ? t("rollbackTimelineFileFallback", { path: first.path }) : t("rollbackTimelineFilesFallback", { path: first.path, count: summary.files.length }),
7301
+ empty: false
7302
+ };
7303
+ }
7304
+ return { text: t("rollbackTimelineNoPrompt"), empty: true };
7305
+ }
7306
+
7307
+ // src/client/rollback/timeline-panel.tsx
7308
+ var import_jsx_runtime17 = require("react/jsx-runtime");
7309
+ var emptyActivity = {
7310
+ turns: 0,
7311
+ steps: 0,
7312
+ checkpoints: 0,
7313
+ liveCheckpoints: 0
7314
+ };
7315
+ function mergeChatActivity(activity, chat) {
7316
+ if (chat === void 0) return activity;
7317
+ if (activity.turns === chat.turns && activity.steps === chat.steps) return activity;
7318
+ return { ...activity, turns: chat.turns, steps: chat.steps };
7319
+ }
7320
+ function CheckpointTimelinePanel(props) {
7321
+ const [state, setState] = (0, import_react16.useState)({ status: "loading" });
7322
+ const [expanded, setExpanded] = (0, import_react16.useState)(props.focusTurn ?? null);
7323
+ const [openingTurn, setOpeningTurn] = (0, import_react16.useState)(null);
7324
+ const [chatActivity, setChatActivity] = (0, import_react16.useState)(() => props.readChatActivity?.());
7325
+ const wasActive = (0, import_react16.useRef)(false);
7326
+ const reload = (0, import_react16.useCallback)(() => {
7327
+ const summaries = props.remote.summaries;
7328
+ if (summaries === void 0) {
7329
+ setState({ status: "error" });
7330
+ return () => {
7331
+ };
7332
+ }
7333
+ const controller = new AbortController();
7334
+ setState({ status: "loading" });
7335
+ void summaries({ sessionId: props.sessionId }, controller.signal).then((result) => {
7336
+ if (controller.signal.aborted) return;
7337
+ if (result.sessionId !== props.sessionId) {
7338
+ setState({ status: "error" });
7339
+ return;
7340
+ }
7341
+ const turns = sortTimelineByConversation(result.turns);
7342
+ const activity2 = result.activity ?? {
7343
+ ...emptyActivity,
7344
+ checkpoints: turns.length,
7345
+ liveCheckpoints: turns.filter((turn) => !turn.rolledBack).length
7346
+ };
7347
+ setState({
7348
+ status: "ready",
7349
+ turns,
7350
+ activity: mergeChatActivity(activity2, props.readChatActivity?.())
7351
+ });
7352
+ if (props.focusTurn !== void 0 && turns.some((turn) => turn.turn === props.focusTurn)) {
7353
+ setExpanded(props.focusTurn);
7354
+ }
7355
+ }).catch(() => {
7356
+ if (!controller.signal.aborted) setState({ status: "error" });
7357
+ });
7358
+ return () => {
7359
+ controller.abort();
7360
+ };
7361
+ }, [props.focusTurn, props.readChatActivity, props.remote, props.sessionId]);
7362
+ (0, import_react16.useEffect)(() => reload(), [reload]);
7363
+ (0, import_react16.useEffect)(() => {
7364
+ const read = props.readChatActivity;
7365
+ if (read === void 0) return;
7366
+ const sync = () => {
7367
+ let next;
7368
+ try {
7369
+ next = read();
7370
+ } catch {
7371
+ return;
7372
+ }
7373
+ setChatActivity((previous) => {
7374
+ if (previous?.turns === next?.turns && previous?.steps === next?.steps) return previous;
7375
+ return next;
7376
+ });
7377
+ };
7378
+ sync();
7379
+ try {
7380
+ return props.subscribeChatActivity?.(sync);
7381
+ } catch {
7382
+ return void 0;
7383
+ }
7384
+ }, [props.readChatActivity, props.subscribeChatActivity]);
7385
+ (0, import_react16.useEffect)(() => {
7386
+ if (chatActivity === void 0) return;
7387
+ setState((previous) => {
7388
+ if (previous.status !== "ready") return previous;
7389
+ const activity2 = mergeChatActivity(previous.activity, chatActivity);
7390
+ if (activity2 === previous.activity) return previous;
7391
+ return { ...previous, activity: activity2 };
7392
+ });
7393
+ }, [chatActivity]);
7394
+ (0, import_react16.useEffect)(() => {
7395
+ if (props.rollback === void 0) return;
7396
+ return props.rollback.subscribe(() => {
7397
+ const active = props.rollback.getSnapshot().active;
7398
+ if (active !== null) {
7399
+ wasActive.current = true;
7400
+ if (active.status === "loading" || active.status === "ready" || active.status === "executing") {
7401
+ setOpeningTurn(active.turn);
7402
+ }
7403
+ return;
7404
+ }
7405
+ setOpeningTurn(null);
7406
+ if (wasActive.current) {
7407
+ wasActive.current = false;
7408
+ reload();
7409
+ }
7410
+ });
7411
+ }, [props.rollback, reload]);
7412
+ if (state.status === "loading") {
7413
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: css_module_default.timelineStatus, role: "status", children: props.t("rollbackTimelineLoading") });
7414
+ }
7415
+ if (state.status === "error") {
7416
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: css_module_default.timelineStatus, children: [
7417
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { role: "alert", children: props.t("rollbackTimelineFailed") }),
7418
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_dsh_client_ui_primitives10.Button, { type: "button", onClick: () => {
7419
+ reload();
7420
+ }, children: props.t("rollbackRetry") })
7421
+ ] });
7422
+ }
7423
+ if (state.turns.length === 0) {
7424
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: css_module_default.timelineStatus, children: props.t("rollbackTimelineEmpty") });
7425
+ }
7426
+ const { activity } = state;
7427
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: css_module_default.timelinePanel, children: [
7428
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: css_module_default.timelineLead, children: props.t("rollbackTimelineLead", {
7429
+ turns: activity.turns,
7430
+ steps: activity.steps,
7431
+ checkpoints: activity.checkpoints,
7432
+ liveCheckpoints: activity.liveCheckpoints
7433
+ }) }),
7434
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("ol", { className: css_module_default.timelineList, children: state.turns.map((summary) => {
7435
+ const open = expanded === summary.turn;
7436
+ const time = formatCheckpointTime(summary.createdAt, props.locale ?? "en");
7437
+ const coverage = coverageAffordance(summary);
7438
+ const prompt = timelinePromptLabel(summary, props.t);
7439
+ const opening = openingTurn === summary.turn;
7440
+ const covered = summary.rolledBack && !summary.tip;
7441
+ const primary = checkpointPrimaryAction(summary);
7442
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
7443
+ "li",
7444
+ {
7445
+ className: css_module_default.timelineItem,
7446
+ "data-coverage": coverage,
7447
+ "data-expanded": open || void 0,
7448
+ "data-rolled-back": summary.rolledBack || void 0,
7449
+ "data-tip": summary.tip || void 0,
7450
+ "data-action": primary,
7451
+ children: [
7452
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
7453
+ "button",
7454
+ {
7455
+ type: "button",
7456
+ className: css_module_default.timelineRow,
7457
+ "aria-expanded": open,
7458
+ onClick: () => {
7459
+ setExpanded(open ? null : summary.turn);
7460
+ },
7461
+ children: [
7462
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("span", { className: css_module_default.timelineHead, children: [
7463
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: css_module_default.timelineTurn, children: props.t("rollbackTimelineTurn", { turn: summary.turn }) }),
7464
+ summary.tip ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: css_module_default.timelineRolledBack, children: props.t("rollbackTimelineTip") }) : summary.rolledBack ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: css_module_default.timelineRolledBack, children: props.t("rollbackTimelineRolledBack") }) : null,
7465
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: css_module_default.timelineCoverage, "data-coverage": coverage, children: timelineCoverageLabel(summary, props.t) }),
7466
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: css_module_default.timelineTime, children: time })
7467
+ ] }),
7468
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
7469
+ "span",
7470
+ {
7471
+ className: prompt.empty ? css_module_default.timelinePromptEmpty : css_module_default.timelinePromptPreview,
7472
+ children: prompt.text
7473
+ }
7474
+ )
7475
+ ]
7476
+ }
7477
+ ),
7478
+ !open ? null : /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: css_module_default.timelineDetail, children: [
7479
+ summary.promptPreview.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: css_module_default.timelinePromptEmpty, children: props.t("rollbackTimelineNoPrompt") }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: css_module_default.timelinePrompt, children: summary.promptPreview }),
7480
+ summary.files.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: css_module_default.timelineFilesEmpty, children: props.t("rollbackNoFiles") }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("ul", { className: css_module_default.timelineFiles, children: summary.files.map((file) => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("li", { "data-change": file.change, children: [
7481
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { children: file.path }),
7482
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: css_module_default.timelineFileChange, "data-change": file.change, children: props.t(`rollbackFile_${file.change}`) })
7483
+ ] }, file.path)) }),
7484
+ summary.gaps.length === 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("ul", { className: css_module_default.timelineGaps, children: summary.gaps.map((gap) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("li", { "data-gap": gap.type, children: timelineGapLabel(gap, props.t) }, `${gap.type}:${gap.reason}`)) }),
7485
+ covered ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: css_module_default.timelineFilesEmpty, role: "status", children: props.t("rollbackTimelineCoveredHint") }) : null,
7486
+ opening ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: css_module_default.timelineFilesEmpty, role: "status", children: props.t("rollbackTimelineOpening") }) : null,
7487
+ primary === "undo" ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
7488
+ import_dsh_client_ui_primitives10.Button,
7489
+ {
7490
+ type: "button",
7491
+ disabled: opening,
7492
+ onClick: () => {
7493
+ setOpeningTurn(summary.turn);
7494
+ props.onUndo(summary.turn);
7495
+ },
7496
+ children: props.t("rollbackUndoAction")
7497
+ }
7498
+ ) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_dsh_client_ui_primitives10.Button, { type: "button", disabled: opening, onClick: () => {
7499
+ setOpeningTurn(summary.turn);
7500
+ props.onRestore(summary.turn);
7501
+ }, children: props.t("rollbackAction") })
7502
+ ] })
7503
+ ]
7504
+ },
7505
+ summary.turn
7506
+ );
7507
+ }) })
7508
+ ] });
7509
+ }
7510
+
7511
+ // src/client/rollback/timeline-tab.tsx
7512
+ var import_jsx_runtime18 = require("react/jsx-runtime");
7513
+ function chatActivityOf(sessions, sessionId) {
7514
+ const binding = sessions?.binding(sessionId);
7515
+ if (binding?.eventSource?.getSnapshot === void 0) return void 0;
7516
+ try {
7517
+ const entries = binding.eventSource.getSnapshot().entries;
7518
+ return activityStatsFromEntries(entries);
7519
+ } catch {
7520
+ return void 0;
7521
+ }
7522
+ }
7523
+ function subscribeChatActivityOf(sessions, sessionId, listener) {
7524
+ const binding = sessions?.binding(sessionId);
7525
+ if (binding === void 0) return () => {
7526
+ };
7527
+ const disposers = [];
7528
+ try {
7529
+ disposers.push(binding.eventSource.subscribe(listener));
7530
+ } catch {
7531
+ }
7532
+ try {
7533
+ const face = binding.session.projections.faceOf("sessionStats");
7534
+ if (typeof face?.subscribe === "function") disposers.push(face.subscribe(listener));
7535
+ } catch {
7536
+ }
7537
+ return () => {
7538
+ while (disposers.length > 0) disposers.pop()?.();
7539
+ };
7540
+ }
7541
+ function paramsOf2(raw) {
7542
+ if (typeof raw !== "object" || raw === null) return {};
7543
+ const record = raw;
7544
+ return {
7545
+ ...typeof record.sessionId === "string" ? { sessionId: record.sessionId } : {},
7546
+ ...typeof record.turn === "number" ? { turn: record.turn } : {}
7547
+ };
7548
+ }
7549
+ function CheckpointTimelineTabBody(props) {
7550
+ const rollback = props.rollbackFor(props.sessionId);
7551
+ const activityBridge = (0, import_react17.useMemo)(() => {
7552
+ const sessions = props.sessions;
7553
+ if (sessions === void 0) return {};
7554
+ const sessionId = props.sessionId;
7555
+ return {
7556
+ readChatActivity: () => chatActivityOf(sessions, sessionId),
7557
+ subscribeChatActivity: (listener) => subscribeChatActivityOf(sessions, sessionId, listener)
7558
+ };
7559
+ }, [props.sessions, props.sessionId]);
7560
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: css_module_default.timelineRightPane, children: [
7561
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
7562
+ CheckpointTimelinePanel,
7563
+ {
7564
+ sessionId: props.sessionId,
7565
+ focusTurn: props.focusTurn,
7566
+ remote: props.remote,
7567
+ rollback,
7568
+ t: props.t,
7569
+ locale: props.locale,
7570
+ ...activityBridge,
7571
+ onRestore: (turn) => {
7572
+ props.onRestore(props.sessionId, turn);
7573
+ },
7574
+ onUndo: (turn) => {
7575
+ props.onUndo(props.sessionId, turn);
7576
+ }
7577
+ }
7578
+ ),
7579
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
7580
+ RollbackModalHost,
7581
+ {
7582
+ rollback,
7583
+ t: props.t,
7584
+ inputActions: rollbackInputActionsFor(props.sessionId),
7585
+ sessionId: props.sessionId,
7586
+ surface: "timeline"
7587
+ }
7588
+ )
7589
+ ] });
7590
+ }
7591
+ function CheckpointTimelineTab(props) {
7592
+ const info = props.useTabInfo();
7593
+ const params = paramsOf2(info.tab.navigation.params);
7594
+ if (params.sessionId === void 0) {
7595
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: css_module_default.timelineRightPane, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("p", { className: css_module_default.timelineStatus, children: props.t("rollbackTimelineNoSession") }) });
7596
+ }
7597
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
7598
+ CheckpointTimelineTabBody,
7599
+ {
7600
+ ...props,
7601
+ sessionId: params.sessionId,
7602
+ focusTurn: params.turn
7603
+ }
7604
+ );
7605
+ }
7606
+ function CheckpointTimelineTabTitle(props) {
7607
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { children: props.t("rollbackTimelineTitle") });
7608
+ }
7609
+
6123
7610
  // src/client/index.ts
6124
7611
  var inject = [
6125
7612
  "remote",
@@ -6198,7 +7685,7 @@ function apply(ctx) {
6198
7685
  }));
6199
7686
  return source === "account" ? all.account : all.apiKey;
6200
7687
  };
6201
- const SettingsTab = (props) => (0, import_react15.createElement)(PluginSettings, {
7688
+ const SettingsTab = (props) => (0, import_react18.createElement)(PluginSettings, {
6202
7689
  form: props.form,
6203
7690
  t: props.t,
6204
7691
  loadCatalog,
@@ -6213,12 +7700,12 @@ function apply(ctx) {
6213
7700
  locale: "agent-enhancer",
6214
7701
  inject: () => ({ form })
6215
7702
  }, SettingsTab)));
6216
- const AccountBalanceChip = () => (0, import_react15.createElement)(ProviderBalanceChip, {
7703
+ const AccountBalanceChip = () => (0, import_react18.createElement)(ProviderBalanceChip, {
6217
7704
  source: "account",
6218
7705
  t,
6219
7706
  load: loadProviderSnapshot("account")
6220
7707
  });
6221
- const ApiKeyBalanceChip = () => (0, import_react15.createElement)(ProviderBalanceChip, {
7708
+ const ApiKeyBalanceChip = () => (0, import_react18.createElement)(ProviderBalanceChip, {
6222
7709
  source: "api-key",
6223
7710
  t,
6224
7711
  load: loadProviderSnapshot("api-key")
@@ -6272,6 +7759,7 @@ function apply(ctx) {
6272
7759
  for (const session of sessions.values()) session.refreshSettings();
6273
7760
  }));
6274
7761
  mountedCtx.effect(() => () => {
7762
+ for (const sessionId of sessions.keys()) disposePromptLedger(sessionId);
6275
7763
  for (const session of sessions.values()) session.dispose();
6276
7764
  sessions.clear();
6277
7765
  });
@@ -6301,7 +7789,7 @@ function apply(ctx) {
6301
7789
  const tContext = mountedCtx.locale.bind("agent-enhancer");
6302
7790
  const inspectContext = (sessionId, category, signal) => agentEnhancerInspectContext.invoke(mountedCtx.remote, { sessionId, category }, signal);
6303
7791
  const compactContext = (sessionId, signal) => agentEnhancerCompactContext.invoke(mountedCtx.remote, { sessionId }, signal);
6304
- const ContextDock = (props) => (0, import_react15.createElement)(ContextInspectDock, {
7792
+ const ContextDock = (props) => (0, import_react18.createElement)(ContextInspectDock, {
6305
7793
  ...props,
6306
7794
  enabled: contextInspectEnabled,
6307
7795
  open: (category) => {
@@ -6312,29 +7800,29 @@ function apply(ctx) {
6312
7800
  },
6313
7801
  t: tContext
6314
7802
  });
6315
- const BillDock = (props) => (0, import_react15.createElement)(UsageMeterDock, {
7803
+ const BillDock = (props) => (0, import_react18.createElement)(UsageMeterDock, {
6316
7804
  ...props,
6317
7805
  open: () => {
6318
7806
  openUsageTab(mountedCtx.sidebarRight);
6319
7807
  },
6320
7808
  t: tContext
6321
7809
  });
6322
- const ContextRightTab = (props) => (0, import_react15.createElement)(ContextInspectRightTab, {
7810
+ const ContextRightTab = (props) => (0, import_react18.createElement)(ContextInspectRightTab, {
6323
7811
  ...props,
6324
7812
  inspect: inspectContext,
6325
7813
  compact: compactContext,
6326
7814
  t: tContext
6327
7815
  });
6328
- const ContextRightTitle = (props) => (0, import_react15.createElement)(
7816
+ const ContextRightTitle = (props) => (0, import_react18.createElement)(
6329
7817
  ContextInspectRightTabTitle,
6330
7818
  { ...props, t: tContext }
6331
7819
  );
6332
- const BillRightTab = (props) => (0, import_react15.createElement)(UsageRightTab, {
7820
+ const BillRightTab = (props) => (0, import_react18.createElement)(UsageRightTab, {
6333
7821
  ...props,
6334
7822
  loadUsage,
6335
7823
  t: tContext
6336
7824
  });
6337
- const BillRightTitle = (props) => (0, import_react15.createElement)(
7825
+ const BillRightTitle = (props) => (0, import_react18.createElement)(
6338
7826
  UsageRightTabTitle,
6339
7827
  { ...props, t: tContext }
6340
7828
  );
@@ -6410,7 +7898,8 @@ function apply(ctx) {
6410
7898
  const applyRollbackMounted = (mountedCtx) => {
6411
7899
  const rollbackRemote = {
6412
7900
  preview: (request, signal) => checkpointRollbackRemote.preview(mountedCtx.remote, request, signal),
6413
- execute: (request, signal) => checkpointRollbackRemote.execute(mountedCtx.remote, request, signal)
7901
+ execute: (request, signal) => checkpointRollbackRemote.execute(mountedCtx.remote, request, signal),
7902
+ summaries: (request, signal) => checkpointRollbackRemote.summaries(mountedCtx.remote, request, signal)
6414
7903
  };
6415
7904
  const rollbackSessions = /* @__PURE__ */ new Map();
6416
7905
  const rollbackRetentions = /* @__PURE__ */ new Map();
@@ -6439,13 +7928,72 @@ function apply(ctx) {
6439
7928
  }
6440
7929
  return rollback;
6441
7930
  };
6442
- const rollbackUserNode = (props) => (0, import_react15.createElement)(
7931
+ const openTimeline = (sessionId, turn) => {
7932
+ openCheckpointTimelineTab(mountedCtx.sidebarRight, turn === void 0 ? { sessionId } : { sessionId, turn });
7933
+ };
7934
+ const restoreFromTimeline = (sessionId, turn) => {
7935
+ queueMicrotask(() => {
7936
+ rollbackFor(sessionId).open(turn, "rollback", { surface: "timeline" });
7937
+ });
7938
+ };
7939
+ const undoFromTimeline = (sessionId, turn) => {
7940
+ queueMicrotask(() => {
7941
+ rollbackFor(sessionId).open(turn, "undo", { surface: "timeline" });
7942
+ });
7943
+ };
7944
+ const TimelineTab = (props) => (0, import_react18.createElement)(
7945
+ CheckpointTimelineTab,
7946
+ {
7947
+ ...props,
7948
+ t: tEnhancer,
7949
+ remote: rollbackRemote,
7950
+ sessions: mountedCtx.get("sessions"),
7951
+ rollbackFor,
7952
+ locale: resolveUiLocale(mountedCtx.locale.getLocale().active) === "zh" ? "zh-CN" : "en",
7953
+ onRestore: restoreFromTimeline,
7954
+ onUndo: undoFromTimeline
7955
+ }
7956
+ );
7957
+ const TimelineTitle = (props) => (0, import_react18.createElement)(
7958
+ CheckpointTimelineTabTitle,
7959
+ { ...props, t: tEnhancer }
7960
+ );
7961
+ const StatsCheckpointDock = (props) => (0, import_react18.createElement)(
7962
+ SessionStatsCheckpointDock,
7963
+ {
7964
+ ...props,
7965
+ enabled: rollbackEnabled,
7966
+ open: (sessionId) => {
7967
+ openTimeline(sessionId);
7968
+ },
7969
+ t: tEnhancer
7970
+ }
7971
+ );
7972
+ const rollbackUserNode = (props) => (0, import_react18.createElement)(
6443
7973
  RollbackUserNode,
6444
- { ...props, rollback: rollbackFor(props.sessionId), tEnhancer, tChat }
7974
+ {
7975
+ ...props,
7976
+ rollback: rollbackFor(props.sessionId),
7977
+ tEnhancer,
7978
+ tChat,
7979
+ onOpenTimeline: (turn) => {
7980
+ openTimeline(props.sessionId, turn);
7981
+ }
7982
+ }
6445
7983
  );
6446
- const rollbackOverlay = (props) => (0, import_react15.createElement)(
7984
+ const rollbackOverlay = (props) => (0, import_react18.createElement)(
6447
7985
  RollbackModalHost,
6448
- { rollback: rollbackFor(props.sessionId), t: tEnhancer, inputActions: props.inputActions }
7986
+ {
7987
+ rollback: rollbackFor(props.sessionId),
7988
+ t: tEnhancer,
7989
+ inputActions: props.inputActions,
7990
+ useSession: props.useSession,
7991
+ sessionId: props.sessionId,
7992
+ surface: "composer",
7993
+ onOpenTimeline: (turn) => {
7994
+ openTimeline(props.sessionId, turn);
7995
+ }
7996
+ }
6449
7997
  );
6450
7998
  const disposers = [];
6451
7999
  const disableRollback = () => {
@@ -6462,6 +8010,22 @@ function apply(ctx) {
6462
8010
  if (!enabled) {
6463
8011
  disableRollback();
6464
8012
  } else if (disposers.length === 0) {
8013
+ disposers.push(mountedCtx.sidebarRightTabs.register({
8014
+ id: CHECKPOINT_TIMELINE_TAB_ID,
8015
+ kind: CHECKPOINT_TIMELINE_TAB_KIND,
8016
+ priority: "extension",
8017
+ title: () => tEnhancer("rollbackTimelineTitle")
8018
+ }));
8019
+ disposers.push(mountedCtx.slots.inject("sidebar.right.pane.tab", () => mountedCtx.slots.register({
8020
+ name: "sidebar.right.pane.tab",
8021
+ key: CHECKPOINT_TIMELINE_TAB_ID,
8022
+ locale: "agent-enhancer"
8023
+ }, TimelineTab)));
8024
+ disposers.push(mountedCtx.slots.inject("sidebar.right.pane.tab.title", () => mountedCtx.slots.register({
8025
+ name: "sidebar.right.pane.tab.title",
8026
+ key: CHECKPOINT_TIMELINE_TAB_ID,
8027
+ locale: "agent-enhancer"
8028
+ }, TimelineTitle)));
6465
8029
  disposers.push(mountedCtx.slots.inject("conversation.chat.node", () => mountedCtx.slots.register({
6466
8030
  name: "conversation.chat.node",
6467
8031
  key: "user",
@@ -6474,8 +8038,15 @@ function apply(ctx) {
6474
8038
  order: 121,
6475
8039
  locale: "agent-enhancer"
6476
8040
  }, rollbackOverlay)));
8041
+ disposers.push(mountedCtx.slots.inject("conversation.composer.dock", () => mountedCtx.slots.register({
8042
+ name: "conversation.composer.dock",
8043
+ id: "agent-enhancer-checkpoint-stats",
8044
+ order: 55,
8045
+ locale: "agent-enhancer"
8046
+ }, StatsCheckpointDock)));
6477
8047
  disposers.push(installRollbackTranscriptFilter(mountedCtx, undoTips));
6478
8048
  disposers.push(installRollbackTurnOutlineFilter(mountedCtx));
8049
+ disposers.push(installRollbackSessionStatsFilter(mountedCtx));
6479
8050
  disposers.push(installRollbackUndoCommand({
6480
8051
  ctx: mountedCtx,
6481
8052
  tips: undoTips,