dsh-agent-enhancer 0.3.0 → 0.3.2

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 (107) 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/dsh/settings.d.ts.map +1 -1
  10. package/lib/client/index.d.ts.map +1 -1
  11. package/lib/client/locales.d.ts +113 -19
  12. package/lib/client/locales.d.ts.map +1 -1
  13. package/lib/client/prompt/coordinator.d.ts +2 -0
  14. package/lib/client/prompt/coordinator.d.ts.map +1 -1
  15. package/lib/client/prompt/history.d.ts.map +1 -1
  16. package/lib/client/prompt/ledger-store.d.ts +8 -0
  17. package/lib/client/prompt/ledger-store.d.ts.map +1 -0
  18. package/lib/client/prompt/ledger.d.ts +15 -0
  19. package/lib/client/prompt/ledger.d.ts.map +1 -0
  20. package/lib/client/rollback/actions.d.ts +1 -0
  21. package/lib/client/rollback/actions.d.ts.map +1 -1
  22. package/lib/client/rollback/controller.d.ts +25 -2
  23. package/lib/client/rollback/controller.d.ts.map +1 -1
  24. package/lib/client/rollback/cut-cache.d.ts +13 -0
  25. package/lib/client/rollback/cut-cache.d.ts.map +1 -0
  26. package/lib/client/rollback/failure.d.ts +7 -0
  27. package/lib/client/rollback/failure.d.ts.map +1 -0
  28. package/lib/client/rollback/format.d.ts +23 -0
  29. package/lib/client/rollback/format.d.ts.map +1 -0
  30. package/lib/client/rollback/input-actions-cache.d.ts +6 -0
  31. package/lib/client/rollback/input-actions-cache.d.ts.map +1 -0
  32. package/lib/client/rollback/modal-host.d.ts +13 -0
  33. package/lib/client/rollback/modal-host.d.ts.map +1 -1
  34. package/lib/client/rollback/preview.d.ts +3 -2
  35. package/lib/client/rollback/preview.d.ts.map +1 -1
  36. package/lib/client/rollback/prompt-entries.d.ts +9 -0
  37. package/lib/client/rollback/prompt-entries.d.ts.map +1 -0
  38. package/lib/client/rollback/remote.d.ts +3 -1
  39. package/lib/client/rollback/remote.d.ts.map +1 -1
  40. package/lib/client/rollback/scope.d.ts +3 -1
  41. package/lib/client/rollback/scope.d.ts.map +1 -1
  42. package/lib/client/rollback/session-stats-dock.d.ts +10 -0
  43. package/lib/client/rollback/session-stats-dock.d.ts.map +1 -0
  44. package/lib/client/rollback/session-stats-filter.d.ts +19 -0
  45. package/lib/client/rollback/session-stats-filter.d.ts.map +1 -0
  46. package/lib/client/rollback/session-stats-meter.d.ts +20 -0
  47. package/lib/client/rollback/session-stats-meter.d.ts.map +1 -0
  48. package/lib/client/rollback/timeline-format.d.ts +23 -0
  49. package/lib/client/rollback/timeline-format.d.ts.map +1 -0
  50. package/lib/client/rollback/timeline-kind.d.ts +13 -0
  51. package/lib/client/rollback/timeline-kind.d.ts.map +1 -0
  52. package/lib/client/rollback/timeline-panel.d.ts +23 -0
  53. package/lib/client/rollback/timeline-panel.d.ts.map +1 -0
  54. package/lib/client/rollback/timeline-tab.d.ts +40 -0
  55. package/lib/client/rollback/timeline-tab.d.ts.map +1 -0
  56. package/lib/client/rollback/transcript-filter.d.ts +17 -2
  57. package/lib/client/rollback/transcript-filter.d.ts.map +1 -1
  58. package/lib/client/rollback/transcript.d.ts +55 -9
  59. package/lib/client/rollback/transcript.d.ts.map +1 -1
  60. package/lib/client/rollback/turn-outline-filter.d.ts.map +1 -1
  61. package/lib/client/rollback/types.d.ts +17 -1
  62. package/lib/client/rollback/types.d.ts.map +1 -1
  63. package/lib/client/rollback/user-node.d.ts +1 -0
  64. package/lib/client/rollback/user-node.d.ts.map +1 -1
  65. package/lib/client.js +1959 -261
  66. package/lib/client.js.map +1 -1
  67. package/lib/config.d.ts +3 -1
  68. package/lib/config.d.ts.map +1 -1
  69. package/lib/host/auto-route/classifier.d.ts.map +1 -1
  70. package/lib/host/auto-route/session-hook.d.ts.map +1 -1
  71. package/lib/host/auto-route/session-selection.d.ts.map +1 -1
  72. package/lib/host/checkpoint/activity.d.ts +43 -0
  73. package/lib/host/checkpoint/activity.d.ts.map +1 -0
  74. package/lib/host/checkpoint/availability.d.ts +8 -1
  75. package/lib/host/checkpoint/availability.d.ts.map +1 -1
  76. package/lib/host/checkpoint/capture.d.ts +12 -4
  77. package/lib/host/checkpoint/capture.d.ts.map +1 -1
  78. package/lib/host/checkpoint/chain-files.d.ts +35 -0
  79. package/lib/host/checkpoint/chain-files.d.ts.map +1 -0
  80. package/lib/host/checkpoint/cut-filter.d.ts +9 -0
  81. package/lib/host/checkpoint/cut-filter.d.ts.map +1 -0
  82. package/lib/host/checkpoint/cut-live.d.ts +13 -0
  83. package/lib/host/checkpoint/cut-live.d.ts.map +1 -0
  84. package/lib/host/checkpoint/cut-store.d.ts +30 -0
  85. package/lib/host/checkpoint/cut-store.d.ts.map +1 -0
  86. package/lib/host/checkpoint/dsh.d.ts.map +1 -1
  87. package/lib/host/checkpoint/files.d.ts +3 -0
  88. package/lib/host/checkpoint/files.d.ts.map +1 -1
  89. package/lib/host/checkpoint/live.d.ts +9 -0
  90. package/lib/host/checkpoint/live.d.ts.map +1 -1
  91. package/lib/host/checkpoint/service.d.ts +125 -4
  92. package/lib/host/checkpoint/service.d.ts.map +1 -1
  93. package/lib/host/checkpoint/store.d.ts +13 -0
  94. package/lib/host/checkpoint/store.d.ts.map +1 -1
  95. package/lib/host/checkpoint/workspace-snapshot.d.ts +30 -0
  96. package/lib/host/checkpoint/workspace-snapshot.d.ts.map +1 -0
  97. package/lib/host/index.d.ts +3 -1
  98. package/lib/host/index.d.ts.map +1 -1
  99. package/lib/host/model.d.ts.map +1 -1
  100. package/lib/host/rpc.d.ts +7 -0
  101. package/lib/host/rpc.d.ts.map +1 -1
  102. package/lib/host/usage/source.d.ts.map +1 -1
  103. package/lib/identity.d.ts +1 -1
  104. package/lib/identity.d.ts.map +1 -1
  105. package/lib/index.js +1677 -774
  106. package/lib/index.js.map +4 -4
  107. 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,19 +1204,69 @@ 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
+ timelineToolbar: "styles_timelineToolbar",
1214
+ timelineSearchRow: "styles_timelineSearchRow",
1215
+ timelineSearch: "styles_timelineSearch",
1216
+ timelineSelectBar: "styles_timelineSelectBar",
1217
+ timelineSelectAll: "styles_timelineSelectAll",
1218
+ timelineBulkActions: "styles_timelineBulkActions",
1219
+ timelineBulkCount: "styles_timelineBulkCount",
1220
+ timelineCheck: "styles_timelineCheck",
1221
+ timelineStats: "styles_timelineStats",
1222
+ timelineStatIn: "styles_timelineStatIn",
1223
+ timelineStatOut: "styles_timelineStatOut",
1224
+ timelineLead: "styles_timelineLead",
1225
+ timelineStatus: "styles_timelineStatus",
1226
+ timelineFilters: "styles_timelineFilters",
1227
+ timelineFilter: "styles_timelineFilter",
1228
+ timelineFilterCount: "styles_timelineFilterCount",
1229
+ timelineList: "styles_timelineList",
1230
+ timelineItem: "styles_timelineItem",
1231
+ timelinePromptPreview: "styles_timelinePromptPreview",
1232
+ timelineMain: "styles_timelineMain",
1233
+ timelineLeadNote: "styles_timelineLeadNote",
1234
+ timelineBoundaryNote: "styles_timelineBoundaryNote",
1235
+ timelineTipBadge: "styles_timelineTipBadge",
1236
+ timelineRolledBackBadge: "styles_timelineRolledBackBadge",
1237
+ timelineRow: "styles_timelineRow",
1238
+ timelineSwitch: "styles_timelineSwitch",
1239
+ timelineTurn: "styles_timelineTurn",
1240
+ timelineRolledBack: "styles_timelineRolledBack",
1241
+ timelineCoverage: "styles_timelineCoverage",
1242
+ timelineMeta: "styles_timelineMeta",
1243
+ timelineTime: "styles_timelineTime",
1244
+ timelineDetail: "styles_timelineDetail",
1245
+ timelineDetailMeta: "styles_timelineDetailMeta",
1246
+ timelineDetailNote: "styles_timelineDetailNote",
1247
+ timelineActions: "styles_timelineActions",
1248
+ contextExcludedBadge: "styles_contextExcludedBadge",
1249
+ userMessageRow: "styles_userMessageRow",
1250
+ timelinePrompt: "styles_timelinePrompt",
1251
+ timelinePromptEmpty: "styles_timelinePromptEmpty",
1252
+ timelineFilesEmpty: "styles_timelineFilesEmpty",
1253
+ timelineFiles: "styles_timelineFiles",
1254
+ timelineGaps: "styles_timelineGaps",
1255
+ timelineFileChange: "styles_timelineFileChange",
1121
1256
  rollbackSection: "styles_rollbackSection",
1122
1257
  rollbackList: "styles_rollbackList",
1123
1258
  rollbackMessage: "styles_rollbackMessage",
1124
1259
  rollbackFile: "styles_rollbackFile",
1125
1260
  rollbackMeta: "styles_rollbackMeta",
1126
1261
  rollbackConflict: "styles_rollbackConflict",
1127
- userMessageRow: "styles_userMessageRow",
1128
1262
  userMessageActions: "styles_userMessageActions",
1129
1263
  userMessageAction: "styles_userMessageAction",
1130
1264
  contextMeterRow: "styles_contextMeterRow",
1131
1265
  contextMeterChevron: "styles_contextMeterChevron",
1132
1266
  usageMeterTitleRow: "styles_usageMeterTitleRow",
1267
+ sessionStatsCheckpointRow: "styles_sessionStatsCheckpointRow",
1133
1268
  usageMeterLinkChevron: "styles_usageMeterLinkChevron",
1269
+ sessionStatsCheckpointChevron: "styles_sessionStatsCheckpointChevron",
1134
1270
  contextRightPanel: "styles_contextRightPanel",
1135
1271
  contextRightHeader: "styles_contextRightHeader",
1136
1272
  contextRightTitleRow: "styles_contextRightTitleRow",
@@ -1280,7 +1416,7 @@ var styles_default = {
1280
1416
  usageRecentTokens: "styles_usageRecentTokens"
1281
1417
  };
1282
1418
  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';
1419
+ 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: 10px;\n min-width: 0;\n align-content: start;\n}\n.styles_timelineToolbar {\n display: flex;\n flex-wrap: wrap;\n gap: 8px 12px;\n align-items: center;\n justify-content: space-between;\n}\n.styles_timelineSearchRow {\n min-width: 0;\n}\n.styles_timelineSearch {\n width: 100%;\n}\n.styles_timelineSelectBar {\n display: flex;\n flex-wrap: wrap;\n gap: 8px 12px;\n align-items: center;\n justify-content: space-between;\n}\n.styles_timelineSelectAll {\n min-width: 0;\n}\n.styles_timelineBulkActions {\n display: flex;\n flex-wrap: wrap;\n gap: 6px 8px;\n align-items: center;\n justify-content: flex-end;\n}\n.styles_timelineBulkCount {\n color: var(--dsw-alias-label-secondary);\n font-size: 0.88em;\n font-variant-numeric: tabular-nums;\n}\n.styles_timelineCheck {\n display: flex;\n align-items: center;\n padding-left: 8px;\n}\n.styles_timelineCheck span:last-child {\n position: absolute;\n width: 1px;\n height: 1px;\n margin: -1px;\n padding: 0;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n border: 0;\n white-space: nowrap;\n}\n.styles_timelineStats {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n align-items: baseline;\n min-width: 0;\n font-variant-numeric: tabular-nums;\n}\n.styles_timelineStatIn,\n.styles_timelineStatOut {\n color: var(--dsw-alias-label-primary);\n font-size: 0.95em;\n font-weight: 650;\n letter-spacing: -0.01em;\n}\n.styles_timelineStatOut {\n color: var(--dsw-alias-label-secondary);\n font-weight: 550;\n}\n.styles_timelineStatOut[data-active] {\n color: color-mix(in srgb, #9a3412 55%, var(--dsw-alias-label-primary, #0f172a));\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_timelineFilters {\n display: flex;\n flex-wrap: wrap;\n gap: 4px;\n padding: 2px;\n border-radius: var(--dsw-radius-sm);\n background: color-mix(in srgb, var(--dsw-alias-bg-layer-2, #fff) 55%, transparent);\n}\n.styles_timelineFilter {\n display: inline-flex;\n gap: 6px;\n align-items: center;\n margin: 0;\n padding: 5px 9px;\n color: var(--dsw-alias-label-secondary);\n font: inherit;\n font-size: 0.88em;\n line-height: 1.2;\n background: transparent;\n border: 0;\n border-radius: calc(var(--dsw-radius-sm) - 1px);\n cursor: pointer;\n}\n.styles_timelineFilter:hover {\n color: var(--dsw-alias-label-primary);\n background: color-mix(in srgb, var(--dsw-alias-interactive-bg-hover, rgba(0, 0, 0, 0.06)) 80%, transparent);\n}\n.styles_timelineFilter[data-active] {\n color: var(--dsw-alias-label-primary);\n font-weight: 650;\n background: color-mix(in srgb, var(--dsw-alias-bg-layer-1, #fff) 88%, transparent);\n box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--dsw-alias-label-tertiary, #94a3b8) 35%, transparent);\n}\n.styles_timelineFilterCount {\n min-width: 1.1em;\n color: inherit;\n font-variant-numeric: tabular-nums;\n opacity: 0.72;\n}\n.styles_timelineList {\n display: grid;\n gap: 2px;\n margin: 0;\n padding: 0;\n list-style: none;\n}\n.styles_timelineItem {\n --timeline-accent: color-mix(in srgb, #0f766e 55%, var(--dsw-alias-label-tertiary, #94a3b8));\n min-width: 0;\n overflow: hidden;\n border-radius: var(--dsw-radius-sm);\n background: transparent;\n box-shadow: inset 3px 0 0 var(--timeline-accent);\n transition: opacity 120ms ease, background-color 120ms ease;\n}\n.styles_timelineItem[data-context-excluded] {\n --timeline-accent: color-mix(in srgb, #9a3412 50%, var(--dsw-alias-label-tertiary, #94a3b8));\n opacity: 0.72;\n background: color-mix(in srgb, var(--dsw-alias-bg-layer-2, #fff) 35%, transparent);\n}\n.styles_timelineItem[data-context-excluded] .styles_timelinePromptPreview {\n text-decoration: line-through;\n text-decoration-thickness: 1px;\n text-decoration-color: color-mix(in srgb, var(--dsw-alias-label-secondary) 55%, transparent);\n color: var(--dsw-alias-label-secondary);\n}\n.styles_timelineItem[data-rolled-back]:not([data-context-excluded]) {\n opacity: 0.85;\n}\n.styles_timelineMain {\n display: grid;\n grid-template-columns: minmax(0, 1fr) auto;\n gap: 4px 8px;\n align-items: center;\n}\n.styles_timelineLeadNote,\n.styles_timelineBoundaryNote {\n margin: 0;\n color: var(--dsw-alias-label-secondary);\n font-size: 0.88em;\n line-height: 1.4;\n}\n.styles_timelineTipBadge,\n.styles_timelineRolledBackBadge {\n margin-left: 6px;\n padding: 1px 7px;\n font-size: 0.82em;\n font-weight: 700;\n line-height: 1.35;\n white-space: nowrap;\n border-radius: 999px;\n}\n.styles_timelineTipBadge {\n color: color-mix(in srgb, #0f766e 70%, var(--dsw-alias-label-primary, #0f172a));\n background: color-mix(in srgb, #14b8a6 16%, transparent);\n box-shadow: inset 0 0 0 1px color-mix(in srgb, #0f766e 28%, transparent);\n}\n.styles_timelineRolledBackBadge {\n color: color-mix(in srgb, #be123c 70%, var(--dsw-alias-label-primary, #0f172a));\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_timelineItem[data-tip] {\n --timeline-accent: color-mix(in srgb, #0f766e 70%, var(--dsw-alias-label-tertiary, #94a3b8));\n}\n.styles_timelineItem[data-selected] {\n background: color-mix(in srgb, var(--dsw-alias-interactive-bg-hover, rgba(0, 0, 0, 0.06)) 55%, transparent);\n}\n.styles_timelineRow {\n display: grid;\n grid-template-columns: auto minmax(0, 1fr) auto;\n gap: 6px 10px;\n align-items: baseline;\n width: 100%;\n margin: 0;\n padding: 8px 4px 8px 10px;\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_timelineSwitch {\n display: flex;\n align-items: center;\n padding: 4px 8px 4px 0;\n}\n.styles_timelineTurn {\n flex: none;\n font-weight: 650;\n font-variant-numeric: tabular-nums;\n white-space: nowrap;\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 color: var(--dsw-alias-label-secondary);\n font-size: 0.82em;\n white-space: nowrap;\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.35;\n -webkit-box-orient: vertical;\n -webkit-line-clamp: 1;\n}\n.styles_timelineDetail {\n display: grid;\n gap: 10px;\n margin: 0 0 0 3px;\n padding: 8px 12px 12px 10px;\n background: color-mix(in srgb, var(--dsw-alias-bg-layer-2, #fff) 72%, transparent);\n border-top: 1px solid color-mix(in srgb, var(--dsw-alias-label-tertiary, #94a3b8) 22%, transparent);\n}\n.styles_timelineDetailMeta {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n align-items: center;\n margin: 0;\n}\n.styles_timelineDetailNote {\n margin: 0;\n color: color-mix(in srgb, #9a3412 55%, var(--dsw-alias-label-primary, #0f172a));\n font-size: 0.88em;\n font-weight: 600;\n}\n.styles_timelineActions {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n}\n.styles_contextExcludedBadge {\n display: inline-flex;\n align-self: flex-start;\n margin: 0 0 4px;\n padding: 2px 8px;\n border-radius: 4px;\n font-size: 0.75em;\n line-height: 1.4;\n color: var(--dsw-alias-label-secondary);\n background: color-mix(in srgb, var(--dsw-alias-bg-layer-2, #fff) 70%, transparent);\n border: 1px solid color-mix(in srgb, var(--dsw-alias-label-secondary) 24%, transparent);\n}\n.styles_userMessageRow[data-context-excluded] {\n opacity: 0.78;\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.35;\n}\n@media (prefers-reduced-motion: reduce) {\n .styles_timelineItem {\n transition: none;\n }\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
1420
  function installCss() {
1285
1421
  const style = document.createElement("style");
1286
1422
  style.setAttribute("data-dsh-agent-enhancer", "");
@@ -1328,6 +1464,29 @@ function UndoIcon() {
1328
1464
  }
1329
1465
  );
1330
1466
  }
1467
+ function TimelineIcon() {
1468
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
1469
+ "svg",
1470
+ {
1471
+ width: "16",
1472
+ height: "16",
1473
+ viewBox: "0 0 16 16",
1474
+ fill: "none",
1475
+ stroke: "currentColor",
1476
+ strokeWidth: "1.5",
1477
+ strokeLinecap: "round",
1478
+ strokeLinejoin: "round",
1479
+ "aria-hidden": "true",
1480
+ children: [
1481
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M4 2.5v11" }),
1482
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "4", cy: "4", r: "1.4", fill: "currentColor", stroke: "none" }),
1483
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "4", cy: "8", r: "1.4", fill: "currentColor", stroke: "none" }),
1484
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "4", cy: "12", r: "1.4", fill: "currentColor", stroke: "none" }),
1485
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M7 4h5M7 8h5M7 12h3.5" })
1486
+ ]
1487
+ }
1488
+ );
1489
+ }
1331
1490
 
