dsh-deep-ptc-mode 1.8.6 → 1.8.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js CHANGED
@@ -6,11 +6,17 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
6
6
  const dictionaries = {
7
7
  zh: {
8
8
  title: '深度 PTC', summary: '选择执行环境,应用于之后新建的深度 PTC 会话。',
9
+ presetName: '深度 PTC 模式',
10
+ presetDescription: '任务运行时可插话,按任务规模制定计划,意图不清时先提问。支持 WSL、PowerShell、Zsh 和 Bash。',
11
+ presetEnvironment: '当前环境:{env}', presetSafeMode: '当前为安全模式', presetOfficial: '官方默认',
9
12
  environment: '执行环境', auto: '自动(Windows:PowerShell;macOS:Zsh;Linux:Bash)',
10
13
  wsl: 'WSL Bash(Windows)', powershell: 'PowerShell(Windows)',
11
14
  zsh: 'Zsh(macOS / Linux)', bash: '原生 Bash(macOS / Linux)',
15
+ windowsBash: '原生 Bash(Windows)', bashPath: 'bash.exe 的绝对路径',
16
+ bashPathHint: '可填写 dsh-ops 随包的 Niubash。路径不可用时保留官方 Shell。受限模式请选 PowerShell。',
12
17
  distribution: 'WSL 发行版', distributionHint: '留空使用 Windows 的默认发行版,例如 Ubuntu。',
13
18
  shell: 'Shell 版本', shellAuto: '自动(沿用官方查找顺序)',
19
+ shellSystem: '{name}(系统自带)', shellPreview: 'PowerShell 7 预览版',
14
20
  shellHint: '只列出本机已发现的常见版本。文件消失后自动回退。WSL 仍只选择发行版。',
15
21
  sessions: '保存后请新建一个“深度PTC模式”会话。已有会话与后台任务保留原环境。',
16
22
  wslHint: 'WSL 暂不支持 Windows 的受限沙箱;受限调用会明确失败,不会自动切换或绕过限制。',
@@ -20,11 +26,17 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
20
26
  },
21
27
  en: {
22
28
  title: 'Deep PTC', summary: 'Choose the execution environment for new Deep PTC sessions.',
29
+ presetName: 'Deep PTC Mode',
30
+ presetDescription: 'Steer running tasks, plan according to task size, and clarify unclear requests. Supports WSL, PowerShell, Zsh, and Bash.',
31
+ presetEnvironment: 'Current environment: {env}', presetSafeMode: 'Safe mode is active', presetOfficial: 'Official default',
23
32
  environment: 'Execution environment', auto: 'Automatic (Windows: PowerShell; macOS: Zsh; Linux: Bash)',
24
33
  wsl: 'WSL Bash (Windows)', powershell: 'PowerShell (Windows)',
25
34
  zsh: 'Zsh (macOS / Linux)', bash: 'Native Bash (macOS / Linux)',
35
+ windowsBash: 'Native Bash (Windows)', bashPath: 'Absolute path to bash.exe',
36
+ bashPathHint: 'You can use the Niubash bundled with dsh-ops. An unavailable path keeps the official shell. Choose PowerShell for confined work.',
26
37
  distribution: 'WSL distribution', distributionHint: 'Leave blank for the Windows default distribution, for example Ubuntu.',
27
38
  shell: 'Shell version', shellAuto: 'Automatic (official lookup)',
39
+ shellSystem: '{name} (system)', shellPreview: 'PowerShell 7 Preview',
28
40
  shellHint: 'Lists common executables found on this machine. A missing file falls back to automatic. WSL still selects a distribution only.',
29
41
  sessions: 'After saving, create a new Deep PTC session. Existing sessions and background jobs keep their environment.',
30
42
  wslHint: 'WSL does not support the confined Windows sandbox. Confined calls fail without execution or fallback.',
@@ -55,8 +67,9 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
55
67
  }, [state.value, state.revision]);
56
68
  if (view === 'summary') return t('summary');
57
69
  if (state.status !== 'ready') return h('p', null, t('loading'));
58
- const allowed = state.value.hostPlatform === 'win32'
59
- ? ['auto', 'wsl', 'powershell'] : ['auto', 'zsh', 'bash'];
70
+ const platform = state.value.hostPlatform;
71
+ const allowed = allowedEnvironments(platform);
72
+ const windowsBash = platform === 'win32' && environment === 'bash';
60
73
  const disabled = !state.writable || saving;
61
74
  const changed = () => {
62
75
  if (!dirty.current) draftRevision.current = state.revision;
@@ -70,7 +83,7 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
70
83
  const ok = await form.mutate([
71
84
  { op: 'set', path: ['environment'], value: environment },
72
85
  { op: 'set', path: ['wslDistribution'], value: distribution.trim() },
73
- { op: 'set', path: ['shellExecutable'], value: shellExecutable },
86
+ { op: 'set', path: ['shellExecutable'], value: windowsBash ? shellExecutable.trim() : shellExecutable },
74
87
  ], draftRevision.current);
75
88
  if (!ok) throw new Error('Configuration was rejected');
76
89
  dirty.current = false;
@@ -79,10 +92,10 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
79
92
  setEnvironment(latest.value?.environment ?? environment);
80
93
  setDistribution(latest.value?.wslDistribution ?? distribution.trim());
81
94
  setShellExecutable(latest.value?.shellExecutable ?? shellExecutable);
82
- setMessage(t('saved'));
95
+ setMessage('saved');
83
96
  } catch {
84
97
  draftRevision.current = form.getSnapshot().revision;
85
- setFailed(true); setMessage(t('failed'));
98
+ setFailed(true); setMessage('failed');
86
99
  } finally { setSaving(false); }
87
100
  }
88
101
  const effective = environment === 'auto'
@@ -96,33 +109,43 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
96
109
  return h('form', { onSubmit: save, style: { display: 'grid', gap: '12px', maxWidth: '600px' } },
97
110
  h('label', { htmlFor: 'deep-ptc-environment' }, t('environment')),
98
111
  h('select', { id: 'deep-ptc-environment', value: environment, disabled, style: control,
99
- onChange: event => { changed(); setEnvironment(event.target.value); } },
112
+ onChange: event => {
113
+ changed();
114
+ const next = event.target.value;
115
+ if (platform === 'win32' && (environment === 'bash' || next === 'bash')) setShellExecutable('');
116
+ setEnvironment(next);
117
+ } },
100
118
  ...['auto', 'wsl', 'powershell', 'zsh', 'bash'].map(value =>
101
- h('option', { key: value, value, disabled: !allowed.includes(value) }, t(value)))),
119
+ h('option', { key: value, value, disabled: !allowed.includes(value) }, t(platform === 'win32' && value === 'bash' ? 'windowsBash' : value)))),
102
120
  environment === 'wsl' ? h(React.Fragment, null,
103
121
  h('label', { htmlFor: 'deep-ptc-distribution' }, t('distribution')),
104
122
  h('input', { id: 'deep-ptc-distribution', value: distribution, disabled, style: control,
105
123
  onChange: event => { changed(); setDistribution(event.target.value); } }),
106
124
  h('p', null, t('distributionHint')), h('p', null, t('wslHint'))) : null,
107
- showShell ? h(React.Fragment, null,
125
+ windowsBash ? h(React.Fragment, null,
126
+ h('label', { htmlFor: 'deep-ptc-shell' }, t('bashPath')),
127
+ h('input', { id: 'deep-ptc-shell', value: shellExecutable, disabled, style: control, required: true,
128
+ onChange: event => { changed(); setShellExecutable(event.target.value); } }),
129
+ h('p', null, t('bashPathHint'))) : showShell ? h(React.Fragment, null,
108
130
  h('label', { htmlFor: 'deep-ptc-shell' }, t('shell')),
109
131
  h('select', { id: 'deep-ptc-shell', value: shellExecutable, disabled, style: control,
110
132
  onChange: event => { changed(); setShellExecutable(event.target.value); } },
111
133
  h('option', { value: '' }, t('shellAuto')),
112
- ...choices.map(item => h('option', { key: item.id, value: item.id }, item.label))),
134
+ ...choices.map(item => h('option', { key: item.id, value: item.id }, shellLabel(item.label, t)))),
113
135
  h('p', null, t('shellHint'))) : null,
