dsh-client-auto-continue 0.15.0 → 0.17.0

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 (46) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/README.md +37 -21
  3. package/README.zh.md +34 -21
  4. package/docs/releases/v0.16.0.md +75 -0
  5. package/docs/releases/v0.17.0.md +62 -0
  6. package/docs/screenshots/01-settings-section.png +0 -0
  7. package/docs/screenshots/01-settings-section.zh.png +0 -0
  8. package/docs/screenshots/02-settings-card.png +0 -0
  9. package/docs/screenshots/02-settings-card.zh.png +0 -0
  10. package/docs/screenshots/07-card-panels.png +0 -0
  11. package/docs/screenshots/07-card-panels.zh.png +0 -0
  12. package/docs/screenshots/08-composer-toggle.png +0 -0
  13. package/docs/screenshots/08-composer-toggle.zh.png +0 -0
  14. package/docs/screenshots/README.md +8 -8
  15. package/docs/third-party-notices.md +19 -0
  16. package/lib/client.js +474 -133
  17. package/lib/client.js.map +4 -4
  18. package/lib/index.js +7560 -117
  19. package/lib/types/client/auto-continue-icon.d.ts +1 -0
  20. package/lib/types/client/bridge.d.ts +3 -1
  21. package/lib/types/client/composer-toggle.d.ts +6 -4
  22. package/lib/types/client/index.d.ts +1 -1
  23. package/lib/types/client/locales.d.ts +11 -8
  24. package/lib/types/client/mode-menu.d.ts +19 -0
  25. package/lib/types/client/native-toast.d.ts +17 -0
  26. package/lib/types/client/settings-card.d.ts +6 -5
  27. package/lib/types/host/engine.d.ts +2 -0
  28. package/lib/types/host/settings-migration.d.ts +14 -0
  29. package/lib/types/index.d.ts +14 -8
  30. package/lib/types/shared/core.d.ts +13 -1
  31. package/locale/en.json +6 -0
  32. package/locale/zh.json +6 -0
  33. package/package.json +24 -14
  34. package/src/client/auto-continue-icon.tsx +35 -0
  35. package/src/client/bridge.ts +35 -4
  36. package/src/client/composer-toggle.tsx +66 -14
  37. package/src/client/index.ts +4 -2
  38. package/src/client/locales.ts +32 -26
  39. package/src/client/mode-menu.tsx +110 -0
  40. package/src/client/native-toast.tsx +44 -0
  41. package/src/client/settings-card.tsx +156 -41
  42. package/src/client/styles.ts +61 -37
  43. package/src/host/engine.ts +54 -12
  44. package/src/host/settings-migration.ts +117 -0
  45. package/src/index.ts +63 -12
  46. package/src/shared/core.ts +23 -1