1332
1491
  // src/client/dsh/controls.tsx
1333
1492
  var import_jsx_runtime2 = require("react/jsx-runtime");
@@ -1382,13 +1541,19 @@ function textOf(node) {
1382
1541
  function turnOf(node) {
1383
1542
  return node.location.kind === "turn" || node.location.kind === "step" ? node.location.turn.turn : void 0;
1384
1543
  }
1544
+ function isDirectUserPrompt(data) {
1545
+ const source = data.source;
1546
+ return source?.kind === "user";
1547
+ }
1385
1548
  function sentPrompts(chat) {
1386
1549
  if (chat === void 0) return [];
1387
1550
  return chat.order.flatMap((key) => {
1388
1551
  const node = chat.nodes.get(key);
1389
1552
  if (node?.kind !== "user") return [];
1390
- const text2 = textOf(node.data);
1391
- return text2.trim() === "" ? [] : [{ seq: node.data.seq, text: text2 }];
1553
+ const data = node.data;
1554
+ if (!isDirectUserPrompt(data)) return [];
1555
+ const text2 = textOf(data);
1556
+ return text2.trim() === "" ? [] : [{ seq: data.seq, text: text2 }];
1392
1557
  });
1393
1558
  }
1394
1559
  function latestCompletedTurn(chat, session) {
@@ -1608,14 +1773,19 @@ function AgentOverlay(props) {
1608
1773
  setSearch(coordinator.searchSnapshot());
1609
1774
  setPrediction(coordinator.predictionSnapshot());
1610
1775
  });
1611
- let unregisterHistory = () => {
1612
- };
1613
- const refreshHistory = () => {
1614
- unregisterHistory();
1615
- unregisterHistory = coordinator.registerHistory({
1616
- load: (requested) => requested === props.sessionId ? sentPrompts(latestRef.current.chat) : []
1617
- });
1776
+ const unregisterHistory = coordinator.registerHistory({
1777
+ load: (requested) => {
1778
+ if (requested !== props.sessionId) return [];
1779
+ return promptLedgerFor(props.sessionId).observe(sentPrompts(latestRef.current.chat));
1780
+ }
1781
+ });
1782
+ const warmHistory = () => {
1783
+ promptLedgerFor(props.sessionId).observe(sentPrompts(latestRef.current.chat));
1784
+ coordinator.invalidateHistoryCache(props.sessionId);
1618
1785
  };
1786
+ const unsubscribeLedger = subscribePromptLedgerInvalidation((sessionId) => {
1787
+ if (sessionId === props.sessionId) coordinator.invalidateHistoryCache(sessionId);
1788
+ });
1619
1789
  let selection = { start: latestRef.current.input.draft.length, end: latestRef.current.input.draft.length };
1620
1790
  const sync = () => {
1621
1791
  selection = readSelection(root) ?? selection;
@@ -1675,7 +1845,7 @@ function AgentOverlay(props) {
1675
1845
  root.ownerDocument.addEventListener("click", onOfficialMenuPointer);
1676
1846
  const active = {
1677
1847
  sync,
1678
- refreshHistory,
1848
+ refreshHistory: warmHistory,
1679
1849
  dispose() {
1680
1850
  root.removeEventListener("keydown", onKeyDown);
1681
1851
  root.removeEventListener("input", onInput);
@@ -1685,12 +1855,14 @@ function AgentOverlay(props) {
1685
1855
  root.ownerDocument.removeEventListener("pointerdown", onOfficialMenuPointer);
1686
1856
  root.ownerDocument.removeEventListener("click", onOfficialMenuPointer);
1687
1857
  unregisterHistory();
1858
+ unsubscribeLedger();
1688
1859
  unsubscribe();
1689
1860
  detach();
1690
1861
  }
1691
1862
  };
1692
1863
  activeRef.current = active;
1693
1864
  sync();
1865
+ warmHistory();
1694
1866
  return () => {
1695
1867
  active.dispose();
1696
1868
  if (activeRef.current === active) activeRef.current = null;
@@ -2880,6 +3052,10 @@ function ContextInspectDock(props) {
2880
3052
  var USAGE_TAB_ID = "dsh-agent-enhancer/usage";
2881
3053
  var USAGE_TAB_KIND = "agentEnhancerUsage";
2882
3054
 
3055
+ // src/client/rollback/timeline-kind.ts
3056
+ var CHECKPOINT_TIMELINE_TAB_ID = "dsh-agent-enhancer/checkpointTimeline";
3057
+ var CHECKPOINT_TIMELINE_TAB_KIND = "agentEnhancerCheckpointTimeline";
3058
+
2883
3059
  // src/client/context/tab.ts
2884
3060
  var CONTEXT_INSPECT_TAB_ID = "dsh-agent-enhancer/contextInspect";
2885
3061
  var CONTEXT_INSPECT_TAB_KIND = "agentEnhancerContextInspect";
@@ -2925,6 +3101,9 @@ function openContextInspectTab(sidebarRight, params) {
2925
3101
  function openUsageTab(sidebarRight) {
2926
3102
  return openRightTab(sidebarRight, USAGE_TAB_KIND, {});
2927
3103
  }
3104
+ function openCheckpointTimelineTab(sidebarRight, params) {
3105
+ return openRightTab(sidebarRight, CHECKPOINT_TIMELINE_TAB_KIND, params);
3106
+ }
2928
3107
 
2929
3108
  // src/client/context/right-tab.tsx
2930
3109
  var import_react7 = require("react");
@@ -4417,60 +4596,107 @@ var agentLocales = {
4417
4596
  contextInspectCompactChanged: "\u538B\u7F29\u8FC7\u7A0B\u4E2D\u5386\u53F2\u5DF2\u53D8\u5316\uFF0C\u4F1A\u8BDD\u672A\u5199\u5165\uFF1B\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002",
4418
4597
  rollback: "\u5BF9\u8BDD\u4E0E\u6587\u4EF6\u6062\u590D",
4419
4598
  rollbackDescription: "\u5728\u5408\u89C4\u7528\u6237\u6D88\u606F\u65C1\u9884\u89C8\u5E76\u6062\u590D\u5BF9\u8BDD\u4E0E\u5DF2\u8DDF\u8E2A\u6587\u4EF6",
4420
- rollbackBoundary: "\u4E0D\u6062\u590D\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\u6216\u672A\u8DDF\u8E2A\u6587\u4EF6\uFF1B\u5173\u95ED\u540E\u4FDD\u7559\u5DF2\u6709\u65E5\u5FD7\u548C\u68C0\u67E5\u70B9\u3002",
4599
+ rollbackBoundary: "\u4EC5\u81EA\u52A8\u6062\u590D\u5BF9\u8BDD\u6295\u5F71\u4E0E\u5DF2\u8DDF\u8E2A\u7684\u6587\u672C\u6587\u4EF6\uFF1B\u8FDB\u7A0B\u3001\u7EC8\u7AEF\u3001\u672A\u8DDF\u8E2A\u4E0E\u4E8C\u8FDB\u5236\u6587\u4EF6\u4E0D\u5728\u8303\u56F4\u5185\u3002\u5173\u95ED\u5F00\u5173\u540E\u4FDD\u7559\u5DF2\u6709\u65E5\u5FD7\u4E0E\u68C0\u67E5\u70B9\u3002",
4421
4600
  rollbackAction: "\u6062\u590D\u5230\u8FD9\u91CC",
4422
4601
  rollbackUndoAction: "\u64A4\u9500\u6062\u590D",
4423
- rollbackUndoCommandDescription: "\u64A4\u56DE\u6700\u8FD1\u4E00\u6B21\u6062\u590D\u6807\u8BB0\uFF0C\u5E76\u8FD8\u539F\u6062\u590D\u524D\u7684\u9884\u89C8\u5185\u5BB9",
4602
+ rollbackUndoCommandDescription: "\u64A4\u56DE\u6700\u8FD1\u4E00\u6B21\u6062\u590D\u6295\u5F71",
4424
4603
  rollbackTitle: "\u6062\u590D\u5230\u7B2C {turn} \u8F6E\u4E4B\u524D",
4425
4604
  rollbackUndoTitle: "\u64A4\u9500\u7B2C {turn} \u8F6E\u6062\u590D",
4426
- 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",
4427
- 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
- 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",
4605
+ rollbackScope: "\u53EF\u4EC5\u6062\u590D\u5BF9\u8BDD\uFF0C\u6216\u540C\u65F6\u6062\u590D\u5DF2\u8DDF\u8E2A\u6587\u672C\u6587\u4EF6\u3002\u65E0\u6587\u4EF6\u53D8\u66F4\u65F6\u4ECD\u53EF\u786E\u8BA4\uFF1B\u6709\u51B2\u7A81\u65F6\u53EF\u4EC5\u6062\u590D\u5BF9\u8BDD\u3002",
4606
+ rollbackScopeAlready: "\u5BF9\u8BDD\u5DF2\u505C\u5728\u6B64\u68C0\u67E5\u70B9\u3002\u786E\u8BA4\u53EA\u4F1A\u91CD\u65B0\u586B\u5165\u8BE5\u8F6E\u8349\u7A3F\uFF1B\u8981\u7528\u300C\u64A4\u9500\u6062\u590D\u300D\u624D\u4F1A\u91CD\u65B0\u663E\u793A\u88AB\u64A4\u56DE\u7684\u6D88\u606F\u3002",
4607
+ rollbackScopeCovered: "\u5F53\u524D\u5DF2\u6062\u590D\u5230\u66F4\u65E9\u7684\u68C0\u67E5\u70B9\u3002\u8BF7\u5148\u300C\u64A4\u9500\u6062\u590D\u300D\uFF0C\u518D\u9009\u62E9\u8FD9\u4E00\u8F6E\u3002",
4608
+ rollbackUndoScope: "\u6E05\u9664\u672C\u6B21\u6062\u590D\u6295\u5F71\uFF0C\u5E76\u5C3D\u91CF\u8FD8\u539F\u6062\u590D\u524D\u7684\u5BF9\u8BDD\u4E0E\u5DF2\u8DDF\u8E2A\u6587\u672C\u6587\u4EF6\u3002",
4609
+ rollbackUndoScopeConversation: "\u6E05\u9664\u672C\u6B21\u4EC5\u5BF9\u8BDD\u6062\u590D\u6295\u5F71\uFF0C\u5E76\u8FD8\u539F\u6062\u590D\u524D\u7684\u5BF9\u8BDD\u9884\u89C8\u3002",
4429
4610
  rollbackClose: "\u5173\u95ED\u6062\u590D\u9884\u89C8",
4430
4611
  rollbackConfirm: "\u6062\u590D\u5BF9\u8BDD\u4E0E\u5DF2\u8DDF\u8E2A\u6587\u4EF6",
4431
4612
  rollbackConfirmConversation: "\u4EC5\u6062\u590D\u5BF9\u8BDD",
4613
+ rollbackConfirmAlready: "\u91CD\u65B0\u586B\u5165\u8349\u7A3F\uFF08\u542B\u6587\u4EF6\uFF09",
4614
+ rollbackConfirmConversationAlready: "\u91CD\u65B0\u586B\u5165\u8349\u7A3F",
4432
4615
  rollbackUndoConfirm: "\u64A4\u9500\u6062\u590D\u5E76\u8FD8\u539F\u9884\u89C8\u5185\u5BB9",
4433
4616
  rollbackUndoConfirmConversation: "\u64A4\u9500\u6062\u590D\u5E76\u8FD8\u539F\u5BF9\u8BDD",
4434
4617
  rollbackCancel: "\u53D6\u6D88",
4618
+ 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",
4619
+ 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
4620
  rollbackLoading: "\u6B63\u5728\u91CD\u65B0\u68C0\u67E5\u5BF9\u8BDD\u548C\u6587\u4EF6\u72B6\u6001\u2026",
4436
4621
  rollbackRestoring: "\u6B63\u5728\u6062\u590D\u5BF9\u8BDD\u4E0E\u5DF2\u8DDF\u8E2A\u6587\u4EF6\u2026",
4437
4622
  rollbackRestoringConversation: "\u6B63\u5728\u6062\u590D\u5BF9\u8BDD\u2026",
4438
4623
  rollbackUndoRestoring: "\u6B63\u5728\u64A4\u9500\u6062\u590D\u5E76\u8FD8\u539F\u5BF9\u8BDD\u4E0E\u5DF2\u8DDF\u8E2A\u6587\u4EF6\u2026",
4439
4624
  rollbackUndoRestoringConversation: "\u6B63\u5728\u64A4\u9500\u6062\u590D\u5E76\u8FD8\u539F\u5BF9\u8BDD\u2026",
4440
4625
  rollbackFailed: "\u6062\u590D\u672A\u5B8C\u6210\uFF0C\u8BF7\u5173\u95ED\u9884\u89C8\u540E\u91CD\u8BD5\u3002",
4626
+ 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",
4627
+ 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",
4628
+ 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",
4629
+ rollbackRetry: "\u91CD\u65B0\u68C0\u67E5",
4441
4630
  rollbackTurnOpen: "\u672C\u8F6E\u5C1A\u672A\u7ED3\u675F",
4442
4631
  rollbackTurnStartMissing: "\u672C\u8F6E\u5F00\u59CB\u4E8B\u4EF6\u5C1A\u672A\u52A0\u8F7D",
4632
+ rollbackSummary: "{messages} \u6761\u6D88\u606F \xB7 {files} \u4E2A\u6587\u4EF6",
4633
+ rollbackSummaryLabel: "\u6062\u590D\u8303\u56F4\u6458\u8981",
4634
+ rollbackMessageEmpty: "\uFF08\u65E0\u6587\u672C\uFF09",
4635
+ rollbackRole_user: "\u7528\u6237",
4636
+ rollbackRole_assistant: "\u52A9\u624B",
4637
+ rollbackRole_tool: "\u5DE5\u5177",
4638
+ rollbackRole_system: "\u7CFB\u7EDF",
4639
+ rollbackRole_other: "\u5176\u4ED6",
4640
+ rollbackCoverageFiles: "\u6062\u590D\u5230\u8FD9\u91CC \xB7 {count} \u4E2A\u5DF2\u8DDF\u8E2A\u6587\u4EF6",
4641
+ rollbackCoveragePartial: "\u6062\u590D\u5230\u8FD9\u91CC \xB7 \u90E8\u5206\u6587\u4EF6\u5FEB\u7167\uFF08{count}\uFF09",
4642
+ rollbackCoverageConversation: "\u6062\u590D\u5230\u8FD9\u91CC \xB7 \u4EC5\u5BF9\u8BDD\u5FEB\u7167",
4643
+ rollbackTimelineTitle: "\u68C0\u67E5\u70B9",
4644
+ rollbackTimelineOpen: "\u68C0\u67E5\u70B9\u65F6\u95F4\u7EBF",
4645
+ rollbackTimelineLead: "{turns} \u8F6E \xB7 {checkpoints} \u4E2A\u68C0\u67E5\u70B9",
4646
+ rollbackTimelineLeadRestoredNote: "\u5DF2\u6295\u5F71\u622A\u65AD\u5230\u5F53\u524D\u6062\u590D\u70B9\u3002",
4647
+ rollbackTimelineFilterEmpty: "\u6CA1\u6709\u5339\u914D\u7684\u8F6E\u6B21\u3002",
4648
+ rollbackTimelineSearchLabel: "\u641C\u7D22\u68C0\u67E5\u70B9",
4649
+ rollbackTimelineSearchPlaceholder: "\u641C\u7D22\u8F6E\u6B21\u53F7\u6216\u63D0\u793A\u8BCD\u2026",
4650
+ rollbackTimelineRestoreHint: "",
4651
+ rollbackTimelineLoading: "\u6B63\u5728\u52A0\u8F7D\u68C0\u67E5\u70B9\u2026",
4652
+ rollbackTimelineFailed: "\u68C0\u67E5\u70B9\u5217\u8868\u52A0\u8F7D\u5931\u8D25\u3002\u8BF7\u91CD\u8BD5\u3002",
4653
+ rollbackTimelineEmpty: "\u6B64\u4F1A\u8BDD\u8FD8\u6CA1\u6709\u53EF\u5C55\u793A\u7684\u68C0\u67E5\u70B9\u3002",
4654
+ rollbackTimelineNoSession: "\u8BF7\u4ECE\u4F1A\u8BDD\u4E2D\u6253\u5F00\u68C0\u67E5\u70B9\u65F6\u95F4\u7EBF\u3002",
4655
+ rollbackTimelineTurn: "\u7B2C {turn} \u8F6E",
4656
+ rollbackTimelineRolledBack: "\u5DF2\u622A\u65AD",
4657
+ rollbackTimelineTip: "\u5F53\u524D\u6062\u590D\u70B9",
4658
+ rollbackTimelineOpening: "\u6B63\u5728\u6253\u5F00\u9884\u89C8\u2026",
4659
+ rollbackTimelineCoveredHint: "\u5DF2\u88AB\u66F4\u65E9\u7684\u6062\u590D\u70B9\u8986\u76D6\uFF0C\u8BF7\u5148\u64A4\u9500\u5F53\u524D\u6062\u590D\u3002",
4660
+ rollbackTimelineNoPrompt: "\u65E0\u53EF\u7528\u63D0\u793A\u8BCD\u6458\u8981",
4661
+ rollbackTimelineFileFallback: "{path}",
4662
+ rollbackTimelineFilesFallback: "{path} \u7B49 {count} \u4E2A\u6587\u4EF6",
4663
+ rollbackTimelineCoverageFiles: "{count} \u4E2A\u5DF2\u8DDF\u8E2A\u6587\u4EF6",
4664
+ rollbackTimelineCoveragePartial: "\u90E8\u5206\u5FEB\u7167 \xB7 {count} \u4E2A\u6587\u4EF6",
4665
+ rollbackTimelineCoverageConversation: "\u4EC5\u5BF9\u8BDD",
4666
+ rollbackTimelineCoverageUnknown: "\u672A\u77E5\u8986\u76D6",
4443
4667
  rollbackMessages: "\u5C06\u64A4\u56DE\u7684\u5BF9\u8BDD",
4444
4668
  rollbackFiles: "\u5C06\u6062\u590D\u7684\u5DF2\u8DDF\u8E2A\u6587\u4EF6",
4445
4669
  rollbackGaps: "\u65E0\u6CD5\u6062\u590D\u7684\u539F\u56E0",
4446
4670
  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",
4671
+ rollbackFilesLimitedHint: "\u5DF2\u8DDF\u8E2A\u6587\u672C\u6587\u4EF6\u4ECD\u53EF\u6062\u590D\uFF1B\u82E5\u6587\u4EF6\u51B2\u7A81\uFF0C\u4ECD\u53EF\u53EA\u6062\u590D\u5BF9\u8BDD\u3002",
4448
4672
  rollbackConflicts: "\u6587\u4EF6\u51B2\u7A81",
4449
4673
  rollbackNoMessages: "\u6CA1\u6709\u53EF\u9884\u89C8\u7684\u5BF9\u8BDD\u6D88\u606F\u3002",
4450
4674
  rollbackNoFiles: "\u6B64\u68C0\u67E5\u70B9\u6CA1\u6709\u5DF2\u8DDF\u8E2A\u6587\u4EF6\u3002",
4451
4675
  rollbackFile_create: "\u5220\u9664\u672C\u8F6E\u521B\u5EFA\u7684\u6587\u4EF6",
4452
4676
  rollbackFile_modify: "\u6062\u590D\u4FEE\u6539\u524D\u5185\u5BB9",
4453
4677
  rollbackFile_delete: "\u6062\u590D\u5DF2\u5220\u9664\u6587\u4EF6",
4454
- rollbackGapWorkspace: "\u5DE5\u4F5C\u533A\u6355\u83B7\u4E0D\u5B8C\u6574",
4678
+ 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
4679
  rollbackGapPrompt: "\u539F\u63D0\u793A\u8BCD\u4E0D\u662F\u7EAF\u6587\u672C",
4456
4680
  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",
4681
+ 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
4682
  rollbackUnavailableSessionChanged: "\u4F1A\u8BDD\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u9884\u89C8",
4459
4683
  rollbackUnavailableRunning: "\u4F1A\u8BDD\u4ECD\u5728\u8FD0\u884C",
4460
4684
  rollbackUnavailablePermission: "\u5F53\u524D\u6CA1\u6709\u6062\u590D\u6743\u9650",
4461
4685
  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
4686
  rollbackUnavailableIncompatible: "\u68C0\u67E5\u70B9\u4E0E\u5F53\u524D\u4F1A\u8BDD\u6216\u63D2\u4EF6\u7248\u672C\u4E0D\u517C\u5BB9",
4464
4687
  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
4688
  rollbackUnavailableSubagent: "\u5B50 Agent \u4F1A\u8BDD\u4E0D\u652F\u6301\u56DE\u6EDA",
4466
4689
  rollbackUnavailableUnknown: "\u5BF9\u8BDD\u7ED3\u6784\u65E0\u6CD5\u5B89\u5168\u8BC6\u522B",
4690
+ rollbackUnavailableAlready: "\u5BF9\u8BDD\u5DF2\u505C\u5728\u6B64\u68C0\u67E5\u70B9",
4691
+ rollbackUnavailableCovered: "\u5DF2\u88AB\u66F4\u65E9\u7684\u6062\u590D\u70B9\u8986\u76D6",
4467
4692
  rollbackConflictUnsafe: "\u6587\u4EF6\u8DEF\u5F84\u4E0D\u5B89\u5168",
4468
4693
  rollbackConflictSymlink: "\u6587\u4EF6\u8DEF\u5F84\u5305\u542B\u7B26\u53F7\u94FE\u63A5",
4469
4694
  rollbackConflictRegular: "\u5F53\u524D\u8DEF\u5F84\u4E0D\u662F\u666E\u901A\u6587\u4EF6",
4470
4695
  rollbackConflictBinary: "\u4E8C\u8FDB\u5236\u6587\u4EF6\u4E0D\u652F\u6301\u6062\u590D",
4471
4696
  rollbackConflictLarge: "\u6587\u4EF6\u8D85\u8FC7\u6062\u590D\u5927\u5C0F\u9650\u5236",
4472
4697
  rollbackConflictBefore: "\u68C0\u67E5\u70B9\u6587\u4EF6\u5185\u5BB9\u65E0\u6548",
4473
- rollbackConflictHash: "\u6587\u4EF6\u5728\u68C0\u67E5\u70B9\u540E\u53D1\u751F\u4E86\u53D8\u5316"
4698
+ rollbackConflictHash: "\u6587\u4EF6\u5728\u68C0\u67E5\u70B9\u540E\u53D1\u751F\u4E86\u53D8\u5316",
4699
+ rollbackConflictHashHint: "\u53EF\u6539\u56DE\u68C0\u67E5\u70B9\u5185\u5BB9\u540E\u91CD\u8BD5\uFF0C\u6216\u5148\u4EC5\u6062\u590D\u5BF9\u8BDD"
4474
4700
  },
4475
4701
  en: {
4476
4702
  historyTitle: "Prompt history",
@@ -4649,60 +4875,107 @@ var agentLocales = {
4649
4875
  contextInspectCompactChanged: "History changed during compaction; nothing was written. Try again.",
4650
4876
  rollback: "Conversation and file restore",
4651
4877
  rollbackDescription: "Preview and restore conversation and tracked files from eligible user messages",
4652
- rollbackBoundary: "Processes, terminals, background jobs, databases, network activity, deployments, third-party state, and untracked files are not restored. Existing logs and checkpoints remain after disable.",
4878
+ rollbackBoundary: "Auto-restores conversation projection and tracked text files only. Processes, terminals, untracked files, and binaries are out of scope. Existing logs and checkpoints remain after disable.",
4653
4879
  rollbackAction: "Restore to here",
4654
4880
  rollbackUndoAction: "Undo restore",
4655
- rollbackUndoCommandDescription: "Withdraw the latest restore marker and bring back the preview",
4881
+ rollbackUndoCommandDescription: "Withdraw the latest restore projection",
4656
4882
  rollbackTitle: "Restore before turn {turn}",
4657
4883
  rollbackUndoTitle: "Undo restore before turn {turn}",
4658
- 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.",
4659
- 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
- rollbackUndoScopeConversation: "Withdraw the conversation-only restore marker and bring back the conversation shown in preview. Tracked files stay as they are.",
4884
+ rollbackScope: "Restore conversation only, or conversation plus tracked text files. Soft gaps do not block confirm; conversation-only remains available when files conflict.",
4885
+ rollbackScopeAlready: "Already at this checkpoint. Confirm only prefills that turn\u2019s draft; use Undo restore to bring withdrawn messages back.",
4886
+ rollbackScopeCovered: "A more recent restore already sits at an earlier checkpoint. Undo that restore first, then choose this turn.",
4887
+ rollbackUndoScope: "Clear the restore projection and bring back the conversation and tracked text files shown in preview when possible.",
4888
+ rollbackUndoScopeConversation: "Clear the conversation-only restore projection and bring back the conversation shown in preview.",
4661
4889
  rollbackClose: "Close restore preview",
4662
4890
  rollbackConfirm: "Restore conversation and tracked files",
4663
4891
  rollbackConfirmConversation: "Restore conversation only",
4892
+ rollbackConfirmAlready: "Prefill draft (with files)",
4893
+ rollbackConfirmConversationAlready: "Prefill draft",
4664
4894
  rollbackUndoConfirm: "Undo restore and bring back preview",
4665
4895
  rollbackUndoConfirmConversation: "Undo restore and bring back conversation",
4666
4896
  rollbackCancel: "Cancel",
4897
+ 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.",
4898
+ rollbackCoveredByEarlier: "An earlier restore (before turn {tipTurn}) already covers this checkpoint. Undo the current restore first, then restore to this turn.",
4667
4899
  rollbackLoading: "Rechecking conversation and file state\u2026",
4668
4900
  rollbackRestoring: "Restoring conversation and tracked files\u2026",
4669
4901
  rollbackRestoringConversation: "Restoring conversation\u2026",
4670
4902
  rollbackUndoRestoring: "Undoing restore and bringing back conversation and tracked files\u2026",
4671
4903
  rollbackUndoRestoringConversation: "Undoing restore and bringing back conversation\u2026",
4672
4904
  rollbackFailed: "Restore did not complete. Close the preview and try again.",
4905
+ rollbackFailedUnavailable: "Restore is unavailable (session changed, still running, or structure incompatible). Close the preview and try again.",
4906
+ rollbackFailedConflict: "Files changed after preview, so full restore was cancelled. Use conversation-only restore, or close and preview again.",
4907
+ 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.",
4908
+ rollbackRetry: "Check again",
4673
4909
  rollbackTurnOpen: "The turn is not closed",
4674
4910
  rollbackTurnStartMissing: "The turn start is not loaded",
4911
+ rollbackSummary: "{messages} messages \xB7 {files} files",
4912
+ rollbackSummaryLabel: "Restore scope summary",
4913
+ rollbackMessageEmpty: "(no text)",
4914
+ rollbackRole_user: "User",
4915
+ rollbackRole_assistant: "Assistant",
4916
+ rollbackRole_tool: "Tool",
4917
+ rollbackRole_system: "System",
4918
+ rollbackRole_other: "Other",
4919
+ rollbackCoverageFiles: "Restore to here \xB7 {count} tracked files",
4920
+ rollbackCoveragePartial: "Restore to here \xB7 partial file snapshot ({count})",
4921
+ rollbackCoverageConversation: "Restore to here \xB7 conversation snapshot",
4922
+ rollbackTimelineTitle: "Checkpoints",
4923
+ rollbackTimelineOpen: "Checkpoint timeline",
4924
+ rollbackTimelineLead: "{turns} turns \xB7 {checkpoints} checkpoints",
4925
+ rollbackTimelineLeadRestoredNote: "Projected truncated to the current restore point.",
4926
+ rollbackTimelineFilterEmpty: "No matching turns.",
4927
+ rollbackTimelineSearchLabel: "Search checkpoints",
4928
+ rollbackTimelineSearchPlaceholder: "Search turn number or prompt\u2026",
4929
+ rollbackTimelineRestoreHint: "",
4930
+ rollbackTimelineLoading: "Loading checkpoints\u2026",
4931
+ rollbackTimelineFailed: "Could not load checkpoints. Try again.",
4932
+ rollbackTimelineEmpty: "No checkpoints to show for this session yet.",
4933
+ rollbackTimelineNoSession: "Open the checkpoint timeline from a conversation.",
4934
+ rollbackTimelineTurn: "Turn {turn}",
4935
+ rollbackTimelineRolledBack: "Truncated",
4936
+ rollbackTimelineTip: "Current restore point",
4937
+ rollbackTimelineOpening: "Opening preview\u2026",
4938
+ rollbackTimelineCoveredHint: "Covered by an earlier restore. Undo the current restore first.",
4939
+ rollbackTimelineNoPrompt: "No prompt summary available",
4940
+ rollbackTimelineFileFallback: "{path}",
4941
+ rollbackTimelineFilesFallback: "{path} \xB7 {count} files",
4942
+ rollbackTimelineCoverageFiles: "{count} tracked files",
4943
+ rollbackTimelineCoveragePartial: "Partial \xB7 {count} files",
4944
+ rollbackTimelineCoverageConversation: "Conversation only",
4945
+ rollbackTimelineCoverageUnknown: "Unknown coverage",
4675
4946
  rollbackMessages: "Conversation to withdraw",
4676
4947
  rollbackFiles: "Tracked files to restore",
4677
4948
  rollbackGaps: "Why restore is unavailable",
4678
4949
  rollbackFilesLimited: "Full restore is limited",
4679
- rollbackFilesLimitedHint: "Conversation-only restore is still available. Skip file restore when workspace capture is incomplete or files conflict.",
4950
+ rollbackFilesLimitedHint: "Tracked text files can still be restored; conversation-only remains available if files conflict.",
4680
4951
  rollbackConflicts: "File conflicts",
4681
4952
  rollbackNoMessages: "No conversation messages are available for preview.",
4682
4953
  rollbackNoFiles: "This checkpoint has no tracked files.",
4683
4954
  rollbackFile_create: "Remove file created in this turn",
4684
4955
  rollbackFile_modify: "Restore previous content",
4685
4956
  rollbackFile_delete: "Restore deleted file",
4686
- rollbackGapWorkspace: "Workspace capture is incomplete",
4957
+ rollbackGapWorkspace: "Workspace capture is incomplete (some shell side effects may be missing)",
4687
4958
  rollbackGapPrompt: "The original prompt was not plain text",
4688
4959
  rollbackUnavailableCheckpoint: "No checkpoint was found for this turn",
4689
- rollbackUnavailableIncomplete: "The checkpoint is incomplete; conversation-only restore is still available",
4960
+ rollbackUnavailableIncomplete: "The checkpoint is incomplete; tracked files and conversation restore are still available; some shell side effects may be missing",
4690
4961
  rollbackUnavailableSessionChanged: "The session changed. Preview again.",
4691
4962
  rollbackUnavailableRunning: "The session is still running",
4692
4963
  rollbackUnavailablePermission: "Restore permission is unavailable",
4693
4964
  rollbackUnavailableDisabled: "Rollback is disabled",
4694
- rollbackUnavailableFirstTurn: "The first-turn boundary is unusual; conversation-only restore may still work",
4695
4965
  rollbackUnavailableIncompatible: "The checkpoint is incompatible with this session or plugin version",
4696
4966
  rollbackUnavailableCompacted: "The conversation was compacted; full file restore may be unavailable, conversation-only restore still works",
4697
4967
  rollbackUnavailableSubagent: "Subagent sessions do not support rollback",
4698
4968
  rollbackUnavailableUnknown: "The conversation structure cannot be verified safely",
4969
+ rollbackUnavailableAlready: "Already at this checkpoint",
4970
+ rollbackUnavailableCovered: "Covered by an earlier restore",
4699
4971
  rollbackConflictUnsafe: "The file path is unsafe",
4700
4972
  rollbackConflictSymlink: "The file path contains a symbolic link",
4701
4973
  rollbackConflictRegular: "The current path is not a regular file",
4702
4974
  rollbackConflictBinary: "Binary files cannot be restored",
4703
4975
  rollbackConflictLarge: "The file exceeds the restore size limit",
4704
4976
  rollbackConflictBefore: "The checkpoint file content is invalid",
4705
- rollbackConflictHash: "File changed after this checkpoint"
4977
+ rollbackConflictHash: "File changed after this checkpoint",
4978
+ rollbackConflictHashHint: "Revert the file to the checkpoint contents, or restore conversation only"
4706
4979
  }
4707
4980
  };
4708
4981
 
@@ -4717,6 +4990,8 @@ function codec(typeSymbol) {
4717
4990
  };
4718
4991
  }
4719
4992
  var requestCodec = codec("dsh-agent-enhancer#CheckpointRollbackRequest");
4993
+ var summariesRequestCodec = codec("dsh-agent-enhancer#CheckpointSummariesRequest");
4994
+ var cutRequestCodec = codec("dsh-agent-enhancer#CheckpointCutRequest");
4720
4995
  var checkpointClientRemoteInfo = {
4721
4996
  package: "dsh-agent-enhancer",
4722
4997
  descriptors: [{
@@ -4739,6 +5014,26 @@ var checkpointClientRemoteInfo = {
4739
5014
  parameters: [{ name: "request", wire: "request", source: "json", codec: requestCodec }],
4740
5015
  cancellation: { parameter: "signal" },
4741
5016
  result: codec("dsh-agent-enhancer#CheckpointRollbackResult")
5017
+ }, {
5018
+ id: "dsh-agent-enhancer#checkpointRollback/summaries",
5019
+ service: "checkpointRollback",
5020
+ namespace: "checkpointRollback",
5021
+ method: "summaries",
5022
+ implementation: "summaries",
5023
+ invocation: { kind: "direct" },
5024
+ parameters: [{ name: "request", wire: "request", source: "json", codec: summariesRequestCodec }],
5025
+ cancellation: { parameter: "signal" },
5026
+ result: codec("dsh-agent-enhancer#CheckpointSummariesResult")
5027
+ }, {
5028
+ id: "dsh-agent-enhancer#checkpointRollback/getCut",
5029
+ service: "checkpointRollback",
5030
+ namespace: "checkpointRollback",
5031
+ method: "getCut",
5032
+ implementation: "getCut",
5033
+ invocation: { kind: "direct" },
5034
+ parameters: [{ name: "request", wire: "request", source: "json", codec: cutRequestCodec }],
5035
+ cancellation: { parameter: "signal" },
5036
+ result: codec("dsh-agent-enhancer#CheckpointCutResult")
4742
5037
  }]
4743
5038
  };
4744
5039
  var CheckpointRollbackClientError = class extends Error {
@@ -4771,6 +5066,12 @@ var checkpointRollbackRemote = {
4771
5066
  },
4772
5067
  execute(remote, request, signal) {
4773
5068
  return invoke(remote, "execute", request, signal);
5069
+ },
5070
+ summaries(remote, request, signal) {
5071
+ return invoke(remote, "summaries", request, signal);
5072
+ },
5073
+ getCut(remote, request, signal) {
5074
+ return invoke(remote, "getCut", request, signal);
4774
5075
  }
4775
5076
  };
4776
5077
 
@@ -5139,6 +5440,28 @@ function ProviderBalanceChip(props) {
5139
5440
  );
5140
5441
  }
5141
5442
 
5443
+ // src/client/rollback/failure.ts
5444
+ function rollbackErrorCodeOf(error) {
5445
+ return error instanceof CheckpointRollbackClientError ? error.code : void 0;
5446
+ }
5447
+ function rollbackFailureMessageKey(code) {
5448
+ switch (code) {
5449
+ case "ROLLBACK_UNAVAILABLE":
5450
+ return "rollbackFailedUnavailable";
5451
+ case "ROLLBACK_CONFLICT":
5452
+ return "rollbackFailedConflict";
5453
+ case "ROLLBACK_RECOVERY_FAILED":
5454
+ return "rollbackFailedRecovery";
5455
+ case "ROLLBACK_FAILED":
5456
+ case void 0:
5457
+ return "rollbackFailed";
5458
+ default: {
5459
+ const _exhaustive = code;
5460
+ return _exhaustive;
5461
+ }
5462
+ }
5463
+ }
5464
+
5142
5465
  // src/host/checkpoint/availability.ts
5143
5466
  var CONVERSATION_SOFT = /* @__PURE__ */ new Set([
5144
5467
  "incomplete-checkpoint",
@@ -5149,27 +5472,38 @@ var CONVERSATION_SOFT = /* @__PURE__ */ new Set([
5149
5472
  "compacted-surface",
5150
5473
  // Conversation restore does not need a workspace cwd.
5151
5474
  "permission-denied",
5152
- // Turn 1 is restorable; keep this soft for older previews that still emit it.
5153
- "first-turn"
5154
5475
  // Non-contiguous logs are unusual but still restorable when a surface was built.
5155
5476
  // Only emit unknown-surface when surface is missing — that case stays hard.
5477
+ // Re-confirming the active tip is a soft no-op (draft prefill / optional files).
5478
+ "already-restored",
5479
+ // Covered cuts need undo-first — UI replaces confirms with Undo, not a fatal gap list.
5480
+ "covered-by-earlier-restore"
5156
5481
  ]);
5157
5482
  var EMPTY_FILES_SOFT = /* @__PURE__ */ new Set([
5158
5483
  "incomplete-checkpoint",
5159
5484
  "workspace-capture-failed",
5160
5485
  "prompt-non-text-content",
5161
- "compacted-surface"
5486
+ "compacted-surface",
5487
+ "already-restored",
5488
+ "covered-by-earlier-restore"
5489
+ ]);
5490
+ var TRACKED_FILES_SOFT = /* @__PURE__ */ new Set([
5491
+ "incomplete-checkpoint",
5492
+ "workspace-capture-failed",
5493
+ "prompt-non-text-content",
5494
+ "already-restored",
5495
+ "covered-by-earlier-restore"
5162
5496
  ]);
5163
5497
  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;
5498
+ const trackedFiles = options.trackedFiles ?? 0;
5499
+ const soft = scope === "conversation" ? CONVERSATION_SOFT : trackedFiles === 0 ? EMPTY_FILES_SOFT : TRACKED_FILES_SOFT;
5167
5500
  return unavailable.filter((reason) => !soft.has(reason));
5168
5501
  }
5169
5502
 
5170
5503
  // src/client/rollback/scope.ts
5171
- function confirmBlocked(unavailable, conflicts, scope, trackedFiles = 0) {
5504
+ function confirmBlocked(unavailable, conflicts, scope, trackedFiles = 0, options = {}) {
5172
5505
  if (blockingUnavailable(unavailable, scope, { trackedFiles }).length > 0) return true;
5506
+ if (options.shadowRestore === true) return false;
5173
5507
  return scope === "conversation-and-files" && conflicts.length > 0;
5174
5508
  }
5175
5509
  function scopeLabel(scope) {
@@ -5180,14 +5514,30 @@ function scopeLabel(scope) {
5180
5514
  var RollbackController = class {
5181
5515
  constructor(options) {
5182
5516
  this.options = options;
5183
- this.snapshot = { enabled: options.enabled(), active: null };
5517
+ this.snapshot = { enabled: options.enabled(), active: null, coverageByTurn: {} };
5518
+ if (options.enabled()) this.refreshCoverage();
5184
5519
  }
5185
5520
  options;
5186
5521
  listeners = /* @__PURE__ */ new Set();
5522
+ surfaces = /* @__PURE__ */ new Set();
5187
5523
  operation = null;
5524
+ coverageByTurn = {};
5525
+ coverageController = null;
5188
5526
  snapshot;
5189
5527
  version = 0;
5190
5528
  disposed = false;
5529
+ /** Last agent running bit from the composer overlay; drives stale-modal refresh. */
5530
+ lastKnownRunning;
5531
+ /**
5532
+ * Modal hosts register so `open` can fall back to any mounted surface — a
5533
+ * timeline click must never leave `active` with no host willing to render it.
5534
+ */
5535
+ registerSurface(surface) {
5536
+ this.surfaces.add(surface);
5537
+ return () => {
5538
+ this.surfaces.delete(surface);
5539
+ };
5540
+ }
5191
5541
  subscribe = (listener) => {
5192
5542
  if (this.disposed) return () => {
5193
5543
  };
@@ -5202,27 +5552,74 @@ var RollbackController = class {
5202
5552
  const enabled = this.options.enabled();
5203
5553
  if (!enabled) {
5204
5554
  this.cancelOperation();
5555
+ this.clearCoverage();
5205
5556
  this.publish();
5206
5557
  return;
5207
5558
  }
5208
5559
  if (this.snapshot.enabled) return;
5209
5560
  this.publish();
5561
+ this.refreshCoverage();
5562
+ }
5563
+ /**
5564
+ * Refresh an open ready/error modal when the session run cycle flips
5565
+ * (running→idle clears session-running / recovery waits; idle→running refreshes gates).
5566
+ */
5567
+ notifySessionRunning(running) {
5568
+ if (this.disposed) return;
5569
+ const previous = this.lastKnownRunning;
5570
+ this.lastKnownRunning = running;
5571
+ if (!this.options.enabled() || previous === void 0 || previous === running) return;
5572
+ const active = this.operation;
5573
+ if (active === null || active.status === "executing" || active.status === "loading") return;
5574
+ this.open(active.turn, active.operation, {
5575
+ surface: active.surface,
5576
+ ...active.atSeq === void 0 ? {} : { atSeq: active.atSeq }
5577
+ });
5210
5578
  }
5211
- open(turn, operation = "rollback") {
5579
+ open(turn, operation = "rollback", options = {}) {
5212
5580
  if (this.disposed || !this.options.enabled() || this.operation?.status === "executing") return;
5213
5581
  this.cancelOperation();
5214
5582
  const version = ++this.version;
5215
5583
  const controller = new AbortController();
5216
- this.operation = { turn, operation, status: "loading", version, controller };
5584
+ const surface = this.resolveSurface(options.surface ?? "composer");
5585
+ this.operation = {
5586
+ turn,
5587
+ operation,
5588
+ status: "loading",
5589
+ version,
5590
+ controller,
5591
+ surface,
5592
+ ...options.atSeq === void 0 ? {} : { atSeq: options.atSeq }
5593
+ };
5217
5594
  this.publish();
5218
- const request = { sessionId: this.options.sessionId, turn, operation };
5595
+ const request = {
5596
+ sessionId: this.options.sessionId,
5597
+ turn,
5598
+ operation,
5599
+ ...options.atSeq === void 0 ? {} : { atSeq: options.atSeq }
5600
+ };
5219
5601
  void this.options.remote.preview(request, controller.signal).then((result) => {
5220
5602
  if (!this.current(version, request, result)) return;
5221
- this.operation = { ...this.operation, status: "ready", preview: result };
5603
+ this.rememberPreviewCoverage(result);
5604
+ this.operation = {
5605
+ ...this.operation,
5606
+ turn: result.turn,
5607
+ status: "ready",
5608
+ preview: result,
5609
+ ...typeof result.atSeq === "number" ? { atSeq: result.atSeq } : {}
5610
+ };
5222
5611
  this.publish();
5223
- }).catch(() => {
5612
+ }).catch((error) => {
5224
5613
  if (!this.current(version, request)) return;
5225
- this.operation = { ...this.operation, status: "error", error: "preview" };
5614
+ if (controller.signal.aborted || error instanceof Error && (error.name === "AbortError" || error.message === "AbortError")) {
5615
+ return;
5616
+ }
5617
+ this.operation = {
5618
+ ...this.operation,
5619
+ status: "error",
5620
+ error: "preview",
5621
+ ...errorFields(error)
5622
+ };
5226
5623
  this.publish();
5227
5624
  });
5228
5625
  }
@@ -5248,10 +5645,17 @@ var RollbackController = class {
5248
5645
  sessionId: this.options.sessionId,
5249
5646
  turn,
5250
5647
  operation,
5251
- scope: effectiveScope
5648
+ scope: effectiveScope,
5649
+ ...typeof preview.atSeq === "number" ? { atSeq: preview.atSeq } : {}
5252
5650
  };
5253
5651
  const controller = new AbortController();
5254
- this.operation = { ...active, status: "executing", scope: effectiveScope, controller };
5652
+ this.operation = {
5653
+ ...active,
5654
+ status: "executing",
5655
+ scope: effectiveScope,
5656
+ controller,
5657
+ surface: active.surface
5658
+ };
5255
5659
  this.publish();
5256
5660
  let result;
5257
5661
  try {
@@ -5259,63 +5663,105 @@ var RollbackController = class {
5259
5663
  } catch (error) {
5260
5664
  if (this.disposed || !this.options.enabled()) return;
5261
5665
  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();
5666
+ this.failExecute(turn, operation, preview, effectiveScope, error);
5273
5667
  return;
5274
5668
  }
5275
5669
  if (this.disposed || !this.options.enabled()) return;
5276
- 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();
5670
+ if (result === null || typeof result !== "object" || result.sessionId !== request.sessionId || Number(result.turn) !== Number(request.turn) || typeof result.draft !== "string") {
5671
+ this.failExecute(turn, operation, preview, effectiveScope);
5288
5672
  return;
5289
5673
  }
5290
5674
  try {
5291
5675
  actions.setDraft(result.draft);
5292
5676
  actions.persistDraft();
5293
5677
  } 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();
5678
+ this.failExecute(turn, operation, preview, effectiveScope);
5305
5679
  return;
5306
5680
  }
5307
5681
  this.operation = null;
5308
5682
  this.publish();
5683
+ this.refreshCoverage();
5309
5684
  }
5310
5685
  dispose() {
5311
5686
  if (this.disposed) return;
5312
5687
  this.disposed = true;
5313
5688
  this.cancelOperation();
5689
+ this.clearCoverage();
5314
5690
  this.listeners.clear();
5315
5691
  }
5692
+ refreshCoverage() {
5693
+ const summaries = this.options.remote.summaries;
5694
+ if (summaries === void 0 || this.disposed || !this.options.enabled()) return;
5695
+ this.coverageController?.abort();
5696
+ const controller = new AbortController();
5697
+ this.coverageController = controller;
5698
+ void summaries({ sessionId: this.options.sessionId }, controller.signal).then((result) => {
5699
+ if (this.disposed || controller.signal.aborted || !this.options.enabled()) return;
5700
+ if (result.sessionId !== this.options.sessionId) return;
5701
+ const next = {};
5702
+ for (const turn of result.turns) next[turn.turn] = turn;
5703
+ this.coverageByTurn = next;
5704
+ this.publish();
5705
+ }).catch(() => {
5706
+ });
5707
+ }
5708
+ rememberPreviewCoverage(preview) {
5709
+ if (preview.operation === "undo") return;
5710
+ const incomplete = preview.unavailable.includes("incomplete-checkpoint") || preview.unavailable.includes("workspace-capture-failed");
5711
+ const previous = this.coverageByTurn[preview.turn];
5712
+ this.coverageByTurn = {
5713
+ ...this.coverageByTurn,
5714
+ [preview.turn]: {
5715
+ turn: preview.turn,
5716
+ coverage: incomplete ? "partial" : "complete",
5717
+ fileCount: preview.files.length,
5718
+ createdAt: previous?.createdAt ?? Date.now(),
5719
+ atSeq: previous?.atSeq ?? 0,
5720
+ prompt: previous?.prompt ?? "",
5721
+ promptPreview: previous?.promptPreview ?? "",
5722
+ files: preview.files.map((file) => ({ path: file.path, change: file.change })),
5723
+ gaps: previous?.gaps ?? [],
5724
+ rolledBack: previous?.rolledBack ?? false,
5725
+ tip: previous?.tip ?? false
5726
+ }
5727
+ };
5728
+ }
5729
+ clearCoverage() {
5730
+ this.coverageController?.abort();
5731
+ this.coverageController = null;
5732
+ this.coverageByTurn = {};
5733
+ }
5734
+ resolveSurface(preferred) {
5735
+ if (this.surfaces.has(preferred)) return preferred;
5736
+ if (this.surfaces.has("composer")) return "composer";
5737
+ if (this.surfaces.has("timeline")) return "timeline";
5738
+ return preferred;
5739
+ }
5316
5740
  current(version, request, response) {
5317
5741
  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);
5742
+ if (this.disposed || !this.options.enabled() || this.version !== version) return false;
5743
+ if (this.operation?.version !== version || this.operation.operation !== operation) return false;
5744
+ if (response === void 0) {
5745
+ return this.operation.turn === request.turn || operation === "undo";
5746
+ }
5747
+ if (response.sessionId !== request.sessionId) return false;
5748
+ if (operation === "undo") return true;
5749
+ return Number(response.turn) === Number(request.turn);
5750
+ }
5751
+ failExecute(turn, operation, preview, scope, error) {
5752
+ this.operation = {
5753
+ turn,
5754
+ operation,
5755
+ status: "error",
5756
+ error: "execute",
5757
+ version: this.version,
5758
+ controller: new AbortController(),
5759
+ preview,
5760
+ scope,
5761
+ surface: this.operation?.surface ?? "composer",
5762
+ ...errorFields(error)
5763
+ };
5764
+ this.publish();
5319
5765
  }
5320
5766
  cancelOperation() {
5321
5767
  this.version += 1;
@@ -5325,16 +5771,59 @@ var RollbackController = class {
5325
5771
  publish() {
5326
5772
  this.snapshot = {
5327
5773
  enabled: !this.disposed && this.options.enabled(),
5774
+ coverageByTurn: this.coverageByTurn,
5328
5775
  active: this.operation === null ? null : {
5329
5776
  turn: this.operation.turn,
5330
5777
  operation: this.operation.operation,
5331
5778
  status: this.operation.status,
5332
5779
  version: this.operation.version,
5780
+ surface: this.operation.surface,
5333
5781
  ...this.operation.preview === void 0 ? {} : { preview: this.operation.preview },
5334
5782
  ...this.operation.scope === void 0 ? {} : { scope: this.operation.scope },
5335
- ...this.operation.error === void 0 ? {} : { error: this.operation.error }
5783
+ ...this.operation.error === void 0 ? {} : { error: this.operation.error },
5784
+ ...this.operation.errorCode === void 0 ? {} : { errorCode: this.operation.errorCode },
5785
+ ...this.operation.atSeq === void 0 ? {} : { atSeq: this.operation.atSeq }
5786
+ }
5787
+ };
5788
+ for (const listener of this.listeners) listener();
5789
+ }
5790
+ };
5791
+ function errorFields(error) {
5792
+ const errorCode = rollbackErrorCodeOf(error);
5793
+ return errorCode === void 0 ? {} : { errorCode };
5794
+ }
5795
+
5796
+ // src/client/rollback/cut-cache.ts
5797
+ var SessionCutCache = class {
5798
+ cuts = /* @__PURE__ */ new Map();
5799
+ listeners = /* @__PURE__ */ new Set();
5800
+ get(sessionId) {
5801
+ return this.cuts.get(sessionId);
5802
+ }
5803
+ set(sessionId, cut) {
5804
+ const previous = this.cuts.get(sessionId);
5805
+ if (previous === cut || previous !== void 0 && cut !== null && previous !== null && previous.hideTurnsFrom === cut.hideTurnsFrom && previous.cutSeq === cut.cutSeq && previous.restoredAtSeq === cut.restoredAtSeq) {
5806
+ if (previous === void 0 && cut === null) {
5807
+ this.cuts.set(sessionId, null);
5808
+ this.emit();
5336
5809
  }
5810
+ return;
5811
+ }
5812
+ this.cuts.set(sessionId, cut);
5813
+ this.emit();
5814
+ }
5815
+ clear(sessionId) {
5816
+ if (!this.cuts.has(sessionId)) return;
5817
+ this.cuts.delete(sessionId);
5818
+ this.emit();
5819
+ }
5820
+ subscribe(listener) {
5821
+ this.listeners.add(listener);
5822
+ return () => {
5823
+ this.listeners.delete(listener);
5337
5824
  };
5825
+ }
5826
+ emit() {
5338
5827
  for (const listener of this.listeners) listener();
5339
5828
  }
5340
5829
  };
@@ -5343,8 +5832,62 @@ var RollbackController = class {
5343
5832
  var import_dsh_client_ui_primitives6 = require("@deepseek-ai/dsh-client-ui-primitives");
5344
5833
  var import_react12 = require("react");
5345
5834
 
5835
+ // src/client/rollback/input-actions-cache.ts
5836
+ var cache = /* @__PURE__ */ new Map();
5837
+ var stubActions = {
5838
+ insertQuote: () => false,
5839
+ captureInsertion: () => ({ start: 0, end: 0, draftRev: 0 }),
5840
+ insertText: () => false,
5841
+ setDraft: () => {
5842
+ },
5843
+ persistDraft: () => {
5844
+ },
5845
+ addAttachments: () => false,
5846
+ removeAttachment: () => {
5847
+ },
5848
+ pruneAttachments: () => {
5849
+ },
5850
+ submit: () => {
5851
+ }
5852
+ };
5853
+ function rememberRollbackInputActions(sessionId, actions) {
5854
+ if (sessionId === void 0 || actions === void 0) return;
5855
+ cache.set(sessionId, actions);
5856
+ }
5857
+ function rollbackInputActionsFor(sessionId) {
5858
+ return cache.get(sessionId) ?? stubActions;
5859
+ }
5860
+
5346
5861
  // src/client/rollback/preview.tsx
5347
5862
  var import_dsh_client_ui_primitives5 = require("@deepseek-ai/dsh-client-ui-primitives");
5863
+
5864
+ // src/client/rollback/format.ts
5865
+ var PREVIEW_TEXT_MAX = 140;
5866
+ function truncatePreviewText(text2, max = PREVIEW_TEXT_MAX) {
5867
+ const normalized = text2.replace(/\s+/g, " ").trim();
5868
+ if (normalized.length <= max) return normalized;
5869
+ return `${normalized.slice(0, Math.max(0, max - 1)).trimEnd()}\u2026`;
5870
+ }
5871
+ function previewMessageRole(type) {
5872
+ if (type.startsWith("user/")) return "user";
5873
+ if (type.startsWith("assistant/")) return "assistant";
5874
+ if (type.startsWith("tool/")) return "tool";
5875
+ if (type.startsWith("system/") || type.startsWith("developer/")) return "system";
5876
+ return "other";
5877
+ }
5878
+ function coverageAffordance(summary) {
5879
+ if (summary === void 0) return "unknown";
5880
+ if (summary.fileCount > 0) {
5881
+ return summary.coverage === "partial" ? "partial" : "files";
5882
+ }
5883
+ return summary.coverage === "partial" ? "partial" : "conversation";
5884
+ }
5885
+ function checkpointPrimaryAction(summary) {
5886
+ if (summary?.tip === true) return "undo";
5887
+ return "restore";
5888
+ }
5889
+
5890
+ // src/client/rollback/preview.tsx
5348
5891
  var import_jsx_runtime13 = require("react/jsx-runtime");
5349
5892
  var UNAVAILABLE_KEYS = {
5350
5893
  "checkpoint-not-found": "rollbackUnavailableCheckpoint",
@@ -5355,11 +5898,12 @@ var UNAVAILABLE_KEYS = {
5355
5898
  "session-running": "rollbackUnavailableRunning",
5356
5899
  "permission-denied": "rollbackUnavailablePermission",
5357
5900
  "rollback-disabled": "rollbackUnavailableDisabled",
5358
- "first-turn": "rollbackUnavailableFirstTurn",
5359
5901
  "incompatible-session": "rollbackUnavailableIncompatible",
5360
5902
  "compacted-surface": "rollbackUnavailableCompacted",
5361
5903
  "subagent-session": "rollbackUnavailableSubagent",
5362
- "unknown-surface": "rollbackUnavailableUnknown"
5904
+ "unknown-surface": "rollbackUnavailableUnknown",
5905
+ "already-restored": "rollbackUnavailableAlready",
5906
+ "covered-by-earlier-restore": "rollbackUnavailableCovered"
5363
5907
  };
5364
5908
  var CONFLICT_KEYS = {
5365
5909
  "unsafe-path": "rollbackConflictUnsafe",
@@ -5371,12 +5915,21 @@ var CONFLICT_KEYS = {
5371
5915
  "invalid-after-image": "rollbackConflictBefore",
5372
5916
  "hash-mismatch": "rollbackConflictHash"
5373
5917
  };
5374
- function RollbackPreview({ active, t }) {
5918
+ var ROLE_KEYS = {
5919
+ user: "rollbackRole_user",
5920
+ assistant: "rollbackRole_assistant",
5921
+ tool: "rollbackRole_tool",
5922
+ system: "rollbackRole_system",
5923
+ other: "rollbackRole_other"
5924
+ };
5925
+ function RollbackPreview({ active, t, onOpenTimeline }) {
5375
5926
  if (active.status === "loading" || active.status === "executing") {
5376
5927
  const loadingKey = active.status === "loading" ? "rollbackLoading" : active.operation === "undo" ? "rollbackUndoRestoring" : "rollbackRestoring";
5377
5928
  return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { role: "status", children: t(loadingKey) });
5378
5929
  }
5379
- if (active.status === "error") return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { role: "alert", children: t("rollbackFailed") });
5930
+ if (active.status === "error") {
5931
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { role: "alert", children: t(rollbackFailureMessageKey(active.errorCode)) });
5932
+ }
5380
5933
  const preview = active.preview;
5381
5934
  if (preview === void 0) return null;
5382
5935
  const hardUnavailable = blockingUnavailable(preview.unavailable, "conversation", {
@@ -5385,17 +5938,36 @@ function RollbackPreview({ active, t }) {
5385
5938
  const filesLimited = active.operation !== "undo" && blockingUnavailable(preview.unavailable, "conversation-and-files", {
5386
5939
  trackedFiles: preview.files.length
5387
5940
  }).length > hardUnavailable.length;
5941
+ const alreadyRestored = active.operation !== "undo" && preview.unavailable.includes("already-restored");
5942
+ const coveredByEarlier = active.operation !== "undo" && preview.unavailable.includes("covered-by-earlier-restore");
5943
+ const tipTurn = preview.tipTurn;
5388
5944
  return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_dsh_client_ui_primitives5.MenuSurface, { className: css_module_default.rollbackPreview, children: [
5945
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: css_module_default.rollbackSummaryRow, children: [
5946
+ /* @__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 }) }),
5947
+ onOpenTimeline === void 0 || active.operation === "undo" ? null : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
5948
+ "button",
5949
+ {
5950
+ type: "button",
5951
+ className: css_module_default.rollbackTimelineLink,
5952
+ onClick: () => {
5953
+ onOpenTimeline(active.turn);
5954
+ },
5955
+ children: t("rollbackTimelineOpen")
5956
+ }
5957
+ )
5958
+ ] }),
5959
+ alreadyRestored ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: css_module_default.rollbackAlready, role: "status", children: t("rollbackAlreadyRestored") }) : null,
5960
+ coveredByEarlier ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: css_module_default.rollbackAlready, role: "status", children: t("rollbackCoveredByEarlier", { tipTurn: tipTurn ?? active.turn }) }) : null,
5389
5961
  /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("section", { className: css_module_default.rollbackSection, "aria-label": t("rollbackMessages"), children: [
5390
5962
  /* @__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)) })
5963
+ 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) => {
5964
+ const role = previewMessageRole(message.type);
5965
+ const text2 = truncatePreviewText(message.text);
5966
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("li", { className: css_module_default.rollbackMessage, children: [
5967
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: css_module_default.rollbackMeta, children: t(ROLE_KEYS[role]) }),
5968
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: text2.length === 0 ? t("rollbackMessageEmpty") : text2 })
5969
+ ] }, message.seq);
5970
+ }) })
5399
5971
  ] }),
5400
5972
  /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("section", { className: css_module_default.rollbackSection, "aria-label": t("rollbackFiles"), children: [
5401
5973
  /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("h3", { children: t("rollbackFiles") }),
@@ -5416,12 +5988,15 @@ function RollbackPreview({ active, t }) {
5416
5988
  /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("h3", { children: t("rollbackConflicts") }),
5417
5989
  /* @__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
5990
  /* @__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]) })
5991
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: css_module_default.rollbackConflict, children: [
5992
+ t(CONFLICT_KEYS[conflict.reason]),
5993
+ conflict.reason === "hash-mismatch" ? ` \xB7 ${t("rollbackConflictHashHint")}` : null
5994
+ ] })
5420
5995
  ] }, `${conflict.path}:${conflict.reason}`)) })
5421
5996
  ] })
5422
5997
  ] });
5423
5998
  }
5424
- function rollbackModalCopy(operation, t, turn, scope) {
5999
+ function rollbackModalCopy(operation, t, turn, scope, alreadyRestored = false, coveredByEarlier = false) {
5425
6000
  if (operation === "undo") {
5426
6001
  const conversationOnly = scope === "conversation";
5427
6002
  return {
@@ -5433,11 +6008,21 @@ function rollbackModalCopy(operation, t, turn, scope) {
5433
6008
  executingConversation: t("rollbackUndoRestoringConversation")
5434
6009
  };
5435
6010
  }
6011
+ if (coveredByEarlier) {
6012
+ return {
6013
+ title: t("rollbackTitle", { turn }),
6014
+ description: t("rollbackScopeCovered"),
6015
+ confirm: t("rollbackConfirm"),
6016
+ confirmConversation: t("rollbackConfirmConversation"),
6017
+ executing: t("rollbackRestoring"),
6018
+ executingConversation: t("rollbackRestoringConversation")
6019
+ };
6020
+ }
5436
6021
  return {
5437
6022
  title: t("rollbackTitle", { turn }),
5438
- description: t("rollbackScope"),
5439
- confirm: t("rollbackConfirm"),
5440
- confirmConversation: t("rollbackConfirmConversation"),
6023
+ description: t(alreadyRestored ? "rollbackScopeAlready" : "rollbackScope"),
6024
+ confirm: t(alreadyRestored ? "rollbackConfirmAlready" : "rollbackConfirm"),
6025
+ confirmConversation: t(alreadyRestored ? "rollbackConfirmConversationAlready" : "rollbackConfirmConversation"),
5441
6026
  executing: t("rollbackRestoring"),
5442
6027
  executingConversation: t("rollbackRestoringConversation")
5443
6028
  };
@@ -5446,23 +6031,39 @@ function rollbackModalCopy(operation, t, turn, scope) {
5446
6031
  // src/client/rollback/modal-host.tsx
5447
6032
  var import_jsx_runtime14 = require("react/jsx-runtime");
5448
6033
  function RollbackModalHost(props) {
6034
+ const surface = props.surface ?? "composer";
5449
6035
  const snapshot = (0, import_react12.useSyncExternalStore)(props.rollback.subscribe, props.rollback.getSnapshot);
5450
6036
  const active = snapshot.active;
6037
+ const owned = active !== null && active.surface === surface;
6038
+ const running = props.useSession === void 0 ? false : props.useSession((state) => state.running);
5451
6039
  const trackedFiles = active?.preview?.files.length ?? 0;
5452
6040
  const undoScope = scopeLabel(active?.scope ?? active?.preview?.scope);
5453
6041
  const conversationBlocked = active?.preview === void 0 || confirmBlocked(active.preview.unavailable, active.preview.conflicts, "conversation", trackedFiles);
5454
6042
  const filesBlocked = active?.preview === void 0 || confirmBlocked(active.preview.unavailable, active.preview.conflicts, "conversation-and-files", trackedFiles);
5455
6043
  const undoBlocked = active?.preview === void 0 || confirmBlocked(active.preview.unavailable, active.preview.conflicts, undoScope, trackedFiles);
5456
- const modal = active === null ? null : rollbackModalCopy(
6044
+ const alreadyRestored = owned && active?.operation === "rollback" && active.preview?.unavailable.includes("already-restored") === true;
6045
+ const coveredByEarlier = owned && active?.operation === "rollback" && active.preview?.unavailable.includes("covered-by-earlier-restore") === true;
6046
+ const modal = !owned || active === null ? null : rollbackModalCopy(
5457
6047
  active.operation,
5458
6048
  props.t,
5459
6049
  active.turn,
5460
- active.operation === "undo" ? undoScope : void 0
6050
+ active.operation === "undo" ? undoScope : void 0,
6051
+ alreadyRestored,
6052
+ coveredByEarlier
5461
6053
  );
5462
6054
  const ready = active?.status === "ready";
5463
6055
  const executing = active?.status === "executing";
6056
+ const errored = active?.status === "error";
5464
6057
  (0, import_react12.useEffect)(() => {
5465
- if (active === null) return;
6058
+ rememberRollbackInputActions(props.sessionId, props.inputActions);
6059
+ }, [props.sessionId, props.inputActions]);
6060
+ (0, import_react12.useEffect)(() => props.rollback.registerSurface(surface), [props.rollback, surface]);
6061
+ (0, import_react12.useEffect)(() => {
6062
+ if (!owned) return;
6063
+ props.rollback.notifySessionRunning(running);
6064
+ }, [props.rollback, running, owned]);
6065
+ (0, import_react12.useEffect)(() => {
6066
+ if (!owned || active === null) return;
5466
6067
  const dialog = document.querySelector(`.${css_module_default.rollbackDialog}`);
5467
6068
  const parent = dialog?.parentElement;
5468
6069
  const byAria = parent?.querySelector('[aria-hidden="true"]');
@@ -5481,8 +6082,8 @@ function RollbackModalHost(props) {
5481
6082
  mask.removeEventListener(type, stop, true);
5482
6083
  }
5483
6084
  };
5484
- }, [active]);
5485
- if (!snapshot.enabled || active === null || modal === null) return null;
6085
+ }, [active, owned]);
6086
+ if (!snapshot.enabled || !owned || active === null || modal === null) return null;
5486
6087
  const requestClose = () => {
5487
6088
  if (active.status === "executing") return;
5488
6089
  props.rollback.close(active.turn);
@@ -5491,6 +6092,18 @@ function RollbackModalHost(props) {
5491
6092
  if (active.status !== "ready" || executing) return;
5492
6093
  void props.rollback.confirm(props.inputActions, scope);
5493
6094
  };
6095
+ const runUndoInstead = () => {
6096
+ if (active.status === "executing") return;
6097
+ const tipTurn = active.preview?.tipTurn ?? active.turn;
6098
+ props.rollback.open(tipTurn, "undo", { surface: active.surface });
6099
+ };
6100
+ const runRetry = () => {
6101
+ if (active.status !== "error") return;
6102
+ props.rollback.open(active.turn, active.operation, {
6103
+ surface: active.surface,
6104
+ ...active.atSeq === void 0 && active.preview?.atSeq === void 0 ? {} : { atSeq: active.atSeq ?? active.preview?.atSeq }
6105
+ });
6106
+ };
5494
6107
  return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
5495
6108
  import_dsh_client_ui_primitives6.Modal,
5496
6109
  {
@@ -5511,7 +6124,7 @@ function RollbackModalHost(props) {
5511
6124
  children: props.t("rollbackCancel")
5512
6125
  }
5513
6126
  ),
5514
- active.operation === "undo" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
6127
+ 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
6128
  import_dsh_client_ui_primitives6.Button,
5516
6129
  {
5517
6130
  type: "button",
@@ -5522,7 +6135,25 @@ function RollbackModalHost(props) {
5522
6135
  },
5523
6136
  children: executing ? modal.executing : modal.confirm
5524
6137
  }
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: [
6138
+ ) : 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)(
6139
+ import_dsh_client_ui_primitives6.Button,
6140
+ {
6141
+ type: "button",
6142
+ "data-modal-autofocus": true,
6143
+ disabled: !ready,
6144
+ onClick: runUndoInstead,
6145
+ children: props.t("rollbackUndoAction")
6146
+ }
6147
+ ) : /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
6148
+ alreadyRestored ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
6149
+ import_dsh_client_ui_primitives6.Button,
6150
+ {
6151
+ type: "button",
6152
+ disabled: !ready,
6153
+ onClick: runUndoInstead,
6154
+ children: props.t("rollbackUndoAction")
6155
+ }
6156
+ ) : null,
5526
6157
  /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
5527
6158
  import_dsh_client_ui_primitives6.Button,
5528
6159
  {
@@ -5548,7 +6179,14 @@ function RollbackModalHost(props) {
5548
6179
  )
5549
6180
  ] })
5550
6181
  ] }),
5551
- children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(RollbackPreview, { active, t: props.t })
6182
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
6183
+ RollbackPreview,
6184
+ {
6185
+ active,
6186
+ t: props.t,
6187
+ onOpenTimeline: props.onOpenTimeline
6188
+ }
6189
+ )
5552
6190
  }
5553
6191
  );
5554
6192
  }
@@ -5583,6 +6221,21 @@ function installRollbackUndoCommand(options) {
5583
6221
  };
5584
6222
  }
5585
6223
 
6224
+ // src/client/rollback/prompt-entries.ts
6225
+ function promptsFromSessionEntries(entries) {
6226
+ const out = [];
6227
+ for (const entry of entries) {
6228
+ if (entry.type !== "event") continue;
6229
+ const event = entry.event;
6230
+ if (event.type !== "user/message") continue;
6231
+ if (event.data.source.kind !== "user") continue;
6232
+ const text2 = event.data.content.flatMap((block2) => block2.type === "text" ? [block2.text] : []).join("");
6233
+ if (text2.trim() === "") continue;
6234
+ out.push({ seq: Number(event.seq), text: text2 });
6235
+ }
6236
+ return out;
6237
+ }
6238
+
5586
6239
  // src/identity.ts
5587
6240
  var PACKAGE_NAME = "dsh-agent-enhancer";
5588
6241
  var LEGACY_PACKAGE_NAME = "dsh-composer-enhancer";
@@ -5596,18 +6249,91 @@ function isRollbackId(id) {
5596
6249
  function isUndoId(id) {
5597
6250
  return id.startsWith(UNDO_PREFIX) || id.startsWith(LEGACY_UNDO_PREFIX);
5598
6251
  }
6252
+ function indexOfRollbackPrefix(id) {
6253
+ const current = id.indexOf(ROLLBACK_PREFIX);
6254
+ if (current >= 0) return current;
6255
+ return id.indexOf(LEGACY_ROLLBACK_PREFIX);
6256
+ }
5599
6257
  function turnFromRollbackId(id) {
5600
6258
  for (const prefix of [ROLLBACK_PREFIX, LEGACY_ROLLBACK_PREFIX]) {
5601
6259
  if (!id.startsWith(prefix)) continue;
5602
6260
  const match = new RegExp(`^${escapeRegExp(prefix)}(\\d+):`).exec(id);
5603
6261
  if (match !== null) return Number(match[1]);
5604
6262
  }
6263
+ const embedded = indexOfRollbackPrefix(id);
6264
+ if (embedded > 0) return turnFromRollbackId(id.slice(embedded));
5605
6265
  return void 0;
5606
6266
  }
5607
6267
  function escapeRegExp(value) {
5608
6268
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
5609
6269
  }
5610
6270
 
6271
+ // src/host/checkpoint/activity.ts
6272
+ function surfaceMessageId(event) {
6273
+ switch (event.type) {
6274
+ case "user/message":
6275
+ return event.data.id;
6276
+ case "system/message":
6277
+ case "developer/message":
6278
+ case "assistant/message":
6279
+ case "tool/result":
6280
+ return event.data.message.id;
6281
+ default:
6282
+ return null;
6283
+ }
6284
+ }
6285
+ function isUndoCopyEvent(event) {
6286
+ const id = surfaceMessageId(event);
6287
+ return id !== null && isUndoId(id);
6288
+ }
6289
+ function isRollbackScaffoldEvent(event) {
6290
+ if (event.type !== "user/message") return false;
6291
+ if (isRollbackId(event.data.id)) return true;
6292
+ return event.data.source.kind === "checkpoint-rollback";
6293
+ }
6294
+ function undoShellRanges(events) {
6295
+ const ranges = [];
6296
+ let turn;
6297
+ let startSeq = 0;
6298
+ let sawUndo = false;
6299
+ let sawReal = false;
6300
+ let lastSeq = 0;
6301
+ const flush = () => {
6302
+ if (turn !== void 0 && sawUndo && !sawReal) {
6303
+ ranges.push({ turn, startSeq, endSeq: lastSeq });
6304
+ }
6305
+ sawUndo = false;
6306
+ sawReal = false;
6307
+ };
6308
+ for (const event of events) {
6309
+ lastSeq = Number(event.seq);
6310
+ if (event.type === "turn/start") {
6311
+ flush();
6312
+ turn = event.data.turn;
6313
+ startSeq = lastSeq;
6314
+ continue;
6315
+ }
6316
+ if (event.type === "turn/end" && turn !== void 0 && event.data.turn === turn) {
6317
+ flush();
6318
+ turn = void 0;
6319
+ continue;
6320
+ }
6321
+ if (turn === void 0 || isRollbackScaffoldEvent(event)) continue;
6322
+ if (isUndoCopyEvent(event)) {
6323
+ sawUndo = true;
6324
+ continue;
6325
+ }
6326
+ if (event.type === "user/message" || event.type === "assistant/message" || event.type === "tool/result" || event.type === "system/message" || event.type === "developer/message") {
6327
+ sawReal = true;
6328
+ }
6329
+ }
6330
+ flush();
6331
+ return ranges;
6332
+ }
6333
+ function inUndoShellRange(seq, ranges) {
6334
+ return ranges.some((range) => seq >= range.startSeq && seq <= range.endSeq);
6335
+ }
6336
+
5611
6337
  // src/client/rollback/marker.ts
5612
6338
  function isRollbackMarkerSource(source) {
5613
6339
  return source?.kind === "checkpoint-rollback";
@@ -5635,18 +6361,8 @@ function isRollbackMarkerEvent(event) {
5635
6361
  if (event.type !== "user/message") return false;
5636
6362
  return isRollbackMarkerMessage(event.data.source, event.data.id);
5637
6363
  }
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
- }
6364
+ function isUndoCopyEvent2(event) {
6365
+ return isUndoCopyEvent(event);
5650
6366
  }
5651
6367
  function markerStillActive(marker, events) {
5652
6368
  return !events.some((event) => {
@@ -5658,6 +6374,24 @@ function markerStillActive(marker, events) {
5658
6374
  function asAppend(event) {
5659
6375
  return { ...event, surfaceOp: "append" };
5660
6376
  }
6377
+ function asBookkeepingTip(event) {
6378
+ if (event.type !== "user/message") return asAppend(event);
6379
+ const source = event.data.source;
6380
+ const alreadyHidden = surfaceOpOf(event) === "append" && source.kind === "checkpoint-rollback";
6381
+ if (alreadyHidden) return event;
6382
+ return {
6383
+ ...event,
6384
+ surfaceOp: "append",
6385
+ data: {
6386
+ ...event.data,
6387
+ source: {
6388
+ kind: "checkpoint-rollback",
6389
+ form: "notice",
6390
+ ...typeof source.summary === "string" ? { summary: source.summary } : {}
6391
+ }
6392
+ }
6393
+ };
6394
+ }
5661
6395
  function turnOfEvent(event) {
5662
6396
  if (event.type === "turn/start" || event.type === "turn/end" || event.type === "step/start" || event.type === "step/end") {
5663
6397
  return event.data.turn;
@@ -5665,43 +6399,221 @@ function turnOfEvent(event) {
5665
6399
  const data = event.data;
5666
6400
  return typeof data.turn === "number" ? data.turn : void 0;
5667
6401
  }
5668
- function activeMarkersOf(events) {
5669
- return events.filter((event) => isRollbackMarkerEvent(event) && markerStillActive(event, events));
6402
+ function activeTipMarkers(events) {
6403
+ const markers = [];
6404
+ for (const event of events) {
6405
+ if (!isRollbackMarkerEvent(event) || !markerStillActive(event, events)) continue;
6406
+ markers.push(event);
6407
+ }
6408
+ if (markers.length === 0) return markers;
6409
+ const latestSeq = Math.max(...markers.map((event) => Number(event.seq)));
6410
+ if (events.some((event) => Number(event.seq) > latestSeq && isUndoCopyEvent2(event))) {
6411
+ return [];
6412
+ }
6413
+ return markers;
5670
6414
  }
5671
- function activeRollbackHideTurnsFrom(entries) {
5672
- const events = entries.flatMap((entry) => entry.type === "event" ? [entry.event] : []);
6415
+ function liveTipMarker(events) {
6416
+ const markers = activeTipMarkers(events);
6417
+ if (markers.length === 0) return void 0;
6418
+ return markers.reduce((latest, event) => Number(event.seq) >= Number(latest.seq) ? event : latest);
6419
+ }
6420
+ function activeRollbackHideTurnsFrom(entries, cut) {
6421
+ if (cut !== null && cut !== void 0) return cut.hideTurnsFrom;
5673
6422
  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
- }
6423
+ for (const tip of activeTipMarkers(entries.flatMap((entry) => entry.type === "event" ? [entry.event] : []))) {
6424
+ if (tip.type !== "user/message") continue;
6425
+ const turn = turnFromRollbackMarkerId(tip.data.id);
6426
+ if (turn === void 0) continue;
6427
+ hideTurnsFrom = hideTurnsFrom === void 0 ? turn : Math.min(hideTurnsFrom, turn);
5679
6428
  }
5680
6429
  return hideTurnsFrom;
5681
6430
  }
5682
- function activeRollbackContinueAfterSeq(entries) {
5683
- const markers = activeMarkersOf(entries.flatMap((entry) => entry.type === "event" ? [entry.event] : []));
6431
+ function activeRollbackContinueAfterSeq(entries, cut) {
6432
+ if (cut !== null && cut !== void 0) return cut.restoredAtSeq;
6433
+ const tip = liveTipMarker(entries.flatMap((entry) => entry.type === "event" ? [entry.event] : []));
6434
+ return tip === void 0 ? void 0 : Number(tip.seq);
6435
+ }
6436
+ function keepPrefixLoadThroughSeq(entries, cut) {
6437
+ if (cut !== null && cut !== void 0) return Math.max(0, cut.cutSeq);
6438
+ const markers = activeTipMarkers(entries.flatMap((entry) => entry.type === "event" ? [entry.event] : []));
5684
6439
  if (markers.length === 0) return void 0;
5685
- return Math.max(...markers.map((event) => Number(event.seq)));
6440
+ let minShadowed;
6441
+ for (const marker of markers) {
6442
+ for (const seq of marker.sourceEventSeqs ?? []) {
6443
+ const value = Number(seq);
6444
+ if (!Number.isFinite(value)) continue;
6445
+ minShadowed = minShadowed === void 0 ? value : Math.min(minShadowed, value);
6446
+ }
6447
+ }
6448
+ if (minShadowed === void 0) return void 0;
6449
+ return Math.max(0, minShadowed - 1);
6450
+ }
6451
+ function hasKeepPrefixConversation(entries) {
6452
+ return entries.some((entry) => {
6453
+ if (entry.type !== "event") return false;
6454
+ const event = entry.event;
6455
+ if (event.type !== "user/message" && event.type !== "assistant/message") return false;
6456
+ return !isRollbackMarkerEvent(event) && !isUndoCopyEvent2(event);
6457
+ });
6458
+ }
6459
+ function needsKeepPrefixHistory(entries, hasMore, cut) {
6460
+ if (!hasMore) return false;
6461
+ if (keepPrefixLoadThroughSeq(entries, cut) === void 0) return false;
6462
+ return !hasKeepPrefixConversation(entries);
5686
6463
  }
5687
- function activeRollbackUndoTip(entries) {
6464
+ function activeRollbackUndoTip(entries, cut) {
6465
+ if (cut !== null && cut !== void 0) {
6466
+ const events2 = entries.flatMap((entry) => entry.type === "event" ? [entry.event] : []);
6467
+ const later2 = events2.some((event) => Number(event.seq) > cut.restoredAtSeq && !isRollbackMarkerEvent(event) && !isUndoCopyEvent2(event));
6468
+ return later2 ? void 0 : { turn: cut.hideTurnsFrom };
6469
+ }
5688
6470
  const events = entries.flatMap((entry) => entry.type === "event" ? [entry.event] : []);
5689
- let tip;
6471
+ const tip = liveTipMarker(events);
6472
+ if (tip === void 0 || tip.type !== "user/message") return void 0;
6473
+ const turn = turnFromRollbackMarkerId(tip.data.id);
6474
+ if (turn === void 0) return void 0;
6475
+ const later = events.some((event) => Number(event.seq) > Number(tip.seq) && !isRollbackMarkerEvent(event) && !isUndoCopyEvent2(event));
6476
+ return later ? void 0 : { turn };
6477
+ }
6478
+ function undoShellRangesFromEntries(entries) {
6479
+ return undoShellRanges(entries.flatMap((entry) => entry.type === "event" ? [entry.event] : []));
6480
+ }
6481
+ function undoSourceSeqOf(id) {
6482
+ const match = /:(\d+)(?::(?:dsh-agent-enhancer|dsh-composer-enhancer):rollback:.*)?$/.exec(id);
6483
+ if (match === null) return void 0;
6484
+ const seq = Number(match[1]);
6485
+ return Number.isFinite(seq) ? seq : void 0;
6486
+ }
6487
+ function surfaceMessageIdOf(event) {
6488
+ switch (event.type) {
6489
+ case "user/message":
6490
+ return event.data.id;
6491
+ case "system/message":
6492
+ case "developer/message":
6493
+ case "assistant/message":
6494
+ case "tool/result":
6495
+ return event.data.message.id;
6496
+ default:
6497
+ return null;
6498
+ }
6499
+ }
6500
+ function asUnmaskedUndoCopy(event, bySeq) {
6501
+ const append = surfaceOpOf(event) === "append" ? event : asAppend(event);
6502
+ const id = surfaceMessageIdOf(event);
6503
+ if (id === null) return append;
6504
+ const sourceSeq = undoSourceSeqOf(id);
6505
+ const original = sourceSeq === void 0 ? void 0 : bySeq.get(sourceSeq);
6506
+ if (original === void 0) return append;
6507
+ const originalTurn = turnOfEvent(original);
6508
+ const originalStep = original.data.step;
6509
+ const data = append.data;
6510
+ const needsTurn = typeof originalTurn === "number" && data.turn !== originalTurn;
6511
+ const needsStep = typeof originalStep === "number" && data.step !== originalStep;
6512
+ if (!needsTurn && !needsStep && append === event) return event;
6513
+ if (!needsTurn && !needsStep) return append;
6514
+ return {
6515
+ ...append,
6516
+ data: {
6517
+ ...append.data,
6518
+ ...typeof originalTurn === "number" ? { turn: originalTurn } : {},
6519
+ ...typeof originalStep === "number" ? { step: originalStep } : {}
6520
+ }
6521
+ };
6522
+ }
6523
+ function activityStatsFromEvents(events) {
6524
+ const closed = /* @__PURE__ */ new Set();
6525
+ const turns = /* @__PURE__ */ new Set();
5690
6526
  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) };
6527
+ if (event.type !== "step/end") continue;
6528
+ const key = `${event.data.turn}:${event.data.step}`;
6529
+ if (closed.has(key)) continue;
6530
+ closed.add(key);
6531
+ turns.add(event.data.turn);
6532
+ }
6533
+ if (closed.size > 0) return { turns: turns.size, steps: closed.size };
6534
+ let steps = 0;
6535
+ for (const event of events) {
6536
+ if (event.type === "turn/start") {
6537
+ turns.add(event.data.turn);
6538
+ continue;
6539
+ }
6540
+ if (event.type !== "assistant/message" || isRollbackMarkerEvent(event)) continue;
6541
+ steps += 1;
6542
+ const turn = turnOfEvent(event);
6543
+ if (turn !== void 0) turns.add(turn);
6544
+ }
6545
+ return { turns: turns.size, steps };
6546
+ }
6547
+ function sourceTurnStepOf(event, bySeq) {
6548
+ const id = surfaceMessageIdOf(event);
6549
+ if (id === null) return void 0;
6550
+ const sourceSeq = undoSourceSeqOf(id);
6551
+ const original = sourceSeq === void 0 ? void 0 : bySeq.get(sourceSeq);
6552
+ if (original !== void 0) {
6553
+ const turn2 = turnOfEvent(original);
6554
+ const step2 = original.data.step;
6555
+ if (typeof turn2 === "number" && typeof step2 === "number") return { turn: turn2, step: step2 };
6556
+ }
6557
+ const turn = turnOfEvent(event);
6558
+ const step = event.data.step;
6559
+ if (typeof turn === "number" && typeof step === "number") return { turn, step };
6560
+ return void 0;
6561
+ }
6562
+ function stepKey(turn, step) {
6563
+ return `${turn}:${step}`;
6564
+ }
6565
+ function collectStepChromeKeys(entries) {
6566
+ const starts = /* @__PURE__ */ new Set();
6567
+ const ends = /* @__PURE__ */ new Set();
6568
+ for (const entry of entries) {
6569
+ if (entry.type !== "event") continue;
6570
+ const event = entry.event;
6571
+ if (event.type === "step/start") starts.add(stepKey(event.data.turn, event.data.step));
6572
+ if (event.type === "step/end") ends.add(stepKey(event.data.turn, event.data.step));
6573
+ }
6574
+ return { starts, ends };
6575
+ }
6576
+ function remapUndoShellStep(event, range, events, bySeq, present) {
6577
+ if (event.type !== "step/start" && event.type !== "step/end") return null;
6578
+ let coords;
6579
+ for (const candidate of events) {
6580
+ const seq = Number(candidate.seq);
6581
+ if (seq < range.startSeq || seq > range.endSeq) continue;
6582
+ if (!isUndoCopyEvent2(candidate)) continue;
6583
+ coords = sourceTurnStepOf(candidate, bySeq);
6584
+ if (coords !== void 0) break;
6585
+ }
6586
+ if (coords === void 0) {
6587
+ const turn = event.data.turn;
6588
+ const step = event.data.step;
6589
+ coords = { turn, step };
6590
+ }
6591
+ const key = stepKey(coords.turn, coords.step);
6592
+ if (event.type === "step/start" && present.starts.has(key)) return null;
6593
+ if (event.type === "step/end" && present.ends.has(key)) return null;
6594
+ if (event.type === "step/start") present.starts.add(key);
6595
+ else present.ends.add(key);
6596
+ if (event.data.turn === coords.turn && event.data.step === coords.step && surfaceOpOf(event) === "append") {
6597
+ return event;
5696
6598
  }
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 };
6599
+ return {
6600
+ ...asAppend(event),
6601
+ data: { ...event.data, turn: coords.turn, step: coords.step }
6602
+ };
5700
6603
  }
5701
- function filterTurnOutline(outline, hideTurnsFrom, continueAfterSeq) {
5702
- if (hideTurnsFrom === void 0 || !Array.isArray(outline)) return outline;
6604
+ function activityStatsFromEntries(entries) {
6605
+ const presented = presentRollbackTranscript(entries);
6606
+ return activityStatsFromEvents(
6607
+ presented.flatMap((entry) => entry.type === "event" ? [entry.event] : [])
6608
+ );
6609
+ }
6610
+ function filterTurnOutline(outline, hideTurnsFrom, continueAfterSeq, omitShellRanges) {
6611
+ if (!Array.isArray(outline)) return outline;
6612
+ if (hideTurnsFrom === void 0 && (omitShellRanges === void 0 || omitShellRanges.length === 0)) return outline;
5703
6613
  const next = outline.filter((entry) => {
5704
6614
  if (!isRecord(entry) || typeof entry.turn !== "number") return true;
6615
+ if (typeof entry.seq === "number" && omitShellRanges !== void 0 && inUndoShellRange(entry.seq, omitShellRanges)) return false;
6616
+ if (hideTurnsFrom === void 0) return true;
5705
6617
  if (entry.turn < hideTurnsFrom) return true;
5706
6618
  return continueAfterSeq !== void 0 && typeof entry.seq === "number" && entry.seq > continueAfterSeq;
5707
6619
  });
@@ -5759,70 +6671,89 @@ function renumberCollidingTurns(entries) {
5759
6671
  });
5760
6672
  return changed ? next : entries;
5761
6673
  }
5762
- function presentRollbackTranscript(entries) {
6674
+ function presentRollbackTranscript(entries, cut) {
5763
6675
  const events = entries.flatMap((entry) => entry.type === "event" ? [entry.event] : []);
6676
+ const bySeq = new Map(events.map((event) => [Number(event.seq), event]));
5764
6677
  const everShadowed = /* @__PURE__ */ new Set();
5765
- const activeMarkers = /* @__PURE__ */ new Set();
5766
- const hideTurnsFrom = activeRollbackHideTurnsFrom(entries);
5767
- const continueAfterSeq = activeRollbackContinueAfterSeq(entries);
5768
- const undoneTurnCuts = /* @__PURE__ */ new Map();
6678
+ const liveTip = cut !== null && cut !== void 0 ? void 0 : liveTipMarker(events);
6679
+ const liveTipSeq = liveTip === void 0 ? void 0 : Number(liveTip.seq);
6680
+ const hideTurnsFrom = activeRollbackHideTurnsFrom(entries, cut);
6681
+ const continueAfterSeq = activeRollbackContinueAfterSeq(entries, cut);
6682
+ const undoRanges = undoShellRanges(events);
5769
6683
  for (const event of events) {
5770
6684
  if (!isRollbackMarkerEvent(event)) continue;
5771
6685
  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
6686
  }
5787
- if (everShadowed.size === 0 && activeMarkers.size === 0 && !events.some(isUndoCopyEvent)) return renumberCollidingTurns(entries);
6687
+ const hasCut = cut !== null && cut !== void 0;
6688
+ if (!hasCut && everShadowed.size === 0 && liveTipSeq === void 0 && undoRanges.length === 0 && !events.some(isUndoCopyEvent2)) return renumberCollidingTurns(entries);
5788
6689
  let changed = false;
5789
6690
  const next = [];
6691
+ const presentSteps = collectStepChromeKeys([]);
5790
6692
  for (const entry of entries) {
5791
6693
  if (entry.type !== "event") {
5792
6694
  next.push(entry);
5793
6695
  continue;
5794
6696
  }
5795
6697
  const event = entry.event;
5796
- if (everShadowed.has(Number(event.seq))) {
6698
+ const seq = Number(event.seq);
6699
+ if (hasCut && seq > cut.cutSeq && seq <= cut.restoredAtSeq) {
5797
6700
  changed = true;
5798
6701
  continue;
5799
6702
  }
5800
- 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) {
6703
+ if (everShadowed.has(seq)) {
5803
6704
  changed = true;
5804
6705
  continue;
5805
6706
  }
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)) {
6707
+ const ownedTurn = turnOfEvent(event);
6708
+ const shell = undoRanges.find((range) => seq >= range.startSeq && seq <= range.endSeq);
6709
+ if (shell !== void 0) {
6710
+ if (event.type === "turn/start" || event.type === "turn/end" || event.type === "tool/call") {
6711
+ changed = true;
6712
+ continue;
6713
+ }
6714
+ if (event.type === "step/start" || event.type === "step/end") {
6715
+ const remapped = remapUndoShellStep(event, shell, events, bySeq, presentSteps);
6716
+ changed = true;
6717
+ if (remapped === null) continue;
6718
+ next.push({ type: "event", event: remapped });
6719
+ continue;
6720
+ }
6721
+ }
6722
+ const beforeTip = continueAfterSeq === void 0 || seq <= continueAfterSeq;
6723
+ if (!hasCut && hideTurnsFrom !== void 0 && ownedTurn !== void 0 && ownedTurn >= hideTurnsFrom && beforeTip && !isRollbackMarkerEvent(event) && !isUndoCopyEvent2(event)) {
5808
6724
  changed = true;
5809
6725
  continue;
5810
6726
  }
6727
+ if (event.type === "step/start") {
6728
+ presentSteps.starts.add(stepKey(event.data.turn, event.data.step));
6729
+ } else if (event.type === "step/end") {
6730
+ presentSteps.ends.add(stepKey(event.data.turn, event.data.step));
6731
+ }
5811
6732
  if (isRollbackMarkerEvent(event)) {
5812
- if (!activeMarkers.has(Number(event.seq))) {
6733
+ if (hasCut) {
5813
6734
  changed = true;
5814
6735
  continue;
5815
6736
  }
5816
- if (surfaceOpOf(event) === "append") {
6737
+ if (liveTipSeq === void 0 || Number(event.seq) !== liveTipSeq) {
6738
+ changed = true;
6739
+ continue;
6740
+ }
6741
+ const tip = asBookkeepingTip(event);
6742
+ if (tip === event && surfaceOpOf(event) === "append") {
5817
6743
  next.push(entry);
5818
6744
  continue;
5819
6745
  }
5820
- next.push({ type: "event", event: asAppend(event) });
6746
+ next.push({ type: "event", event: tip });
5821
6747
  changed = true;
5822
6748
  continue;
5823
6749
  }
5824
- if (isUndoCopyEvent(event) && surfaceOpOf(event) !== "append") {
5825
- next.push({ type: "event", event: asAppend(event) });
6750
+ if (isUndoCopyEvent2(event)) {
6751
+ const displayed = asUnmaskedUndoCopy(event, bySeq);
6752
+ if (displayed === event) {
6753
+ next.push(entry);
6754
+ continue;
6755
+ }
6756
+ next.push({ type: "event", event: displayed });
5826
6757
  changed = true;
5827
6758
  continue;
5828
6759
  }
@@ -5832,22 +6763,141 @@ function presentRollbackTranscript(entries) {
5832
6763
  }
5833
6764
 
5834
6765
  // src/client/rollback/transcript-filter.ts
5835
- function installRollbackTranscriptFilter(ctx, tips) {
6766
+ var KEEP_PREFIX_MAX_PAGES = 12;
6767
+ function eventSeq(entry) {
6768
+ if (entry.type !== "event") return void 0;
6769
+ const value = Number(entry.event.seq);
6770
+ return Number.isFinite(value) ? value : void 0;
6771
+ }
6772
+ function mergeTranscriptEntries(raw, incoming) {
6773
+ const bySeq = /* @__PURE__ */ new Map();
6774
+ for (const entry of raw) {
6775
+ const seq = eventSeq(entry);
6776
+ if (seq !== void 0) bySeq.set(seq, entry);
6777
+ }
6778
+ const rest = [];
6779
+ for (const entry of incoming) {
6780
+ const seq = eventSeq(entry);
6781
+ if (seq === void 0) {
6782
+ rest.push(entry);
6783
+ continue;
6784
+ }
6785
+ bySeq.set(seq, entry);
6786
+ }
6787
+ return [
6788
+ ...[...bySeq.entries()].sort((left, right) => left[0] - right[0]).map(([, entry]) => entry),
6789
+ ...rest
6790
+ ];
6791
+ }
6792
+ function sameEntries(left, right) {
6793
+ if (left === right) return true;
6794
+ if (left.length !== right.length) return false;
6795
+ for (let index = 0; index < left.length; index += 1) {
6796
+ const a = left[index];
6797
+ const b = right[index];
6798
+ if (a === b) continue;
6799
+ if (a.type !== b.type) return false;
6800
+ if (a.type === "event" && b.type === "event" && Number(a.event.seq) !== Number(b.event.seq)) {
6801
+ return false;
6802
+ }
6803
+ }
6804
+ return true;
6805
+ }
6806
+ function installRollbackTranscriptFilter(ctx, tips, cuts) {
5836
6807
  const sessions = ctx.get("sessions");
5837
6808
  if (sessions?.list === void 0 || typeof sessions.binding !== "function") return () => {
5838
6809
  };
5839
6810
  const watched = /* @__PURE__ */ new Map();
5840
- const syncSession = (sessionId) => {
5841
- const binding = sessions.binding(sessionId);
5842
- const source = binding?.eventSource;
5843
- if (source?.replace === void 0) {
5844
- tips?.set(sessionId, void 0);
6811
+ const rawWindows = /* @__PURE__ */ new Map();
6812
+ const keepPrefixAttempted = /* @__PURE__ */ new Map();
6813
+ const loadingKeepPrefix = /* @__PURE__ */ new Set();
6814
+ const syncing = /* @__PURE__ */ new Set();
6815
+ const sessionOpen = (session) => session.openState === void 0 || session.openState === "open";
6816
+ const requestKeepPrefix = (sessionId, binding, entries) => {
6817
+ if (loadingKeepPrefix.has(sessionId)) return;
6818
+ const cut = cuts?.get(sessionId) ?? null;
6819
+ const tipSeq = activeRollbackContinueAfterSeq(entries, cut);
6820
+ if (tipSeq === void 0) return;
6821
+ if (keepPrefixAttempted.get(sessionId) === tipSeq) return;
6822
+ const session = binding.session;
6823
+ const source = binding.eventSource;
6824
+ if (session === void 0 || source.replace === void 0) return;
6825
+ if (!sessionOpen(session) || session.loadingOlder === true) return;
6826
+ const target = keepPrefixLoadThroughSeq(entries, cut);
6827
+ if (session.hasMore === false) {
6828
+ keepPrefixAttempted.set(sessionId, tipSeq);
6829
+ return;
6830
+ }
6831
+ if (target === void 0) {
6832
+ keepPrefixAttempted.set(sessionId, tipSeq);
6833
+ return;
6834
+ }
6835
+ if (typeof session.baseSeq === "number" && session.baseSeq <= target && !needsKeepPrefixHistory(entries, true, cut)) {
6836
+ keepPrefixAttempted.set(sessionId, tipSeq);
6837
+ return;
6838
+ }
6839
+ if (typeof session.loadThrough !== "function" && typeof session.loadOlder !== "function") {
6840
+ keepPrefixAttempted.set(sessionId, tipSeq);
5845
6841
  return;
5846
6842
  }
5847
- const window2 = source.getSnapshot();
5848
- const presented = presentRollbackTranscript(window2.entries);
5849
- tips?.set(sessionId, activeRollbackUndoTip(presented)?.turn);
5850
- if (presented !== window2.entries) source.replace(presented, window2.hasMore);
6843
+ loadingKeepPrefix.add(sessionId);
6844
+ void (async () => {
6845
+ try {
6846
+ if (typeof session.loadThrough === "function") {
6847
+ await session.loadThrough(target);
6848
+ }
6849
+ if (typeof session.loadOlder === "function") {
6850
+ for (let page = 0; page < KEEP_PREFIX_MAX_PAGES; page += 1) {
6851
+ const snap = source.getSnapshot();
6852
+ const liveCut = cuts?.get(sessionId) ?? null;
6853
+ const raw = rawWindows.get(sessionId)?.entries ?? snap.entries;
6854
+ const presented = presentRollbackTranscript(raw, liveCut);
6855
+ if (!needsKeepPrefixHistory(presented, snap.hasMore || session.hasMore !== false, liveCut)) break;
6856
+ if (session.hasMore === false || session.loadingOlder === true) break;
6857
+ await session.loadOlder();
6858
+ }
6859
+ }
6860
+ } finally {
6861
+ keepPrefixAttempted.set(sessionId, tipSeq);
6862
+ loadingKeepPrefix.delete(sessionId);
6863
+ syncSession(sessionId);
6864
+ }
6865
+ })();
6866
+ };
6867
+ const syncSession = (sessionId) => {
6868
+ if (syncing.has(sessionId)) return;
6869
+ syncing.add(sessionId);
6870
+ try {
6871
+ const binding = sessions.binding(sessionId);
6872
+ const source = binding?.eventSource;
6873
+ if (source?.replace === void 0) {
6874
+ tips?.set(sessionId, void 0);
6875
+ return;
6876
+ }
6877
+ const window2 = source.getSnapshot();
6878
+ const cut = cuts?.get(sessionId) ?? null;
6879
+ const previous = rawWindows.get(sessionId);
6880
+ const merged = previous === void 0 ? window2.entries : mergeTranscriptEntries(previous.entries, window2.entries);
6881
+ const raw = { entries: merged, hasMore: window2.hasMore };
6882
+ rawWindows.set(sessionId, raw);
6883
+ const before = promptLedgerFor(sessionId).list().length;
6884
+ promptLedgerFor(sessionId).observe(promptsFromSessionEntries(raw.entries));
6885
+ if (promptLedgerFor(sessionId).list().length !== before) {
6886
+ invalidatePromptHistory(sessionId);
6887
+ }
6888
+ const presented = presentRollbackTranscript(raw.entries, cut);
6889
+ tips?.set(sessionId, activeRollbackUndoTip(presented, cut)?.turn);
6890
+ const tipSeq = activeRollbackContinueAfterSeq(presented, cut);
6891
+ if (tipSeq === void 0) keepPrefixAttempted.delete(sessionId);
6892
+ if (!sameEntries(presented, window2.entries)) {
6893
+ source.replace(presented, raw.hasMore);
6894
+ }
6895
+ if (needsKeepPrefixHistory(presented, window2.hasMore, cut) && binding !== void 0) {
6896
+ requestKeepPrefix(sessionId, binding, presented);
6897
+ }
6898
+ } finally {
6899
+ syncing.delete(sessionId);
6900
+ }
5851
6901
  };
5852
6902
  const watch = (sessionId) => {
5853
6903
  if (watched.has(sessionId)) return;
@@ -5858,17 +6908,29 @@ function installRollbackTranscriptFilter(ctx, tips) {
5858
6908
  const unsubSource = source.subscribe(() => {
5859
6909
  syncSession(sessionId);
5860
6910
  });
6911
+ const unsubSession = binding.session?.subscribe?.(() => {
6912
+ syncSession(sessionId);
6913
+ }) ?? (() => {
6914
+ });
5861
6915
  const unsubRetention = retention?.subscribe(() => {
5862
6916
  if (sessions.binding(sessionId) === void 0) {
5863
6917
  watched.get(sessionId)?.();
5864
6918
  watched.delete(sessionId);
6919
+ loadingKeepPrefix.delete(sessionId);
6920
+ keepPrefixAttempted.delete(sessionId);
6921
+ rawWindows.delete(sessionId);
5865
6922
  tips?.set(sessionId, void 0);
6923
+ cuts?.clear(sessionId);
5866
6924
  }
5867
6925
  }) ?? (() => {
5868
6926
  });
5869
6927
  watched.set(sessionId, () => {
5870
6928
  unsubSource();
6929
+ unsubSession();
5871
6930
  unsubRetention();
6931
+ loadingKeepPrefix.delete(sessionId);
6932
+ keepPrefixAttempted.delete(sessionId);
6933
+ rawWindows.delete(sessionId);
5872
6934
  tips?.set(sessionId, void 0);
5873
6935
  });
5874
6936
  syncSession(sessionId);
@@ -5877,11 +6939,19 @@ function installRollbackTranscriptFilter(ctx, tips) {
5877
6939
  for (const id of sessions.list.getSnapshot().ids ?? []) watch(id);
5878
6940
  };
5879
6941
  const unsubList = sessions.list.subscribe(syncList);
6942
+ const unsubCuts = cuts?.subscribe(() => {
6943
+ for (const id of watched.keys()) syncSession(id);
6944
+ }) ?? (() => {
6945
+ });
5880
6946
  syncList();
5881
6947
  return () => {
5882
6948
  unsubList();
6949
+ unsubCuts();
5883
6950
  for (const dispose of watched.values()) dispose();
5884
6951
  watched.clear();
6952
+ loadingKeepPrefix.clear();
6953
+ keepPrefixAttempted.clear();
6954
+ rawWindows.clear();
5885
6955
  };
5886
6956
  }
5887
6957
 
@@ -5900,8 +6970,9 @@ function installRollbackTurnOutlineFilter(ctx) {
5900
6970
  const entries = source.getSnapshot().entries;
5901
6971
  const hideTurnsFrom = activeRollbackHideTurnsFrom(entries);
5902
6972
  const continueAfterSeq = activeRollbackContinueAfterSeq(entries);
6973
+ const omitShellRanges = undoShellRangesFromEntries(entries);
5903
6974
  const base = hostOutlines.has(sessionId) ? hostOutlines.get(sessionId) : projections.get("turnOutline");
5904
- const filtered = filterTurnOutline(base, hideTurnsFrom, continueAfterSeq);
6975
+ const filtered = filterTurnOutline(base, hideTurnsFrom, continueAfterSeq, omitShellRanges);
5905
6976
  if (Object.is(filtered, projections.get("turnOutline"))) return;
5906
6977
  const currentSeq = Number(projections.seqOf("turnOutline") ?? 0);
5907
6978
  const nextSeq = Number.isFinite(currentSeq) ? currentSeq + 1 : 1;
@@ -5965,6 +7036,12 @@ function installRollbackTurnOutlineFilter(ctx) {
5965
7036
  };
5966
7037
  }
5967
7038
 
7039
+ // src/client/rollback/session-stats-filter.ts
7040
+ function installRollbackSessionStatsFilter(_ctx) {
7041
+ return () => {
7042
+ };
7043
+ }
7044
+
5968
7045
  // src/client/rollback/undo-tip.ts
5969
7046
  var RollbackUndoTipStore = class {
5970
7047
  tips = /* @__PURE__ */ new Map();
@@ -6003,23 +7080,53 @@ function RollbackMessageActions(props) {
6003
7080
  if (!snapshot.enabled) return null;
6004
7081
  const canExecute = props.useAccess("checkpointRollback/execute");
6005
7082
  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
- ) });
7083
+ const summary = snapshot.coverageByTurn[turn.turn];
7084
+ const affordance = coverageAffordance(summary);
7085
+ const primary = checkpointPrimaryAction(summary);
7086
+ const entryLabel = primary === "undo" ? props.t("rollbackUndoAction") : props.t("rollbackAction");
7087
+ const coverageLabel = disabledReason !== null || primary === "undo" ? null : affordance === "files" ? props.t("rollbackCoverageFiles", { count: summary.fileCount }) : affordance === "partial" ? props.t("rollbackCoveragePartial", {
7088
+ count: summary.fileCount
7089
+ }) : affordance === "conversation" ? props.t("rollbackCoverageConversation") : null;
7090
+ const entryTooltip = disabledReason !== null ? props.t(disabledReason) : coverageLabel ?? entryLabel;
7091
+ const timelineLabel = props.t("rollbackTimelineOpen");
7092
+ const actionDisabled = disabledReason !== null;
7093
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
7094
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_dsh_client_ui_primitives8.Tooltip, { label: entryTooltip, side: "bottom", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
7095
+ "button",
7096
+ {
7097
+ type: "button",
7098
+ className: css_module_default.userMessageAction,
7099
+ "aria-label": entryTooltip,
7100
+ title: entryTooltip,
7101
+ disabled: actionDisabled,
7102
+ "data-unavailable": actionDisabled || void 0,
7103
+ "data-coverage": primary === "restore" && affordance !== "unknown" ? affordance : void 0,
7104
+ "data-action": primary,
7105
+ onClick: () => {
7106
+ if (actionDisabled) return;
7107
+ if (primary === "undo") {
7108
+ props.rollback.open(turn.turn, "undo");
7109
+ return;
7110
+ }
7111
+ props.rollback.open(turn.turn, "rollback");
7112
+ },
7113
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(UndoIcon, {})
7114
+ }
7115
+ ) }),
7116
+ 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)(
7117
+ "button",
7118
+ {
7119
+ type: "button",
7120
+ className: css_module_default.userMessageAction,
7121
+ "aria-label": timelineLabel,
7122
+ title: timelineLabel,
7123
+ onClick: () => {
7124
+ props.onOpenTimeline?.(turn.turn);
7125
+ },
7126
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(TimelineIcon, {})
7127
+ }
7128
+ ) })
7129
+ ] });
6023
7130
  }
6024
7131
 
6025
7132
  // src/client/rollback/content-parts.ts
@@ -6096,7 +7203,8 @@ function RollbackUserNode(props) {
6096
7203
  const turn = turnOf2(props.node.location);
6097
7204
  const isMarker = isRollbackMarkerMessage(data.source, messageId);
6098
7205
  const rollbackTurn = turnFromRollbackMarkerId(messageId) ?? turn?.turn;
6099
- const rollbackEnabled = (0, import_react14.useSyncExternalStore)(props.rollback.subscribe, props.rollback.getSnapshot).enabled;
7206
+ const snapshot = (0, import_react14.useSyncExternalStore)(props.rollback.subscribe, props.rollback.getSnapshot);
7207
+ const rollbackEnabled = snapshot.enabled;
6100
7208
  return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: css_module_default.userMessageRow, children: [
6101
7209
  props.renderFactorySlot("conversation.chat.user.content", {
6102
7210
  content: prepared,
@@ -6113,13 +7221,499 @@ function RollbackUserNode(props) {
6113
7221
  t: props.tEnhancer,
6114
7222
  turn,
6115
7223
  useSession: props.useSession,
6116
- useAccess: props.useAccess
7224
+ useAccess: props.useAccess,
7225
+ onOpenTimeline: props.onOpenTimeline
6117
7226
  }
6118
7227
  ) : null
6119
7228
  ] })
6120
7229
  ] });
6121
7230
  }
6122
7231
 
7232
+ // src/client/rollback/session-stats-dock.tsx
7233
+ var import_react15 = require("react");
7234
+
7235
+ // src/client/rollback/session-stats-meter.ts
7236
+ var CHECKPOINT_ATTR = "data-agent-enhancer-checkpoint";
7237
+ var TITLE_RE2 = /会话统计|Session\s*statistics|Session\s*stats/i;
7238
+ var STAT_RE = /TTFT|TPS|模型用时|工具调用|首\s*token|输出速度|tok\s*\/\s*s/i;
7239
+ function cls3(value) {
7240
+ return value ?? "";
7241
+ }
7242
+ function textOf3(node) {
7243
+ return (node.textContent ?? "").replace(/\s+/g, " ").trim();
7244
+ }
7245
+ function isContextCompositionPanel2(dialog) {
7246
+ return dialog.querySelectorAll(":scope > dl > div").length === 3;
7247
+ }
7248
+ function isTokenUsagePanel2(dialog) {
7249
+ const text2 = textOf3(dialog);
7250
+ return /Token\s*(?:用量|usage)/i.test(text2) && /\d[\d,]*\s*tok/i.test(text2);
7251
+ }
7252
+ function isSessionStatsPanel(dialog) {
7253
+ if (isContextCompositionPanel2(dialog) || isTokenUsagePanel2(dialog)) return false;
7254
+ const text2 = textOf3(dialog);
7255
+ if (!TITLE_RE2.test(text2)) return false;
7256
+ return STAT_RE.test(text2);
7257
+ }
7258
+ function findOpenSessionStatsPanel() {
7259
+ const dock = document.querySelector("[data-composer-dock]");
7260
+ if (!(dock instanceof HTMLElement)) return null;
7261
+ const triggers = dock.querySelectorAll('button[aria-haspopup="dialog"][aria-expanded="true"]');
7262
+ if (triggers.length === 0) return null;
7263
+ const dialogs = document.querySelectorAll('body > [role="dialog"]');
7264
+ for (let index = dialogs.length - 1; index >= 0; index -= 1) {
7265
+ const dialog = dialogs[index];
7266
+ if (dialog === void 0) continue;
7267
+ if (isSessionStatsPanel(dialog)) return dialog;
7268
+ }
7269
+ return null;
7270
+ }
7271
+ function findSessionStatsTitleRow(panel) {
7272
+ const candidates = [];
7273
+ for (const node of panel.querySelectorAll("*")) {
7274
+ if (!(node instanceof HTMLElement) || node === panel) continue;
7275
+ const text2 = textOf3(node);
7276
+ if (!TITLE_RE2.test(text2)) continue;
7277
+ if (STAT_RE.test(text2) && text2.length > 40) continue;
7278
+ candidates.push(node);
7279
+ }
7280
+ if (candidates.length === 0) return null;
7281
+ candidates.sort((left, right) => left.querySelectorAll("*").length - right.querySelectorAll("*").length);
7282
+ return candidates[0] ?? null;
7283
+ }
7284
+ function enhanceTitleRow2(row, options) {
7285
+ if (row.getAttribute(CHECKPOINT_ATTR) === "1") return;
7286
+ row.setAttribute(CHECKPOINT_ATTR, "1");
7287
+ row.classList.add(cls3(css_module_default.sessionStatsCheckpointRow));
7288
+ row.tabIndex = 0;
7289
+ row.setAttribute("role", "button");
7290
+ row.setAttribute("aria-label", options.label());
7291
+ if (!row.querySelector("[data-agent-enhancer-checkpoint-chevron]")) {
7292
+ const chevron = document.createElement("span");
7293
+ chevron.dataset.agentEnhancerCheckpointChevron = "1";
7294
+ chevron.className = cls3(css_module_default.sessionStatsCheckpointChevron);
7295
+ chevron.setAttribute("aria-hidden", "true");
7296
+ chevron.textContent = "\u203A";
7297
+ row.append(chevron);
7298
+ }
7299
+ const open = () => {
7300
+ if (!options.enabled()) return;
7301
+ const sessionId = options.sessionId();
7302
+ if (sessionId === void 0 || sessionId === "") return;
7303
+ options.open();
7304
+ };
7305
+ row.addEventListener("click", (event) => {
7306
+ event.preventDefault();
7307
+ event.stopPropagation();
7308
+ open();
7309
+ });
7310
+ row.addEventListener("keydown", (event) => {
7311
+ if (event.key !== "Enter" && event.key !== " ") return;
7312
+ event.preventDefault();
7313
+ event.stopPropagation();
7314
+ open();
7315
+ });
7316
+ }
7317
+ function installSessionStatsCheckpointLink(options) {
7318
+ const scan = () => {
7319
+ try {
7320
+ const panel = findOpenSessionStatsPanel();
7321
+ if (panel === null) return;
7322
+ const title = findSessionStatsTitleRow(panel);
7323
+ if (title !== null) enhanceTitleRow2(title, options);
7324
+ } catch {
7325
+ }
7326
+ };
7327
+ const observer = new MutationObserver(scan);
7328
+ observer.observe(document.body, {
7329
+ childList: true,
7330
+ subtree: true,
7331
+ attributes: true,
7332
+ attributeFilter: ["aria-expanded"]
7333
+ });
7334
+ scan();
7335
+ return () => {
7336
+ observer.disconnect();
7337
+ };
7338
+ }
7339
+
7340
+ // src/client/rollback/session-stats-dock.tsx
7341
+ function SessionStatsCheckpointDock(props) {
7342
+ const sessionId = props.sessionId;
7343
+ (0, import_react15.useEffect)(() => installSessionStatsCheckpointLink({
7344
+ enabled: props.enabled,
7345
+ sessionId: () => sessionId,
7346
+ open: () => {
7347
+ if (sessionId === void 0) return;
7348
+ props.open(sessionId);
7349
+ },
7350
+ label: () => props.t("rollbackTimelineOpen")
7351
+ }), [sessionId, props.enabled, props.open, props.t]);
7352
+ return null;
7353
+ }
7354
+
7355
+ // src/client/rollback/timeline-tab.tsx
7356
+ var import_react17 = require("react");
7357
+
7358
+ // src/client/rollback/timeline-panel.tsx
7359
+ var import_dsh_client_ui_primitives10 = require("@deepseek-ai/dsh-client-ui-primitives");
7360
+ var import_react16 = require("react");
7361
+
7362
+ // src/client/rollback/timeline-format.ts
7363
+ function timelineCoverageLabel(summary, t) {
7364
+ const affordance = coverageAffordance(summary);
7365
+ switch (affordance) {
7366
+ case "files":
7367
+ return t("rollbackTimelineCoverageFiles", { count: summary.fileCount });
7368
+ case "partial":
7369
+ return t("rollbackTimelineCoveragePartial", { count: summary.fileCount });
7370
+ case "conversation":
7371
+ return t("rollbackTimelineCoverageConversation");
7372
+ case "unknown":
7373
+ return t("rollbackTimelineCoverageUnknown");
7374
+ default: {
7375
+ const _exhaustive = affordance;
7376
+ return _exhaustive;
7377
+ }
7378
+ }
7379
+ }
7380
+ function timelineGapLabel(gap, t) {
7381
+ switch (gap.type) {
7382
+ case "prompt":
7383
+ return t("rollbackGapPrompt");
7384
+ case "workspace":
7385
+ return t("rollbackGapWorkspace");
7386
+ default: {
7387
+ const _exhaustive = gap;
7388
+ return _exhaustive;
7389
+ }
7390
+ }
7391
+ }
7392
+ function formatCheckpointTime(createdAt, locale) {
7393
+ try {
7394
+ return new Intl.DateTimeFormat(locale, {
7395
+ month: "short",
7396
+ day: "numeric",
7397
+ hour: "2-digit",
7398
+ minute: "2-digit"
7399
+ }).format(new Date(createdAt));
7400
+ } catch {
7401
+ return new Date(createdAt).toLocaleString();
7402
+ }
7403
+ }
7404
+ function timelinePromptLabel(summary, t) {
7405
+ if (summary.promptPreview.length > 0) {
7406
+ return { text: summary.promptPreview, empty: false };
7407
+ }
7408
+ const first = summary.files[0];
7409
+ if (first !== void 0) {
7410
+ return {
7411
+ text: summary.files.length === 1 ? t("rollbackTimelineFileFallback", { path: first.path }) : t("rollbackTimelineFilesFallback", { path: first.path, count: summary.files.length }),
7412
+ empty: false
7413
+ };
7414
+ }
7415
+ return { text: t("rollbackTimelineNoPrompt"), empty: true };
7416
+ }
7417
+
7418
+ // src/client/rollback/timeline-panel.tsx
7419
+ var import_jsx_runtime17 = require("react/jsx-runtime");
7420
+ function mergeChatActivity(activity, chat) {
7421
+ if (chat === void 0) return activity;
7422
+ if (activity.turns === chat.turns && activity.steps === chat.steps) return activity;
7423
+ return { ...activity, turns: chat.turns, steps: chat.steps };
7424
+ }
7425
+ function matchesQuery(summary, query) {
7426
+ const normalized = query.trim().toLowerCase();
7427
+ if (normalized.length === 0) return true;
7428
+ if (String(summary.turn).includes(normalized)) return true;
7429
+ if (summary.prompt.toLowerCase().includes(normalized)) return true;
7430
+ if (summary.promptPreview.toLowerCase().includes(normalized)) return true;
7431
+ return summary.files.some((file) => file.path.toLowerCase().includes(normalized));
7432
+ }
7433
+ function CheckpointTimelinePanel(props) {
7434
+ const [state, setState] = (0, import_react16.useState)({ status: "loading" });
7435
+ const [expanded, setExpanded] = (0, import_react16.useState)(props.focusTurn ?? null);
7436
+ const [query, setQuery] = (0, import_react16.useState)("");
7437
+ const [busyTurn, setBusyTurn] = (0, import_react16.useState)(null);
7438
+ const wasActive = (0, import_react16.useRef)(false);
7439
+ const [chatActivity, setChatActivity] = (0, import_react16.useState)(
7440
+ () => props.readChatActivity?.() ?? void 0
7441
+ );
7442
+ const load = (0, import_react16.useCallback)((options = {}) => {
7443
+ const summaries = props.remote.summaries;
7444
+ if (summaries === void 0) {
7445
+ setState({ status: "error" });
7446
+ return;
7447
+ }
7448
+ if (!options.quiet) setState({ status: "loading" });
7449
+ const controller = new AbortController();
7450
+ void summaries({ sessionId: props.sessionId }, controller.signal).then((result) => {
7451
+ setState({
7452
+ status: "ready",
7453
+ turns: result.turns,
7454
+ activity: mergeChatActivity(result.activity, props.readChatActivity?.())
7455
+ });
7456
+ }, () => {
7457
+ if (!options.quiet) setState({ status: "error" });
7458
+ });
7459
+ return () => {
7460
+ controller.abort();
7461
+ };
7462
+ }, [props.remote.summaries, props.sessionId, props.readChatActivity]);
7463
+ (0, import_react16.useEffect)(() => load(), [load]);
7464
+ (0, import_react16.useEffect)(() => {
7465
+ if (props.subscribeChatActivity === void 0) return;
7466
+ return props.subscribeChatActivity(() => {
7467
+ setChatActivity(props.readChatActivity?.());
7468
+ });
7469
+ }, [props.subscribeChatActivity, props.readChatActivity]);
7470
+ (0, import_react16.useEffect)(() => {
7471
+ setState((previous) => {
7472
+ if (previous.status !== "ready") return previous;
7473
+ const activity = mergeChatActivity(previous.activity, chatActivity);
7474
+ if (activity === previous.activity) return previous;
7475
+ return { ...previous, activity };
7476
+ });
7477
+ }, [chatActivity]);
7478
+ (0, import_react16.useEffect)(() => {
7479
+ if (props.rollback === void 0) return;
7480
+ return props.rollback.subscribe(() => {
7481
+ const active = props.rollback.getSnapshot().active;
7482
+ if (active !== null) {
7483
+ wasActive.current = true;
7484
+ return;
7485
+ }
7486
+ if (wasActive.current) {
7487
+ wasActive.current = false;
7488
+ load({ quiet: true });
7489
+ }
7490
+ });
7491
+ }, [props.rollback, load]);
7492
+ const visible = (0, import_react16.useMemo)(() => {
7493
+ if (state.status !== "ready") return [];
7494
+ return state.turns.filter((turn) => matchesQuery(turn, query));
7495
+ }, [state, query]);
7496
+ const openRestore = (summary, operation) => {
7497
+ if (props.rollback === void 0) return;
7498
+ setBusyTurn(summary.turn);
7499
+ props.rollback.open(summary.turn, operation, { surface: "timeline", atSeq: summary.atSeq });
7500
+ setBusyTurn(null);
7501
+ };
7502
+ if (state.status === "loading") {
7503
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: css_module_default.timelineStatus, role: "status", children: props.t("rollbackTimelineLoading") });
7504
+ }
7505
+ if (state.status === "error") {
7506
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: css_module_default.timelineStatus, children: [
7507
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { role: "alert", children: props.t("rollbackTimelineFailed") }),
7508
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_dsh_client_ui_primitives10.Button, { type: "button", onClick: () => {
7509
+ load();
7510
+ }, children: props.t("rollbackRetry") })
7511
+ ] });
7512
+ }
7513
+ if (state.turns.length === 0) {
7514
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: css_module_default.timelineStatus, children: props.t("rollbackTimelineEmpty") });
7515
+ }
7516
+ const tipTurn = state.turns.find((turn) => turn.tip)?.turn;
7517
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: css_module_default.timelinePanel, children: [
7518
+ tipTurn === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("header", { className: css_module_default.timelineToolbar, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: css_module_default.timelineLeadNote, role: "note", children: props.t("rollbackTimelineLeadRestoredNote") }) }),
7519
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: css_module_default.timelineSearchRow, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
7520
+ import_dsh_client_ui_primitives10.Input,
7521
+ {
7522
+ type: "search",
7523
+ value: query,
7524
+ className: css_module_default.timelineSearch,
7525
+ placeholder: props.t("rollbackTimelineSearchPlaceholder"),
7526
+ "aria-label": props.t("rollbackTimelineSearchLabel"),
7527
+ onChange: (event) => {
7528
+ setQuery(event.target.value);
7529
+ }
7530
+ }
7531
+ ) }),
7532
+ visible.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: css_module_default.timelineStatus, children: props.t("rollbackTimelineFilterEmpty") }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("ol", { className: css_module_default.timelineList, children: visible.map((summary) => {
7533
+ const open = expanded === summary.turn;
7534
+ const time = formatCheckpointTime(summary.createdAt, props.locale ?? "en");
7535
+ const coverage = coverageAffordance(summary);
7536
+ const prompt = timelinePromptLabel(summary, props.t);
7537
+ const busy = busyTurn === summary.turn;
7538
+ const isTip = summary.tip;
7539
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
7540
+ "li",
7541
+ {
7542
+ className: css_module_default.timelineItem,
7543
+ "data-coverage": coverage,
7544
+ "data-expanded": open || void 0,
7545
+ "data-rolled-back": summary.rolledBack || void 0,
7546
+ "data-tip": isTip || void 0,
7547
+ children: [
7548
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: css_module_default.timelineMain, children: [
7549
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
7550
+ "button",
7551
+ {
7552
+ type: "button",
7553
+ className: css_module_default.timelineRow,
7554
+ "aria-expanded": open,
7555
+ onClick: () => {
7556
+ setExpanded(open ? null : summary.turn);
7557
+ },
7558
+ children: [
7559
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("span", { className: css_module_default.timelineTurn, children: [
7560
+ props.t("rollbackTimelineTurn", { turn: summary.turn }),
7561
+ isTip ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: css_module_default.timelineTipBadge, children: props.t("rollbackTimelineTip") }) : null,
7562
+ summary.rolledBack && !isTip ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: css_module_default.timelineRolledBackBadge, children: props.t("rollbackTimelineRolledBack") }) : null
7563
+ ] }),
7564
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
7565
+ "span",
7566
+ {
7567
+ className: prompt.empty ? css_module_default.timelinePromptEmpty : css_module_default.timelinePromptPreview,
7568
+ children: prompt.text
7569
+ }
7570
+ ),
7571
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: css_module_default.timelineTime, children: time })
7572
+ ]
7573
+ }
7574
+ ),
7575
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: css_module_default.timelineActions, children: isTip ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
7576
+ import_dsh_client_ui_primitives10.Button,
7577
+ {
7578
+ type: "button",
7579
+ disabled: busy || props.rollback === void 0,
7580
+ onClick: () => {
7581
+ openRestore(summary, "undo");
7582
+ },
7583
+ children: props.t("rollbackUndoAction")
7584
+ }
7585
+ ) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
7586
+ import_dsh_client_ui_primitives10.Button,
7587
+ {
7588
+ type: "button",
7589
+ disabled: busy || props.rollback === void 0,
7590
+ onClick: () => {
7591
+ openRestore(summary, "rollback");
7592
+ },
7593
+ children: props.t("rollbackAction")
7594
+ }
7595
+ ) })
7596
+ ] }),
7597
+ !open ? null : /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: css_module_default.timelineDetail, children: [
7598
+ 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 }),
7599
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: css_module_default.timelineDetailMeta, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: css_module_default.timelineCoverage, "data-coverage": coverage, children: timelineCoverageLabel(summary, props.t) }) }),
7600
+ summary.files.length === 0 ? null : /* @__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: [
7601
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { children: file.path }),
7602
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: css_module_default.timelineFileChange, "data-change": file.change, children: props.t(`rollbackFile_${file.change}`) })
7603
+ ] }, file.path)) }),
7604
+ 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}`)) })
7605
+ ] })
7606
+ ]
7607
+ },
7608
+ `${summary.turn}:${summary.atSeq}`
7609
+ );
7610
+ }) })
7611
+ ] });
7612
+ }
7613
+
7614
+ // src/client/rollback/timeline-tab.tsx
7615
+ var import_jsx_runtime18 = require("react/jsx-runtime");
7616
+ function chatActivityOf(sessions, sessionId) {
7617
+ const binding = sessions?.binding(sessionId);
7618
+ if (binding?.eventSource?.getSnapshot === void 0) return void 0;
7619
+ try {
7620
+ const entries = binding.eventSource.getSnapshot().entries;
7621
+ return activityStatsFromEntries(entries);
7622
+ } catch {
7623
+ return void 0;
7624
+ }
7625
+ }
7626
+ function subscribeChatActivityOf(sessions, sessionId, listener) {
7627
+ const binding = sessions?.binding(sessionId);
7628
+ if (binding === void 0) return () => {
7629
+ };
7630
+ const disposers = [];
7631
+ try {
7632
+ disposers.push(binding.eventSource.subscribe(listener));
7633
+ } catch {
7634
+ }
7635
+ try {
7636
+ const face = binding.session.projections.faceOf("sessionStats");
7637
+ if (typeof face?.subscribe === "function") disposers.push(face.subscribe(listener));
7638
+ } catch {
7639
+ }
7640
+ return () => {
7641
+ while (disposers.length > 0) disposers.pop()?.();
7642
+ };
7643
+ }
7644
+ function paramsOf2(raw) {
7645
+ if (typeof raw !== "object" || raw === null) return {};
7646
+ const record = raw;
7647
+ return {
7648
+ ...typeof record.sessionId === "string" ? { sessionId: record.sessionId } : {},
7649
+ ...typeof record.turn === "number" ? { turn: record.turn } : {}
7650
+ };
7651
+ }
7652
+ function resolveTimelineSessionId(scopedSessionId, params) {
7653
+ if (typeof scopedSessionId === "string" && scopedSessionId !== "") {
7654
+ return scopedSessionId;
7655
+ }
7656
+ return params.sessionId;
7657
+ }
7658
+ function CheckpointTimelineTabBody(props) {
7659
+ const rollback = props.rollbackFor(props.sessionId);
7660
+ const activityBridge = (0, import_react17.useMemo)(() => {
7661
+ const sessions = props.sessions;
7662
+ if (sessions === void 0) return {};
7663
+ const sessionId = props.sessionId;
7664
+ return {
7665
+ readChatActivity: () => chatActivityOf(sessions, sessionId),
7666
+ subscribeChatActivity: (listener) => subscribeChatActivityOf(sessions, sessionId, listener)
7667
+ };
7668
+ }, [props.sessions, props.sessionId]);
7669
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: css_module_default.timelineRightPane, children: [
7670
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
7671
+ CheckpointTimelinePanel,
7672
+ {
7673
+ sessionId: props.sessionId,
7674
+ focusTurn: props.focusTurn,
7675
+ remote: props.remote,
7676
+ rollback,
7677
+ t: props.t,
7678
+ locale: props.locale,
7679
+ ...activityBridge
7680
+ }
7681
+ ),
7682
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
7683
+ RollbackModalHost,
7684
+ {
7685
+ rollback,
7686
+ t: props.t,
7687
+ inputActions: rollbackInputActionsFor(props.sessionId),
7688
+ sessionId: props.sessionId,
7689
+ surface: "timeline"
7690
+ }
7691
+ )
7692
+ ] });
7693
+ }
7694
+ function CheckpointTimelineTab(props) {
7695
+ const info = props.useTabInfo();
7696
+ const params = paramsOf2(info.tab.navigation.params);
7697
+ const sessionId = resolveTimelineSessionId(
7698
+ typeof props.sessionId === "string" ? props.sessionId : void 0,
7699
+ params
7700
+ );
7701
+ if (sessionId === void 0) {
7702
+ 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") }) });
7703
+ }
7704
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
7705
+ CheckpointTimelineTabBody,
7706
+ {
7707
+ ...props,
7708
+ sessionId,
7709
+ focusTurn: params.turn
7710
+ }
7711
+ );
7712
+ }
7713
+ function CheckpointTimelineTabTitle(props) {
7714
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { children: props.t("rollbackTimelineTitle") });
7715
+ }
7716
+
6123
7717
  // src/client/index.ts
6124
7718
  var inject = [
6125
7719
  "remote",
@@ -6198,7 +7792,7 @@ function apply(ctx) {
6198
7792
  }));
6199
7793
  return source === "account" ? all.account : all.apiKey;
6200
7794
  };
6201
- const SettingsTab = (props) => (0, import_react15.createElement)(PluginSettings, {
7795
+ const SettingsTab = (props) => (0, import_react18.createElement)(PluginSettings, {
6202
7796
  form: props.form,
6203
7797
  t: props.t,
6204
7798
  loadCatalog,
@@ -6213,12 +7807,12 @@ function apply(ctx) {
6213
7807
  locale: "agent-enhancer",
6214
7808
  inject: () => ({ form })
6215
7809
  }, SettingsTab)));
6216
- const AccountBalanceChip = () => (0, import_react15.createElement)(ProviderBalanceChip, {
7810
+ const AccountBalanceChip = () => (0, import_react18.createElement)(ProviderBalanceChip, {
6217
7811
  source: "account",
6218
7812
  t,
6219
7813
  load: loadProviderSnapshot("account")
6220
7814
  });
6221
- const ApiKeyBalanceChip = () => (0, import_react15.createElement)(ProviderBalanceChip, {
7815
+ const ApiKeyBalanceChip = () => (0, import_react18.createElement)(ProviderBalanceChip, {
6222
7816
  source: "api-key",
6223
7817
  t,
6224
7818
  load: loadProviderSnapshot("api-key")
@@ -6272,6 +7866,7 @@ function apply(ctx) {
6272
7866
  for (const session of sessions.values()) session.refreshSettings();
6273
7867
  }));
6274
7868
  mountedCtx.effect(() => () => {
7869
+ for (const sessionId of sessions.keys()) disposePromptLedger(sessionId);
6275
7870
  for (const session of sessions.values()) session.dispose();
6276
7871
  sessions.clear();
6277
7872
  });
@@ -6301,7 +7896,7 @@ function apply(ctx) {
6301
7896
  const tContext = mountedCtx.locale.bind("agent-enhancer");
6302
7897
  const inspectContext = (sessionId, category, signal) => agentEnhancerInspectContext.invoke(mountedCtx.remote, { sessionId, category }, signal);
6303
7898
  const compactContext = (sessionId, signal) => agentEnhancerCompactContext.invoke(mountedCtx.remote, { sessionId }, signal);
6304
- const ContextDock = (props) => (0, import_react15.createElement)(ContextInspectDock, {
7899
+ const ContextDock = (props) => (0, import_react18.createElement)(ContextInspectDock, {
6305
7900
  ...props,
6306
7901
  enabled: contextInspectEnabled,
6307
7902
  open: (category) => {
@@ -6312,29 +7907,29 @@ function apply(ctx) {
6312
7907
  },
6313
7908
  t: tContext
6314
7909
  });
6315
- const BillDock = (props) => (0, import_react15.createElement)(UsageMeterDock, {
7910
+ const BillDock = (props) => (0, import_react18.createElement)(UsageMeterDock, {
6316
7911
  ...props,
6317
7912
  open: () => {
6318
7913
  openUsageTab(mountedCtx.sidebarRight);
6319
7914
  },
6320
7915
  t: tContext
6321
7916
  });
6322
- const ContextRightTab = (props) => (0, import_react15.createElement)(ContextInspectRightTab, {
7917
+ const ContextRightTab = (props) => (0, import_react18.createElement)(ContextInspectRightTab, {
6323
7918
  ...props,
6324
7919
  inspect: inspectContext,
6325
7920
  compact: compactContext,
6326
7921
  t: tContext
6327
7922
  });
6328
- const ContextRightTitle = (props) => (0, import_react15.createElement)(
7923
+ const ContextRightTitle = (props) => (0, import_react18.createElement)(
6329
7924
  ContextInspectRightTabTitle,
6330
7925
  { ...props, t: tContext }
6331
7926
  );
6332
- const BillRightTab = (props) => (0, import_react15.createElement)(UsageRightTab, {
7927
+ const BillRightTab = (props) => (0, import_react18.createElement)(UsageRightTab, {
6333
7928
  ...props,
6334
7929
  loadUsage,
6335
7930
  t: tContext
6336
7931
  });
6337
- const BillRightTitle = (props) => (0, import_react15.createElement)(
7932
+ const BillRightTitle = (props) => (0, import_react18.createElement)(
6338
7933
  UsageRightTabTitle,
6339
7934
  { ...props, t: tContext }
6340
7935
  );
@@ -6410,42 +8005,122 @@ function apply(ctx) {
6410
8005
  const applyRollbackMounted = (mountedCtx) => {
6411
8006
  const rollbackRemote = {
6412
8007
  preview: (request, signal) => checkpointRollbackRemote.preview(mountedCtx.remote, request, signal),
6413
- execute: (request, signal) => checkpointRollbackRemote.execute(mountedCtx.remote, request, signal)
8008
+ execute: (request, signal) => checkpointRollbackRemote.execute(mountedCtx.remote, request, signal),
8009
+ summaries: (request, signal) => checkpointRollbackRemote.summaries(mountedCtx.remote, request, signal),
8010
+ getCut: (request, signal) => checkpointRollbackRemote.getCut(mountedCtx.remote, request, signal)
6414
8011
  };
6415
8012
  const rollbackSessions = /* @__PURE__ */ new Map();