114
136
  h('p', null, t('sessions')),
115
137
  !state.writable ? h('p', { role: 'status' }, t('readOnly')) : null,
116
- message ? h('p', { role: failed ? 'alert' : 'status' }, message) : null,
117
- h('button', { type: 'submit', disabled, style: { justifySelf: 'start', padding: '7px 16px' } }, t(saving ? 'saving' : 'save')),
138
+ message ? h('p', { role: failed ? 'alert' : 'status' }, t(message)) : null,
139
+ h('button', { type: 'submit', disabled: disabled || (windowsBash && !shellExecutable.trim()),
140
+ style: { justifySelf: 'start', padding: '7px 16px' } }, t(saving ? 'saving' : 'save')),
118
141
  );
119
142
  }
120
143
 
121
144
  function ToolStateControls({ sessionId, useProjection, reset, t }) {
122
145
  const [busy, setBusy] = React.useState(false);
123
- const [message, setMessage] = React.useState('');
146
+ const [message, setMessage] = React.useState(null);
124
147
  const generation = React.useRef(0);
125
- React.useEffect(() => { generation.current++; setBusy(false); setMessage(''); return () => { generation.current++; }; }, [sessionId]);
148
+ React.useEffect(() => { generation.current++; setBusy(false); setMessage(null); return () => { generation.current++; }; }, [sessionId]);
126
149
  let preset, state;
127
150
  try {
128
151
  if (typeof useProjection !== 'function') return null;
@@ -134,16 +157,25 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
134
157
  const failed = state && typeof state === 'object' ? state.report?.tools ?? [] : [];
135
158
  async function reload() {
136
159
  const current = generation.current;
137
- setBusy(true); setMessage('');
160
+ setBusy(true); setMessage(null);
138
161
  try {
139
162
  const outcome = await reset();
140
163
  if (current !== generation.current) return;
141
- if (outcome?.ok === false) throw new Error(outcome.error?.message || t('toolResetFailed'));
164
+ if (outcome?.ok === false) throw new Error(outcome.error?.message);
142
165
  const reply = outcome?.ok === true ? outcome.value : outcome;
166
+ if (reply === undefined) {
167
+ setMessage({ key: 'toolResetFailed', reason: 'toolResetUnavailable' });
168
+ return;
169
+ }
143
170
  const result = reply?.result ?? reply;
144
- if (result?.kind !== 'success') throw new Error(result?.text || t('toolResetFailed'));
145
- setMessage(t('toolResetDone'));
146
- } catch (error) { if (current === generation.current) setMessage(t('toolResetFailed') + ': ' + String(error?.message ?? error).slice(0,220)); }
171
+ if (result?.kind !== 'success') throw new Error(result?.text);
172
+ setMessage({ key: 'toolResetDone' });
173
+ } catch (error) {
174
+ if (current === generation.current) {
175
+ const detail = String(error?.message ?? error ?? '').slice(0, 220);
176
+ setMessage({ key: 'toolResetFailed', detail });
177
+ }
178
+ }
147
179
  finally { if (current === generation.current) setBusy(false); }
148
180
  }
149
181
  return h('section', { className: 'dpt-side-section dpt-side-tools', 'aria-label': t('toolsSection') },
@@ -154,17 +186,27 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
154
186
  h('ul', null, ...failed.map(row => h('li', { key: row.name }, h('code', null, row.name), ` — ${row.provider}`)))) : null,
155
187
  h('button', { type: 'button', className: 'dpt-btn dpt-btn-block', onClick: reload, disabled: busy, title: t('toolResetHint'), 'aria-busy': busy },
156
188
  busy ? t('toolResetBusy') : t('toolReset')),
157
- h('p', { className: 'dpt-side-note', role: 'status', 'data-tone': message ? (message === t('toolResetDone') ? 'ok' : 'error') : undefined },
158
- message || t('toolResetHint')));
189
+ h('p', { className: 'dpt-side-note', role: 'status', 'data-tone': message ? (message.key === 'toolResetDone' ? 'ok' : 'error') : undefined },
190
+ message ? [t(message.key), message.reason ? t(message.reason) : commandText(message.detail, t)].filter(Boolean).join(' ') : t('toolResetHint')));
159
191
  }
160
192
  Object.assign(dictionaries.zh, {
193
+ visualEffects: '界面特效', visualEffectsHint: '使用外部主题或 UI 插件时,建议关闭此开关。',
194
+ jobsTitle: '后台任务', jobsEmpty: '本会话暂无后台任务。', jobsMore: '另有 {count} 个任务',
195
+ jobRunning: '运行中', jobStopping: '正在停止', jobCompleted: '已完成', jobKilled: '已取消', jobFailed: '已失败',
161
196
  toolReset: '重载所有工具状态', toolResetBusy: '正在重载…', toolResetDone: '本对话工具状态已重载。',
162
- toolResetFailed: '重载失败,请确认当前连接及操作权限。', toolResetHint: '清除本对话的故障标记和按需加载选择;正在运行的任务继续执行。',
197
+ toolResetFailed: '未能重载工具状态。', toolResetUnavailable: '当前会话无法调用工具重载命令。',
198
+ commandNoSession: '当前没有活动对话。', commandWrongMode: '该功能仅在深度 PTC 会话中可用。', commandInvalidSkill: '无效的 Skill 卡片操作。',
199
+ toolResetHint: '清除本对话的故障标记和按需加载选择;正在运行的任务继续执行。',
163
200
  toolFailures: '工具适配提醒', toolFailureHint: '以下外部工具调用失败,可能存在适配问题,已在本对话中禁用。任务会优先使用其他可用工具;未进一步排查故障原因。',
164
201
  });
165
202
  Object.assign(dictionaries.en, {
203
+ visualEffects: 'Visual effects', visualEffectsHint: 'Keep this off when using an external theme or UI plugin.',
204
+ jobsTitle: 'Background jobs', jobsEmpty: 'No background jobs in this conversation.', jobsMore: '{count} more jobs',
205
+ jobRunning: 'Running', jobStopping: 'Stopping', jobCompleted: 'Completed', jobKilled: 'Canceled', jobFailed: 'Failed',
166
206
  toolReset: 'Reload all tool states', toolResetBusy: 'Reloading…', toolResetDone: 'Tool states reloaded for this conversation.',
167
- toolResetFailed: 'Reload failed. Check the connection and access permissions.', toolResetHint: 'Clear quarantine and on-demand selections in this conversation. Running jobs continue.',
207
+ toolResetFailed: 'Could not reload tool states.', toolResetUnavailable: 'The reload command is unavailable in this conversation.',
208
+ commandNoSession: 'No active conversation.', commandWrongMode: 'This command is available in Deep PTC sessions only.', commandInvalidSkill: 'Invalid skill card command.',
209
+ toolResetHint: 'Clear quarantine and on-demand selections in this conversation. Running jobs continue.',
168
210
  toolFailures: 'Tool compatibility notice', toolFailureHint: 'These external tools failed and may have compatibility issues. They are disabled in this conversation. Continue with working alternatives; no root-cause investigation was performed.',
169
211
  });