package/lib/client.js CHANGED
@@ -37,6 +37,10 @@ __export(index_exports, {
37
37
  module.exports = __toCommonJS(index_exports);
38
38
 
39
39
  // src/shared/core.ts
40
+ var isSessionMode = (value) => value === "default" || value === "off" || value === "recover" || value === "loop";
41
+ function sessionMode(modes, sessionId) {
42
+ return Object.prototype.hasOwnProperty.call(modes, sessionId) && isSessionMode(modes[sessionId]) ? modes[sessionId] : "default";
43
+ }
40
44
  var LOCALIZED_TEXT_DEFAULTS = {
41
45
  zh: {
42
46
  continueText: "继续",
@@ -79,6 +83,7 @@ var DEFAULT_CONFIG = {
79
83
  backoffMaxMs: 3e5,
80
84
  notify: false,
81
85
  paused: false,
86
+ sessionModes: {},
82
87
  showComposerToggle: true,
83
88
  loopGuard: true,
84
89
  loopShortChars: 40,
@@ -92,14 +97,6 @@ var ECHO_WINDOW_MS = 10 * 60 * 1e3;
92
97
 
93
98
  // src/client/locales.ts
94
99
  var zh = {
95
- "card.title": "自动继续",
96
- "card.description": "恢复意外中断的会话,按你的节奏继续。",
97
- "repo.star": "觉得好用的话,点个 Star 吧",
98
- "repo.note": "HsiangNianian 的开源插件,也欢迎反馈和 PR。",
99
- "repo.link": "GitHub 仓库",
100
- "repo.aria": "在新标签页打开 HsiangNianian/dsh-auto-continue 的 GitHub 仓库",
101
- "chrome.enabled": "已启用",
102
- "chrome.paused": "已暂停",
103
100
  "chrome.saved": "所有更改已保存",
104
101
  "notification.title": "自动继续设置",
105
102
  "notification.enabled": "设置已保存,浏览器通知已开启。",
@@ -109,6 +106,9 @@ var zh = {
109
106
  "notification.unsupported": "设置已保存,当前浏览器不支持通知。",
110
107
  "notification.failed": "设置已保存,但浏览器通知未能发出。请检查网站和系统的通知权限。",
111
108
  "chrome.categories": "设置类别",
109
+ "repo.star": "觉得好用的话,点个 Star 吧",
110
+ "repo.link": "GitHub 仓库",
111
+ "repo.aria": "在新标签页打开 HsiangNianian/dsh-auto-continue 的 GitHub 仓库",
112
112
  "category.general.title": "常规",
113
113
  "category.general.description": "控制自动继续的启停、显示和通知。",
114
114
  "category.recovery.title": "重试策略",
@@ -121,11 +121,18 @@ var zh = {
121
121
  "category.safety.description": "避免重复执行工具,识别并打断无效循环。",
122
122
  "category.status.title": "状态与日志",
123
123
  "category.status.description": "查看活动记录与暂停的会话。",
124
- "field.paused": "自动继续",
124
+ "field.paused": "全局启用自动继续",
125
125
  "field.showComposerToggle": "在会话区显示自动继续开关",
126
- "field.showComposerToggleHint": "默认显示。隐藏开关不会暂停自动继续;点击保存后生效。",
126
+ "field.showComposerToggleHint": "默认显示。隐藏控件不会改变会话模式;点击保存后生效。",
127
127
  "composer.label": "自动继续",
128
- "composer.scope": "控制当前配置下所有会话的自动继续,修改立即保存。",
128
+ "composer.mode": "自动继续模式",
129
+ "composer.scope": "只控制当前会话,立即保存并同步到其他标签页。关闭后也不再自动打断循环。",
130
+ "composer.default": "跟随默认",
131
+ "composer.off": "关闭",
132
+ "composer.recover": "仅故障恢复",
133
+ "composer.loop": "自主循环",
134
+ "composer.paused": "全局已暂停",
135
+ "composer.unavailable": "等待宿主连接",
129
136
  "composer.saving": "正在保存自动继续设置…",
130
137
  "composer.saveFailed": "保存失败,请重试",
131
138
  "field.pausedHint": "恢复意外中断的会话。关闭并保存后,全局暂停恢复并取消已排队的继续。循环守卫独立运行;如需停止自动打断,请同时关闭循环守卫。",
@@ -137,8 +144,8 @@ var zh = {
137
144
  "default.continueTextMaxTokens": LOCALIZED_TEXT_DEFAULTS.zh.continueTextMaxTokens,
138
145
  "field.resumeSilentTurns": "续跑无输出回合",
139
146
  "field.resumeSilentTurnsHint": "已观察到模型活动但没有可见输出时续跑;不把空回合、图片或扩展内容误判为静默,冷却与连续上限照常生效。",
140
- "field.resumeCompletedTurns": "自主循环(每个回合后都续跑)",
141
- "field.resumeCompletedTurnsHint": "正常完成后经过宽限期自动续跑,不受恢复冷却和次数上限限制;仅有推理或显式无输出的回合仍消耗重试预算。暂停或关闭该选项可停止后续接力,手动停止或发送消息会取消当前待发送的继续提示。",
147
+ "field.resumeCompletedTurns": "默认会话模式",
148
+ "field.resumeCompletedTurnsHint": "用于没有单独设置模式的会话。仅故障恢复不会接力正常完成的回合;自主循环会在正常完成后继续。无输出和失败回合仍受重试预算约束。",
142
149
  "field.continueTextLoop": "自主循环的继续文本",
143
150
  "field.continueTextLoopHint": "自主循环每次续跑时发送的文本。",
144
151
  "default.continueTextLoop": LOCALIZED_TEXT_DEFAULTS.zh.continueTextLoop,
@@ -227,6 +234,7 @@ var zh = {
227
234
  "chrome.expand": "展开设置",
228
235
  "chrome.unsaved": "未保存",
229
236
  "chrome.readOnly": "当前部署的设置只读。",
237
+ "chrome.unavailable": "设置暂不可用。",
230
238
  "chrome.saveFailed": "部署未接受这些值, 已保留供你修改。",
231
239
  "chrome.discard": "放弃",
232
240
  "chrome.saving": "保存中…",
@@ -239,14 +247,6 @@ var zh = {
239
247
  "chrome.off": "关"
240
248
  };
241
249
  var en = {
242
- "card.title": "Auto continue",
243
- "card.description": "Resume interrupted sessions, at your pace.",
244
- "repo.star": "Finding it useful? Leave a Star",
245
- "repo.note": "By HsiangNianian. Feedback and PRs welcome.",
246
- "repo.link": "GitHub repo",
247
- "repo.aria": "Open HsiangNianian/dsh-auto-continue on GitHub in a new tab",
248
- "chrome.enabled": "Enabled",
249
- "chrome.paused": "Paused",
250
250
  "chrome.saved": "All changes saved",
251
251
  "notification.title": "Auto-continue settings",
252
252
  "notification.enabled": "Settings saved. Browser notifications are on.",
@@ -256,6 +256,9 @@ var en = {
256
256
  "notification.unsupported": "Settings saved. This browser does not support notifications.",
257
257
  "notification.failed": "Settings saved, but the notification could not be sent. Check notification permissions for this site and your system.",
258
258
  "chrome.categories": "Settings categories",
259
+ "repo.star": "Finding it useful? Leave a Star",
260
+ "repo.link": "GitHub repo",
261
+ "repo.aria": "Open HsiangNianian/dsh-auto-continue on GitHub in a new tab",
259
262
  "category.general.title": "General",
260
263
  "category.general.description": "Control automatic recovery, visibility, and notifications.",
261
264
  "category.recovery.title": "Retry strategy",
@@ -268,11 +271,18 @@ var en = {
268
271
  "category.safety.description": "Avoid duplicate tool actions and break unproductive loops.",
269
272
  "category.status.title": "Status and logs",
270
273
  "category.status.description": "View activity and paused sessions.",
271
- "field.paused": "Auto-continue",
274
+ "field.paused": "Enable auto-continue globally",
272
275
  "field.showComposerToggle": "Show auto-continue switch in the composer",
273
- "field.showComposerToggleHint": "Shown by default. Hiding the switch does not pause auto-continue. Click Save to apply.",
276
+ "field.showComposerToggleHint": "Shown by default. Hiding the control does not change session modes. Click Save to apply.",
274
277
  "composer.label": "Auto-continue",
275
- "composer.scope": "Controls auto-continue for all sessions in this profile. Changes save immediately.",
278
+ "composer.mode": "Auto-continue mode",
279
+ "composer.scope": "Only affects this session. Saved immediately and synced across tabs. Off also disables loop-guard interruptions here.",
280
+ "composer.default": "Follow default",
281
+ "composer.off": "Off",
282
+ "composer.recover": "Recovery only",
283
+ "composer.loop": "Autonomous loop",
284
+ "composer.paused": "Globally paused",
285
+ "composer.unavailable": "Waiting for host",
276
286
  "composer.saving": "Saving auto-continue setting…",
277
287
  "composer.saveFailed": "Could not save. Try again.",
278
288
  "field.pausedHint": "Resume interrupted sessions. Turn off and save to pause recovery globally and cancel queued continuations. The loop guard stays active; turn it off separately to stop automatic interruptions.",
@@ -284,8 +294,8 @@ var en = {
284
294
  "default.continueTextMaxTokens": LOCALIZED_TEXT_DEFAULTS.en.continueTextMaxTokens,
285
295
  "field.resumeSilentTurns": "Resume silent turns",
286
296
  "field.resumeSilentTurnsHint": "Resume observed model activity without visible output. No-op turns, images and extension blocks are not treated as silent; cooldown and retry limits still apply.",
287
- "field.resumeCompletedTurns": "Autonomous loop (continue after every turn)",
288
- "field.resumeCompletedTurnsHint": "Continue normal completions after grace, without the recovery cooldown or cap. Reasoning-only and explicit silent endings still consume the retry budget. Pause or disable this option to stop future handoffs; Stop or a manual message cancels the queued continuation.",
297
+ "field.resumeCompletedTurns": "Default session mode",
298
+ "field.resumeCompletedTurnsHint": "Applies to sessions without their own mode. Recovery only leaves normal completions alone; autonomous loop continues after them. Silent and failed turns still consume the retry budget.",
289
299
  "field.continueTextLoop": "Continue text (autonomous loop)",
290
300
  "field.continueTextLoopHint": "Text sent on each autonomous-loop continuation.",
291
301
  "default.continueTextLoop": LOCALIZED_TEXT_DEFAULTS.en.continueTextLoop,
@@ -374,6 +384,7 @@ var en = {
374
384
  "chrome.expand": "Show settings",
375
385
  "chrome.unsaved": "Unsaved",
376
386
  "chrome.readOnly": "This deployment stores settings read-only.",
387
+ "chrome.unavailable": "Settings are unavailable.",
377
388
  "chrome.saveFailed": "The deployment did not accept these values; they were left for you to correct.",
378
389
  "chrome.discard": "Discard",
379
390
  "chrome.saving": "Saving…",
@@ -451,6 +462,21 @@ function readTodayStats() {
451
462
  function readRecoveryAttempts() {
452
463
  return state.recoveryAttempts;
453
464
  }
465
+ function readSessionPolicy() {
466
+ return state.sessionPolicy;
467
+ }
468
+ async function setSessionMode(sessionId, mode) {
469
+ if (!state.sessionPolicy?.writable) throw new Error("Session settings are unavailable");
470
+ const response = await fetch("/api/auto-continue-action", {
471
+ method: "POST",
472
+ headers: { "content-type": "application/json" },
473
+ body: JSON.stringify({ action: "set-session-mode", sessionId, mode })
474
+ });
475
+ const result = await response.json();
476
+ if (!response.ok || result?.ok !== true || result.sessionId !== sessionId || result.mode !== mode) {
477
+ throw new Error("Session mode was not saved");
478
+ }
479
+ }
454
480
  function resetTodayStats() {
455
481
  void postAction({ action: "reset-stats" });
456
482
  }
@@ -475,10 +501,12 @@ async function postAction(payload) {
475
501
  }
476
502
  function handleEvent(event) {
477
503
  if (event.type === "state") {
504
+ const policy = event.sessionPolicy;
478
505
  state = {
479
506
  stats: event.stats ?? EMPTY_STATS,
480
507
  paused: event.paused ?? [],
481
- recoveryAttempts: event.recoveryAttempts ?? []
508
+ recoveryAttempts: event.recoveryAttempts ?? [],
509
+ sessionPolicy: policy && typeof policy.modes === "object" && policy.modes !== null && !Array.isArray(policy.modes) && (policy.defaultMode === "recover" || policy.defaultMode === "loop") && typeof policy.paused === "boolean" && typeof policy.writable === "boolean" ? policy : void 0
482
510
  };
483
511
  for (const listener of listeners) listener();
484
512
  } else if (event.type === "notice" && event.notice !== void 0) {
@@ -522,6 +550,11 @@ function showNotification(notice) {
522
550
  function startBridge() {
523
551
  let stopped = false;
524
552
  let controller;
553
+ const disconnected = () => {
554
+ state = { ...state, sessionPolicy: void 0 };
555
+ for (const listener of listeners) listener();
556
+ };
557
+ disconnected();
525
558
  const loop = async () => {
526
559
  while (!stopped) {
527
560
  controller = new AbortController();
@@ -533,7 +566,7 @@ function startBridge() {
533
566
  let buffer = "";
534
567
  for (; ; ) {
535
568
  const { done, value } = await reader.read();
536
- if (done) break;
569
+ if (done || stopped) break;
537
570
  buffer += decoder.decode(value, { stream: true });
538
571
  let idx = buffer.indexOf("\n\n");
539
572
  while (idx !== -1) {
@@ -552,13 +585,17 @@ function startBridge() {
552
585
  }
553
586
  } catch {
554
587
  }
555
- if (!stopped) await new Promise((resolve) => setTimeout(resolve, 3e3));
588
+ if (!stopped) {
589
+ disconnected();
590
+ await new Promise((resolve) => setTimeout(resolve, 3e3));
591
+ }
556
592
  }
557
593
  };
558
594
  void loop();
559
595
  return () => {
560
596
  stopped = true;
561
597
  controller?.abort();
598
+ disconnected();
562
599
  };
563
600
  }
564
601
 
@@ -764,13 +801,39 @@ var CardForm = class {
764
801
 
765
802
  // src/client/styles.ts
766
803
  var css = `
767
- .dshAcComposer { display: inline-flex; align-items: center; gap: 7px; min-height: 32px; flex: 0 0 auto; font: inherit; }
768
- .dshAcComposerLabel { color: var(--dsw-alias-label-secondary); font-size: 12px; white-space: nowrap; }
769
- .dshAcSwitchTarget { display: inline-flex; align-items: center; min-height: 32px; }
804
+ .dshAcComposer { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 6px; min-width: 0; min-height: 32px; max-width: 100%; font: inherit; }
805
+ .dshAcComposerCore { display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; }
806
+ .dshAcComposerCore > span { min-width: 0; }
807
+ .dshAcModeTrigger { display: inline-flex; align-items: center; gap: 3px; min-width: 0; max-width: 132px; height: 28px; margin-left: -1px; padding: 0 4px 0 7px; border: 0; border-radius: var(--dsw-radius-sm, 6px); background: none; color: var(--dsw-alias-label-secondary); font: inherit; font-size: 13px; font-weight: 500; line-height: 20px; cursor: pointer; }
808
+ .dshAcModeTrigger:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover); color: var(--dsw-alias-label-primary); }
809
+ .dshAcModeTrigger:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary)); }
810
+ .dshAcModeTrigger:disabled { color: var(--dsw-alias-label-dimmed, var(--dsw-alias-label-tertiary)); cursor: default; }
811
+ .dshAcModeTriggerLabel { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
812
+ .dshAcModeChevron { display: inline-flex; flex: none; color: var(--dsw-alias-label-caption, var(--dsw-alias-label-tertiary)); transition: transform .12s ease; }
813
+ .dshAcModeChevron > svg { display: block; width: 14px; height: 14px; }
814
+ .dshAcModeChevronFallback { fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
815
+ .dshAcModeChevron[data-open=true] { transform: rotate(180deg); }
816
+ .dshAcModeMenu { position: relative; display: inline-flex; align-items: center; gap: 3px; min-width: 0; max-width: 132px; height: 28px; margin-left: -1px; padding: 0 4px 0 7px; border-radius: var(--dsw-radius-sm, 6px); color: var(--dsw-alias-label-secondary); font-size: 13px; font-weight: 500; line-height: 20px; }
817
+ .dshAcModeMenu:hover:not([data-disabled=true]) { color: var(--dsw-alias-label-primary); background: var(--dsw-alias-interactive-bg-hover); }
818
+ .dshAcModeMenu[data-disabled=true] { color: var(--dsw-alias-label-dimmed, var(--dsw-alias-label-tertiary)); }
819
+ .dshAcComposerSelect { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; background: var(--dsw-alias-bg-base); color: var(--dsw-alias-label-primary); font: inherit; font-size: 12px; }
820
+ .dshAcComposerSelect:disabled { cursor: default; }
821
+ /* Settings-card select (default session mode); kept scoped so the composer's
822
+ invisible overlay cannot stretch it over the whole app. */
823
+ .dshAcCard .dshAcMode { min-height: 32px; max-width: 100%; padding: 4px 6px; border: 1px solid var(--dsh-ac-line); border-radius: 6px; background: var(--dsh-ac-bg); color: var(--dsh-ac-text); font: inherit; font-size: 12px; }
824
+ .dshAcCard .dshAcMode:disabled { opacity: .5; }
825
+ .dshAcCard .dshAcMode:focus-visible { outline: 2px solid var(--dsh-ac-text); outline-offset: 3px; }
826
+ .dshAcComposerLabel { display: inline-flex; align-items: center; gap: 5px; flex: none; color: var(--dsw-alias-label-secondary); font-size: 12px; white-space: nowrap; }
827
+ .dshAcComposerText { display: inline; }
828
+ .dshAcComposerIcon { display: inline-flex; flex: none; color: var(--dsw-alias-label-secondary); }
829
+ .dshAcComposerIcon > svg { display: block; width: 14px; height: 14px; }
830
+ .dshAcComposerIconFallback { fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
831
+ .dshAcSwitchTarget { display: inline-flex; align-items: center; flex: none; min-height: 32px; }
770
832
  .dshAcSwitchTarget > button { position: relative; }
771
833
  .dshAcSwitchTarget > button::before { content: ''; position: absolute; inset: -6px -3px; }
772
834
  .dshAcComposerError { color: var(--dsw-alias-state-error-primary, var(--dsw-alias-label-secondary)); font-size: 12px; max-width: 160px; }
773
835
  .dshAcComposerError:empty { display: none; }
836
+ .dshAcToastIcon { display: block; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
774
837
  .dshAcSwitch { position: relative; box-sizing: border-box; flex: none; width: 36px; height: 20px; padding: 2px; border: 0; border-radius: 999px; background: var(--dsw-alias-border-l3); cursor: pointer; }
775
838
  .dshAcSwitch[aria-checked='true'] { background: var(--dsw-alias-brand-primary); }
776
839
  .dshAcSwitch > span { display: block; width: 16px; height: 16px; border-radius: 50%; background: var(--dsw-alias-label-primary-foreground); }
@@ -797,27 +860,28 @@ var css = `
797
860
  .dshAcCard button { cursor: pointer; }
798
861
  .dshAcCard button:disabled { opacity: .4; cursor: default; }
799
862
  .dshAcCard :is(a,button,input,textarea):focus-visible { outline: 2px solid var(--dsh-ac-text); outline-offset: 3px; }
800
- .dshAcHeaderFrame { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); align-items: center; gap: 24px; margin: 20px 0; padding: 16px 18px; border-radius: 9px; color: #f9fafb; background: #23262c; }
801
- .dshAcIntroduction { min-width: 0; }
802
- .dshAcTitleLine { display: flex; align-items: center; gap: 10px; }
803
- .dshAcTitleLine h2 { font-size: 17px; font-weight: 620; line-height: 1.4; white-space: nowrap; }
804
- .dshAcStatus { white-space: nowrap; font-size: 11px; color: #dce0e6; background: #ffffff14; border-radius: 5px; padding: 2px 7px; }
805
- .dshAcIntroduction p { margin-top: 5px; color: #b9bec8; font-size: 12px; line-height: 1.6; }
806
- .dshAcRepository { display: flex; align-items: center; gap: 12px; min-width: 0; }
807
- .dshAcStar { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border: 1px solid #625032; border-radius: 50%; background: #302c25; color: #e9be6d; }
808
- .dshAcStar svg { width: 18px; height: 18px; fill: #e9be6d12; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; }
809
- .dshAcRepositoryCopy { display: flex; flex: 1; min-width: 0; flex-direction: column; gap: 5px; }
810
- .dshAcRepositoryCopy strong { font-size: 13px; font-weight: 560; line-height: 1.5; }
811
- .dshAcRepositoryCopy > span { color: #b9bec8; font-size: 10px; line-height: 1.6; }
812
- .dshAcRepositoryCopy > * { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
813
- .dshAcCard a.dshAcGithub { display: inline-flex; align-items: center; justify-content: center; gap: 8px; flex: none; min-height: 38px; padding: 9px 11px; border: 1px solid transparent; border-radius: 6px; color: #202329; background: #f4f5f7; text-decoration: none; font-size: 12px; font-weight: 550; white-space: nowrap; transition: background-color 140ms ease, box-shadow 140ms ease; }
814
- .dshAcCard a.dshAcGithub:hover { background: #fff; box-shadow: 0 0 0 3px #ffffff18; }
815
- .dshAcCard a.dshAcGithub:focus-visible { outline-color: #e9be6d; }
816
- .dshAcGithub > svg { flex: none; width: 17px; height: 17px; fill: currentColor; }
817
- .dshAcGithub > svg.dshAcExternal { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; margin-left: 2px; }
818
- .dshAcGithubShort { display: none; }
863
+ .dshAcInvite { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; margin: 0 0 18px; color: var(--dsh-ac-muted); font-size: 12px; line-height: 1.6; }
864
+ .dshAcInviteStar { color: #e9be6d; font-size: 13px; line-height: 1; }
865
+ .dshAcRepoLink { display: inline-flex; align-items: center; gap: 5px; color: var(--dsh-ac-text); text-decoration: none; }
866
+ .dshAcRepoLink:hover { text-decoration: underline; }
867
+ .dshAcRepoLink > svg:first-child { width: 14px; height: 14px; fill: currentColor; }
868
+ .dshAcRepoLink > svg.dshAcExternal { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
869
+ .dshAcNativeFields { display: flex; flex-direction: column; min-width: 0; }
870
+ .dshAcNativeField { display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 12px 0; }
871
+ .dshAcNativeHead { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; }
872
+ .dshAcNativeLabel { color: var(--dsh-ac-text); font-size: 13px; font-weight: 500; line-height: 19.5px; }
873
+ .dshAcNativeHint { color: var(--dsh-ac-muted); font-size: 12px; line-height: 18px; }
874
+ .dshAcNativeToggleRow { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-width: 0; }
875
+ .dshAcNativeActions { display: inline-flex; align-items: center; flex: none; gap: 10px; }
876
+ .dshAcNativeReset { padding: 0; border: 0; background: none; color: var(--dsh-ac-muted); font-size: 11px; white-space: nowrap; }
877
+ .dshAcNativeReset:hover:not(:disabled) { color: var(--dsh-ac-text); text-decoration: underline; }
878
+ .dshAcNativeSegment { display: block; min-width: 0; }
879
+ .dshAcNativeSegment[data-disabled=true] { opacity: .5; pointer-events: none; }
880
+ .dshAcNativeTextarea { box-sizing: border-box; width: 100%; min-height: 66px; resize: vertical; padding: 8px 12px; border: 1px solid var(--dsw-alias-border-l2); border-radius: 12px; background: var(--dsw-alias-bg-layer-2, #353638); color: var(--dsh-ac-text); font: inherit; font-size: 13px; line-height: 19.5px; }
881
+ .dshAcNativeTextarea::placeholder { color: var(--dsh-ac-muted); opacity: .7; }
882
+ .dshAcNativeTextarea[aria-invalid=true] { border-color: var(--dsw-alias-state-error-primary); }
819
883
  .dshAcReadOnly { padding: 10px 0; color: var(--dsh-ac-muted); }
820
- .dshAcLayout { display: grid; grid-template-columns: 164px minmax(0, 1fr); border-top: 1px solid var(--dsh-ac-line); min-height: 462px; }
884
+ .dshAcLayout { display: grid; grid-template-columns: 164px minmax(0, 1fr); min-height: 462px; }
821
885
  .dshAcNav { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px 16px 0; position: sticky; top: 16px; align-self: start; }
822
886
  .dshAcNav > button { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 37px; padding: 8px 11px; border: 0; border-radius: 6px; text-align: left; background: none; color: var(--dsw-alias-label-secondary); }
823
887
  .dshAcNav > button:hover, .dshAcNav > button[aria-selected=true] { color: var(--dsh-ac-text); background: var(--dsw-alias-interactive-bg-hover); }
@@ -864,9 +928,6 @@ var css = `
864
928
  .dshAcPauseId { flex: 1; font: 12px ui-monospace, SFMono-Regular, monospace; }
865
929
  .dshAcRecovery { display: grid; gap: 4px; min-width: 0; overflow-wrap: anywhere; }
866
930
  @container auto-continue-settings (max-width: 760px) {
867
- .dshAcHeaderFrame { grid-template-columns: minmax(0, 1fr) auto; gap: 16px; }
868
- .dshAcRepositoryCopy { display: none; }
869
- .dshAcRepository { gap: 10px; }
870
931
  .dshAcLayout { grid-template-columns: 136px minmax(0, 1fr); }
871
932
  .dshAcCategory { padding-left: 20px; }
872
933
  .dshAcFieldControl { flex-direction: column-reverse; align-items: flex-end; gap: 6px; }
@@ -882,18 +943,18 @@ var css = `
882
943
  .dshAcFooter { align-items: flex-start; flex-direction: column; gap: 10px; }
883
944
  .dshAcFooter > div { width: 100%; justify-content: flex-end; }
884
945
  }
885
- @container auto-continue-settings (max-width: 440px) {
886
- .dshAcHeaderFrame { gap: 12px; padding: 14px; }
887
- .dshAcTitleLine { gap: 6px; }
888
- .dshAcTitleLine h2 { font-size: 15px; white-space: normal; }
889
- .dshAcStatus { padding: 2px 5px; font-size: 10px; }
890
- .dshAcIntroduction p { font-size: 11px; }
891
- .dshAcStar, .dshAcGithubLong { display: none; }
892
- .dshAcGithubShort { display: inline; }
893
- .dshAcCard a.dshAcGithub { gap: 6px; padding: 8px; font-size: 11px; }
894
- .dshAcGithub > svg.dshAcExternal { display: none; }
946
+ /* Match the composer's own pickers (permission/mode) instead of the viewport:
947
+ the nearest query container is the composer row, so the label collapses at
948
+ the same 460px threshold as the native permission picker. */
949
+ @container (width <= 640px) {
950
+ .dshAcComposerCore { gap: 5px; }
951
+ .dshAcModeTrigger, .dshAcModeMenu { max-width: 104px; padding: 0 3px 0 6px; }
952
+ }
953
+ @container (width <= 460px) {
954
+ .dshAcComposerText { display: none; }
955
+ .dshAcModeTrigger, .dshAcModeMenu { max-width: 28px; padding: 0 2px; }
956
+ .dshAcModeTriggerLabel { display: none; }
895
957
  }
896
- @media (prefers-reduced-motion: reduce) { .dshAcCard a.dshAcGithub { transition: none; } }
897
958
 
898
959
  `;
899
960
  function injectStyles() {
@@ -946,6 +1007,17 @@ function showSettingsNotification(notice, locale, permission) {
946
1007
  // src/client/settings-card.tsx
947
1008
  var import_jsx_runtime2 = require("react/jsx-runtime");
948
1009
  injectStyles();
1010
+ var nativeSettings = (() => {
1011
+ try {
1012
+ return require("@deepseek-ai/dsh-client-ui-primitives");
1013
+ } catch {
1014
+ return {};
1015
+ }
1016
+ })();
1017
+ var NativeSettingsForm = nativeSettings.SettingsForm;
1018
+ var NativeValueField = nativeSettings.SettingsValueField;
1019
+ var NativeSegmentedControl = nativeSettings.SegmentedControl;
1020
+ var hasNativeSettings = typeof NativeSettingsForm === "function" && typeof NativeValueField === "function";
949
1021
  var AutoContinueSettingsCardController = class {
950
1022
  /**
951
1023
  * @param scope - the bound settings scope for the `auto-continue` namespace.
@@ -953,8 +1025,8 @@ var AutoContinueSettingsCardController = class {
953
1025
  constructor(scope, getLocale) {
954
1026
  this.scope = scope;
955
1027
  this.getLocale = getLocale;
956
- this.composerSaving = false;
957
- this.composerFailed = false;
1028
+ this.composerSaving = /* @__PURE__ */ new Set();
1029
+ this.composerFailed = /* @__PURE__ */ new Set();
958
1030
  this.disposed = false;
959
1031
  this.saveSequence = 0;
960
1032
  this.form = new CardForm(scope, [
@@ -992,6 +1064,7 @@ var AutoContinueSettingsCardController = class {
992
1064
  ]);
993
1065
  this.store = this.form.bind(() => this.projection(), createSnapshotStore);
994
1066
  this.composer = this.form.bind(() => this.composerProjection(), createSnapshotStore);
1067
+ this.stopComposer = subscribeBridge(() => this.composer.set(this.composerProjection()));
995
1068
  }
996
1069
  projection() {
997
1070
  return {
@@ -1055,44 +1128,44 @@ var AutoContinueSettingsCardController = class {
1055
1128
  this.notificationFeedback = showSettingsNotification(before === after ? "saved" : after ? "enabled" : "disabled", this.getLocale(), result);
1056
1129
  this.store.set(this.projection());
1057
1130
  }
1058
- injectComposer() {
1059
- return { hooks: { autoContinueComposer: this.composer }, setEnabled: (enabled) => void this.setEnabled(enabled) };
1131
+ injectComposer(sessionId) {
1132
+ return { hooks: { autoContinueComposer: this.composer }, sessionId, setMode: (mode) => void this.setMode(sessionId, mode) };
1060
1133
  }
1061
1134
  composerProjection() {
1062
1135
  const snapshot = this.scope.getSnapshot();
1136
+ const policy = readSessionPolicy();
1063
1137
  return {
1064
1138
  visible: snapshot.status === "ready" && (snapshot.value?.showComposerToggle ?? DEFAULT_CONFIG.showComposerToggle),
1065
- enabled: !(snapshot.value?.paused ?? DEFAULT_CONFIG.paused),
1066
- writable: canWriteSettings(snapshot),
1067
- saving: this.composerSaving,
1068
- failed: this.composerFailed
1139
+ policy,
1140
+ writable: canWriteSettings(snapshot) && policy?.writable === true,
1141
+ saving: new Set(this.composerSaving),
1142
+ failed: new Set(this.composerFailed)
1069
1143
  };
1070
1144
  }
1071
- async setEnabled(enabled) {
1072
- if (this.disposed || this.composerSaving || !this.composerProjection().writable) return;
1073
- this.composerSaving = true;
1074
- this.composerFailed = false;
1145
+ async setMode(sessionId, mode) {
1146
+ if (this.disposed || !sessionId || this.composerSaving.has(sessionId) || !this.composerProjection().writable) return;
1147
+ this.composerSaving.add(sessionId);
1148
+ this.composerFailed.delete(sessionId);
1075
1149
  this.composer.set(this.composerProjection());
1076
1150
  try {
1077
- const result = await this.scope.set("paused", !enabled);
1078
- this.composerFailed = result === false || this.composerProjection().enabled !== enabled;
1151
+ await setSessionMode(sessionId, mode);
1079
1152
  } catch {
1080
- this.composerFailed = true;
1153
+ this.composerFailed.add(sessionId);
1081
1154
  } finally {
1082
- this.composerSaving = false;
1155
+ this.composerSaving.delete(sessionId);
1083
1156
  if (!this.disposed) this.composer.set(this.composerProjection());
1084
1157
  }
1085
1158
  }
1086
1159
  /** Release this card's subscription to the provider-owned settings form. */
1087
1160
  dispose() {
1088
1161
  this.disposed = true;
1162
+ this.stopComposer();
1089
1163
  this.form.dispose();
1090
1164
  }
1091
1165
  };
1092
1166
  function AutoContinueSettingsPage(props) {
1093
1167
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("ul", { style: { listStyle: "none", margin: 0, padding: 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AutoContinueSettingsCard, { ...props }) });
1094
1168
  }
1095
- var REPOSITORY_URL = "https://github.com/HsiangNianian/dsh-auto-continue";
1096
1169
  var groups = [
1097
1170
  { id: "general", fields: ["paused", "showComposerToggle", "resumeSilentTurns", "resumeCompletedTurns", "notify"] },
1098
1171
  { id: "recovery", fields: ["graceMs", "cooldownMs", "maxConsecutive", "classify", "retryableErrorPatterns", "backoffFactor", "backoffMaxMs"] },
@@ -1111,20 +1184,14 @@ var textDefaults = {
1111
1184
  guardDoneText: "default.guardDoneText",
1112
1185
  loopText: "default.loopText"
1113
1186
  };
1114
- function GitHubMark() {
1115
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M12 2.4a9.8 9.8 0 0 0-3.1 19.1c.5.1.7-.2.7-.5v-1.9c-2.8.6-3.4-1.2-3.4-1.2-.5-1.1-1.1-1.4-1.1-1.4-.9-.6.1-.6.1-.6 1 0 1.5 1 1.5 1 .9 1.5 2.3 1.1 2.9.8.1-.6.4-1.1.6-1.3-2.2-.3-4.6-1.1-4.6-4.9 0-1.1.4-2 1-2.7-.1-.3-.4-1.3.1-2.7 0 0 .8-.3 2.8 1a9.5 9.5 0 0 1 5 0c1.9-1.3 2.8-1 2.8-1 .5 1.4.2 2.4.1 2.7.6.7 1 1.6 1 2.7 0 3.8-2.3 4.6-4.6 4.9.4.3.7.9.7 1.8V21c0 .3.2.6.7.5A9.8 9.8 0 0 0 12 2.4Z" }) });
1116
- }
1187
+ var REPOSITORY_URL = "https://github.com/HsiangNianian/dsh-auto-continue";
1117
1188
  function RepositoryInvite({ t }) {
1118
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("aside", { className: "dshAcRepository", children: [
1119
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dshAcStar", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", { viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "m12 3 2.78 5.63L21 9.53l-4.5 4.39 1.06 6.2L12 17.2l-5.56 2.92 1.06-6.2L3 9.53l6.22-.9L12 3Z" }) }) }),
1120
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "dshAcRepositoryCopy", children: [
1121
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: t("repo.star") }),
1122
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: t("repo.note") })
1123
- ] }),
1124
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("a", { className: "dshAcGithub", href: REPOSITORY_URL, target: "_blank", rel: "noopener noreferrer", "aria-label": t("repo.aria"), children: [
1125
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(GitHubMark, {}),
1126
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dshAcGithubLong", children: t("repo.link") }),
1127
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dshAcGithubShort", children: "GitHub" }),
1189
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("p", { className: "dshAcInvite", children: [
1190
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dshAcInviteStar", "aria-hidden": "true", children: "★" }),
1191
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: t("repo.star") }),
1192
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("a", { className: "dshAcRepoLink", href: REPOSITORY_URL, target: "_blank", rel: "noopener noreferrer", "aria-label": t("repo.aria"), children: [
1193
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M12 2.4a9.8 9.8 0 0 0-3.1 19.1c.5.1.7-.2.7-.5v-1.9c-2.8.6-3.4-1.2-3.4-1.2-.5-1.1-1.1-1.4-1.1-1.4-.9-.6.1-.6.1-.6 1 0 1.5 1 1.5 1 .9 1.5 2.3 1.1 2.9.8.1-.6.4-1.1.6-1.3-2.2-.3-4.6-1.1-4.6-4.9 0-1.1.4-2 1-2.7-.1-.3-.4-1.3.1-2.7 0 0 .8-.3 2.8 1a9.5 9.5 0 0 1 5 0c1.9-1.3 2.8-1 2.8-1 .5 1.4.2 2.4.1 2.7.6.7 1 1.6 1 2.7 0 3.8-2.3 4.6-4.6 4.9.4.3.7.9.7 1.8V21c0 .3.2.6.7.5A9.8 9.8 0 0 0 12 2.4Z" }) }),
1194
+ t("repo.link"),
1128
1195
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", { className: "dshAcExternal", viewBox: "0 0 16 16", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M6 3h7v7M13 3 7 9M11 9v3a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1h3" }) })
1129
1196
  ] })
1130
1197
  ] });
@@ -1145,7 +1212,22 @@ function SettingField({ name, id, state: state2, actions, disabled, t }) {
1145
1212
  ] }),
1146
1213
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dshAcFieldControl", children: [
1147
1214
  state2.overridden && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "dshAcReset", disabled, "aria-label": `${t("chrome.reset")}: ${label}`, onClick: () => actions.resetField(name), children: t("chrome.reset") }),
1148
- boolean ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dshAcSwitchTarget", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1215
+ name === "resumeCompletedTurns" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1216
+ "select",
1217
+ {
1218
+ id,
1219
+ className: "dshAcMode",
1220
+ "aria-label": label,
1221
+ "aria-describedby": `${id}-hint`,
1222
+ disabled,
1223
+ value: String(value),
1224
+ onChange: (event) => actions.edit(name, event.target.value),
1225
+ children: [
1226
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "false", children: t("composer.recover") }),
1227
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "true", children: t("composer.loop") })
1228
+ ]
1229
+ }
1230
+ ) : boolean ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dshAcSwitchTarget", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1149
1231
  NativeSwitch,
1150
1232
  {
1151
1233
  label,
@@ -1158,6 +1240,92 @@ function SettingField({ name, id, state: state2, actions, disabled, t }) {
1158
1240
  ] })
1159
1241
  ] });
1160
1242
  }
1243
+ function NativeSettingField({ name, id, state: state2, actions, disabled, t }) {
1244
+ const boolean = typeof DEFAULT_CONFIG[name] === "boolean";
1245
+ const numeric = typeof DEFAULT_CONFIG[name] === "number";
1246
+ const label = t(`field.${name}`);
1247
+ const hint = t(`field.${name}Hint`);
1248
+ const value = state2.text === "" ? DEFAULT_CONFIG[name] : state2.text === "true";
1249
+ const placeholderKey = textDefaults[name];
1250
+ const placeholder = placeholderKey ? t(placeholderKey) : name === "retryableErrorPatterns" ? t("field.retryableErrorPatternsPlaceholder") : String(DEFAULT_CONFIG[name]);
1251
+ const reset = state2.overridden ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "dshAcNativeReset", disabled, "aria-label": `${t("chrome.reset")}: ${label}`, onClick: () => actions.resetField(name), children: t("chrome.reset") }) : null;
1252
+ if (name === "resumeCompletedTurns") {
1253
+ const items = [{ value: "false", label: t("composer.recover") }, { value: "true", label: t("composer.loop") }];
1254
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dshAcNativeField", "data-field": name, children: [
1255
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dshAcNativeHead", children: [
1256
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("label", { className: "dshAcNativeLabel", htmlFor: id, children: label }),
1257
+ reset
1258
+ ] }),
1259
+ NativeSegmentedControl ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(NativeSegmentedControl, { id, options: items, value: value ? "true" : "false", onChange: (next) => actions.edit(name, next), label, disabled }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("select", { id, className: "dshAcMode", "aria-label": label, disabled, value: String(value), onChange: (event) => actions.edit(name, event.target.value), children: [
1260
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "false", children: t("composer.recover") }),
1261
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "true", children: t("composer.loop") })
1262
+ ] }),
1263
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "dshAcNativeHint", id: `${id}-hint`, children: hint })
1264
+ ] });
1265
+ }
1266
+ if (boolean) {
1267
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dshAcNativeField", "data-field": name, children: [
1268
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dshAcNativeToggleRow", children: [
1269
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("label", { className: "dshAcNativeLabel", htmlFor: id, children: label }),
1270
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "dshAcNativeActions", children: [
1271
+ reset,
1272
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1273
+ NativeSwitch,
1274
+ {
1275
+ label,
1276
+ title: hint,
1277
+ disabled,
1278
+ checked: name === "paused" ? !value : Boolean(value),
1279
+ onChange: (checked) => actions.edit(name, String(name === "paused" ? !checked : checked))
1280
+ }
1281
+ )
1282
+ ] })
1283
+ ] }),
1284
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "dshAcNativeHint", id: `${id}-hint`, children: hint })
1285
+ ] });
1286
+ }
1287
+ if (numeric) {
1288
+ const ValueField = NativeValueField;
1289
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1290
+ ValueField,
1291
+ {
1292
+ id,
1293
+ label,
1294
+ hint,
1295
+ overriddenLabel: t("chrome.overridden"),
1296
+ resetLabel: t("chrome.reset"),
1297
+ invalidLabel: t("chrome.invalidNumber"),
1298
+ disabled,
1299
+ numeric: true,
1300
+ ...state2,
1301
+ placeholder,
1302
+ onEdit: (text) => actions.edit(name, text),
1303
+ onReset: () => actions.resetField(name)
1304
+ }
1305
+ );
1306
+ }
1307
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dshAcNativeField", "data-field": name, children: [
1308
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dshAcNativeHead", children: [
1309
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("label", { className: "dshAcNativeLabel", htmlFor: id, children: label }),
1310
+ reset
1311
+ ] }),
1312
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1313
+ "textarea",
1314
+ {
1315
+ id,
1316
+ className: "dshAcNativeTextarea",
1317
+ rows: name === "retryableErrorPatterns" ? 3 : 2,
1318
+ disabled,
1319
+ value: state2.text,
1320
+ placeholder,
1321
+ "aria-invalid": state2.invalid || void 0,
1322
+ "aria-describedby": `${id}-hint`,
1323
+ onChange: (event) => actions.edit(name, event.target.value)
1324
+ }
1325
+ ),
1326
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "dshAcNativeHint", id: `${id}-hint`, children: state2.invalid ? t("chrome.invalidNumber") : hint })
1327
+ ] });
1328
+ }
1161
1329
  function LivePanels(props) {
1162
1330
  const { t } = props;
1163
1331
  const [, refresh] = (0, import_react.useState)(0);
@@ -1306,19 +1474,11 @@ function AutoContinueSettingsCard(props) {
1306
1474
  const [active, setActive] = (0, import_react.useState)("general");
1307
1475
  const prefix = (0, import_react.useId)();
1308
1476
  const group = groups.find((item) => item.id === active);
1477
+ const native = hasNativeSettings;
1309
1478
  if (!state2.available) return null;
1310
1479
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("li", { className: "dshAcCard", children: [
1311
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("header", { className: "dshAcHeaderFrame", children: [
1312
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dshAcIntroduction", children: [
1313
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dshAcTitleLine", children: [
1314
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h2", { children: t("card.title") }),
1315
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dshAcStatus", children: t(state2.enabled ? "chrome.enabled" : "chrome.paused") })
1316
- ] }),
1317
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: t("card.description") })
1318
- ] }),
1319
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(RepositoryInvite, { t })
1320
- ] }),
1321
- !state2.writable && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "dshAcReadOnly", role: "status", children: t("chrome.readOnly") }),
1480
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(RepositoryInvite, { t }),
1481
+ !native && !state2.writable && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "dshAcReadOnly", role: "status", children: t("chrome.readOnly") }),
1322
1482
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dshAcLayout", children: [
1323
1483
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dshAcNav", role: "tablist", "aria-label": t("chrome.categories"), children: groups.map((item, index) => {
1324
1484
  const invalid = item.fields.some((name) => state2[name].invalid);
@@ -1358,39 +1518,220 @@ function AutoContinueSettingsCard(props) {
1358
1518
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h3", { children: t(`category.${active}.title`) }),
1359
1519
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: t(`category.${active}.description`) })
1360
1520
  ] }),
1361
- group.fields.map((name) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SettingField, { name, id: `${prefix}-${name}`, state: state2[name], actions: props, disabled: !state2.writable, t }, name)),
1362
- active === "status" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(LivePanels, { t })
1363
- ] })
1364
- ] }),
1365
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("footer", { className: "dshAcFooter", "data-dirty": state2.dirty, children: [
1366
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: state2.failed || state2.invalid ? "dshAcInvalid" : "dshAcHint", role: "status", children: t(state2.failed ? "chrome.saveFailed" : state2.invalid ? "chrome.invalidNumber" : state2.saving ? "chrome.saving" : state2.dirty ? "chrome.unsaved" : state2.notificationFeedback ?? "chrome.saved") }),
1367
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
1368
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "dshAcDiscard", disabled: !state2.dirty || state2.saving, onClick: props.discard, children: t("chrome.discard") }),
1369
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "dshAcSave", disabled: !state2.dirty || state2.invalid || state2.saving || !state2.writable, onClick: props.save, children: t(state2.saving ? "chrome.saving" : "chrome.save") })
1521
+ native ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(NativeSettingsForm, { labels: {
1522
+ save: t("chrome.save"),
1523
+ saving: t("chrome.saving"),
1524
+ saveFailed: t("chrome.saveFailed"),
1525
+ readOnly: t("chrome.readOnly"),
1526
+ unavailable: t("chrome.unavailable")
1527
+ }, state: state2, onSave: props.save, onDiscard: props.discard, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dshAcNativeFields", children: [
1528
+ group.fields.map((name) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(NativeSettingField, { name, id: `${prefix}-${name}`, state: state2[name], actions: props, disabled: !state2.writable, t }, name)),
1529
+ active === "status" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(LivePanels, { t })
1530
+ ] }) }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
1531
+ group.fields.map((name) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SettingField, { name, id: `${prefix}-${name}`, state: state2[name], actions: props, disabled: !state2.writable, t }, name)),
1532
+ active === "status" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(LivePanels, { t }),
1533
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("footer", { className: "dshAcFooter", "data-dirty": state2.dirty, children: [
1534
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: state2.failed || state2.invalid ? "dshAcInvalid" : "dshAcHint", role: "status", children: t(state2.failed ? "chrome.saveFailed" : state2.invalid ? "chrome.invalidNumber" : state2.saving ? "chrome.saving" : state2.dirty ? "chrome.unsaved" : state2.notificationFeedback ?? "chrome.saved") }),
1535
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
1536
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "dshAcDiscard", disabled: !state2.dirty || state2.saving, onClick: props.discard, children: t("chrome.discard") }),
1537
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "dshAcSave", disabled: !state2.dirty || state2.invalid || state2.saving || !state2.writable, onClick: props.save, children: t(state2.saving ? "chrome.saving" : "chrome.save") })
1538
+ ] })
1539
+ ] })
1540
+ ] })
1370
1541
  ] })
1371
1542
  ] })
1372
1543
  ] });
1373
1544
  }
1374
1545
 
1375
1546
  // src/client/composer-toggle.tsx
1547
+ var import_react3 = require("react");
1548
+
1549
+ // src/client/mode-menu.tsx
1550
+ var import_react2 = require("react");
1376
1551
  var import_jsx_runtime3 = require("react/jsx-runtime");
1377
- function AutoContinueComposerToggle(props) {
1378
- const state2 = props.useAutoContinueComposer((snapshot) => snapshot);
1379
- if (!state2.visible) return null;
1380
- const title = props.t(!state2.writable ? "chrome.readOnly" : state2.saving ? "composer.saving" : "composer.scope");
1381
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "dshAcComposer", title, children: [
1382
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dshAcComposerLabel", children: props.t("composer.label") }),
1383
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dshAcSwitchTarget", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1384
- NativeSwitch,
1552
+ var primitives = (() => {
1553
+ try {
1554
+ return require("@deepseek-ai/dsh-client-ui-primitives");
1555
+ } catch {
1556
+ return {};
1557
+ }
1558
+ })();
1559
+ var HostMenu = primitives.Menu;
1560
+ var HostChevron = primitives.IconChevronDownOutlineRegular;
1561
+ function ChevronDown() {
1562
+ if (HostChevron) return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(HostChevron, {});
1563
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("svg", { className: "dshAcModeChevronFallback", viewBox: "0 0 16 16", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "m4.5 6.25 3.5 3.5 3.5-3.5" }) });
1564
+ }
1565
+ function ModeMenu(props) {
1566
+ const [open, setOpen] = (0, import_react2.useState)(false);
1567
+ const expanded = open && !props.disabled;
1568
+ (0, import_react2.useEffect)(() => {
1569
+ if (props.disabled) setOpen(false);
1570
+ }, [props.disabled]);
1571
+ const choose = (id) => {
1572
+ setOpen(false);
1573
+ if (isSessionMode(id) && id !== props.mode) props.onChange(id);
1574
+ };
1575
+ if (HostMenu) {
1576
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1577
+ HostMenu,
1385
1578
  {
1386
- checked: state2.enabled,
1387
- onChange: props.setEnabled,
1388
- disabled: !state2.writable || state2.saving,
1389
- label: props.t("composer.label"),
1390
- title
1579
+ open: expanded,
1580
+ side: "top",
1581
+ portal: true,
1582
+ items: props.options,
1583
+ selectedId: props.mode,
1584
+ onSelect: choose,
1585
+ onClose: () => setOpen(false),
1586
+ anchor: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
1587
+ "button",
1588
+ {
1589
+ type: "button",
1590
+ className: "dshAcModeTrigger",
1591
+ disabled: props.disabled,
1592
+ "aria-label": props.ariaLabel,
1593
+ "aria-haspopup": "menu",
1594
+ "aria-expanded": expanded,
1595
+ title: props.title,
1596
+ onClick: () => setOpen((value) => !value),
1597
+ children: [
1598
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dshAcModeTriggerLabel", children: props.label }),
1599
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dshAcModeChevron", "data-open": expanded, "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ChevronDown, {}) })
1600
+ ]
1601
+ }
1602
+ )
1391
1603
  }
1392
- ) }),
1393
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dshAcComposerError", role: "status", children: state2.failed ? props.t("composer.saveFailed") : null })
1604
+ );
1605
+ }
1606
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "dshAcModeMenu", "data-disabled": props.disabled, title: props.title, children: [
1607
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dshAcModeTriggerLabel", children: props.label }),
1608
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dshAcModeChevron", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ChevronDown, {}) }),
1609
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1610
+ "select",
1611
+ {
1612
+ className: "dshAcComposerSelect",
1613
+ "aria-label": props.selectLabel,
1614
+ disabled: props.disabled,
1615
+ value: props.mode,
1616
+ onChange: (event) => {
1617
+ if (isSessionMode(event.target.value)) props.onChange(event.target.value);
1618
+ },
1619
+ children: props.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("option", { value: option.id, children: option.label }, option.id))
1620
+ }
1621
+ )
1622
+ ] });
1623
+ }
1624
+
1625
+ // src/client/auto-continue-icon.tsx
1626
+ var import_jsx_runtime4 = require("react/jsx-runtime");
1627
+ var primitives2 = (() => {
1628
+ try {
1629
+ return require("@deepseek-ai/dsh-client-ui-primitives");
1630
+ } catch {
1631
+ return {};
1632
+ }
1633
+ })();
1634
+ var HostRefresh = primitives2.IconRefreshOutlineRegular;
1635
+ function AutoContinueIcon() {
1636
+ if (HostRefresh) return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(HostRefresh, {});
1637
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("svg", { className: "dshAcComposerIconFallback", viewBox: "0 0 16 16", "aria-hidden": "true", children: [
1638
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M13.25 8a5.25 5.25 0 1 1-1.54-3.71" }),
1639
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M13.25 3.1v3.3h-3.3" })
1640
+ ] });
1641
+ }
1642
+
1643
+ // src/client/native-toast.tsx
1644
+ var import_jsx_runtime5 = require("react/jsx-runtime");
1645
+ var primitives3 = (() => {
1646
+ try {
1647
+ return require("@deepseek-ai/dsh-client-ui-primitives");
1648
+ } catch {
1649
+ return {};
1650
+ }
1651
+ })();
1652
+ var NativeToast = primitives3.Toast;
1653
+ var hasNativeToast = typeof NativeToast === "function";
1654
+ function WarningIcon() {
1655
+ const Icon = primitives3.IconWarningOutlineRegular;
1656
+ if (Icon) return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Icon, {});
1657
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("svg", { className: "dshAcToastIcon", viewBox: "0 0 16 16", "aria-hidden": "true", children: [
1658
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M8 2.3 14.3 13H1.7L8 2.3Z" }),
1659
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M8 6.2v3.1M8 11.8v.1" })
1660
+ ] });
1661
+ }
1662
+
1663
+ // src/client/composer-toggle.tsx
1664
+ var import_jsx_runtime6 = require("react/jsx-runtime");
1665
+ var HOST_UNAVAILABLE_DELAY_MS = 3e3;
1666
+ function HostUnavailableToast({ text }) {
1667
+ const [visible, setVisible] = (0, import_react3.useState)(false);
1668
+ (0, import_react3.useEffect)(() => {
1669
+ const timer = setTimeout(() => setVisible(true), HOST_UNAVAILABLE_DELAY_MS);
1670
+ return () => clearTimeout(timer);
1671
+ }, []);
1672
+ if (!hasNativeToast || !visible) return null;
1673
+ const Toast = NativeToast;
1674
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Toast, { text, icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(WarningIcon, {}), onDone: () => setVisible(false) });
1675
+ }
1676
+ function SaveFailureToast({ text }) {
1677
+ const [visible, setVisible] = (0, import_react3.useState)(true);
1678
+ if (!hasNativeToast || !visible) return null;
1679
+ const Toast = NativeToast;
1680
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Toast, { text, icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(WarningIcon, {}), onDone: () => setVisible(false) });
1681
+ }
1682
+ function AutoContinueComposerToggle(props) {
1683
+ const state2 = props.useAutoContinueComposer((snapshot) => snapshot);
1684
+ if (!state2.visible || !props.sessionId) return null;
1685
+ const failed = state2.failed.has(props.sessionId);
1686
+ const saving = state2.saving.has(props.sessionId);
1687
+ const policy = state2.policy;
1688
+ const mode = sessionMode(policy?.modes ?? {}, props.sessionId);
1689
+ const disabled = !policy || !state2.writable || saving;
1690
+ const title = props.t(!policy ? "composer.unavailable" : !state2.writable ? "chrome.readOnly" : saving ? "composer.saving" : "composer.scope");
1691
+ const modeName = props.t(`composer.${mode}`);
1692
+ const defaultName = policy ? `${props.t("composer.default")} (${props.t(`composer.${policy.defaultMode}`)})` : props.t("composer.default");
1693
+ const fullModeLabel = mode === "default" ? defaultName : modeName;
1694
+ const modeTitle = `${props.t("composer.mode")}: ${fullModeLabel}`;
1695
+ const options = [
1696
+ { id: "default", label: defaultName },
1697
+ { id: "off", label: props.t("composer.off") },
1698
+ { id: "recover", label: props.t("composer.recover") },
1699
+ { id: "loop", label: props.t("composer.loop") }
1700
+ ];
1701
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "dshAcComposer", title, "aria-busy": saving || void 0, children: [
1702
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "dshAcComposerCore", children: [
1703
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "dshAcComposerLabel", children: [
1704
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "dshAcComposerIcon", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(AutoContinueIcon, {}) }),
1705
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "dshAcComposerText", children: props.t("composer.label") })
1706
+ ] }),
1707
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "dshAcSwitchTarget", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1708
+ NativeSwitch,
1709
+ {
1710
+ checked: !!policy && mode !== "off",
1711
+ onChange: (enabled) => props.setMode(enabled ? "default" : "off"),
1712
+ disabled,
1713
+ label: props.t("composer.label"),
1714
+ title
1715
+ }
1716
+ ) }),
1717
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1718
+ ModeMenu,
1719
+ {
1720
+ mode,
1721
+ options,
1722
+ label: modeName,
1723
+ ariaLabel: modeTitle,
1724
+ selectLabel: props.t("composer.mode"),
1725
+ title: modeTitle,
1726
+ disabled,
1727
+ onChange: props.setMode
1728
+ }
1729
+ )
1730
+ ] }),
1731
+ policy?.paused && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "dshAcComposerLabel", children: props.t("composer.paused") }),
1732
+ !policy && hasNativeToast && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(HostUnavailableToast, { text: props.t("composer.unavailable") }),
1733
+ failed && hasNativeToast && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SaveFailureToast, { text: props.t("composer.saveFailed") }),
1734
+ failed && !hasNativeToast && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "dshAcComposerError", role: "status", children: props.t("composer.saveFailed") })
1394
1735
  ] });
1395
1736
  }
1396
1737
 
@@ -1438,7 +1779,7 @@ function mountSettings(ctx, scope) {
1438
1779
  name: "conversation.input.left",
1439
1780
  id: "auto-continue",
1440
1781
  locale: NS,
1441
- inject: () => controller.injectComposer()
1782
+ inject: (sessionId) => controller.injectComposer(sessionId)
1442
1783
  },
1443
1784
  AutoContinueComposerToggle
1444
1785
  )