6416
8013
  const rollbackRetentions = /* @__PURE__ */ new Map();
6417
8014
  const undoTips = new RollbackUndoTipStore();
8015
+ const cutCache = new SessionCutCache();
8016
+ const refreshCut = async (sessionId) => {
8017
+ const getCut = rollbackRemote.getCut;
8018
+ if (getCut === void 0) return;
8019
+ try {
8020
+ const result = await getCut({ sessionId }, new AbortController().signal);
8021
+ cutCache.set(sessionId, result.cut === null ? null : {
8022
+ hideTurnsFrom: result.cut.hideTurnsFrom,
8023
+ cutSeq: result.cut.cutSeq,
8024
+ restoredAtSeq: result.cut.restoredAtSeq
8025
+ });
8026
+ } catch {
8027
+ }
8028
+ };
6418
8029
  const tEnhancer = mountedCtx.locale.bind("agent-enhancer");
6419
8030
  const tChat = mountedCtx.locale.bind("chat");
6420
8031
  const rollbackEnabled = () => resolveSettings(form.getSnapshot().value).rollbackEnabled;
6421
8032
  const rollbackFor = (sessionId) => {
6422
8033
  let rollback = rollbackSessions.get(sessionId);
6423
8034
  if (rollback === void 0) {
8035
+ const remote = {
8036
+ ...rollbackRemote,
8037
+ async execute(request, signal) {
8038
+ const result = await rollbackRemote.execute(request, signal);
8039
+ await refreshCut(sessionId);
8040
+ return result;
8041
+ },
8042
+ async summaries(request, signal) {
8043
+ const summaries = rollbackRemote.summaries;
8044
+ if (summaries === void 0) throw new Error("summaries unavailable");
8045
+ const result = await summaries(request, signal);
8046
+ void refreshCut(sessionId);
8047
+ return result;
8048
+ }
8049
+ };
6424
8050
  rollback = new RollbackController({
6425
8051
  sessionId,
6426
8052
  enabled: rollbackEnabled,
6427
- remote: rollbackRemote
8053
+ remote
6428
8054
  });
6429
8055
  rollbackSessions.set(sessionId, rollback);
8056
+ void refreshCut(sessionId);
6430
8057
  const sessions = mountedCtx.get("sessions");
6431
8058
  if (sessions !== void 0) {
6432
8059
  const retention = sessions.retainInfo(sessionId);
6433
8060
  rollbackRetentions.set(sessionId, retention.subscribe(() => {
6434
8061
  if ((retention.getSnapshot().retainedBy.mainView ?? 0) === 0) {
6435
8062
  rollbackSessions.get(sessionId)?.close();
8063
+ cutCache.clear(sessionId);
6436
8064
  }
6437
8065
  }));
6438
8066
  }
6439
8067
  }
6440
8068
  return rollback;
6441
8069
  };