170
212
  Object.assign(dictionaries.zh, {
@@ -205,6 +247,15 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
205
247
  // Placeholders are filled here, so the text is right whether or not the host locale interpolates.
206
248
  const fill = (text, values) => String(text).replace(/\{(\w+)\}/gu, (whole, key) => values[key] === undefined ? whole : String(values[key]));
207
249
  const tf = (t, key, values) => fill(t(key, values), values);
250
+ const commandMessageKeys = new Map([
251
+ ['No active conversation. / 当前没有活动对话。', 'commandNoSession'],
252
+ ['This command is available in Deep PTC sessions only. / 该功能仅在深度 PTC 会话中可用。', 'commandWrongMode'],
253
+ ['Invalid skill card command. / 无效的 Skill 卡片操作。', 'commandInvalidSkill'],
254
+ ]);
255
+ function commandText(text, t) {
256
+ const key = commandMessageKeys.get(text);
257
+ return key ? t(key) : text;
258
+ }
208
259
  let T = key => key;
209
260
  let hostCtx;
210
261
  let ReactDOM;
@@ -291,9 +342,19 @@ ${DARK} .dpt-agents,${DARK} .dpt-agents-pill{box-shadow:0 10px 30px rgba(0,0,0,.
291
342
  .dpt-agent:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover,rgba(16,24,40,.05))}
292
343
  .dpt-agent:disabled{cursor:default}
293
344
  .dpt-agent-dot{flex:none;width:8px;height:8px;margin-top:6px;border-radius:50%;background:var(--dsw-alias-label-tertiary,#98a2b3)}
294
- .dpt-agent[data-state="running"] .dpt-agent-dot,.dpt-agents-pill[data-state="running"] .dpt-agent-dot{background:var(--dpt-accent,#3370ff);animation:dpt-dot-flash 1.2s ease-in-out infinite}
345
+ .dpt-agent[data-state="running"] .dpt-agent-dot,.dpt-agents-pill[data-state="running"] .dpt-agent-dot,.dpt-job[data-state="running"] .dpt-agent-dot{background:var(--dpt-accent,#3370ff)}
346
+ ${ON} .dpt-agents-pill[data-state="running"] .dpt-agent-dot,${ON} .dpt-agent[data-state="running"] .dpt-agent-dot{animation:dpt-dot-flash 1.2s ease-in-out infinite}
295
347
  @keyframes dpt-dot-flash{0%,100%{opacity:1;box-shadow:0 0 4px 1px color-mix(in srgb,var(--dpt-accent,#3370ff) 55%,transparent)}50%{opacity:.35;box-shadow:0 0 10px 3px color-mix(in srgb,var(--dpt-accent,#3370ff) 75%,transparent)}}
296
348
  .dpt-agent[data-state="completed"] .dpt-agent-dot{background:var(--dsw-alias-state-success-primary,#0f7a4f)}
349
+ .dpt-job[data-state="completed"] .dpt-agent-dot{background:var(--dsw-alias-state-success-primary,#0f7a4f)}
350
+ .dpt-job[data-state="stopping"] .dpt-agent-dot,.dpt-job[data-state="killed"] .dpt-agent-dot{background:var(--dsw-alias-state-warn-primary,#b45309)}
351
+ .dpt-job[data-state="failed"] .dpt-agent-dot{background:var(--dsw-alias-state-error-primary,#c4321f)}
352
+ .dpt-side-effects .dpt-side-label{align-items:center}
353
+ .dpt-jobs-list{display:grid;gap:4px;list-style:none;padding:0;margin:0}
354
+ .dpt-job,.dpt-jobs-more{padding:5px 6px;border-radius:6px;background:var(--dpt-surface-soft,var(--dsw-alias-fill-secondary,transparent))}
355
+ .dpt-job{display:flex;align-items:flex-start;gap:7px}
356
+ .dpt-jobs-more summary{cursor:pointer;font-size:11px;line-height:16px}
357
+ .dpt-jobs-more .dpt-jobs-list{margin-top:4px}
297
358
  .dpt-agent-main{flex:1;min-width:0;display:flex;flex-direction:column}
298
359
  .dpt-agent-name{font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
299
360
  .dpt-agent-meta{font-size:11px;line-height:16px;color:var(--dsw-alias-label-tertiary,#667085);font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
@@ -410,7 +471,7 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
410
471
  @keyframes dpt-pop{from{opacity:0;transform:translateY(8px) scale(0.98)}to{opacity:1;transform:none}}
411
472
  .dpt-ripple{position:fixed;z-index:2147483000;pointer-events:none;width:20px;height:20px;margin:-10px 0 0 -10px;border-radius:50%;border:2px solid color-mix(in srgb,var(--dpt-brand,#3370ff) 75%,transparent);background:radial-gradient(circle,color-mix(in srgb,var(--dpt-brand,#3370ff) 45%,transparent),color-mix(in srgb,var(--dpt-brand,#3370ff) 12%,transparent) 60%,transparent 72%);animation:dpt-ripple 650ms cubic-bezier(.22,1,.36,1) forwards}
412
473
  @keyframes dpt-ripple{0%{transform:scale(.3);opacity:1}100%{transform:scale(7);opacity:0}}
413
- .dpt-fx{position:fixed;inset:0;width:100vw;height:100vh;z-index:2147482000;pointer-events:none}
474
+ .dpt-fx{position:fixed;inset:0;width:100vw;height:100vh;z-index:2147482000;pointer-events:none;-webkit-app-region:initial!important}
414
475
  @media (prefers-reduced-motion:reduce){
415
476
  ${ON} *,${ON} *::before,${ON} *::after{animation-duration:0.01ms !important;animation-iteration-count:1 !important;transition-duration:0.01ms !important;scroll-behavior:auto !important}
416
477
  }
@@ -452,6 +513,27 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
452
513
  },
453
514
  };
454
515
  const BUSY = { bridge: false, dom: false, was: false, timer: 0 };
516
+ const EFFECTS_KEY = `${PLUGIN}:visual-effects`;
517
+ function readEffects() {
518
+ try { return localStorage.getItem(EFFECTS_KEY) !== '0'; } catch { return true; }
519
+ }
520
+ let effectsEnabled = readEffects();
521
+ const effectListeners = new Set();
522
+ const getEffects = () => effectsEnabled;
523
+ function subscribeEffects(listener) {
524
+ effectListeners.add(listener);
525
+ return () => effectListeners.delete(listener);
526
+ }
527
+ function setEffects(enabled) {
528
+ if (effectsEnabled === enabled) return;
529
+ effectsEnabled = enabled;
530
+ for (const listener of effectListeners) listener();
531
+ }
532
+ function toggleEffects() {
533
+ const enabled = !effectsEnabled;
534
+ try { localStorage.setItem(EFFECTS_KEY, enabled ? '1' : '0'); } catch { /* use the in-memory preference */ }
535
+ setEffects(enabled);
536
+ }
455
537
  // The standalone dsh-refined-ui draws the same look; never stack both.
456
538
  const refinedPresent = () => typeof document !== 'undefined' && document.querySelector('style[data-plugin="dsh-refined-ui"]') !== null;
457
539
  const uiOn = () => typeof document !== 'undefined' && document.body?.hasAttribute('data-dpt-ui');
@@ -459,7 +541,7 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
459
541
  if (typeof document === 'undefined') return;
460
542
  const busy = uiOn() && (BUSY.bridge || BUSY.dom);
461
543
  document.body.toggleAttribute('data-dpt-busy', busy);
462
- if (BUSY.was && !busy) {
544
+ if (BUSY.was && !busy && uiOn()) {
463
545
  const card = document.querySelector('[data-dpt-composer]');
464
546
  if (card) {
465
547
  card.setAttribute('data-dpt-done', '');
@@ -471,23 +553,43 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
471
553
  }
472
554
  function watchActiveSession() {
473
555
  if (typeof document === 'undefined') return () => {};
556
+ let stopVisuals;
557
+ function disableVisuals() {
558
+ if (!stopVisuals) return;
559
+ clearTimeout(BUSY.timer);
560
+ document.querySelectorAll('[data-dpt-done]').forEach(node => node.removeAttribute('data-dpt-done'));
561
+ stopVisuals();
562
+ stopVisuals = undefined;
563
+ }
474
564
  const update = () => {
475
565
  const current = SESSIONS.current();
476
- const on = current?.preset === 'deep-ptc' && !refinedPresent();
566
+ const on = effectsEnabled && current?.preset === 'deep-ptc' && !refinedPresent();
477
567
  document.body.toggleAttribute('data-dpt-ui', on);
478
568
  // Like dsh-refined-ui, a running subagent keeps the conversation working.
479
569
  BUSY.bridge = on && (current?.busy === true || SESSIONS.working.get(current?.id) === true);
480
570
  applyBusy();
571
+ if (on && !stopVisuals) {
572
+ const cleanups = [watchSurfaces(), watchPalette(), watchInteractions(), watchFx(), watchDiagnostics()];
573
+ stopVisuals = () => cleanups.reverse().forEach(cleanup => cleanup());
574
+ } else if (!on) disableVisuals();
481
575
  };
482
576
  SESSIONS.subs.add(update);
577
+ const unsubscribe = subscribeEffects(update);
578
+ const sync = event => { if (event.key === EFFECTS_KEY || event.key === null) setEffects(readEffects()); };
579
+ window.addEventListener('storage', sync);
483
580
  // Visibility changes without a remount (split views, tab switches) are caught here.
484
581
  const timer = setInterval(update, 1000);
485
582
  update();
486
583
  return () => {
487
584
  SESSIONS.subs.delete(update);
585
+ unsubscribe();
586
+ window.removeEventListener('storage', sync);
488
587
  clearInterval(timer);
489
588
  document.body.removeAttribute('data-dpt-ui');
490
589
  document.body.removeAttribute('data-dpt-busy');
590
+ BUSY.bridge = false;
591
+ BUSY.was = false;
592
+ disableVisuals();
491
593
  };
492
594
  }
493
595
 
@@ -496,7 +598,8 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
496
598
  function watchSurfaces() {
497
599
  if (typeof document === 'undefined' || typeof MutationObserver === 'undefined') return () => {};
498
600
  const tagged = new Set();
499
- const relativized = new Set();
601
+ const relativized = new Map();
602
+ const highlighted = new Set();
500
603
  let frame = 0;
501
604
  const mark = (node, attribute) => { node.setAttribute(attribute, ''); tagged.add([node, attribute]); };
502
605
  const findComposer = input => {
@@ -515,7 +618,10 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
515
618
  card = findComposer(input);
516
619
  if (!card) continue;
517
620
  mark(card, 'data-dpt-composer');
518
- if (getComputedStyle(card).position === 'static') { card.style.position = 'relative'; relativized.add(card); }
621
+ if (getComputedStyle(card).position === 'static') {
622
+ relativized.set(card, [card.style.position, card.style.getPropertyPriority('position')]);
623
+ card.style.position = 'relative';
624
+ }
519
625
  }
520
626
  if (card.querySelector('[data-dpt-send]')) continue;
521
627
  // The send button is the right-most button in the card.
@@ -546,6 +652,7 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
546
652
  const rect = host.getBoundingClientRect();
547
653
  host.style.setProperty('--dpt-mx', `${event.clientX - rect.left}px`);
548
654
  host.style.setProperty('--dpt-my', `${event.clientY - rect.top}px`);
655
+ highlighted.add(host);
549
656
  }
550
657
  const run = () => {
551
658
  frame = 0;
@@ -567,8 +674,13 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
567
674
  applyBusy();
568
675
  for (const [node, attribute] of tagged) node.removeAttribute(attribute);
569
676
  tagged.clear();
570
- for (const node of relativized) node.style.position = '';
571
- relativized.clear();
677
+ for (const [node, [position, priority]] of relativized) {
678
+ if (node.style.position === 'relative') node.style.setProperty('position', position, priority);
679
+ }
680
+ for (const node of highlighted) {
681
+ node.style.removeProperty('--dpt-mx');
682
+ node.style.removeProperty('--dpt-my');
683
+ }
572
684
  };
573
685
  }
574
686
 
@@ -603,7 +715,7 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
603
715
  }
604
716
  function watchPalette() {
605
717
  if (typeof document === 'undefined') return () => {};
606
- let backdrop = null, input = null, list = null, items = [], shown = [], index = 0;
718
+ let backdrop = null, panel, foot, input, list, items = [], shown = [], index = 0;
607
719
  const close = () => { backdrop?.remove(); backdrop = null; };
608
720
  function mark() {
609
721
  for (let at = 0; at < list.children.length; at++) list.children[at].setAttribute('aria-selected', at === index ? 'true' : 'false');
@@ -644,25 +756,29 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
644
756
  close();
645
757
  setTimeout(() => { try { item.run(); } catch (error) { console.warn(`[${PLUGIN}] palette action failed:`, error); } }, 30);
646
758
  }
647
- function open() {
759
+ function translatePalette() {
760
+ if (!backdrop) return;
761
+ panel.setAttribute('aria-label', T('palTitle'));
762
+ input.placeholder = T('palPlaceholder');
763
+ input.setAttribute('aria-label', input.placeholder);
764
+ foot.textContent = T('palFoot');
648
765
  items = paletteItems();
766
+ filter();
767
+ }
768
+ function open() {
649
769
  backdrop = document.createElement('div');
650
770
  backdrop.className = 'dpt-pal-backdrop';
651
771
  backdrop.setAttribute('data-dpt-palette', '');
652
- const panel = document.createElement('div');
772
+ panel = document.createElement('div');
653
773
  panel.className = 'dpt-pal';
654
774
  panel.setAttribute('role', 'dialog');
655
- panel.setAttribute('aria-label', T('palTitle'));
656
775
  input = document.createElement('input');
657
776
  input.className = 'dpt-pal-input';
658
- input.placeholder = T('palPlaceholder');
659
- input.setAttribute('aria-label', T('palPlaceholder'));
660
777
  list = document.createElement('div');
661
778
  list.className = 'dpt-pal-list';
662
779
  list.setAttribute('role', 'listbox');
663
- const foot = document.createElement('div');
780
+ foot = document.createElement('div');
664
781
  foot.className = 'dpt-pal-foot';
665
- foot.textContent = T('palFoot');
666
782
  panel.append(input, list, foot);
667
783
  backdrop.appendChild(panel);
668
784
  document.body.appendChild(backdrop);
@@ -675,7 +791,7 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
675
791
  else if (event.key === 'Enter') { event.preventDefault(); choose(index); }
676
792
  else if (event.key === 'Escape') { event.preventDefault(); close(); }
677
793
  });
678
- filter();
794
+ translatePalette();
679
795
  input.focus();
680
796
  }
681
797
  function onKey(event) {
@@ -686,7 +802,8 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
686
802
  if (backdrop) close(); else open();
687
803
  }
688
804
  document.addEventListener('keydown', onKey, true);
689
- return () => { document.removeEventListener('keydown', onKey, true); close(); };
805
+ const unsubscribe = hostCtx.locale.subscribe?.(translatePalette);
806
+ return () => { unsubscribe?.(); document.removeEventListener('keydown', onKey, true); close(); };
690
807
  }
691
808
 
692
809
  // Click ripple, magnetic send button, "/" focuses the composer, Alt+Up/Down switches sessions.
@@ -743,8 +860,8 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
743
860
 
744
861
  // Send burst, completion sparkle and embers while the agent works.
745
862
  function watchFx() {
746
- if (typeof document === 'undefined' || typeof requestAnimationFrame === 'undefined') return () => {};
747
- const reduce = window.matchMedia?.('(prefers-reduced-motion: reduce)').matches === true;
863
+ if (typeof document === 'undefined' || typeof requestAnimationFrame === 'undefined' || typeof MutationObserver === 'undefined'
864
+ || window.matchMedia?.('(prefers-reduced-motion: reduce)')?.matches === true) return () => {};
748
865
  const canvas = document.createElement('canvas');
749
866
  canvas.className = 'dpt-fx';
750
867
  canvas.setAttribute('aria-hidden', 'true');
@@ -752,16 +869,18 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
752
869
  if (!paint) return () => {};
753
870
  document.body.appendChild(canvas);
754
871
  const dpr = Math.min(window.devicePixelRatio || 1, 2);
755
- let width = 0, height = 0, parts = [], raf = 0, lastEmber = 0, wasBusy = false;
872
+ let width = 0, height = 0, parts = [], raf = 0, lastEmber = 0;
873
+ const fireworks = new Set();
756
874
  const hues = ['#3370ff', '#5b8cff', '#7fd0ff', '#9dbcff', '#b48cff', '#ffffff'];
757
875
  const busy = () => document.body.hasAttribute('data-dpt-busy');
876
+ let wasBusy = busy();
758
877
  function resize() {
759
878
  width = window.innerWidth; height = window.innerHeight;
760
879
  canvas.width = width * dpr; canvas.height = height * dpr;
761
880
  paint.setTransform(dpr, 0, 0, dpr, 0, 0);
762
881
  }
763
882
  function burst(x, y, count, power) {
764
- if (reduce || !uiOn()) return;
883
+ if (!uiOn()) return;
765
884
  for (let index = 0; index < count; index++) {
766
885
  const angle = Math.random() * Math.PI * 2, speed = (0.4 + Math.random()) * power;
767
886
  parts.push({ x, y, vx: Math.cos(angle) * speed, vy: Math.sin(angle) * speed - power * 0.35, life: 1,
@@ -777,7 +896,7 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
777
896
  const composer = document.querySelector('[data-dpt-composer]');
778
897
  const now = performance.now();
779
898
  // Embers rise from the composer while the agent works: twice as often as dsh-refined-ui, slightly larger.
780
- if (busy() && !reduce && composer && now - lastEmber > 35) {
899
+ if (busy() && composer && now - lastEmber > 35) {
781
900
  lastEmber = now;
782
901
  const rect = composer.getBoundingClientRect();
783
902
  parts.push({ x: rect.left + 12 + Math.random() * (rect.width - 24), y: rect.top + 2, vx: (Math.random() - 0.5) * 0.5,
@@ -827,8 +946,15 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
827
946
  observer.observe(document.body, { attributes: true, attributeFilter: ['data-dpt-busy'] });
828
947
  document.addEventListener('pointerdown', onDown, true);
829
948
  document.addEventListener('keydown', onKey, true);
949
+ if (wasBusy) kick();
830
950
  FX.burst = () => {
831
- [[0.3, 0.45], [0.5, 0.3], [0.7, 0.45]].forEach(([x, y], index) => setTimeout(() => burst(width * x, height * y, 60, 5.6), index * 220));
951
+ [[0.3, 0.45], [0.5, 0.3], [0.7, 0.45]].forEach(([x, y], index) => {
952
+ const timer = setTimeout(() => {
953
+ fireworks.delete(timer);
954
+ burst(width * x, height * y, 60, 5.6);
955
+ }, index * 220);
956
+ fireworks.add(timer);
957
+ });
832
958
  };
833
959
  return () => {
834
960
  FX.burst = () => {};
@@ -837,6 +963,7 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
837
963
  document.removeEventListener('keydown', onKey, true);
838
964
  observer.disconnect();
839
965
  if (raf) cancelAnimationFrame(raf);
966
+ for (const timer of fireworks) clearTimeout(timer);
840
967
  canvas.remove();
841
968
  };
842
969
  }
@@ -887,6 +1014,15 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
887
1014
  onClick: () => { if (!disabled) onChange(!on); } }, h('span', { className: 'dpt-switch-thumb', 'aria-hidden': 'true' }));
888
1015
  }
889
1016
 
1017
+ function VisualEffectsSection({ t }) {
1018
+ const enabled = React.useSyncExternalStore(subscribeEffects, getEffects, getEffects);
1019
+ const label = t('visualEffects');
1020
+ return h('section', { className: 'dpt-side-section dpt-side-effects', 'aria-label': label },
1021
+ h('div', { className: 'dpt-side-label' }, h('span', null, label),
1022
+ h(SkillSwitch, { on: enabled, label, onChange: toggleEffects })),
1023
+ h('p', { className: 'dpt-side-note' }, t('visualEffectsHint')));
1024
+ }
1025
+
890
1026
  function SkillCard({ turn, useProjection, useChat, setSkill, setAll, t }) {
891
1027
  const [busy, setBusy] = React.useState(false);
892
1028
  const [expanded, setExpanded] = React.useState(false);
@@ -1048,10 +1184,92 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
1048
1184
  const NO_FORM = { status: 'unavailable' };
1049
1185
  const noSubscribe = () => () => {};
1050
1186
  const noSnapshot = () => NO_FORM;
1051
- const allowedEnvironments = platform => platform === 'win32' ? ['auto', 'wsl', 'powershell'] : ['auto', 'zsh', 'bash'];
1187
+ const allowedEnvironments = platform => platform === 'win32' ? ['auto', 'wsl', 'powershell', 'bash'] : ['auto', 'zsh', 'bash'];
1052
1188
  const effectiveEnvironment = (environment, platform) => environment !== 'auto' ? environment
1053
1189
  : platform === 'win32' ? 'powershell' : platform === 'darwin' ? 'zsh' : 'bash';
1054
1190
  const envLabel = (value, t) => value === 'auto' ? t('envAuto') : ENV_SHORT[value] ?? value;
1191
+ function shellLabel(label, t) {
1192
+ if (label === 'PowerShell 7 Preview') return t('shellPreview');
1193
+ const system = /^(bash|zsh) \(system\)$/u.exec(label);
1194
+ return system ? tf(t, 'shellSystem', { name: system[1] }) : label;
1195
+ }
1196
+
1197
+ const PRESET_LABEL_SLOTS = [
1198
+ ['conversation.hero.agentPreset', undefined, 'useAgentPresetSeat', 'options'],
1199
+ ['conversation.session.header.actions', 'agent-preset', 'useAgentPresets', 'options'],
1200
+ ['settings.section', 'agent-presets', 'useAgentPresetSection', 'rows'],
1201
+ ];
1202
+
1203
+ function translatedPreset(row, t) {
1204
+ if (row?.id !== 'deep-ptc') return row;
1205
+ const name = t('presetName');
1206
+ const description = row.description ?? '';
1207
+ let status;
1208
+ if (description.endsWith('当前为安全模式')) status = t('presetSafeMode');
1209
+ else {
1210
+ // The preset derivation publishes the mounted environment in this suffix.
1211
+ const current = /当前环境:(\S+)(?: \(([^\n]*)\))?$/u.exec(description);
1212
+ if (current) {
1213
+ const shell = current[1] === '官方默认' ? t('presetOfficial') : envLabel(current[1], t);
1214
+ status = tf(t, 'presetEnvironment', { env: current[2] ? `${shell} (${current[2]})` : shell });
1215
+ }
1216
+ }
1217
+ return { ...row, name, description: [t('presetDescription'), status].filter(Boolean).join(' ') };
1218
+ }
1219
+
1220
+ function presetSnapshotTranslator(rowsKey, t) {
1221
+ const cache = new WeakMap();
1222
+ return snapshot => {
1223
+ if (!snapshot || typeof snapshot !== 'object') return snapshot;
1224
+ if (cache.has(snapshot)) return cache.get(snapshot);
1225
+ const rows = snapshot[rowsKey];
1226
+ const error = snapshot.error;
1227
+ const hasPreset = Array.isArray(rows) && rows.some(row => row.id === 'deep-ptc');
1228
+ const hasPresetError = error?.preset?.id === 'deep-ptc';
1229
+ const localized = hasPreset || hasPresetError ? {
1230
+ ...snapshot,
1231
+ ...(hasPreset ? { [rowsKey]: rows.map(row => translatedPreset(row, t)) } : {}),
1232
+ ...(hasPresetError ? { error: { ...error, preset: translatedPreset(error.preset, t) } } : {}),
1233
+ } : snapshot;
1234
+ cache.set(snapshot, localized);
1235
+ return localized;
1236
+ };
1237
+ }
1238
+
1239
+ // Keep the native picker and its actions. A higher-priority slot entry supplies localized
1240
+ // display snapshots only for our row, while the host owns the actual selection and preset.
1241
+ function installPresetLabels(slots, t, useLocaleRevision) {
1242
+ if (typeof slots.entriesOfSlot !== 'function' || typeof slots.entries !== 'function' || typeof slots.subscribe !== 'function') return;
1243
+ for (const [name, id, hook, rows] of PRESET_LABEL_SLOTS) {
1244
+ slots.inject(name, () => {
1245
+ let original;
1246
+ let dispose;
1247
+ const sync = () => {
1248
+ const entry = slots.entries(name).find(item => item.options?.id === id && (item.options?.priority ?? 0) === 0
1249
+ && item.locale === 'settings.agentPreset' && !item.children && !item.store && typeof item.component === 'function');
1250
+ if (entry === original) return;
1251
+ original = entry;
1252
+ dispose?.();
1253
+ dispose = undefined;
1254
+ if (!entry) return;
1255
+ function LocalizedPresetSlot(props) {
1256
+ const revision = useLocaleRevision();
1257
+ const translate = React.useMemo(() => presetSnapshotTranslator(rows, t), [revision]);
1258
+ const useRoster = props[hook];
1259
+ const useLocalizedRoster = React.useCallback((select, equal) => useRoster(
1260
+ snapshot => select(translate(snapshot)), equal), [useRoster, translate]);
1261
+ return h(entry.component, typeof useRoster === 'function' ? { ...props, [hook]: useLocalizedRoster } : props);
1262
+ }
1263
+ try {
1264
+ dispose = slots.register({ ...entry.options, name, priority: -1, locale: entry.locale, inject: entry.inject }, LocalizedPresetSlot);
1265
+ } catch { /* Another plugin may already own the presentation slot. */ }
1266
+ };
1267
+ const unsubscribe = slots.subscribe(name, sync);
1268
+ sync();
1269
+ return () => { unsubscribe(); dispose?.(); };
1270
+ });
1271
+ }
1272
+ }
1055
1273
 
1056
1274
  function useSettingsForm(form) {
1057
1275
  const subscribe = React.useCallback(listener => form ? form.subscribe(listener) : () => {}, [form]);
@@ -1064,11 +1282,14 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
1064
1282
  const [saving, setSaving] = React.useState(false);
1065
1283
  const [message, setMessage] = React.useState(null);
1066
1284
  const [distribution, setDistribution] = React.useState(undefined);
1285
+ const [bashPath, setBashPath] = React.useState(undefined);
1067
1286
  if (!form || state.status === 'unavailable') return null;
1068
1287
  if (state.status !== 'ready' || !state.value) return h('section', { className: 'dpt-side-section' }, h('p', { className: 'dpt-side-note' }, t('loading')));
1069
1288
  const value = state.value;
1070
1289
  const platform = value.hostPlatform;
1071
1290
  const environment = value.environment ?? 'auto';
1291
+ const editingBash = platform === 'win32' && (environment === 'bash' || bashPath !== undefined);
1292
+ const bashDraft = bashPath ?? value.shellExecutable ?? '';
1072
1293
  const effective = effectiveEnvironment(environment, platform);
1073
1294
  const choices = (Array.isArray(value.shellChoices) ? value.shellChoices : []).filter(item => item && typeof item.id === 'string');
1074
1295
  const disabled = !state.writable || saving;
@@ -1079,21 +1300,27 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
1079
1300
  try {
1080
1301
  const ok = await form.mutate(ops, form.getSnapshot().revision);
1081
1302
  if (!ok) throw new Error('rejected');
1082
- setMessage({ tone: 'ok', text: tf(t, 'envSaved', { env: label }) });
1303
+ setMessage({ tone: 'ok', label });
1083
1304
  return true;
1084
1305
  } catch {
1085
- setMessage({ tone: 'error', text: t('envFailed') });
1306
+ setMessage({ tone: 'error' });
1086
1307
  return false;
1087
1308
  } finally { setSaving(false); }
1088
1309
  }
1089
1310
  function choose(next) {
1311
+ if (platform === 'win32' && next === 'bash') {
1312
+ if (environment !== 'bash') setBashPath('');
1313
+ setMessage(null);
1314
+ return;
1315
+ }
1316
+ setBashPath(undefined);
1090
1317
  if (next === environment) return;
1091
1318
  const family = effectiveEnvironment(next, platform);
1092
1319
  const current = choices.find(item => item.id === value.shellExecutable);
1093
1320
  const ops = [{ op: 'set', path: ['environment'], value: next }];
1094
1321
  // A shell picked for another family would not apply; fall back to the official lookup.
1095
1322
  if (value.shellExecutable && current?.family !== family) ops.push({ op: 'set', path: ['shellExecutable'], value: '' });
1096
- void save(ops, envLabel(next, t));
1323
+ void save(ops, next === 'auto' ? { key: 'envAuto' } : envLabel(next, t));
1097
1324
  }
1098
1325
  async function saveDistribution(event) {
1099
1326
  event?.preventDefault?.();
@@ -1101,26 +1328,100 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
1101
1328
  if (next === savedDistribution) { setDistribution(undefined); return; }
1102
1329
  if (await save([{ op: 'set', path: ['wslDistribution'], value: next }], next ? `WSL (${next})` : 'WSL')) setDistribution(undefined);
1103
1330
  }
1331
+ async function saveBash(event) {
1332
+ event.preventDefault();
1333
+ const next = bashDraft.trim();
1334
+ if (!next || (environment === 'bash' && next === value.shellExecutable)) return;
1335
+ if (await save([{ op: 'set', path: ['environment'], value: 'bash' },
1336
+ { op: 'set', path: ['shellExecutable'], value: next }], 'Bash')) setBashPath(undefined);
1337
+ }
1104
1338
  const familyChoices = choices.filter(item => item.family === effective);
1339
+ let note = t('envThisSession');
1340
+ if (message?.tone === 'error') note = t('envFailed');
1341
+ else if (message) {
1342
+ const label = message.label;
1343
+ const env = typeof label === 'string' ? label : label.key ? t(label.key) : shellLabel(label.shell, t);
1344
+ note = tf(t, 'envSaved', { env });
1345
+ } else if (!state.writable) note = t('readOnly');
1346
+ else if (environment === 'auto') note = tf(t, 'envAutoNow', { env: envLabel(effective, t) });
1105
1347
  return h('section', { className: 'dpt-side-section', 'aria-label': t('environment') },
1106
1348
  h('div', { className: 'dpt-side-label' }, h('span', null, t('environment')), h('span', { className: 'dpt-side-hint' }, t('envForNew'))),
1107
1349
  h('div', { className: 'dpt-seg', role: 'radiogroup', 'aria-label': t('environment') },
1108
1350
  ...allowedEnvironments(platform).map(option => h('button', { key: option, type: 'button', role: 'radio', className: 'dpt-seg-btn',
1109
- 'aria-checked': option === environment, disabled, title: t(option), onClick: () => choose(option) }, envLabel(option, t)))),
1110
- effective === 'wsl' ? h('form', { className: 'dpt-field', onSubmit: saveDistribution },
1351
+ 'aria-checked': option === (editingBash ? 'bash' : environment), disabled,
1352
+ title: t(platform === 'win32' && option === 'bash' ? 'windowsBash' : option),
1353
+ onClick: () => choose(option) }, envLabel(option, t)))),
1354
+ editingBash ? h(React.Fragment, null,
1355
+ h('form', { className: 'dpt-field', onSubmit: saveBash },
1356
+ h('input', { className: 'dpt-input', value: bashDraft, disabled, placeholder: t('bashPath'), 'aria-label': t('bashPath'),
1357
+ onChange: event => { setBashPath(event.target.value); setMessage(null); } }),
1358
+ (environment !== 'bash' || bashDraft.trim() !== value.shellExecutable)
1359
+ ? h('button', { type: 'submit', className: 'dpt-btn', disabled: disabled || !bashDraft.trim() }, t('save')) : null),
1360
+ h('p', { className: 'dpt-side-note' }, t('bashPathHint'))) : null,
1361
+ !editingBash && effective === 'wsl' ? h('form', { className: 'dpt-field', onSubmit: saveDistribution },
1111
1362
  h('input', { className: 'dpt-input', value: draft, disabled, placeholder: t('envDefaultDistribution'), 'aria-label': t('distribution'),
1112
1363
  title: t('distributionHint'), onChange: event => { setDistribution(event.target.value); setMessage(null); } }),
1113
1364
  draft.trim() !== savedDistribution ? h('button', { type: 'submit', className: 'dpt-btn', disabled }, t('save')) : null) : null,
1114
- effective !== 'wsl' && familyChoices.length > 0 ? h('div', { className: 'dpt-field' },
1365
+ !editingBash && effective !== 'wsl' && familyChoices.length > 0 ? h('div', { className: 'dpt-field' },
1115
1366
  h('select', { className: 'dpt-select', value: value.shellExecutable ?? '', disabled, 'aria-label': t('shell'), title: t('shellHint'),
1116
1367
  onChange: event => { const item = familyChoices.find(choice => choice.id === event.target.value);
1117
- void save([{ op: 'set', path: ['shellExecutable'], value: event.target.value }], item ? item.label : t('shellAuto')); } },
1118
- h('option', { value: '' }, t('shellAuto')), ...familyChoices.map(item => h('option', { key: item.id, value: item.id }, item.label)))) : null,
1119
- h('p', { className: 'dpt-side-note', role: 'status', 'data-tone': message?.tone },
1120
- message ? message.text : !state.writable ? t('readOnly') : environment === 'auto' ? tf(t, 'envAutoNow', { env: envLabel(effective, t) }) : t('envThisSession')));
1368
+ void save([{ op: 'set', path: ['shellExecutable'], value: event.target.value }], item ? { shell: item.label } : { key: 'shellAuto' }); } },
1369
+ h('option', { value: '' }, t('shellAuto')), ...familyChoices.map(item => h('option', { key: item.id, value: item.id }, shellLabel(item.label, t))))) : null,
1370
+ h('p', { className: 'dpt-side-note', role: 'status', 'data-tone': message?.tone }, note));
1371
+ }
1372
+
1373
+ const JOB_STATUS = new Map([
1374
+ ['running', 'jobRunning'], ['stopping', 'jobStopping'], ['completed', 'jobCompleted'],
1375
+ ['killed', 'jobKilled'], ['failed', 'jobFailed'],
1376
+ ]);
1377
+ const JOB_PREVIEW_LIMIT = 6;
1378
+ const ACTIVE_JOB_LIMIT = 5;
1379
+ const FINISHED_JOB_LIMIT = 3;
1380
+
1381
+ function BackgroundJobs({ jobs, t }) {
1382
+ const active = [];
1383
+ const finished = [];
1384
+ for (const job of jobs ?? []) {
1385
+ if (job.status === 'running' || job.status === 'stopping') active.push(job);
1386
+ else if (JOB_STATUS.has(job.status)) finished.push(job);
1387
+ }
1388
+ active.sort((left, right) => left.startedAt - right.startedAt);
1389
+ finished.sort((left, right) =>
1390
+ (right.finishedAt ?? right.startedAt) - (left.finishedAt ?? left.startedAt) || left.startedAt - right.startedAt);
1391
+
1392
+ const eligible = [...active.slice(0, ACTIVE_JOB_LIMIT), ...finished.slice(0, FINISHED_JOB_LIMIT)];
1393
+ const total = active.length + finished.length;
1394
+ // Overflow itself occupies one of the six positions, including overflow from either status cap.
1395
+ const hasOverflow = total > eligible.length || total > JOB_PREVIEW_LIMIT;
1396
+ const visibleLimit = hasOverflow ? JOB_PREVIEW_LIMIT - 1 : JOB_PREVIEW_LIMIT;
1397
+ const visible = eligible.slice(0, visibleLimit);
1398
+ const hidden = visible.length < total ? [...active, ...finished].filter(job => !visible.includes(job)) : [];
1399
+ const row = job => {
1400
+ const label = job.label || job.kind || job.id;
1401
+ return h('li', { key: job.id, className: 'dpt-job', 'data-state': job.status },
1402
+ h('span', { className: 'dpt-agent-dot', 'aria-hidden': 'true' }),
1403
+ h('span', { className: 'dpt-agent-main' },
1404
+ h('span', { className: 'dpt-agent-name', title: label }, label),
1405
+ h('span', { className: 'dpt-agent-meta' }, t(JOB_STATUS.get(job.status)))));
1406
+ };
1407
+ const title = t('jobsTitle');
1408
+ return h('section', { className: 'dpt-side-section', 'aria-label': title },
1409
+ h('div', { className: 'dpt-side-label' }, h('span', null, title)),
1410
+ total ? h('ul', { className: 'dpt-jobs-list' }, ...visible.map(row),
1411
+ hidden.length ? h('li', { className: 'dpt-jobs-more' },
1412
+ h('details', null, h('summary', null, tf(t, 'jobsMore', { count: hidden.length })),
1413
+ h('ul', { className: 'dpt-jobs-list' }, ...hidden.map(row)))) : null)
1414
+ : h('p', { className: 'dpt-side-note' }, t('jobsEmpty')));
1415
+ }
1416
+
1417
+ // Desktop RCs expose the jobs roster through a dedicated service. Other hosts include it in sessions.
1418
+ function LiveBackgroundJobs({ sessionId, useJobs, watchJobs, t }) {
1419
+ const jobs = useJobs(state => state.rows[sessionId]);
1420
+ React.useEffect(() => watchJobs(sessionId), [sessionId, watchJobs]);
1421
+ return h(BackgroundJobs, { jobs, t });
1121
1422
  }
1122
1423
 
1123
- function SidePanel({ sessionId, useSessions, useProjection, reset, form, t }) {
1424
+ function SidePanel({ sessionId, useSessions, useProjection, useJobs, watchJobs, reset, form, t }) {
1124
1425
  const sessions = typeof useSessions === 'function' ? useSessions(state => state) : undefined;
1125
1426
  let tools;
1126
1427
  try { tools = typeof useProjection === 'function' ? useProjection('deepPtcTools') : undefined; } catch { tools = undefined; }
@@ -1135,7 +1436,7 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
1135
1436
  const running = rows.filter(row => row.state === 'running').length;
1136
1437
  const completed = rows.filter(row => row.state === 'completed').length;
1137
1438
  const hasEnvironment = !!form && settings.status !== 'unavailable';
1138
- const layout = useChatRegion(sessionId, (rows.length > 0 || hasEnvironment || hasTools) && canPortal());
1439
+ const layout = useChatRegion(sessionId, canPortal());
1139
1440
  const docked = !!layout && layout.wide && !collapsed;
1140
1441
  React.useEffect(() => {
1141
1442
  if (running === 0) return undefined;
@@ -1159,7 +1460,7 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
1159
1460
  };
1160
1461
  return () => { PANEL.toggle = () => {}; };
1161
1462
  }, [layout?.wide]);
1162
- if (!layout || (rows.length === 0 && !hasEnvironment && !hasTools) || !canPortal()) return null;
1463
+ if (!layout || !canPortal()) return null;
1163
1464
  const position = { top: `${layout.top}px`, right: `${layout.right}px` };
1164
1465
  const summary = [running ? tf(t, 'agentsRunning', { count: running }) : null, completed ? tf(t, 'agentsCompleted', { count: completed }) : null,
1165
1466
  rows.length - running - completed > 0 ? tf(t, 'agentsIdle', { count: rows.length - running - completed }) : null].filter(Boolean).join(' · ');
@@ -1185,6 +1486,7 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
1185
1486
  h('path', { d: 'M6 4l4 4-4 4', stroke: 'currentColor', strokeWidth: 1.5, strokeLinecap: 'round', strokeLinejoin: 'round' })))),
1186
1487
  h('div', { className: 'dpt-side-body' },
1187
1488
  hasEnvironment ? h(EnvironmentSection, { form, t }) : null,
1489
+ h(VisualEffectsSection, { t }),
1188
1490
  rows.length ? h('section', { className: 'dpt-side-section dpt-side-agents', 'aria-label': t('agentsTitle') },
1189
1491
  h('div', { className: 'dpt-side-label' }, h('span', null, t('agentsTitle')), h('span', { className: 'dpt-side-hint', title: summary }, summary)),
1190
1492
  h('ol', { className: 'dpt-agents-list' }, ...rows.map(row => {
@@ -1196,6 +1498,9 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
1196
1498
  h('span', { className: 'dpt-agent-main' }, h('span', { className: 'dpt-agent-name', title: row.label }, row.label),
1197
1499
  h('span', { className: 'dpt-agent-meta' }, meta))));
1198
1500
  }))) : null,
1501
+ typeof useJobs === 'function' && typeof watchJobs === 'function'
1502
+ ? h(LiveBackgroundJobs, { key: sessionId, sessionId, useJobs, watchJobs, t })
1503
+ : h(BackgroundJobs, { key: sessionId, jobs: sessions?.jobsBySession?.[sessionId], t }),
1199
1504
  hasTools ? h(ToolStateControls, { sessionId, useProjection, reset, t }) : null)), document.body);
1200
1505
  }
1201
1506
 
@@ -1229,9 +1534,9 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
1229
1534
 
1230
1535
  // The skill switches run a host command, and the host logs every command. The log keeps it; the
1231
1536
  // conversation shows nothing for a success and a short line for a failure.
1232
- function SkillCommandRow({ node }) {
1537
+ function SkillCommandRow({ node, t }) {
1233
1538
  const outcome = node?.outcome;
1234
- if (outcome?.kind === 'error') return h('div', { className: 'dpt-command-error', role: 'status' }, outcome.text);
1539
+ if (outcome?.kind === 'error') return h('div', { className: 'dpt-command-error', role: 'status' }, commandText(outcome.text, t));
1235
1540
  return h('span', { hidden: true, 'data-dpt-hidden-command': SKILL_COMMAND_NAME });
1236
1541
  }
1237
1542
 
@@ -1246,25 +1551,28 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
1246
1551
  function apply(ctx) {
1247
1552
  hostCtx = ctx;
1248
1553
  const t = ctx.locale.bind('deep-ptc');
1554
+ const subscribeLocale = listener => ctx.locale.subscribe?.(listener) ?? noSubscribe();
1555
+ const readLocale = () => ctx.locale.getSnapshot?.()?.revision ?? 0;
1556
+ const useLocaleRevision = () => React.useSyncExternalStore(subscribeLocale, readLocale, readLocale);
1557
+ function LocalizedSlot({ component, ...props }) {
1558
+ useLocaleRevision();
1559
+ return h(component, { ...props, t: props.t ?? t });
1560
+ }
1249
1561
  T = key => t(key);
1250
1562
  ctx.effect(() => ctx.locale.register('deep-ptc', dictionaries));
1563
+ installPresetLabels(ctx.slots, t, useLocaleRevision);
1251
1564
  ctx.effect(() => injectCss(), `${PLUGIN}: style`);
1252
1565
  ctx.effect(() => watchActiveSession(), `${PLUGIN}: active session`);
1253
- ctx.effect(() => watchSurfaces(), `${PLUGIN}: surface tags`);
1254
- ctx.effect(() => watchPalette(), `${PLUGIN}: command palette`);
1255
- ctx.effect(() => watchInteractions(), `${PLUGIN}: interactions`);
1256
- ctx.effect(() => watchFx(), `${PLUGIN}: effects`);
1257
- ctx.effect(() => watchDiagnostics(), `${PLUGIN}: diagnostics`);
1258
1566
  const form = ctx.configForms.get(NS);
1259
1567
  ctx.effect(() => ctx.configForms.whileServed([NS], () =>
1260
1568
  ctx.slots.inject('plugins.item', () => ctx.slots.register({
1261
1569
  name: 'plugins.item', id: 'deep-ptc', order: 41,
1262
1570
  label: () => t('title'), locale: 'deep-ptc',
1263
- }, props => h(Card, { ...props, form, t })))));
1571
+ }, props => h(LocalizedSlot, { ...props, form, component: Card })))));
1264
1572
  try {
1265
1573
  ctx.slots.inject('conversation.chat.commandview', () => ctx.slots.register({
1266
- name: 'conversation.chat.commandview', key: SKILL_COMMAND_NAME,
1267
- }, SkillCommandRow));
1574
+ name: 'conversation.chat.commandview', key: SKILL_COMMAND_NAME, locale: 'deep-ptc',
1575
+ }, props => h(LocalizedSlot, { ...props, component: SkillCommandRow })));
1268
1576
  } catch { /* without the renderer the host shows its generic command row */ }
1269
1577
  try {
1270
1578
  // Each conversation header reports which session is on screen and whether it works.
@@ -1276,25 +1584,33 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
1276
1584
  ctx.inject?.(['remote', 'remote.commands'], child => {
1277
1585
  try {
1278
1586
  child.slots.inject('conversation.chat.turnTail', () => child.slots.register({
1279
- name: 'conversation.chat.turnTail', id: 'deep-ptc-skills', order: 20,
1587
+ name: 'conversation.chat.turnTail', id: 'deep-ptc-skills', order: 20, locale: 'deep-ptc',
1280
1588
  inject: sessionId => ({
1281
1589
  setSkill: (name, enabled) => runSkillCommand(child, sessionId, { action: 'set', name, enabled }),
1282
1590
  setAll: enabled => runSkillCommand(child, sessionId, { action: 'all', enabled }),
1283
1591
  }),
1284
- }, props => h(SkillTail, { ...props, t })));
1592
+ }, props => h(LocalizedSlot, { ...props, component: SkillTail })));
1285
1593
  } catch { /* a broken card must not take the conversation with it */ }
1286
1594
  try {
1287
1595
  // The side card draws beside the conversation through a portal; nothing shows under the composer.
1288
1596
  child.slots.inject('conversation.composer.dock', () => child.slots.register({
1289
- name: 'conversation.composer.dock', id: 'deep-ptc-side', order: 89,
1290
- inject: sessionId => ({
1291
- reset: () => {
1292
- const execute = child.remote?.commands?.execute;
1293
- if (typeof execute !== 'function') return Promise.resolve({ ok: false, error: { message: 'unavailable' } });
1294
- return execute(sessionId, '/deep-ptc-reset-tools', []);
1295
- },
1296
- }),
1297
- }, props => h(SideCardHost, { ...props, form, t })));
1597
+ name: 'conversation.composer.dock', id: 'deep-ptc-side', order: 89, locale: 'deep-ptc',
1598
+ inject: sessionId => {
1599
+ const jobs = child.get?.('jobs');
1600
+ const props = {
1601
+ reset: () => {
1602
+ const execute = child.remote?.commands?.execute;
1603
+ if (typeof execute !== 'function') return Promise.resolve({ ok: true, value: undefined });
1604
+ return execute(sessionId, '/deep-ptc-reset-tools', []);
1605
+ },
1606
+ };
1607
+ if (jobs?.state && typeof jobs.watchRows === 'function') {
1608
+ props.hooks = { jobs: jobs.state };
1609
+ props.watchJobs = id => jobs.watchRows(id);
1610
+ }
1611
+ return props;
1612
+ },
1613
+ }, props => h(LocalizedSlot, { ...props, form, component: SideCardHost })));
1298
1614
  } catch { /* the composer stays usable when this slot cannot register */ }
1299
1615
  });
1300
1616
  } catch { /* the composer stays usable when this slot cannot register */ }