6442
- const rollbackUserNode = (props) => (0, import_react15.createElement)(
8070
+ const openTimeline = (sessionId, turn) => {
8071
+ openCheckpointTimelineTab(mountedCtx.sidebarRight, turn === void 0 ? { sessionId } : { sessionId, turn });
8072
+ };
8073
+ const TimelineTab = (props) => (0, import_react18.createElement)(
8074
+ CheckpointTimelineTab,
8075
+ {
8076
+ ...props,
8077
+ t: tEnhancer,
8078
+ remote: rollbackRemote,
8079
+ sessions: mountedCtx.get("sessions"),
8080
+ rollbackFor,
8081
+ locale: resolveUiLocale(mountedCtx.locale.getLocale().active) === "zh" ? "zh-CN" : "en"
8082
+ }
8083
+ );
8084
+ const TimelineTitle = (props) => (0, import_react18.createElement)(
8085
+ CheckpointTimelineTabTitle,
8086
+ { ...props, t: tEnhancer }
8087
+ );
8088
+ const StatsCheckpointDock = (props) => (0, import_react18.createElement)(
8089
+ SessionStatsCheckpointDock,
8090
+ {
8091
+ ...props,
8092
+ enabled: rollbackEnabled,
8093
+ open: (sessionId) => {
8094
+ openTimeline(sessionId);
8095
+ },
8096
+ t: tEnhancer
8097
+ }
8098
+ );
8099
+ const rollbackUserNode = (props) => (0, import_react18.createElement)(
6443
8100
  RollbackUserNode,
6444
- { ...props, rollback: rollbackFor(props.sessionId), tEnhancer, tChat }
8101
+ {
8102
+ ...props,
8103
+ rollback: rollbackFor(props.sessionId),
8104
+ tEnhancer,
8105
+ tChat,
8106
+ onOpenTimeline: (turn) => {
8107
+ openTimeline(props.sessionId, turn);
8108
+ }
8109
+ }
6445
8110
  );
6446
- const rollbackOverlay = (props) => (0, import_react15.createElement)(
8111
+ const rollbackOverlay = (props) => (0, import_react18.createElement)(
6447
8112
  RollbackModalHost,
6448
- { rollback: rollbackFor(props.sessionId), t: tEnhancer, inputActions: props.inputActions }
8113
+ {
8114
+ rollback: rollbackFor(props.sessionId),
8115
+ t: tEnhancer,
8116
+ inputActions: props.inputActions,
8117
+ useSession: props.useSession,
8118
+ sessionId: props.sessionId,
8119
+ surface: "composer",
8120
+ onOpenTimeline: (turn) => {
8121
+ openTimeline(props.sessionId, turn);
8122
+ }
8123
+ }
6449
8124
  );
6450
8125
  const disposers = [];
6451
8126
  const disableRollback = () => {
@@ -6462,6 +8137,22 @@ function apply(ctx) {
6462
8137
  if (!enabled) {
6463
8138
  disableRollback();
6464
8139
  } else if (disposers.length === 0) {
8140
+ disposers.push(mountedCtx.sidebarRightTabs.register({
8141
+ id: CHECKPOINT_TIMELINE_TAB_ID,
8142
+ kind: CHECKPOINT_TIMELINE_TAB_KIND,
8143
+ priority: "extension",
8144
+ title: () => tEnhancer("rollbackTimelineTitle")
8145
+ }));
8146
+ disposers.push(mountedCtx.slots.inject("sidebar.right.pane.tab", () => mountedCtx.slots.register({
8147
+ name: "sidebar.right.pane.tab",
8148
+ key: CHECKPOINT_TIMELINE_TAB_ID,
8149
+ locale: "agent-enhancer"
8150
+ }, TimelineTab)));
8151
+ disposers.push(mountedCtx.slots.inject("sidebar.right.pane.tab.title", () => mountedCtx.slots.register({
8152
+ name: "sidebar.right.pane.tab.title",
8153
+ key: CHECKPOINT_TIMELINE_TAB_ID,
8154
+ locale: "agent-enhancer"
8155
+ }, TimelineTitle)));
6465
8156
  disposers.push(mountedCtx.slots.inject("conversation.chat.node", () => mountedCtx.slots.register({
6466
8157
  name: "conversation.chat.node",
6467
8158
  key: "user",
@@ -6474,8 +8165,15 @@ function apply(ctx) {
6474
8165
  order: 121,
6475
8166
  locale: "agent-enhancer"
6476
8167
  }, rollbackOverlay)));
6477
- disposers.push(installRollbackTranscriptFilter(mountedCtx, undoTips));
8168
+ disposers.push(mountedCtx.slots.inject("conversation.composer.dock", () => mountedCtx.slots.register({
8169
+ name: "conversation.composer.dock",
8170
+ id: "agent-enhancer-checkpoint-stats",
8171
+ order: 55,
8172
+ locale: "agent-enhancer"
8173
+ }, StatsCheckpointDock)));
8174
+ disposers.push(installRollbackTranscriptFilter(mountedCtx, undoTips, cutCache));
6478
8175
  disposers.push(installRollbackTurnOutlineFilter(mountedCtx));
8176
+ disposers.push(installRollbackSessionStatsFilter(mountedCtx));
6479
8177
  disposers.push(installRollbackUndoCommand({
6480
8178
  ctx: mountedCtx,
6481
8179
  tips: undoTips,