dsh-deep-ptc-mode 1.8.7 → 1.9.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.
package/lib/client.js CHANGED
@@ -6,6 +6,9 @@ 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)',
@@ -13,6 +16,7 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
13
16
  bashPathHint: '可填写 dsh-ops 随包的 Niubash。路径不可用时保留官方 Shell。受限模式请选 PowerShell。',
14
17
  distribution: 'WSL 发行版', distributionHint: '留空使用 Windows 的默认发行版,例如 Ubuntu。',
15
18
  shell: 'Shell 版本', shellAuto: '自动(沿用官方查找顺序)',
19
+ shellSystem: '{name}(系统自带)', shellPreview: 'PowerShell 7 预览版',
16
20
  shellHint: '只列出本机已发现的常见版本。文件消失后自动回退。WSL 仍只选择发行版。',
17
21
  sessions: '保存后请新建一个“深度PTC模式”会话。已有会话与后台任务保留原环境。',
18
22
  wslHint: 'WSL 暂不支持 Windows 的受限沙箱;受限调用会明确失败,不会自动切换或绕过限制。',
@@ -22,6 +26,9 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
22
26
  },
23
27
  en: {
24
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',
25
32
  environment: 'Execution environment', auto: 'Automatic (Windows: PowerShell; macOS: Zsh; Linux: Bash)',
26
33
  wsl: 'WSL Bash (Windows)', powershell: 'PowerShell (Windows)',
27
34
  zsh: 'Zsh (macOS / Linux)', bash: 'Native Bash (macOS / Linux)',
@@ -29,6 +36,7 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
29
36
  bashPathHint: 'You can use the Niubash bundled with dsh-ops. An unavailable path keeps the official shell. Choose PowerShell for confined work.',
30
37
  distribution: 'WSL distribution', distributionHint: 'Leave blank for the Windows default distribution, for example Ubuntu.',
31
38
  shell: 'Shell version', shellAuto: 'Automatic (official lookup)',
39
+ shellSystem: '{name} (system)', shellPreview: 'PowerShell 7 Preview',
32
40
  shellHint: 'Lists common executables found on this machine. A missing file falls back to automatic. WSL still selects a distribution only.',
33
41
  sessions: 'After saving, create a new Deep PTC session. Existing sessions and background jobs keep their environment.',
34
42
  wslHint: 'WSL does not support the confined Windows sandbox. Confined calls fail without execution or fallback.',
@@ -84,10 +92,10 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
84
92
  setEnvironment(latest.value?.environment ?? environment);
85
93
  setDistribution(latest.value?.wslDistribution ?? distribution.trim());
86
94
  setShellExecutable(latest.value?.shellExecutable ?? shellExecutable);
87
- setMessage(t('saved'));
95
+ setMessage('saved');
88
96
  } catch {
89
97
  draftRevision.current = form.getSnapshot().revision;
90
- setFailed(true); setMessage(t('failed'));
98
+ setFailed(true); setMessage('failed');
91
99
  } finally { setSaving(false); }
92
100
  }
93
101
  const effective = environment === 'auto'
@@ -123,11 +131,11 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
123
131
  h('select', { id: 'deep-ptc-shell', value: shellExecutable, disabled, style: control,
124
132
  onChange: event => { changed(); setShellExecutable(event.target.value); } },
125
133
  h('option', { value: '' }, t('shellAuto')),
126
- ...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)))),
127
135
  h('p', null, t('shellHint'))) : null,
128
136
  h('p', null, t('sessions')),
129
137
  !state.writable ? h('p', { role: 'status' }, t('readOnly')) : null,
130
- message ? h('p', { role: failed ? 'alert' : 'status' }, message) : null,
138
+ message ? h('p', { role: failed ? 'alert' : 'status' }, t(message)) : null,
131
139
  h('button', { type: 'submit', disabled: disabled || (windowsBash && !shellExecutable.trim()),
132
140
  style: { justifySelf: 'start', padding: '7px 16px' } }, t(saving ? 'saving' : 'save')),
133
141
  );
@@ -135,9 +143,9 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
135
143
 
136
144
  function ToolStateControls({ sessionId, useProjection, reset, t }) {
137
145
  const [busy, setBusy] = React.useState(false);
138
- const [message, setMessage] = React.useState('');
146
+ const [message, setMessage] = React.useState(null);
139
147
  const generation = React.useRef(0);
140
- React.useEffect(() => { generation.current++; setBusy(false); setMessage(''); return () => { generation.current++; }; }, [sessionId]);
148
+ React.useEffect(() => { generation.current++; setBusy(false); setMessage(null); return () => { generation.current++; }; }, [sessionId]);
141
149
  let preset, state;
142
150
  try {
143
151
  if (typeof useProjection !== 'function') return null;
@@ -149,20 +157,23 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
149
157
  const failed = state && typeof state === 'object' ? state.report?.tools ?? [] : [];
150
158
  async function reload() {
151
159
  const current = generation.current;
152
- setBusy(true); setMessage('');
160
+ setBusy(true); setMessage(null);
153
161
  try {
154
162
  const outcome = await reset();
155
163
  if (current !== generation.current) return;
156
164
  if (outcome?.ok === false) throw new Error(outcome.error?.message);
157
165
  const reply = outcome?.ok === true ? outcome.value : outcome;
158
- if (reply === undefined) throw new Error(t('toolResetUnavailable'));
166
+ if (reply === undefined) {
167
+ setMessage({ key: 'toolResetFailed', reason: 'toolResetUnavailable' });
168
+ return;
169
+ }
159
170
  const result = reply?.result ?? reply;
160
171
  if (result?.kind !== 'success') throw new Error(result?.text);
161
- setMessage(t('toolResetDone'));
172
+ setMessage({ key: 'toolResetDone' });
162
173
  } catch (error) {
163
174
  if (current === generation.current) {
164
175
  const detail = String(error?.message ?? error ?? '').slice(0, 220);
165
- setMessage(detail ? `${t('toolResetFailed')} ${detail}` : t('toolResetFailed'));
176
+ setMessage({ key: 'toolResetFailed', detail });
166
177
  }
167
178
  }
168
179
  finally { if (current === generation.current) setBusy(false); }
@@ -175,8 +186,8 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
175
186
  h('ul', null, ...failed.map(row => h('li', { key: row.name }, h('code', null, row.name), ` — ${row.provider}`)))) : null,
176
187
  h('button', { type: 'button', className: 'dpt-btn dpt-btn-block', onClick: reload, disabled: busy, title: t('toolResetHint'), 'aria-busy': busy },
177
188
  busy ? t('toolResetBusy') : t('toolReset')),
178
- h('p', { className: 'dpt-side-note', role: 'status', 'data-tone': message ? (message === t('toolResetDone') ? 'ok' : 'error') : undefined },
179
- 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')));
180
191
  }
181
192
  Object.assign(dictionaries.zh, {
182
193
  visualEffects: '界面特效', visualEffectsHint: '使用外部主题或 UI 插件时,建议关闭此开关。',
@@ -184,6 +195,7 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
184
195
  jobRunning: '运行中', jobStopping: '正在停止', jobCompleted: '已完成', jobKilled: '已取消', jobFailed: '已失败',
185
196
  toolReset: '重载所有工具状态', toolResetBusy: '正在重载…', toolResetDone: '本对话工具状态已重载。',
186
197
  toolResetFailed: '未能重载工具状态。', toolResetUnavailable: '当前会话无法调用工具重载命令。',
198
+ commandNoSession: '当前没有活动对话。', commandWrongMode: '该功能仅在深度 PTC 会话中可用。', commandInvalidSkill: '无效的 Skill 卡片操作。',
187
199
  toolResetHint: '清除本对话的故障标记和按需加载选择;正在运行的任务继续执行。',
188
200
  toolFailures: '工具适配提醒', toolFailureHint: '以下外部工具调用失败,可能存在适配问题,已在本对话中禁用。任务会优先使用其他可用工具;未进一步排查故障原因。',
189
201
  });
@@ -193,6 +205,7 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
193
205
  jobRunning: 'Running', jobStopping: 'Stopping', jobCompleted: 'Completed', jobKilled: 'Canceled', jobFailed: 'Failed',
194
206
  toolReset: 'Reload all tool states', toolResetBusy: 'Reloading…', toolResetDone: 'Tool states reloaded for this conversation.',
195
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.',
196
209
  toolResetHint: 'Clear quarantine and on-demand selections in this conversation. Running jobs continue.',
197
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.',
198
211
  });
@@ -203,15 +216,20 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
203
216
  skillShowAll: '显示全部 {count} 个', skillShowLess: '收起',
204
217
  agentsTitle: '子代理', agentsRunning: '{count} 个运行中', agentsCompleted: '{count} 个已完成', agentsIdle: '{count} 个空闲',
205
218
  agentRunning: '运行中', agentCompleted: '已完成', agentIdle: '空闲', agentExternal: '外部',
206
- agentsCollapse: '收起侧边卡片', agentsExpand: '展开侧边卡片', agentOpen: '在右侧栏打开这个子代理的对话',
219
+ agentOpen: '在右侧栏打开这个子代理的对话',
207
220
  sideTitle: '深度 PTC', toolsSection: '工具状态', envAuto: '自动', envForNew: '新会话生效', envThisSession: '本会话保持创建时的环境。',
208
221
  envAutoNow: '当前按自动选择:{env}。本会话保持创建时的环境。', envSaved: '已保存,之后新建的会话使用 {env}。',
209
222
  envFailed: '未能保存,请检查发行版名称或设置是否已在别处修改。', envDefaultDistribution: '默认发行版',
210
223
  durationSeconds: '{s} 秒', durationMinutes: '{m} 分 {s} 秒', durationHours: '{h} 小时 {m} 分', tokens: '{value} tokens',
211
- palTitle: '命令面板', palPlaceholder: '搜索会话,或输入命令…', palEmpty: '没有匹配的结果', palFoot: '↑↓ 选择 ↵ 打开 Esc 关闭',
212
- palCommand: '命令', palEffect: '特效', palSession: '会话', palNewSub: '开始一个新的对话', palPluginsSub: '打开插件页面',
213
- palAutomationSub: '打开自动化任务', palAgents: '侧边卡片:展开 / 收起', palAgentsSub: '执行环境与子代理',
214
- palFireworks: '放烟花', palFireworksSub: '庆祝一下',
224
+ sideGuide: '执行环境、子代理、后台任务、输出文件与 SSH', sideOtherMode: '当前对话不是深度 PTC 模式。这里的执行环境用于之后新建的深度 PTC 会话。',
225
+ capsuleOpen: '打开深度 PTC 面板',
226
+ outputsTitle: '输出文件', outputsEmpty: '本会话暂无输出文件。', outputsMore: '另有 {count} 个文件',
227
+ outputPresented: '已交付', outputTurn: '第 {turn} 轮',
228
+ sshTitle: 'SSH 连接', sshHint: '非交互连接', sshNoClient: '未找到 OpenSSH 客户端', sshConfigured: '已配置',
229
+ sshUsed: '第 {turn} 轮 · {count} 次', sshFailed: '第 {turn} 轮失败', sshEmpty: '~/.ssh/config 中没有主机别名,本会话也未连接过远程主机。',
230
+ appearance: '外观', visualEffectsAuto: '检测到外观插件 {name},特效默认关闭。手动打开后会保留你的选择。',
231
+ diagTitle: '诊断信息', diagHint: '复制后可附在 issue 中,便于排查界面问题。', diagCopy: '复制诊断信息', diagCopied: '已复制',
232
+ shellStore: 'PowerShell 7(应用商店)', presetSafeReason: '当前为安全模式:{reason}',
215
233
  });
216
234
  Object.assign(dictionaries.en, {
217
235
  skillTitle: 'Skills in context', skillLoaded: '{count} loaded', skillClosing: '{count} leave after your next message',
@@ -220,38 +238,52 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
220
238
  skillShowAll: 'Show all {count}', skillShowLess: 'Show less',
221
239
  agentsTitle: 'Subagents', agentsRunning: '{count} running', agentsCompleted: '{count} done', agentsIdle: '{count} idle',
222
240
  agentRunning: 'Running', agentCompleted: 'Done', agentIdle: 'Idle', agentExternal: 'External',
223
- agentsCollapse: 'Collapse the side card', agentsExpand: 'Expand the side card', agentOpen: 'Open this subagent in the right sidebar',
241
+ agentOpen: 'Open this subagent in the right sidebar',
224
242
  sideTitle: 'Deep PTC', toolsSection: 'Tool state', envAuto: 'Auto', envForNew: 'for new sessions', envThisSession: 'This session keeps the environment it was created with.',
225
243
  envAutoNow: 'Automatic picks {env}. This session keeps the environment it was created with.', envSaved: 'Saved. New sessions use {env}.',
226
244
  envFailed: 'Could not save. Check the distribution name, or whether settings changed elsewhere.', envDefaultDistribution: 'Default distribution',
227
245
  durationSeconds: '{s}s', durationMinutes: '{m}m {s}s', durationHours: '{h}h {m}m', tokens: '{value} tokens',
228
- palTitle: 'Command palette', palPlaceholder: 'Search sessions or type a command…', palEmpty: 'No matches', palFoot: '↑↓ select ↵ open Esc close',
229
- palCommand: 'Command', palEffect: 'Effect', palSession: 'Session', palNewSub: 'Start a new conversation', palPluginsSub: 'Open plugins',
230
- palAutomationSub: 'Open automations', palAgents: 'Side card: expand / collapse', palAgentsSub: 'Execution environment and subagents',
231
- palFireworks: 'Fireworks', palFireworksSub: 'Celebrate',
246
+ sideGuide: 'Environment, subagents, background jobs, output files and SSH', sideOtherMode: 'This conversation is not in Deep PTC mode. The environment here applies to new Deep PTC sessions.',
247
+ capsuleOpen: 'Open the Deep PTC panel',
248
+ outputsTitle: 'Output files', outputsEmpty: 'No output files in this conversation.', outputsMore: '{count} more files',
249
+ outputPresented: 'Delivered', outputTurn: 'Turn {turn}',
250
+ sshTitle: 'SSH connections', sshHint: 'non-interactive', sshNoClient: 'OpenSSH client not found', sshConfigured: 'Configured',
251
+ sshUsed: 'Turn {turn} · {count}×', sshFailed: 'Failed in turn {turn}', sshEmpty: 'No host aliases in ~/.ssh/config and no remote host reached in this conversation.',
252
+ appearance: 'Appearance', visualEffectsAuto: '{name} is installed, so effects start off. Turning them on keeps your choice.',
253
+ diagTitle: 'Diagnostics', diagHint: 'Copy and attach to an issue to help investigate interface problems.', diagCopy: 'Copy diagnostics', diagCopied: 'Copied',
254
+ shellStore: 'PowerShell 7 (Microsoft Store)', presetSafeReason: 'Safe mode: {reason}',
232
255
  });
233
256
 
234
257
  // Placeholders are filled here, so the text is right whether or not the host locale interpolates.
235
258
  const fill = (text, values) => String(text).replace(/\{(\w+)\}/gu, (whole, key) => values[key] === undefined ? whole : String(values[key]));
236
259
  const tf = (t, key, values) => fill(t(key, values), values);
237
- let T = key => key;
260
+ const commandMessageKeys = new Map([
261
+ ['No active conversation. / 当前没有活动对话。', 'commandNoSession'],
262
+ ['This command is available in Deep PTC sessions only. / 该功能仅在深度 PTC 会话中可用。', 'commandWrongMode'],
263
+ ['Invalid skill card command. / 无效的 Skill 卡片操作。', 'commandInvalidSkill'],
264
+ ]);
265
+ function commandText(text, t) {
266
+ const key = commandMessageKeys.get(text);
267
+ return key ? t(key) : text;
268
+ }
238
269
  let hostCtx;
239
- let ReactDOM;
240
- try { ReactDOM = require('react-dom'); } catch { ReactDOM = undefined; }
241
- const canPortal = () => typeof ReactDOM?.createPortal === 'function' && typeof document !== 'undefined';
242
270
 
243
271
  // ---------------------------------------------------------------------------------------------
244
- // Stylesheet. The cards are only rendered in Deep PTC sessions. The refined look and its motion
245
- // (ported from dsh-refined-ui, without its floating task windows) apply only while the
246
- // conversation on screen is a Deep PTC session: every rule is scoped by body[data-dpt-ui].
272
+ // Stylesheet. The cards render only in Deep PTC sessions. The visual effects (the refined look and
273
+ // its motion) apply only while the conversation on screen is a Deep PTC session and effects are on:
274
+ // every effect rule is scoped by body[data-dpt-ui]. Effect rules target the host's own stable
275
+ // attributes (data-composer-card, data-message-bubble); the send button is the one element tagged.
276
+ // Looping animations change opacity or transform only, so the compositor runs them without repaints.
247
277
  // ---------------------------------------------------------------------------------------------
248
278
  const PLUGIN = 'dsh-deep-ptc-mode';
249
279
  const ON = 'body[data-dpt-ui]';
250
280
  const ON0 = ':where(body[data-dpt-ui])';
251
281
  const DARK = 'body[data-ds-dark-theme]:not([data-ds-dark-theme="false"])';
252
282
  const ON_DARK = 'body[data-dpt-ui][data-ds-dark-theme]:not([data-ds-dark-theme="false"])';
283
+ const COMPOSER = '[data-composer-card]';
284
+ const BUBBLE = ':is([data-chat-flow-kind="user"],[data-chat-flow-kind="steering"]) [data-message-bubble]';
253
285
  const CARD_CSS = `
254
- .dpt-card,.dpt-agents,.dpt-agents-pill{--dpt-accent:var(--dpt-brand,#3370ff);--dpt-ease:cubic-bezier(.22,1,.36,1)}
286
+ .dpt-card,.dpt-panel,.dpt-capsule,.dpt-settings{--dpt-accent:var(--dpt-brand,#3370ff);--dpt-ease:cubic-bezier(.22,1,.36,1);--dpt-line:var(--dsw-alias-border-l1,#e3e7ee)}
255
287
  .dpt-card{--dpt-card-fill:var(--dsw-static-neutral-50,#f7f8fa);box-sizing:border-box;width:100%;margin:2px 0 4px;border:.5px solid var(--dsw-alias-border-l2,#d6dce6);border-radius:var(--dsw-radius-lg,16px);background:var(--dpt-card-fill);color:var(--dsw-alias-label-primary,#101828);font-size:13px;line-height:20px;overflow:hidden;animation:dpt-rise 220ms var(--dpt-ease) both}
256
288
  ${DARK} .dpt-card{--dpt-card-fill:var(--dsw-static-neutral-850,#1a1f29)}
257
289
  .dpt-card-head{display:flex;align-items:center;gap:10px;padding:10px 12px 6px}
@@ -261,11 +293,13 @@ ${DARK} .dpt-card{--dpt-card-fill:var(--dsw-static-neutral-850,#1a1f29)}
261
293
  .dpt-card-sub{font-size:11px;line-height:16px;color:var(--dsw-alias-label-tertiary,#667085);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
262
294
  .dpt-card-sub [data-tone="warn"]{color:var(--dsw-alias-state-warn-primary,#b45309)}
263
295
  .dpt-card-actions{flex:none;display:flex;gap:6px}
264
- .dpt-btn{box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;height:26px;padding:0 10px;border:.5px solid var(--dsw-alias-border-l3,#c9d0db);border-radius:var(--dsw-radius-sm,8px);background:var(--dsw-alias-button-floating-fill,#fff);color:var(--dsw-alias-label-primary,#101828);font:inherit;font-size:12px;line-height:18px;white-space:nowrap;cursor:pointer;transition:background-color 120ms,border-color 120ms,opacity 120ms}
265
- .dpt-btn:hover:not(:disabled){background:var(--dsw-alias-button-floating-hover,var(--dsw-alias-interactive-bg-hover,rgba(16,24,40,.05)))}
296
+ .dpt-btn{box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;height:26px;padding:0 10px;border:1px solid color-mix(in srgb,var(--dpt-accent) 35%,transparent);border-radius:var(--dsw-radius-sm,8px);background:var(--dsw-alias-bg-base,#fff);color:var(--dsw-alias-label-primary,#101828);font:inherit;font-size:12px;font-weight:500;line-height:18px;white-space:nowrap;cursor:pointer;transition:background-color 120ms,border-color 120ms,opacity 120ms}
297
+ .dpt-btn:hover:not(:disabled){background:color-mix(in srgb,var(--dpt-accent) 8%,var(--dsw-alias-bg-base,#fff))}
298
+ .dpt-card .dpt-btn{border:.5px solid var(--dsw-alias-border-l3,#c9d0db);background:var(--dsw-alias-button-floating-fill,#fff);font-weight:400}
299
+ .dpt-card .dpt-btn:hover:not(:disabled){background:var(--dsw-alias-button-floating-hover,var(--dsw-alias-interactive-bg-hover,rgba(16,24,40,.05)))}
266
300
  .dpt-btn:disabled{opacity:.45;cursor:default}
267
301
  .dpt-btn[aria-busy="true"]{cursor:wait}
268
- .dpt-btn:focus-visible,.dpt-switch:focus-visible,.dpt-agent:focus-visible,.dpt-icon-btn:focus-visible,.dpt-link:focus-visible,.dpt-agents-pill:focus-visible{outline:2px solid var(--dpt-accent,#3370ff);outline-offset:2px}
302
+ .dpt-btn:focus-visible,.dpt-switch:focus-visible,.dpt-agent:focus-visible,.dpt-icon-btn:focus-visible,.dpt-link:focus-visible,.dpt-capsule:focus-visible{outline:2px solid var(--dpt-accent,#3370ff);outline-offset:2px}
269
303
  .dpt-skill-list{list-style:none;margin:0;padding:0 4px 4px;display:flex;flex-direction:column;gap:2px}
270
304
  .dpt-skill{display:flex;align-items:center;gap:12px;padding:7px 8px 7px 10px;border-radius:10px;transition:background-color 120ms}
271
305
  .dpt-skill:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(16,24,40,.05))}
@@ -283,29 +317,24 @@ ${DARK} .dpt-card{--dpt-card-fill:var(--dsw-static-neutral-850,#1a1f29)}
283
317
  .dpt-switch[aria-checked="true"] .dpt-switch-thumb{transform:translateX(14px)}
284
318
  .dpt-card-foot{display:flex;align-items:center;justify-content:space-between;gap:12px;margin:0;padding:8px 14px 10px;border-top:.5px solid var(--dsw-alias-border-l1,#e3e7ee);font-size:11px;line-height:16px;color:var(--dsw-alias-label-tertiary,#667085)}
285
319
  .dpt-link{flex:none;border:0;background:none;padding:0;font:inherit;color:var(--dpt-accent,#3370ff);cursor:pointer}
286
- .dpt-agents{position:fixed;z-index:40;box-sizing:border-box;width:248px;display:flex;flex-direction:column;border-radius:16px;border:.5px solid var(--dsw-alias-border-l2,#d6dce6);background:color-mix(in srgb,var(--dsw-alias-bg-base,#fff) 88%,transparent);-webkit-backdrop-filter:blur(16px) saturate(1.2);backdrop-filter:blur(16px) saturate(1.2);box-shadow:0 10px 30px rgba(16,24,40,.08),0 1px 3px rgba(16,24,40,.06);color:var(--dsw-alias-label-primary,#101828);font-size:13px;line-height:20px;overflow:hidden;animation:dpt-rise 220ms var(--dpt-ease) both}
287
- ${DARK} .dpt-agents,${DARK} .dpt-agents-pill{box-shadow:0 10px 30px rgba(0,0,0,.45),0 1px 3px rgba(0,0,0,.35)}
288
- .dpt-agents-head{display:flex;align-items:center;gap:8px;padding:10px 8px 6px 14px}
289
- .dpt-agents-title{flex:none;font-weight:600}
290
- .dpt-agents-count{flex:1;min-width:0;font-size:11px;line-height:16px;color:var(--dsw-alias-label-tertiary,#667085);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
291
- .dpt-icon-btn{flex:none;display:grid;place-items:center;width:24px;height:24px;padding:0;border:0;border-radius:8px;background:transparent;color:var(--dsw-alias-label-secondary,#4a5565);cursor:pointer}
292
- .dpt-icon-btn:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(16,24,40,.05))}
293
- .dpt-side-body{overflow:auto;min-height:0}
320
+ .dpt-panel{box-sizing:border-box;display:flex;flex-direction:column;height:100%;min-height:0;color:var(--dsw-alias-label-primary,#101828);font-size:13px;line-height:20px}
321
+ .dpt-panel[data-inline]{height:auto;max-height:min(60vh,520px);margin:6px 0 2px;border:1px solid var(--dpt-line);border-radius:14px;background:var(--dsw-alias-bg-base,#fff);overflow:hidden;animation:dpt-rise 200ms var(--dpt-ease) both}
322
+ .dpt-side-body{flex:1;overflow:auto;min-height:0;padding-top:10px}
294
323
  .dpt-side-section{padding:2px 14px 12px}
295
- .dpt-side-section+.dpt-side-section{border-top:.5px solid var(--dsw-alias-border-l1,#e3e7ee);padding-top:10px}
324
+ .dpt-side-section+.dpt-side-section{border-top:1px solid var(--dpt-line);padding-top:10px}
296
325
  .dpt-side-agents{padding-left:8px;padding-right:8px}
297
326
  .dpt-side-agents .dpt-agents-list{display:flex;flex-direction:column;gap:4px;padding:2px 0}
298
327
  .dpt-side-agents>.dpt-side-label{padding:0 6px}
299
328
  .dpt-side-label{display:flex;align-items:baseline;justify-content:space-between;gap:8px;margin-bottom:6px;font-size:12px;line-height:18px;font-weight:600;color:var(--dsw-alias-label-secondary,#4a5565)}
300
329
  .dpt-side-hint{min-width:0;font-size:11px;font-weight:400;color:var(--dsw-alias-label-tertiary,#667085);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
301
- .dpt-seg{display:flex;gap:2px;padding:2px;border-radius:10px;background:var(--dsw-alias-interactive-bg-hover,rgba(16,24,40,.05))}
330
+ .dpt-seg{display:flex;gap:2px;padding:2px;border-radius:10px;background:color-mix(in srgb,var(--dpt-accent) 9%,transparent)}
302
331
  .dpt-seg-btn{flex:1;min-width:0;height:26px;padding:0 6px;border:0;border-radius:8px;background:transparent;color:var(--dsw-alias-label-secondary,#4a5565);font:inherit;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;cursor:pointer;transition:background-color 120ms,color 120ms,box-shadow 120ms}
303
332
  .dpt-seg-btn:hover:not(:disabled):not([aria-checked="true"]){color:var(--dsw-alias-label-primary,#101828)}
304
- .dpt-seg-btn[aria-checked="true"]{background:var(--dsw-alias-bg-base,#fff);color:var(--dsw-alias-label-primary,#101828);font-weight:600;box-shadow:0 1px 2px rgba(16,24,40,.12),0 0 0 .5px var(--dsw-alias-border-l1,#e3e7ee)}
333
+ .dpt-seg-btn[aria-checked="true"]{background:var(--dsw-alias-bg-base,#fff);color:var(--dsw-alias-label-primary,#101828);font-weight:600;box-shadow:0 1px 3px color-mix(in srgb,var(--dpt-accent) 25%,transparent),0 0 0 1px color-mix(in srgb,var(--dpt-accent) 35%,transparent)}
305
334
  .dpt-seg-btn:disabled{cursor:default}
306
335
  .dpt-seg-btn:focus-visible,.dpt-input:focus-visible,.dpt-select:focus-visible{outline:2px solid var(--dpt-accent,#3370ff);outline-offset:1px}
307
336
  .dpt-field{display:flex;gap:6px;margin-top:8px}
308
- .dpt-input,.dpt-select{flex:1;min-width:0;box-sizing:border-box;height:28px;padding:0 8px;border:.5px solid var(--dsw-alias-border-l2,#d6dce6);border-radius:8px;background:var(--dsw-alias-bg-base,#fff);color:inherit;font:inherit;font-size:12px}
337
+ .dpt-input,.dpt-select{flex:1;min-width:0;box-sizing:border-box;height:28px;padding:0 8px;border:1px solid var(--dpt-line);border-radius:8px;background:var(--dsw-alias-bg-base,#fff);color:inherit;font:inherit;font-size:12px}
309
338
  .dpt-btn-block{display:flex;width:100%}
310
339
  .dpt-side-hint[data-tone="warn"]{color:var(--dsw-alias-state-warn-primary,#b45309)}
311
340
  .dpt-tool-failures{margin:0 0 8px;padding:8px 10px;border-radius:10px;background:color-mix(in srgb,var(--dsw-alias-state-warn-primary,#d97706) 10%,transparent);font-size:11px;line-height:16px;color:var(--dsw-alias-label-secondary,#4a5565)}
@@ -317,14 +346,13 @@ ${DARK} .dpt-agents,${DARK} .dpt-agents-pill{box-shadow:0 10px 30px rgba(0,0,0,.
317
346
  .dpt-side-note[data-tone="error"]{color:var(--dsw-alias-state-error-primary,#c4321f)}
318
347
  .dpt-agents-list{list-style:none;margin:0;padding:0;overflow:visible;min-height:0}
319
348
  .dpt-agent{display:flex;align-items:flex-start;gap:10px;width:100%;box-sizing:border-box;padding:7px 8px 7px calc(8px + var(--dpt-depth,0) * 14px);border:0;border-radius:10px;background:transparent;color:inherit;font:inherit;text-align:left;cursor:pointer;transition:background-color 120ms}
320
- .dpt-agent:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover,rgba(16,24,40,.05))}
349
+ .dpt-agent:hover:not(:disabled){background:color-mix(in srgb,var(--dpt-accent) 7%,transparent)}
321
350
  .dpt-agent:disabled{cursor:default}
322
351
  .dpt-agent-dot{flex:none;width:8px;height:8px;margin-top:6px;border-radius:50%;background:var(--dsw-alias-label-tertiary,#98a2b3)}
323
- .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)}
324
- ${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}
325
- @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)}}
326
- .dpt-agent[data-state="completed"] .dpt-agent-dot{background:var(--dsw-alias-state-success-primary,#0f7a4f)}
327
- .dpt-job[data-state="completed"] .dpt-agent-dot{background:var(--dsw-alias-state-success-primary,#0f7a4f)}
352
+ .dpt-agent[data-state="running"] .dpt-agent-dot,.dpt-capsule[data-state="running"] .dpt-agent-dot,.dpt-job[data-state="running"] .dpt-agent-dot{background:var(--dpt-accent,#3370ff);box-shadow:0 0 6px 2px color-mix(in srgb,var(--dpt-accent,#3370ff) 60%,transparent)}
353
+ ${ON} .dpt-capsule[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}
354
+ @keyframes dpt-dot-flash{0%,100%{opacity:1}50%{opacity:.35}}
355
+ .dpt-agent[data-state="completed"] .dpt-agent-dot,.dpt-job[data-state="completed"] .dpt-agent-dot{background:var(--dsw-alias-state-success-primary,#0f7a4f)}
328
356
  .dpt-job[data-state="stopping"] .dpt-agent-dot,.dpt-job[data-state="killed"] .dpt-agent-dot{background:var(--dsw-alias-state-warn-primary,#b45309)}
329
357
  .dpt-job[data-state="failed"] .dpt-agent-dot{background:var(--dsw-alias-state-error-primary,#c4321f)}
330
358
  .dpt-side-effects .dpt-side-label{align-items:center}
@@ -336,32 +364,35 @@ ${ON} .dpt-agents-pill[data-state="running"] .dpt-agent-dot,${ON} .dpt-agent[dat
336
364
  .dpt-agent-main{flex:1;min-width:0;display:flex;flex-direction:column}
337
365
  .dpt-agent-name{font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
338
366
  .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}
339
- .dpt-agents-pill{position:fixed;z-index:40;display:inline-flex;align-items:center;gap:8px;height:30px;padding:0 12px;box-sizing:border-box;border-radius:999px;border:.5px solid var(--dsw-alias-border-l2,#d6dce6);background:color-mix(in srgb,var(--dsw-alias-bg-base,#fff) 88%,transparent);-webkit-backdrop-filter:blur(16px);backdrop-filter:blur(16px);box-shadow:0 6px 20px rgba(16,24,40,.08);color:var(--dsw-alias-label-primary,#101828);font:inherit;font-size:12px;cursor:pointer;animation:dpt-rise 220ms var(--dpt-ease) both}
340
- .dpt-agents-pill .dpt-agent-dot{margin-top:0}
341
- .dpt-agents,.dpt-agents-pill{--dpt-line:var(--dsw-alias-border-l1,#e3e7ee)}
342
- .dpt-agents{background:var(--dsw-alias-bg-base,#fff);-webkit-backdrop-filter:none;backdrop-filter:none;border:1px solid var(--dpt-line);box-shadow:0 12px 32px color-mix(in srgb,var(--dpt-accent) 14%,transparent),0 1px 3px rgba(16,24,40,.06)}
343
- .dpt-agents-head{margin-bottom:8px;padding-bottom:8px;border-bottom:1px solid var(--dpt-line)}
344
- .dpt-agents-title{display:flex;align-items:center;gap:8px}
345
- .dpt-agents-title::before{content:"";width:8px;height:8px;border-radius:50%;background:linear-gradient(135deg,var(--dpt-brand-light,#7fb0ff),var(--dpt-accent));box-shadow:0 0 0 3px color-mix(in srgb,var(--dpt-accent) 15%,transparent)}
346
- .dpt-agents .dpt-icon-btn{color:var(--dsw-alias-label-secondary,#4a5565)}
347
- .dpt-agents .dpt-icon-btn:hover{background:color-mix(in srgb,var(--dpt-accent) 10%,transparent)}
348
- .dpt-agents .dpt-side-section+.dpt-side-section{border-top:1px solid var(--dpt-line)}
349
- .dpt-agents .dpt-seg{background:color-mix(in srgb,var(--dpt-accent) 9%,transparent)}
350
- .dpt-agents .dpt-seg-btn{color:var(--dsw-alias-label-secondary,#4a5565)}
351
- .dpt-agents .dpt-seg-btn[aria-checked="true"]{background:#fff;color:var(--dsw-alias-label-primary,#101828);box-shadow:0 1px 3px color-mix(in srgb,var(--dpt-accent) 25%,transparent),0 0 0 1px color-mix(in srgb,var(--dpt-accent) 35%,transparent)}
352
- .dpt-agents .dpt-input,.dpt-agents .dpt-select{background:#fff;border:1px solid var(--dpt-line)}
353
- .dpt-agents .dpt-btn{background:#fff;border:1px solid color-mix(in srgb,var(--dpt-accent) 35%,transparent);color:var(--dsw-alias-label-primary,#101828);font-weight:500}
354
- .dpt-agents .dpt-btn:hover:not(:disabled){background:color-mix(in srgb,var(--dpt-accent) 8%,#fff)}
355
- .dpt-agents .dpt-agent:hover:not(:disabled){background:color-mix(in srgb,var(--dpt-accent) 7%,transparent)}
356
- .dpt-agents-pill{background:var(--dsw-alias-bg-base,#fff);-webkit-backdrop-filter:none;backdrop-filter:none;border:1px solid var(--dpt-line);color:var(--dsw-alias-label-primary,#101828);box-shadow:0 6px 20px color-mix(in srgb,var(--dpt-accent) 18%,transparent)}
357
- ${DARK} .dpt-agents .dpt-seg-btn[aria-checked="true"],${DARK} .dpt-agents .dpt-input,${DARK} .dpt-agents .dpt-select,${DARK} .dpt-agents .dpt-btn{background:var(--dsw-alias-bg-base,#161b24)}
358
- [data-conversation-region="chat"][data-dpt-docked]{margin-right:272px!important}
359
- .dpt-agents[data-split]{border:0;border-left:1px solid var(--dpt-line,#e3e7ee);border-radius:0;box-shadow:none;animation:dpt-fade-in 160ms ease-out both}
360
- @keyframes dpt-fade-in{from{opacity:0}to{opacity:1}}
367
+ .dpt-capsule-row{display:flex;flex-direction:column;align-items:flex-end;padding:4px 2px 0}
368
+ .dpt-capsule{display:inline-flex;align-items:center;gap:8px;max-width:100%;height:26px;padding:0 11px;box-sizing:border-box;border-radius:999px;border:1px solid var(--dpt-line);background:var(--dsw-alias-bg-base,#fff);color:var(--dsw-alias-label-secondary,#4a5565);font:inherit;font-size:12px;cursor:pointer;transition:border-color 120ms,color 120ms}
369
+ .dpt-capsule>span:last-child{min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
370
+ .dpt-capsule:hover,.dpt-capsule[aria-expanded="true"]{color:var(--dsw-alias-label-primary,#101828);border-color:color-mix(in srgb,var(--dpt-accent) 40%,transparent)}
371
+ .dpt-capsule .dpt-agent-dot{margin-top:0}
372
+ .dpt-capsule-row>.dpt-panel{align-self:stretch}
373
+ .dpt-tab-title{display:inline-flex;align-items:center;gap:6px}
374
+ .dpt-tab-title::before,.dpt-panel-mark::before{content:"";width:8px;height:8px;border-radius:50%;background:linear-gradient(135deg,var(--dpt-brand-light,#7fb0ff),var(--dpt-accent,#3370ff))}
375
+ .dpt-settings{display:grid;gap:22px;max-width:640px;font-size:13px;line-height:20px;color:var(--dsw-alias-label-primary,#101828)}
376
+ .dpt-settings h3{margin:0 0 10px;font-size:14px;line-height:20px;font-weight:600}
377
+ .dpt-settings .dpt-side-section{padding:0}
378
+ .dpt-settings .dpt-side-section+.dpt-side-section{border:0;padding:0}
379
+ .dpt-settings-row{display:flex;align-items:center;justify-content:space-between;gap:16px}
380
+ .dpt-diag{margin:8px 0 0;padding:10px 12px;max-height:220px;overflow:auto;border-radius:10px;border:1px solid var(--dpt-line);font:11px/16px var(--ds-font-family-code,ui-monospace,monospace);white-space:pre-wrap;word-break:break-word}
381
+ .dpt-files{display:grid;gap:1px;list-style:none;margin:0;padding:0}
382
+ .dpt-file{display:flex;align-items:center;gap:6px;min-width:0;height:22px;padding:0 6px;border-radius:6px;font-size:12px;line-height:18px}
383
+ .dpt-file:hover{background:color-mix(in srgb,var(--dpt-accent) 6%,transparent)}
384
+ .dpt-file-name{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-family:var(--ds-font-family-code,ui-monospace,monospace);font-size:11.5px}
385
+ .dpt-file-meta{flex:none;max-width:45%;font-size:11px;color:var(--dsw-alias-label-tertiary,#667085);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
386
+ .dpt-file[data-kind="presented"] .dpt-file-name{color:var(--dpt-accent,#3370ff)}
387
+ .dpt-files-more{padding:0 6px}
388
+ .dpt-files-more summary{cursor:pointer;height:22px;font-size:11px;line-height:22px;color:var(--dsw-alias-label-tertiary,#667085)}
389
+ .dpt-host .dpt-agent-dot{width:6px;height:6px;margin-top:0}
390
+ .dpt-host[data-state="ok"] .dpt-agent-dot{background:var(--dsw-alias-state-success-primary,#0f7a4f)}
391
+ .dpt-host[data-state="failed"] .dpt-agent-dot{background:var(--dsw-alias-state-error-primary,#c4321f)}
361
392
  [data-chat-flow-kind="command"]:has([data-dpt-hidden-command]){display:none!important}
362
393
  .dpt-command-error{padding:4px 2px;font-size:12px;line-height:18px;color:var(--dsw-alias-state-error-primary,#c4321f)}
363
394
  @keyframes dpt-rise{from{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}
364
- @media (prefers-reduced-motion:reduce){.dpt-card,.dpt-agents,.dpt-agents-pill,.dpt-agent-dot,.dpt-switch,.dpt-switch-thumb{animation:none!important;transition:none!important}}
395
+ @media (prefers-reduced-motion:reduce){.dpt-card,.dpt-panel,.dpt-capsule,.dpt-agent-dot,.dpt-switch,.dpt-switch-thumb{animation:none!important;transition:none!important}}
365
396
  `;
366
397
  const THEME_CSS = `
367
398
  ${ON}{--dpt-dur-fast:120ms;--dpt-dur-base:200ms;--dpt-ease-out:cubic-bezier(0.22,1,0.36,1);--dpt-brand:#3370ff;--dpt-brand-ink:#1f4fc4;--dpt-brand-light:color-mix(in srgb,var(--dpt-brand) 70%,#7fd0ff)}
@@ -402,18 +433,19 @@ ${ON0} :where(button,[role="button"],[role="menuitem"],[role="tab"],a,summary,se
402
433
  }
403
434
  ${ON0} :where(button:active:not(:disabled),[role="button"]:active:not([aria-disabled="true"])){transform:scale(0.98)}
404
435
  ${ON} ::selection{background:color-mix(in srgb,var(--dpt-brand) 24%,transparent)}
405
- ${ON} [data-dpt-composer]{box-shadow:0 10px 30px rgba(16,24,40,0.07),0 2px 6px rgba(16,24,40,0.05);transition:border-color var(--dpt-dur-base) var(--dpt-ease-out),box-shadow var(--dpt-dur-base) var(--dpt-ease-out),transform var(--dpt-dur-base) var(--dpt-ease-out)}
406
- ${ON_DARK} [data-dpt-composer]{box-shadow:0 10px 30px rgba(0,0,0,0.45),0 2px 6px rgba(0,0,0,0.35)}
407
- ${ON} [data-dpt-composer]::before{content:"";position:absolute;inset:-1px;border-radius:inherit;padding:1.5px;pointer-events:none;background:linear-gradient(115deg,var(--dpt-brand),var(--dpt-brand-light),var(--dpt-brand),var(--dpt-brand-light));background-size:300% 100%;-webkit-mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);-webkit-mask-composite:xor;mask-composite:exclude;opacity:0;transition:opacity var(--dpt-dur-base) var(--dpt-ease-out)}
408
- ${ON} [data-dpt-composer]:focus-within::before{opacity:1;animation:dpt-sheen 5s linear infinite}
409
- ${ON}:not([data-dpt-busy]) [data-dpt-composer]:focus-within{box-shadow:0 0 0 4px color-mix(in srgb,var(--dpt-brand) 10%,transparent),0 14px 38px color-mix(in srgb,var(--dpt-brand) 16%,transparent) !important}
410
- ${ON} [data-dpt-composer]:hover:not(:focus-within){background-image:radial-gradient(360px circle at var(--dpt-mx,50%) var(--dpt-my,50%),color-mix(in srgb,var(--dpt-brand) 7%,transparent),transparent 70%)}
436
+ ${ON} ${COMPOSER}{position:relative;box-shadow:0 10px 30px rgba(16,24,40,0.07),0 2px 6px rgba(16,24,40,0.05);transition:border-color var(--dpt-dur-base) var(--dpt-ease-out),box-shadow var(--dpt-dur-base) var(--dpt-ease-out)}
437
+ ${ON_DARK} ${COMPOSER}{box-shadow:0 10px 30px rgba(0,0,0,0.45),0 2px 6px rgba(0,0,0,0.35)}
438
+ ${ON} ${COMPOSER}::before{content:"";position:absolute;inset:-1px;border-radius:inherit;padding:1.5px;pointer-events:none;background:linear-gradient(115deg,var(--dpt-brand),var(--dpt-brand-light),var(--dpt-brand),var(--dpt-brand-light));background-size:300% 100%;-webkit-mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);-webkit-mask-composite:xor;mask-composite:exclude;opacity:0;transition:opacity var(--dpt-dur-base) var(--dpt-ease-out)}
439
+ ${ON} ${COMPOSER}:focus-within::before{opacity:1}
440
+ ${ON} ${COMPOSER}::after{content:"";position:absolute;inset:0;border-radius:inherit;pointer-events:none;opacity:0;box-shadow:0 0 0 4px color-mix(in srgb,var(--dpt-brand) 22%,transparent),0 0 44px 10px color-mix(in srgb,var(--dpt-brand) 46%,transparent),0 14px 44px color-mix(in srgb,var(--dpt-brand) 22%,transparent);transition:opacity var(--dpt-dur-base) var(--dpt-ease-out)}
441
+ ${ON}:not([data-dpt-busy]) ${COMPOSER}:focus-within{box-shadow:0 0 0 4px color-mix(in srgb,var(--dpt-brand) 10%,transparent),0 14px 38px color-mix(in srgb,var(--dpt-brand) 16%,transparent) !important}
442
+ ${ON} ${COMPOSER}:hover:not(:focus-within){background-image:radial-gradient(360px circle at var(--dpt-mx,50%) var(--dpt-my,50%),color-mix(in srgb,var(--dpt-brand) 7%,transparent),transparent 70%)}
411
443
  @keyframes dpt-sheen{from{background-position:0% 0}to{background-position:300% 0}}
412
444
  ${ON} [data-dpt-send]:not(:disabled):not([aria-disabled="true"]){background-image:linear-gradient(135deg,var(--dpt-brand-light),var(--dpt-brand)) !important;color:#fff !important;box-shadow:0 4px 14px color-mix(in srgb,var(--dpt-brand) 38%,transparent);transition:transform 160ms var(--dpt-ease-out),box-shadow 160ms var(--dpt-ease-out),filter var(--dpt-dur-fast) var(--dpt-ease-out) !important}
413
445
  ${ON} [data-dpt-send]:not(:disabled):not([aria-disabled="true"]):hover{transform:translateY(-1px);box-shadow:0 8px 20px color-mix(in srgb,var(--dpt-brand) 46%,transparent);filter:saturate(1.08)}
414
446
  ${ON} [data-dpt-send]:not(:disabled):not([aria-disabled="true"]):active{transform:translateY(0) scale(0.94);transition-duration:60ms}
415
- ${ON} [data-dpt-bubble]{background-image:linear-gradient(90deg,color-mix(in srgb,var(--dpt-brand) 20%,transparent),color-mix(in srgb,var(--dpt-brand) 7%,transparent)) !important;background-color:transparent !important;color:var(--dsw-alias-label-primary) !important;border-radius:18px 18px 6px 18px !important;box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--dpt-brand) 16%,transparent);animation:dpt-bubble-rise var(--dpt-dur-base) var(--dpt-ease-out) both}
416
- ${ON} [data-dpt-bubble] *{color:inherit}
447
+ ${ON} ${BUBBLE}{background-image:linear-gradient(90deg,color-mix(in srgb,var(--dpt-brand) 20%,transparent),color-mix(in srgb,var(--dpt-brand) 7%,transparent)) !important;background-color:transparent !important;color:var(--dsw-alias-label-primary) !important;border-radius:18px 18px 6px 18px !important;box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--dpt-brand) 16%,transparent);animation:dpt-bubble-rise var(--dpt-dur-base) var(--dpt-ease-out) both}
448
+ ${ON} ${BUBBLE} *{color:inherit}
417
449
  @keyframes dpt-bubble-rise{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
418
450
  ${ON} [data-chat-flow-kind="assistant-step"]{font-size:15px}
419
451
  ${ON} [data-chat-flow-kind="assistant-step"] :is(p,li){line-height:1.82}
@@ -424,32 +456,18 @@ ${ON} [data-row-key^="session:"][role="treeitem"]{transition:background-color va
424
456
  ${ON} [data-row-key^="session:"][role="treeitem"]:hover{background-color:color-mix(in srgb,var(--dpt-brand) 7%,transparent)}
425
457
  ${ON} [data-row-key^="session:"][role="treeitem"]:hover:not(:is([aria-selected="true"],[aria-current="true"],[data-selected="true"],.ld-row-selected)){background-image:radial-gradient(160px circle at var(--dpt-mx,50%) var(--dpt-my,50%),color-mix(in srgb,var(--dpt-brand) 18%,transparent),transparent 72%)}
426
458
  ${ON} [data-row-key^="session:"][role="treeitem"]:is([aria-selected="true"],[aria-current="true"],[data-selected="true"],.ld-row-selected){background-image:linear-gradient(90deg,color-mix(in srgb,var(--dpt-brand) 15%,transparent),color-mix(in srgb,var(--dpt-brand) 3%,transparent));font-weight:500}
427
- ${ON}[data-dpt-busy] [data-dpt-composer]::before{opacity:1;padding:2.5px;animation:dpt-sheen 1.6s linear infinite}
428
- ${ON}[data-dpt-busy] [data-dpt-composer]{border-color:color-mix(in srgb,var(--dpt-brand) 55%,transparent) !important;animation:dpt-breathe 1.9s ease-in-out infinite}
429
- @keyframes dpt-breathe{0%,100%{box-shadow:0 0 0 1px color-mix(in srgb,var(--dpt-brand) 35%,transparent),0 0 16px 2px color-mix(in srgb,var(--dpt-brand) 28%,transparent),0 10px 30px color-mix(in srgb,var(--dpt-brand) 12%,transparent)}50%{box-shadow:0 0 0 4px color-mix(in srgb,var(--dpt-brand) 22%,transparent),0 0 44px 10px color-mix(in srgb,var(--dpt-brand) 50%,transparent),0 14px 44px color-mix(in srgb,var(--dpt-brand) 24%,transparent)}}
430
- ${ON} [data-dpt-composer][data-dpt-done]{animation:dpt-done 900ms var(--dpt-ease-out) 1}
459
+ ${ON}[data-dpt-busy] ${COMPOSER}::before{opacity:1;padding:2.5px;animation:dpt-sheen 1.6s linear infinite}
460
+ ${ON}[data-dpt-busy] ${COMPOSER}{border-color:color-mix(in srgb,var(--dpt-brand) 55%,transparent) !important}
461
+ ${ON}[data-dpt-busy] ${COMPOSER}::after{animation:dpt-glow 1.9s ease-in-out infinite}
462
+ @keyframes dpt-glow{0%,100%{opacity:.3}50%{opacity:1}}
463
+ ${ON} ${COMPOSER}[data-dpt-done]{animation:dpt-done 900ms var(--dpt-ease-out) 1}
431
464
  @keyframes dpt-done{0%{box-shadow:0 0 0 0 color-mix(in srgb,var(--dpt-brand) 60%,transparent)}100%{box-shadow:0 0 0 26px color-mix(in srgb,var(--dpt-brand) 0%,transparent)}}
432
465
  ${ON}[data-dpt-busy] [data-dpt-send]{position:relative}
433
466
  ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-4px;border-radius:50%;padding:2.5px;pointer-events:none;background:conic-gradient(from 0deg,transparent 0 40%,var(--dpt-brand-light) 70%,#fff 100%);-webkit-mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);-webkit-mask-composite:xor;mask-composite:exclude;animation:dpt-spin 1.1s linear infinite}
434
467
  @keyframes dpt-spin{to{transform:rotate(360deg)}}
435
- .dpt-pal-backdrop{position:fixed;inset:0;z-index:2147483000;display:flex;justify-content:center;align-items:flex-start;padding-top:14vh;background:color-mix(in srgb,#0b1220 32%,transparent);-webkit-backdrop-filter:blur(8px) saturate(1.1);backdrop-filter:blur(8px) saturate(1.1);animation:dpt-fade 200ms cubic-bezier(.22,1,.36,1) both}
436
- .dpt-pal{position:relative;width:min(600px,92vw);overflow:hidden;border-radius:20px;background:var(--dsw-alias-bg-base,#fff);color:var(--dsw-alias-label-primary,#101828);border:1px solid var(--dsw-alias-border-l2,#d6dce6);box-shadow:0 24px 70px rgba(11,18,32,0.35);font:14px/1.5 var(--ds-font-family,system-ui,sans-serif);animation:dpt-pop 200ms cubic-bezier(.22,1,.36,1) both}
437
- .dpt-pal::before{content:"";position:absolute;left:0;right:0;top:0;height:2px;background:linear-gradient(90deg,var(--dpt-brand,#3370ff),var(--dpt-brand-light,#7fb0ff),var(--dpt-brand,#3370ff));background-size:200% 100%;animation:dpt-sheen 6s linear infinite}
438
- .dpt-pal-input{display:block;width:100%;box-sizing:border-box;padding:18px 20px;border:0;outline:0;background:transparent;color:inherit;font:inherit;font-size:16px;border-bottom:1px solid var(--dsw-alias-border-l1,#e3e7ee)}
439
- .dpt-pal-input::placeholder{color:var(--dsw-alias-label-tertiary,#667085)}
440
- .dpt-pal-list{max-height:min(52vh,420px);overflow:auto;padding:8px}
441
- .dpt-pal-item{display:flex;align-items:center;gap:10px;padding:9px 12px;border-radius:12px;cursor:pointer;transition:background-color 120ms}
442
- .dpt-pal-item[aria-selected="true"]{background-image:linear-gradient(90deg,color-mix(in srgb,var(--dpt-brand,#3370ff) 20%,transparent),color-mix(in srgb,var(--dpt-brand,#3370ff) 7%,transparent))}
443
- .dpt-pal-kind{flex:none;font-size:11px;line-height:18px;padding:0 8px;border-radius:999px;background:color-mix(in srgb,var(--dpt-brand,#3370ff) 12%,transparent);color:var(--dpt-brand-ink,#1f4fc4)}
444
- .dpt-pal-title{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
445
- .dpt-pal-sub{flex:none;font-size:12px;color:var(--dsw-alias-label-tertiary,#667085)}
446
- .dpt-pal-empty{padding:22px;text-align:center;color:var(--dsw-alias-label-tertiary,#667085)}
447
- .dpt-pal-foot{display:flex;gap:16px;padding:9px 20px;font-size:12px;color:var(--dsw-alias-label-tertiary,#667085);border-top:1px solid var(--dsw-alias-border-l1,#e3e7ee)}
448
- @keyframes dpt-fade{from{opacity:0}to{opacity:1}}
449
- @keyframes dpt-pop{from{opacity:0;transform:translateY(8px) scale(0.98)}to{opacity:1;transform:none}}
450
468
  .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}
451
469
  @keyframes dpt-ripple{0%{transform:scale(.3);opacity:1}100%{transform:scale(7);opacity:0}}
452
- .dpt-fx{position:fixed;inset:0;width:100vw;height:100vh;z-index:2147482000;pointer-events:none;-webkit-app-region:initial!important}
470
+ .dpt-fx{position:fixed;left:0;top:0;z-index:2147482000;pointer-events:none;-webkit-app-region:initial!important}
453
471
  @media (prefers-reduced-motion:reduce){
454
472
  ${ON} *,${ON} *::before,${ON} *::after{animation-duration:0.01ms !important;animation-iteration-count:1 !important;transition-duration:0.01ms !important;scroll-behavior:auto !important}
455
473
  }
@@ -469,12 +487,21 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
469
487
 
470
488
  // ---------------------------------------------------------------------------------------------
471
489
  // Which session is on screen. Each conversation header mounts a hidden bridge; the visible one
472
- // in the main conversation decides whether the refined look is on and whether the agent works.
490
+ // in the main conversation decides whether the effects are on and whether the agent works. An
491
+ // IntersectionObserver on each bridge's container reports when a conversation is shown or hidden
492
+ // without remounting (split views, a fullscreen sidebar).
473
493
  // ---------------------------------------------------------------------------------------------
474
494
  const SESSIONS = {
475
495
  map: new Map(), subs: new Set(),
476
- // Sessions whose subagents are running, reported by the side card (Deep PTC sessions only).
496
+ // Sessions whose subagents are running, reported by the capsule (Deep PTC sessions only).
477
497
  working: new Map(),
498
+ visibility: undefined,
499
+ watch(element) {
500
+ if (!element || typeof IntersectionObserver !== 'function') return () => {};
501
+ this.visibility ??= new IntersectionObserver(() => this.emit());
502
+ this.visibility.observe(element);
503
+ return () => this.visibility?.unobserve(element);
504
+ },
478
505
  setWorking(id, value) { if (this.working.get(id) === value) return; if (value) this.working.set(id, true); else this.working.delete(id); this.emit(); },
479
506
  set(id, value) { this.map.set(id, value); this.emit(); },
480
507
  del(id) { this.map.delete(id); this.emit(); },
@@ -490,37 +517,53 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
490
517
  return pick ?? fallback;
491
518
  },
492
519
  };
493
- const BUSY = { bridge: false, dom: false, was: false, timer: 0 };
520
+
521
+ // ---------------------------------------------------------------------------------------------
522
+ // The visual effects switch. Without an explicit choice the effects are on, unless an appearance
523
+ // plugin restyles the same composer and bubbles. The host's module loader tags every plugin's
524
+ // <style> with data-plugin, so detection reads only that host-guaranteed marker.
525
+ // ---------------------------------------------------------------------------------------------
494
526
  const EFFECTS_KEY = `${PLUGIN}:visual-effects`;
495
- function readEffects() {
496
- try { return localStorage.getItem(EFFECTS_KEY) !== '0'; } catch { return true; }
527
+ const APPEARANCE_PLUGINS = ['dsh-claude-style', 'dsh-refined-ui'];
528
+ function appearancePlugin() {
529
+ if (typeof document === 'undefined') return undefined;
530
+ return APPEARANCE_PLUGINS.find(name => document.querySelector(`style[data-plugin="${name}"]`) !== null);
531
+ }
532
+ function storedEffects() {
533
+ try {
534
+ const value = localStorage.getItem(EFFECTS_KEY);
535
+ return value === '1' ? true : value === '0' ? false : undefined;
536
+ } catch { return undefined; }
497
537
  }
498
- let effectsEnabled = readEffects();
538
+ let effectsChoice = storedEffects();
499
539
  const effectListeners = new Set();
500
- const getEffects = () => effectsEnabled;
540
+ const getEffects = () => effectsChoice ?? appearancePlugin() === undefined;
541
+ const getEffectsChoice = () => effectsChoice;
501
542
  function subscribeEffects(listener) {
502
543
  effectListeners.add(listener);
503
544
  return () => effectListeners.delete(listener);
504
545
  }
505
- function setEffects(enabled) {
506
- if (effectsEnabled === enabled) return;
507
- effectsEnabled = enabled;
546
+ function setEffectsChoice(choice) {
547
+ if (effectsChoice === choice) return;
548
+ effectsChoice = choice;
508
549
  for (const listener of effectListeners) listener();
509
550
  }
510
551
  function toggleEffects() {
511
- const enabled = !effectsEnabled;
552
+ const enabled = !getEffects();
512
553
  try { localStorage.setItem(EFFECTS_KEY, enabled ? '1' : '0'); } catch { /* use the in-memory preference */ }
513
- setEffects(enabled);
554
+ setEffectsChoice(enabled);
514
555
  }
515
- // The standalone dsh-refined-ui draws the same look; never stack both.
556
+ // The standalone dsh-refined-ui draws the same look; never stack both, whatever the switch says.
516
557
  const refinedPresent = () => typeof document !== 'undefined' && document.querySelector('style[data-plugin="dsh-refined-ui"]') !== null;
517
558
  const uiOn = () => typeof document !== 'undefined' && document.body?.hasAttribute('data-dpt-ui');
559
+
560
+ const BUSY = { on: false, was: false, timer: 0 };
518
561
  function applyBusy() {
519
562
  if (typeof document === 'undefined') return;
520
- const busy = uiOn() && (BUSY.bridge || BUSY.dom);
563
+ const busy = uiOn() && BUSY.on;
521
564
  document.body.toggleAttribute('data-dpt-busy', busy);
522
565
  if (BUSY.was && !busy && uiOn()) {
523
- const card = document.querySelector('[data-dpt-composer]');
566
+ const card = document.querySelector(COMPOSER);
524
567
  if (card) {
525
568
  card.setAttribute('data-dpt-done', '');
526
569
  clearTimeout(BUSY.timer);
@@ -529,6 +572,7 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
529
572
  }
530
573
  BUSY.was = busy;
531
574
  }
575
+
532
576
  function watchActiveSession() {
533
577
  if (typeof document === 'undefined') return () => {};
534
578
  let stopVisuals;
@@ -541,250 +585,79 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
541
585
  }
542
586
  const update = () => {
543
587
  const current = SESSIONS.current();
544
- const on = effectsEnabled && current?.preset === 'deep-ptc' && !refinedPresent();
588
+ const on = getEffects() && current?.preset === 'deep-ptc' && !refinedPresent();
545
589
  document.body.toggleAttribute('data-dpt-ui', on);
546
590
  // Like dsh-refined-ui, a running subagent keeps the conversation working.
547
- BUSY.bridge = on && (current?.busy === true || SESSIONS.working.get(current?.id) === true);
591
+ BUSY.on = on && (current?.busy === true || SESSIONS.working.get(current?.id) === true);
548
592
  applyBusy();
549
593
  if (on && !stopVisuals) {
550
- const cleanups = [watchSurfaces(), watchPalette(), watchInteractions(), watchFx()];
594
+ const cleanups = [watchSurfaces(), watchFx()];
551
595
  stopVisuals = () => cleanups.reverse().forEach(cleanup => cleanup());
552
596
  } else if (!on) disableVisuals();
553
597
  };
554
598
  SESSIONS.subs.add(update);
555
599
  const unsubscribe = subscribeEffects(update);
556
- const sync = event => { if (event.key === EFFECTS_KEY || event.key === null) setEffects(readEffects()); };
600
+ const sync = event => { if (event.key === EFFECTS_KEY || event.key === null) setEffectsChoice(storedEffects()); };
557
601
  window.addEventListener('storage', sync);
558
- // Visibility changes without a remount (split views, tab switches) are caught here.
559
- const timer = setInterval(update, 1000);
560
602
  update();
561
603
  return () => {
562
604
  SESSIONS.subs.delete(update);
563
605
  unsubscribe();
564
606
  window.removeEventListener('storage', sync);
565
- clearInterval(timer);
566
607
  document.body.removeAttribute('data-dpt-ui');
567
608
  document.body.removeAttribute('data-dpt-busy');
568
- BUSY.bridge = false;
609
+ BUSY.on = false;
569
610
  BUSY.was = false;
570
611
  disableVisuals();
571
612
  };
572
613
  }
573
614
 
574
- // Tag the composer card, its send button and the user bubbles so the CSS needs no hashed class
575
- // names. Only data-dpt-* attributes (and position:relative on a static composer) are written.
615
+ // The send button carries no stable host attribute: it is the right-most button in the composer
616
+ // card. Pointer effects (spotlight, magnetic send button, click ripple) read layout at most once
617
+ // per animation frame, whatever the pointer rate.
576
618
  function watchSurfaces() {
577
619
  if (typeof document === 'undefined' || typeof MutationObserver === 'undefined') return () => {};
620
+ const reduce = window.matchMedia?.('(prefers-reduced-motion: reduce)').matches === true;
578
621
  const tagged = new Set();
579
- const relativized = new Map();
580
622
  const highlighted = new Set();
581
- let frame = 0;
582
- const mark = (node, attribute) => { node.setAttribute(attribute, ''); tagged.add([node, attribute]); };
583
- const findComposer = input => {
584
- for (let node = input.parentElement, depth = 0; node && node !== document.body && depth < 8; node = node.parentElement, depth++) {
585
- const style = getComputedStyle(node);
586
- const round = parseFloat(style.borderTopLeftRadius) >= 14;
587
- const framed = style.boxShadow !== 'none' || parseFloat(style.borderTopWidth) > 0;
588
- if (round && framed) return node;
589
- }
590
- return null;
591
- };
592
- function tagComposer() {
593
- for (const input of document.querySelectorAll('[data-composer-input]')) {
594
- let card = input.closest('[data-dpt-composer]');
595
- if (!card) {
596
- card = findComposer(input);
597
- if (!card) continue;
598
- mark(card, 'data-dpt-composer');
599
- if (getComputedStyle(card).position === 'static') {
600
- relativized.set(card, [card.style.position, card.style.getPropertyPriority('position')]);
601
- card.style.position = 'relative';
602
- }
603
- }
623
+ let tagFrame = 0, pointerFrame = 0, pointer = null, magnet = null;
624
+ function tagSend() {
625
+ tagFrame = 0;
626
+ for (const card of document.querySelectorAll(COMPOSER)) {
604
627
  if (card.querySelector('[data-dpt-send]')) continue;
605
- // The send button is the right-most button in the card.
606
628
  let best = null, bestRight = -1;
607
629
  for (const button of card.querySelectorAll('button,[role="button"]')) {
608
630
  const rect = button.getBoundingClientRect();
609
631
  if (rect.width > 0 && rect.right >= bestRight) { best = button; bestRight = rect.right; }
610
632
  }
611
- if (best) mark(best, 'data-dpt-send');
633
+ if (best) { best.setAttribute('data-dpt-send', ''); tagged.add(best); }
612
634
  }
613
635
  }
614
- function tagBubbles() {
615
- for (const row of document.querySelectorAll('[data-chat-flow-kind="user"],[data-chat-flow-kind="steering"]')) {
616
- if (row.querySelector('[data-dpt-bubble]')) continue;
617
- const nodes = row.querySelectorAll('*');
618
- for (let index = 0; index < nodes.length && index < 60; index++) {
619
- const node = nodes[index];
620
- if (node.tagName === 'BUTTON' || node.tagName === 'SVG' || !node.textContent?.trim()) continue;
621
- const style = getComputedStyle(node);
622
- const filled = style.backgroundColor && style.backgroundColor !== 'transparent' && style.backgroundColor !== 'rgba(0, 0, 0, 0)';
623
- if (filled && parseFloat(style.borderTopLeftRadius) >= 10) { mark(node, 'data-dpt-bubble'); break; }
624
- }
636
+ function track() {
637
+ pointerFrame = 0;
638
+ const event = pointer;
639
+ pointer = null;
640
+ if (!event || !uiOn()) return;
641
+ const host = event.target?.closest?.(`[data-row-key^="session:"],${COMPOSER}`);
642
+ if (host) {
643
+ const rect = host.getBoundingClientRect();
644
+ host.style.setProperty('--dpt-mx', `${event.x - rect.left}px`);
645
+ host.style.setProperty('--dpt-my', `${event.y - rect.top}px`);
646
+ highlighted.add(host);
625
647
  }
648
+ if (reduce) return;
649
+ const button = document.querySelector('[data-dpt-send]');
650
+ if (magnet && magnet !== button) { magnet.style.translate = ''; magnet = null; }
651
+ if (!button) return;
652
+ const rect = button.getBoundingClientRect();
653
+ const dx = event.x - (rect.left + rect.width / 2), dy = event.y - (rect.top + rect.height / 2);
654
+ if (Math.hypot(dx, dy) < 70) { button.style.translate = `${(dx * 0.18).toFixed(1)}px ${(dy * 0.18).toFixed(1)}px`; magnet = button; }
655
+ else if (magnet) { button.style.translate = ''; magnet = null; }
626
656
  }
627
657
  function onMove(event) {
628
- const host = event.target?.closest?.('[data-row-key^="session:"],[data-dpt-composer]');
629
- if (!host || !uiOn()) return;
630
- const rect = host.getBoundingClientRect();
631
- host.style.setProperty('--dpt-mx', `${event.clientX - rect.left}px`);
632
- host.style.setProperty('--dpt-my', `${event.clientY - rect.top}px`);
633
- highlighted.add(host);
634
- }
635
- const run = () => {
636
- frame = 0;
637
- tagComposer();
638
- tagBubbles();
639
- BUSY.dom = document.querySelector('[data-streaming="true"]') !== null;
640
- applyBusy();
641
- };
642
- const schedule = () => { if (!frame) frame = requestAnimationFrame(run); };
643
- const observer = new MutationObserver(schedule);
644
- observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['data-streaming'] });
645
- document.addEventListener('pointermove', onMove, { capture: true, passive: true });
646
- schedule();
647
- return () => {
648
- observer.disconnect();
649
- document.removeEventListener('pointermove', onMove, true);
650
- if (frame) cancelAnimationFrame(frame);
651
- BUSY.dom = false;
652
- applyBusy();
653
- for (const [node, attribute] of tagged) node.removeAttribute(attribute);
654
- tagged.clear();
655
- for (const [node, [position, priority]] of relativized) {
656
- if (node.style.position === 'relative') node.style.setProperty('position', position, priority);
657
- }
658
- for (const node of highlighted) {
659
- node.style.removeProperty('--dpt-mx');
660
- node.style.removeProperty('--dpt-my');
661
- }
662
- };
663
- }
664
-
665
- // Ctrl/Cmd+K palette. It only clicks entries the host already renders.
666
- const PANEL = { toggle() {}, state: {} };
667
- const FX = { burst() {} };
668
- function findClickable(labels) {
669
- let fallback = null;
670
- for (const node of document.querySelectorAll('button,[role="button"],[role="treeitem"],[role="menuitem"],a,div,span')) {
671
- if (!labels.includes((node.textContent ?? '').trim()) || node.closest('[data-dpt-palette]')) continue;
672
- const role = node.getAttribute('role');
673
- if (node.tagName === 'BUTTON' || node.tagName === 'A' || role === 'button' || role === 'treeitem' || role === 'menuitem') return node;
674
- fallback ??= node;
658
+ pointer = { x: event.clientX, y: event.clientY, target: event.target };
659
+ if (!pointerFrame) pointerFrame = requestAnimationFrame(track);
675
660
  }
676
- return fallback;
677
- }
678
- function paletteItems() {
679
- const items = [];
680
- for (const [labels, sub] of [[['新会话', 'New session'], 'palNewSub'], [['插件', 'Plugins'], 'palPluginsSub'], [['自动化任务', 'Automations'], 'palAutomationSub']]) {
681
- const node = findClickable(labels);
682
- if (node) items.push({ kind: T('palCommand'), title: (node.textContent ?? '').trim(), sub: T(sub), run: () => node.click() });
683
- }
684
- items.push({ kind: T('palEffect'), title: T('palAgents'), sub: T('palAgentsSub'), run: () => PANEL.toggle() });
685
- items.push({ kind: T('palEffect'), title: T('palFireworks'), sub: T('palFireworksSub'), run: () => FX.burst() });
686
- const rows = document.querySelectorAll('[data-row-key^="session:"]');
687
- for (let index = 0; index < rows.length && index < 80; index++) {
688
- const row = rows[index];
689
- const lines = (row.innerText ?? '').split('\n').map(line => line.trim()).filter(Boolean);
690
- if (lines.length) items.push({ kind: T('palSession'), title: lines[0], sub: lines.length > 1 ? lines.at(-1) : '', run: () => row.click() });
691
- }
692
- return items;
693
- }
694
- function watchPalette() {
695
- if (typeof document === 'undefined') return () => {};
696
- let backdrop = null, input = null, list = null, items = [], shown = [], index = 0;
697
- const close = () => { backdrop?.remove(); backdrop = null; };
698
- function mark() {
699
- for (let at = 0; at < list.children.length; at++) list.children[at].setAttribute('aria-selected', at === index ? 'true' : 'false');
700
- list.children[index]?.scrollIntoView?.({ block: 'nearest' });
701
- }
702
- function render() {
703
- list.textContent = '';
704
- if (!shown.length) {
705
- const empty = document.createElement('div');
706
- empty.className = 'dpt-pal-empty';
707
- empty.textContent = T('palEmpty');
708
- list.appendChild(empty);
709
- return;
710
- }
711
- shown.forEach((item, at) => {
712
- const row = document.createElement('div');
713
- row.className = 'dpt-pal-item';
714
- row.setAttribute('role', 'option');
715
- const kind = document.createElement('span'); kind.className = 'dpt-pal-kind'; kind.textContent = item.kind;
716
- const title = document.createElement('span'); title.className = 'dpt-pal-title'; title.textContent = item.title;
717
- const sub = document.createElement('span'); sub.className = 'dpt-pal-sub'; sub.textContent = item.sub;
718
- row.append(kind, title, sub);
719
- row.addEventListener('pointermove', () => { if (index !== at) { index = at; mark(); } });
720
- row.addEventListener('click', () => choose(at));
721
- list.appendChild(row);
722
- });
723
- mark();
724
- }
725
- function filter() {
726
- const query = input.value.trim().toLowerCase();
727
- shown = query ? items.filter(item => `${item.title} ${item.kind}`.toLowerCase().includes(query)) : items.slice(0, 12);
728
- index = 0;
729
- render();
730
- }
731
- function choose(at) {
732
- const item = shown[at];
733
- if (!item) return;
734
- close();
735
- setTimeout(() => { try { item.run(); } catch (error) { console.warn(`[${PLUGIN}] palette action failed:`, error); } }, 30);
736
- }
737
- function open() {
738
- items = paletteItems();
739
- backdrop = document.createElement('div');
740
- backdrop.className = 'dpt-pal-backdrop';
741
- backdrop.setAttribute('data-dpt-palette', '');
742
- const panel = document.createElement('div');
743
- panel.className = 'dpt-pal';
744
- panel.setAttribute('role', 'dialog');
745
- panel.setAttribute('aria-label', T('palTitle'));
746
- input = document.createElement('input');
747
- input.className = 'dpt-pal-input';
748
- input.placeholder = T('palPlaceholder');
749
- input.setAttribute('aria-label', T('palPlaceholder'));
750
- list = document.createElement('div');
751
- list.className = 'dpt-pal-list';
752
- list.setAttribute('role', 'listbox');
753
- const foot = document.createElement('div');
754
- foot.className = 'dpt-pal-foot';
755
- foot.textContent = T('palFoot');
756
- panel.append(input, list, foot);
757
- backdrop.appendChild(panel);
758
- document.body.appendChild(backdrop);
759
- backdrop.addEventListener('pointerdown', event => { if (event.target === backdrop) close(); });
760
- input.addEventListener('input', filter);
761
- input.addEventListener('keydown', event => {
762
- if (event.isComposing || event.keyCode === 229) return;
763
- if (event.key === 'ArrowDown') { event.preventDefault(); index = Math.min(index + 1, shown.length - 1); mark(); }
764
- else if (event.key === 'ArrowUp') { event.preventDefault(); index = Math.max(index - 1, 0); mark(); }
765
- else if (event.key === 'Enter') { event.preventDefault(); choose(index); }
766
- else if (event.key === 'Escape') { event.preventDefault(); close(); }
767
- });
768
- filter();
769
- input.focus();
770
- }
771
- function onKey(event) {
772
- if (!(event.ctrlKey || event.metaKey) || event.altKey || event.shiftKey || (event.key !== 'k' && event.key !== 'K')) return;
773
- if (!backdrop && !uiOn()) return;
774
- event.preventDefault();
775
- event.stopPropagation();
776
- if (backdrop) close(); else open();
777
- }
778
- document.addEventListener('keydown', onKey, true);
779
- return () => { document.removeEventListener('keydown', onKey, true); close(); };
780
- }
781
-
782
- // Click ripple, magnetic send button, "/" focuses the composer, Alt+Up/Down switches sessions.
783
- function watchInteractions() {
784
- if (typeof document === 'undefined') return () => {};
785
- const reduce = window.matchMedia?.('(prefers-reduced-motion: reduce)').matches === true;
786
- let magnet = null;
787
- const typing = target => target && (target.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/u.test(target.tagName));
788
661
  function onDown(event) {
789
662
  if (event.button !== 0 || reduce || !uiOn()) return;
790
663
  if (!event.target?.closest?.('button,a,[role=button],[role=treeitem],[role=tab],[role=menuitem],[role=option],summary')) return;
@@ -795,43 +668,32 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
795
668
  document.body.appendChild(ripple);
796
669
  setTimeout(() => ripple.remove(), 700);
797
670
  }
798
- function onMove(event) {
799
- const button = uiOn() ? document.querySelector('[data-dpt-send]') : null;
800
- if (magnet && magnet !== button) { magnet.style.translate = ''; magnet = null; }
801
- if (!button || reduce) return;
802
- const rect = button.getBoundingClientRect();
803
- const dx = event.clientX - (rect.left + rect.width / 2), dy = event.clientY - (rect.top + rect.height / 2);
804
- if (Math.hypot(dx, dy) < 70) { button.style.translate = `${(dx * 0.18).toFixed(1)}px ${(dy * 0.18).toFixed(1)}px`; magnet = button; }
805
- else if (magnet) { button.style.translate = ''; magnet = null; }
806
- }
807
- function onKey(event) {
808
- if (event.isComposing || event.keyCode === 229 || !uiOn() || document.querySelector('.dpt-pal-backdrop')) return;
809
- if (event.key === '/' && !event.ctrlKey && !event.metaKey && !event.altKey && !typing(event.target)) {
810
- const input = document.querySelector('[data-composer-input]');
811
- if (input) { event.preventDefault(); input.focus(); }
812
- return;
813
- }
814
- if (event.altKey && !event.ctrlKey && !event.metaKey && (event.key === 'ArrowUp' || event.key === 'ArrowDown')) {
815
- const rows = [...document.querySelectorAll('[data-row-key^="session:"][role="treeitem"]')];
816
- if (!rows.length) return;
817
- const current = rows.findIndex(row => row.matches('[aria-selected="true"],[aria-current="true"],[data-selected="true"]'));
818
- const next = rows[Math.max(0, Math.min(rows.length - 1, current + (event.key === 'ArrowDown' ? 1 : -1)))];
819
- if (next && next !== rows[current]) { event.preventDefault(); next.click(); next.scrollIntoView({ block: 'nearest' }); }
820
- }
821
- }
822
- document.addEventListener('pointerdown', onDown, true);
823
- document.addEventListener('pointermove', onMove, true);
824
- document.addEventListener('keydown', onKey, true);
671
+ // Streaming text mutates the document constantly; each burst costs one cheap query per frame.
672
+ const observer = new MutationObserver(() => { if (!tagFrame) tagFrame = requestAnimationFrame(tagSend); });
673
+ observer.observe(document.body, { childList: true, subtree: true });
674
+ document.addEventListener('pointermove', onMove, { capture: true, passive: true });
675
+ document.addEventListener('pointerdown', onDown, { capture: true, passive: true });
676
+ tagSend();
825
677
  return () => {
826
- document.removeEventListener('pointerdown', onDown, true);
678
+ observer.disconnect();
827
679
  document.removeEventListener('pointermove', onMove, true);
828
- document.removeEventListener('keydown', onKey, true);
680
+ document.removeEventListener('pointerdown', onDown, true);
681
+ if (tagFrame) cancelAnimationFrame(tagFrame);
682
+ if (pointerFrame) cancelAnimationFrame(pointerFrame);
829
683
  if (magnet) magnet.style.translate = '';
684
+ for (const node of tagged) node.removeAttribute('data-dpt-send');
685
+ tagged.clear();
686
+ for (const node of highlighted) {
687
+ node.style.removeProperty('--dpt-mx');
688
+ node.style.removeProperty('--dpt-my');
689
+ }
830
690
  for (const node of document.querySelectorAll('.dpt-ripple')) node.remove();
831
691
  };
832
692
  }
833
693
 
834
- // Send burst, completion sparkle and embers while the agent works.
694
+ // Send burst, completion sparkle and embers while the agent works. The canvas covers only the
695
+ // composer and the space above it where the sparks rise, at no more than 1.5 device pixels per
696
+ // CSS pixel, and the frame loop stops whenever nothing moves or the window is hidden.
835
697
  function watchFx() {
836
698
  if (typeof document === 'undefined' || typeof requestAnimationFrame === 'undefined' || typeof MutationObserver === 'undefined'
837
699
  || window.matchMedia?.('(prefers-reduced-motion: reduce)')?.matches === true) return () => {};
@@ -841,60 +703,74 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
841
703
  const paint = canvas.getContext('2d');
842
704
  if (!paint) return () => {};
843
705
  document.body.appendChild(canvas);
844
- const dpr = Math.min(window.devicePixelRatio || 1, 2);
845
- let width = 0, height = 0, parts = [], raf = 0, lastEmber = 0;
846
- const fireworks = new Set();
706
+ const dpr = Math.min(window.devicePixelRatio || 1, 1.5);
707
+ const PAD_X = 48, PAD_TOP = 240, PAD_BOTTOM = 24, MAX_PARTS = 160;
847
708
  const hues = ['#3370ff', '#5b8cff', '#7fd0ff', '#9dbcff', '#b48cff', '#ffffff'];
709
+ let box, parts = [], raf = 0, lastEmber = 0;
848
710
  const busy = () => document.body.hasAttribute('data-dpt-busy');
849
711
  let wasBusy = busy();
850
- function resize() {
851
- width = window.innerWidth; height = window.innerHeight;
852
- canvas.width = width * dpr; canvas.height = height * dpr;
853
- paint.setTransform(dpr, 0, 0, dpr, 0, 0);
712
+ function place() {
713
+ const composer = document.querySelector(COMPOSER)?.getBoundingClientRect();
714
+ if (!composer || composer.width === 0) { box = undefined; canvas.style.display = 'none'; return; }
715
+ const left = Math.max(0, Math.floor(composer.left - PAD_X)), top = Math.max(0, Math.floor(composer.top - PAD_TOP));
716
+ const width = Math.max(1, Math.ceil(Math.min(window.innerWidth, composer.right + PAD_X) - left));
717
+ const height = Math.max(1, Math.ceil(Math.min(window.innerHeight, composer.bottom + PAD_BOTTOM) - top));
718
+ if (box?.width !== width || box?.height !== height) {
719
+ canvas.width = Math.round(width * dpr); canvas.height = Math.round(height * dpr);
720
+ canvas.style.width = `${width}px`; canvas.style.height = `${height}px`;
721
+ paint.setTransform(dpr, 0, 0, dpr, 0, 0);
722
+ }
723
+ if (box?.left !== left || box?.top !== top) canvas.style.transform = `translate(${left}px,${top}px)`;
724
+ canvas.style.display = '';
725
+ box = { left, top, width, height, composer };
854
726
  }
727
+ const kick = () => { if (!raf && !document.hidden) { place(); raf = requestAnimationFrame(frame); } };
855
728
  function burst(x, y, count, power) {
856
729
  if (!uiOn()) return;
857
- for (let index = 0; index < count; index++) {
730
+ for (let index = 0; index < count && parts.length < MAX_PARTS; index++) {
858
731
  const angle = Math.random() * Math.PI * 2, speed = (0.4 + Math.random()) * power;
859
732
  parts.push({ x, y, vx: Math.cos(angle) * speed, vy: Math.sin(angle) * speed - power * 0.35, life: 1,
860
733
  decay: 0.014 + Math.random() * 0.016, r: 1.4 + Math.random() * 2.4, color: hues[(Math.random() * hues.length) | 0] });
861
734
  }
862
735
  kick();
863
736
  }
864
- const kick = () => { if (!raf) raf = requestAnimationFrame(frame); };
865
- function frame() {
737
+ function frame(now) {
866
738
  raf = 0;
867
- paint.clearRect(0, 0, width, height);
868
- paint.globalCompositeOperation = 'lighter';
869
- const composer = document.querySelector('[data-dpt-composer]');
870
- const now = performance.now();
871
- // Embers rise from the composer while the agent works: twice as often as dsh-refined-ui, slightly larger.
872
- if (busy() && composer && now - lastEmber > 35) {
739
+ if (!box) { parts = []; return; }
740
+ paint.clearRect(0, 0, box.width, box.height);
741
+ // Embers rise from the composer while the agent works.
742
+ if (busy() && now - lastEmber > 35 && parts.length < MAX_PARTS) {
873
743
  lastEmber = now;
874
- const rect = composer.getBoundingClientRect();
744
+ const rect = box.composer;
875
745
  parts.push({ x: rect.left + 12 + Math.random() * (rect.width - 24), y: rect.top + 2, vx: (Math.random() - 0.5) * 0.5,
876
746
  vy: -(0.5 + Math.random() * 1.1), gravity: -0.004, life: 1, decay: 0.009 + Math.random() * 0.01,
877
747
  r: 1.8 + Math.random() * 2.4, color: hues[(Math.random() * 4) | 0] });
878
748
  }
879
- parts = parts.filter(part => part.life > 0);
749
+ paint.globalCompositeOperation = 'lighter';
750
+ let live = 0;
880
751
  for (const part of parts) {
881
752
  part.x += part.vx; part.y += part.vy; part.vy += part.gravity ?? 0.09; part.vx *= 0.985; part.life -= part.decay;
882
- paint.globalAlpha = Math.max(part.life, 0);
753
+ if (part.life <= 0) continue;
754
+ parts[live++] = part;
755
+ paint.globalAlpha = part.life;
883
756
  paint.fillStyle = part.color;
884
757
  paint.beginPath();
885
- paint.arc(part.x, part.y, part.r * (0.4 + part.life * 0.6), 0, 6.3);
758
+ paint.arc(part.x - box.left, part.y - box.top, part.r * (0.4 + part.life * 0.6), 0, 6.3);
886
759
  paint.fill();
887
760
  }
761
+ parts.length = live;
888
762
  paint.globalAlpha = 1;
889
763
  paint.globalCompositeOperation = 'source-over';
890
- if (parts.length || busy()) kick();
764
+ if (parts.length || busy()) raf = document.hidden ? 0 : requestAnimationFrame(frame);
765
+ else paint.clearRect(0, 0, box.width, box.height);
891
766
  }
892
767
  const center = node => { const rect = node.getBoundingClientRect(); return [rect.left + rect.width / 2, rect.top + rect.height / 2]; };
893
768
  function onDown(event) {
894
769
  const button = event.target?.closest?.('[data-dpt-send]');
895
770
  if (button && event.button === 0) burst(...center(button), 34, 4.2);
896
771
  }
897
- function onKey(event) {
772
+ // Sending with Enter bursts like a click; the key event is only observed, never consumed.
773
+ function onSend(event) {
898
774
  if (event.key !== 'Enter' || event.shiftKey || event.isComposing || event.keyCode === 229) return;
899
775
  if (!event.target?.closest?.('[data-composer-input]')) return;
900
776
  const button = document.querySelector('[data-dpt-send]');
@@ -903,9 +779,9 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
903
779
  const observer = new MutationObserver(() => {
904
780
  const now = busy();
905
781
  if (wasBusy && !now) {
906
- const composer = document.querySelector('[data-dpt-composer]');
907
- if (composer) {
908
- const rect = composer.getBoundingClientRect();
782
+ place();
783
+ const rect = box?.composer;
784
+ if (rect) {
909
785
  burst(rect.left + rect.width / 2, rect.top, 22, 3.2);
910
786
  burst(rect.left + rect.width * 0.25, rect.top, 10, 2.4);
911
787
  burst(rect.left + rect.width * 0.75, rect.top, 10, 2.4);
@@ -914,66 +790,37 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
914
790
  if (now) kick();
915
791
  wasBusy = now;
916
792
  });
917
- resize();
918
- window.addEventListener('resize', resize);
793
+ const onResize = () => { if (raf) place(); };
794
+ const onVisibility = () => { if (!document.hidden && (parts.length || busy())) kick(); };
795
+ window.addEventListener('resize', onResize);
796
+ document.addEventListener('visibilitychange', onVisibility);
919
797
  observer.observe(document.body, { attributes: true, attributeFilter: ['data-dpt-busy'] });
920
- document.addEventListener('pointerdown', onDown, true);
921
- document.addEventListener('keydown', onKey, true);
798
+ document.addEventListener('pointerdown', onDown, { capture: true, passive: true });
799
+ document.addEventListener('keydown', onSend, { capture: true, passive: true });
922
800
  if (wasBusy) kick();
923
- FX.burst = () => {
924
- [[0.3, 0.45], [0.5, 0.3], [0.7, 0.45]].forEach(([x, y], index) => {
925
- const timer = setTimeout(() => {
926
- fireworks.delete(timer);
927
- burst(width * x, height * y, 60, 5.6);
928
- }, index * 220);
929
- fireworks.add(timer);
930
- });
931
- };
932
801
  return () => {
933
- FX.burst = () => {};
934
- window.removeEventListener('resize', resize);
802
+ window.removeEventListener('resize', onResize);
803
+ document.removeEventListener('visibilitychange', onVisibility);
935
804
  document.removeEventListener('pointerdown', onDown, true);
936
- document.removeEventListener('keydown', onKey, true);
805
+ document.removeEventListener('keydown', onSend, true);
937
806
  observer.disconnect();
938
807
  if (raf) cancelAnimationFrame(raf);
939
- for (const timer of fireworks) clearTimeout(timer);
940
808
  canvas.remove();
941
809
  };
942
810
  }
943
811
 
944
- // Ctrl+Alt+D shows and copies a read-only outline of the markers this plugin relies on.
812
+ // A read-only outline of what the effects rely on, copied from the settings page for bug reports.
945
813
  function diagnostics() {
946
- const count = selector => document.querySelectorAll(selector).length;
814
+ const count = selector => typeof document === 'undefined' ? 0 : document.querySelectorAll(selector).length;
947
815
  const current = SESSIONS.current();
948
- const lines = [
949
- `${PLUGIN} client | ui=${uiOn()} busy=${document.body.hasAttribute('data-dpt-busy')} session=${current?.id ?? '-'} preset=${current?.preset ?? '-'} refined-ui=${refinedPresent()}`,
950
- `tags: composer=${count('[data-dpt-composer]')} send=${count('[data-dpt-send]')} bubble=${count('[data-dpt-bubble]')} docked=${count('[data-dpt-docked]')}`,
951
- `markers: composer-input=${count('[data-composer-input]')} user-rows=${count('[data-chat-flow-kind="user"]')} assistant=${count('[data-chat-flow-kind="assistant-step"]')} session-rows=${count('[data-row-key^="session:"]')} chat-regions=${count('[data-conversation-region="chat"]')} main=${count('[data-slot="main.conversation"]')}`,
952
- `cards: skills=${count('.dpt-skills')} side=${count('.dpt-agents')} pill=${count('.dpt-agents-pill')} side-state=${JSON.stringify(PANEL.state)}`,
953
- ];
954
- return lines.join('\n');
816
+ return [
817
+ `${PLUGIN} client | effects=${getEffects()} choice=${String(effectsChoice)} appearance=${appearancePlugin() ?? '-'} ui=${uiOn()}`,
818
+ `session=${current?.id ?? '-'} preset=${current?.preset ?? '-'} busy=${current?.busy === true} working=${SESSIONS.working.size}`,
819
+ `host: composer=${count(COMPOSER)} input=${count('[data-composer-input]')} bubble=${count('[data-message-bubble]')} send=${count('[data-dpt-send]')}`,
820
+ `ui: capsule=${count('.dpt-capsule')} panel=${count('.dpt-panel')} skills=${count('.dpt-skills')}`,
821
+ `ua=${typeof navigator === 'undefined' ? '-' : navigator.userAgent}`,
822
+ ].join('\n');
955
823
  }
956
- function watchDiagnostics() {
957
- if (typeof document === 'undefined') return () => {};
958
- let panel = null;
959
- const close = () => { panel?.remove(); panel = null; };
960
- function onKey(event) {
961
- if (!(event.ctrlKey && event.altKey && (event.key === 'd' || event.key === 'D'))) return;
962
- if (!panel && !uiOn()) return;
963
- event.preventDefault();
964
- if (panel) { close(); return; }
965
- const text = diagnostics();
966
- try { navigator.clipboard?.writeText(text); } catch { /* copying is a convenience */ }
967
- panel = document.createElement('pre');
968
- panel.dataset.plugin = PLUGIN;
969
- panel.textContent = text;
970
- panel.style.cssText = 'position:fixed;z-index:2147483647;right:12px;bottom:12px;max-width:760px;max-height:70vh;overflow:auto;margin:0;padding:10px 12px;background:#0b1220;color:#dbe7ff;font:11px/1.45 ui-monospace,Consolas,monospace;border-radius:10px;white-space:pre-wrap;box-shadow:0 10px 30px rgba(0,0,0,.4)';
971
- document.body.appendChild(panel);
972
- }
973
- document.addEventListener('keydown', onKey, true);
974
- return () => { document.removeEventListener('keydown', onKey, true); close(); };
975
- }
976
-
977
824
  // ---------------------------------------------------------------------------------------------
978
825
  // Skill card, at the end of the latest turn in the conversation.
979
826
  // ---------------------------------------------------------------------------------------------
@@ -989,11 +836,13 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
989
836
 
990
837
  function VisualEffectsSection({ t }) {
991
838
  const enabled = React.useSyncExternalStore(subscribeEffects, getEffects, getEffects);
839
+ const choice = React.useSyncExternalStore(subscribeEffects, getEffectsChoice, getEffectsChoice);
840
+ const appearance = choice === undefined ? appearancePlugin() : undefined;
992
841
  const label = t('visualEffects');
993
842
  return h('section', { className: 'dpt-side-section dpt-side-effects', 'aria-label': label },
994
843
  h('div', { className: 'dpt-side-label' }, h('span', null, label),
995
844
  h(SkillSwitch, { on: enabled, label, onChange: toggleEffects })),
996
- h('p', { className: 'dpt-side-note' }, t('visualEffectsHint')));
845
+ h('p', { className: 'dpt-side-note' }, appearance ? tf(t, 'visualEffectsAuto', { name: appearance }) : t('visualEffectsHint')));
997
846
  }
998
847
 
999
848
  function SkillCard({ turn, useProjection, useChat, setSkill, setAll, t }) {
@@ -1043,17 +892,10 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
1043
892
  }
1044
893
 
1045
894
  // ---------------------------------------------------------------------------------------------
1046
- // Subagent panel beside the main conversation. Rows follow the official subagent catalog and
1047
- // timing projections; a row opens the official subagent chat in the right sidebar.
895
+ // The Deep PTC panel. Subagent rows follow the official subagent catalog and timing projections;
896
+ // a row opens the official subagent chat in the right sidebar.
1048
897
  // ---------------------------------------------------------------------------------------------
1049
898
  const AGENT_ROWS = 24;
1050
- const PANEL_WIDTH = 248;
1051
- // Docked, the card is a column split off the right side of the conversation, flush with its edge.
1052
- const SPLIT_WIDTH = 272;
1053
- const DOCK_MIN_WIDTH = 960;
1054
- const COLLAPSED_KEY = `${PLUGIN}:subagents-collapsed`;
1055
- const readCollapsed = () => { try { return localStorage.getItem(COLLAPSED_KEY) === '1'; } catch { return false; } };
1056
- const writeCollapsed = value => { try { localStorage.setItem(COLLAPSED_KEY, value ? '1' : '0'); } catch { /* per-viewer convenience only */ } };
1057
899
 
1058
900
  function subagentRows(sessions, rootId, now) {
1059
901
  const catalogOf = id => {
@@ -1113,42 +955,7 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
1113
955
  const workspace = hostCtx?.get?.('uiWorkspace');
1114
956
  if (typeof workspace?.openSession === 'function') {
1115
957
  workspace.openSession({ parentSessionId: row.parentId, childSessionId: row.id, mode: row.mode });
1116
- return;
1117
958
  }
1118
- const escaped = typeof CSS !== 'undefined' && CSS.escape ? CSS.escape(row.id) : row.id;
1119
- document.querySelector(`[data-row-key="session:${escaped}"]`)?.click();
1120
- }
1121
-
1122
- // Where the panel sits: the right edge of this session's chat region, above the composer.
1123
- function useChatRegion(sessionId, enabled) {
1124
- const [layout, setLayout] = React.useState(undefined);
1125
- React.useEffect(() => {
1126
- if (!enabled || typeof document === 'undefined') { setLayout(undefined); return undefined; }
1127
- let last = '';
1128
- let lastRegion;
1129
- const measure = () => {
1130
- const escaped = typeof CSS !== 'undefined' && CSS.escape ? CSS.escape(sessionId) : sessionId;
1131
- const regions = [...document.querySelectorAll(`[data-conversation-region="chat"][data-conversation-session="${escaped}"]`)];
1132
- const anyMain = document.querySelector('[data-slot="main.conversation"]') !== null;
1133
- const region = regions.find(node => !anyMain || node.closest('[data-slot="main.conversation"]'));
1134
- const rect = region?.getBoundingClientRect();
1135
- if (!region || !rect || rect.width === 0) { if (last !== '-') { last = '-'; lastRegion = undefined; setLayout(undefined); } return; }
1136
- // Docked, the region gives up the column's width, so its parent marks the conversation's right edge.
1137
- const host = region.parentElement?.getBoundingClientRect() ?? rect;
1138
- const composer = region.querySelector('[data-composer-seat]')?.getBoundingClientRect();
1139
- const bottom = composer && composer.top > rect.top ? composer.top - 12 : rect.bottom - 12;
1140
- const next = { region, top: Math.round(rect.top + 12), right: Math.round(window.innerWidth - rect.right + 16),
1141
- maxHeight: Math.max(120, Math.round(bottom - rect.top - 12)), wide: host.width >= DOCK_MIN_WIDTH,
1142
- split: { top: Math.round(rect.top), right: Math.round(window.innerWidth - host.right), height: Math.round(rect.height) } };
1143
- const key = `${next.top}|${next.right}|${next.maxHeight}|${next.wide}|${next.split.top}|${next.split.right}|${next.split.height}`;
1144
- if (key !== last || region !== lastRegion) { last = key; lastRegion = region; setLayout(next); }
1145
- };
1146
- measure();
1147
- const timer = setInterval(measure, 400);
1148
- window.addEventListener('resize', measure);
1149
- return () => { clearInterval(timer); window.removeEventListener('resize', measure); };
1150
- }, [sessionId, enabled]);
1151
- return layout;
1152
959
  }
1153
960
 
1154
961
  // The execution environment for Deep PTC sessions created from now on. It writes the same host
@@ -1161,6 +968,97 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
1161
968
  const effectiveEnvironment = (environment, platform) => environment !== 'auto' ? environment
1162
969
  : platform === 'win32' ? 'powershell' : platform === 'darwin' ? 'zsh' : 'bash';
1163
970
  const envLabel = (value, t) => value === 'auto' ? t('envAuto') : ENV_SHORT[value] ?? value;
971
+ function shellLabel(label, t) {
972
+ if (label === 'PowerShell 7 Preview') return t('shellPreview');
973
+ if (label === 'PowerShell 7 (Microsoft Store)') return t('shellStore');
974
+ const system = /^(bash|zsh) \(system\)$/u.exec(label);
975
+ return system ? tf(t, 'shellSystem', { name: system[1] }) : label;
976
+ }
977
+
978
+ // Only slots that show one entry are localized here. The settings page lists every entry of
979
+ // settings.section, so Deep PTC has its own page instead of a second Agent presets entry.
980
+ const PRESET_LABEL_SLOTS = [
981
+ ['conversation.hero.agentPreset', undefined, 'useAgentPresetSeat', 'options'],
982
+ ['conversation.session.header.actions', 'agent-preset', 'useAgentPresets', 'options'],
983
+ ];
984
+
985
+ // The host publishes `Deep PTC · <status>` (presetDescription in lib/model.mjs), readable as is in
986
+ // any language. This reads the status back so the picker can show it in the active language.
987
+ const STATUS_PREFIX = 'Deep PTC · ';
988
+ const SAFE_LABEL = '安全模式 Safe mode';
989
+ const OFFICIAL_LABEL = '官方 Shell Official shell';
990
+ function presetStatus(description) {
991
+ if (typeof description !== 'string' || !description.startsWith(STATUS_PREFIX)) return undefined;
992
+ const text = description.slice(STATUS_PREFIX.length);
993
+ if (text.startsWith(SAFE_LABEL)) return { kind: 'safe', reason: text.slice(SAFE_LABEL.length).replace(/^:\s*/u, '') };
994
+ if (text === OFFICIAL_LABEL) return { kind: 'official' };
995
+ const environment = /^(WSL|PowerShell|Zsh|Bash)(?: \((.+)\))?$/u.exec(text);
996
+ return environment ? { kind: 'environment', label: environment[1], distribution: environment[2] } : undefined;
997
+ }
998
+
999
+ function translatedPreset(row, t) {
1000
+ if (row?.id !== 'deep-ptc') return row;
1001
+ const status = presetStatus(row.description);
1002
+ let line;
1003
+ if (status?.kind === 'safe') line = status.reason ? tf(t, 'presetSafeReason', { reason: status.reason }) : t('presetSafeMode');
1004
+ else if (status?.kind === 'official') line = tf(t, 'presetEnvironment', { env: t('presetOfficial') });
1005
+ else if (status?.kind === 'environment') line = tf(t, 'presetEnvironment', { env: status.distribution ? `${status.label} (${status.distribution})` : status.label });
1006
+ return { ...row, name: t('presetName'), description: [t('presetDescription'), line].filter(Boolean).join(' ') };
1007
+ }
1008
+
1009
+ function presetSnapshotTranslator(rowsKey, t) {
1010
+ const cache = new WeakMap();
1011
+ return snapshot => {
1012
+ if (!snapshot || typeof snapshot !== 'object') return snapshot;
1013
+ if (cache.has(snapshot)) return cache.get(snapshot);
1014
+ const rows = snapshot[rowsKey];
1015
+ const error = snapshot.error;
1016
+ const hasPreset = Array.isArray(rows) && rows.some(row => row.id === 'deep-ptc');
1017
+ const hasPresetError = error?.preset?.id === 'deep-ptc';
1018
+ const localized = hasPreset || hasPresetError ? {
1019
+ ...snapshot,
1020
+ ...(hasPreset ? { [rowsKey]: rows.map(row => translatedPreset(row, t)) } : {}),
1021
+ ...(hasPresetError ? { error: { ...error, preset: translatedPreset(error.preset, t) } } : {}),
1022
+ } : snapshot;
1023
+ cache.set(snapshot, localized);
1024
+ return localized;
1025
+ };
1026
+ }
1027
+
1028
+ // Keep the native picker and its actions. A higher-priority slot entry supplies localized
1029
+ // display snapshots only for our row, while the host owns the actual selection and preset.
1030
+ function installPresetLabels(slots, t, useLocaleRevision) {
1031
+ if (typeof slots.entriesOfSlot !== 'function' || typeof slots.entries !== 'function' || typeof slots.subscribe !== 'function') return;
1032
+ for (const [name, id, hook, rows] of PRESET_LABEL_SLOTS) {
1033
+ slots.inject(name, () => {
1034
+ let original;
1035
+ let dispose;
1036
+ const sync = () => {
1037
+ const entry = slots.entries(name).find(item => item.options?.id === id && (item.options?.priority ?? 0) === 0
1038
+ && item.locale === 'settings.agentPreset' && !item.children && !item.store && typeof item.component === 'function');
1039
+ if (entry === original) return;
1040
+ original = entry;
1041
+ dispose?.();
1042
+ dispose = undefined;
1043
+ if (!entry) return;
1044
+ function LocalizedPresetSlot(props) {
1045
+ const revision = useLocaleRevision();
1046
+ const translate = React.useMemo(() => presetSnapshotTranslator(rows, t), [revision]);
1047
+ const useRoster = props[hook];
1048
+ const useLocalizedRoster = React.useCallback((select, equal) => useRoster(
1049
+ snapshot => select(translate(snapshot)), equal), [useRoster, translate]);
1050
+ return h(entry.component, typeof useRoster === 'function' ? { ...props, [hook]: useLocalizedRoster } : props);
1051
+ }
1052
+ try {
1053
+ dispose = slots.register({ ...entry.options, name, priority: -1, locale: entry.locale, inject: entry.inject }, LocalizedPresetSlot);
1054
+ } catch { /* Another plugin may already own the presentation slot. */ }
1055
+ };
1056
+ const unsubscribe = slots.subscribe(name, sync);
1057
+ sync();
1058
+ return () => { unsubscribe(); dispose?.(); };
1059
+ });
1060
+ }
1061
+ }
1164
1062
 
1165
1063
  function useSettingsForm(form) {
1166
1064
  const subscribe = React.useCallback(listener => form ? form.subscribe(listener) : () => {}, [form]);
@@ -1191,10 +1089,10 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
1191
1089
  try {
1192
1090
  const ok = await form.mutate(ops, form.getSnapshot().revision);
1193
1091
  if (!ok) throw new Error('rejected');
1194
- setMessage({ tone: 'ok', text: tf(t, 'envSaved', { env: label }) });
1092
+ setMessage({ tone: 'ok', label });
1195
1093
  return true;
1196
1094
  } catch {
1197
- setMessage({ tone: 'error', text: t('envFailed') });
1095
+ setMessage({ tone: 'error' });
1198
1096
  return false;
1199
1097
  } finally { setSaving(false); }
1200
1098
  }
@@ -1211,7 +1109,7 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
1211
1109
  const ops = [{ op: 'set', path: ['environment'], value: next }];
1212
1110
  // A shell picked for another family would not apply; fall back to the official lookup.
1213
1111
  if (value.shellExecutable && current?.family !== family) ops.push({ op: 'set', path: ['shellExecutable'], value: '' });
1214
- void save(ops, envLabel(next, t));
1112
+ void save(ops, next === 'auto' ? { key: 'envAuto' } : envLabel(next, t));
1215
1113
  }
1216
1114
  async function saveDistribution(event) {
1217
1115
  event?.preventDefault?.();
@@ -1227,6 +1125,14 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
1227
1125
  { op: 'set', path: ['shellExecutable'], value: next }], 'Bash')) setBashPath(undefined);
1228
1126
  }
1229
1127
  const familyChoices = choices.filter(item => item.family === effective);
1128
+ let note = t('envThisSession');
1129
+ if (message?.tone === 'error') note = t('envFailed');
1130
+ else if (message) {
1131
+ const label = message.label;
1132
+ const env = typeof label === 'string' ? label : label.key ? t(label.key) : shellLabel(label.shell, t);
1133
+ note = tf(t, 'envSaved', { env });
1134
+ } else if (!state.writable) note = t('readOnly');
1135
+ else if (environment === 'auto') note = tf(t, 'envAutoNow', { env: envLabel(effective, t) });
1230
1136
  return h('section', { className: 'dpt-side-section', 'aria-label': t('environment') },
1231
1137
  h('div', { className: 'dpt-side-label' }, h('span', null, t('environment')), h('span', { className: 'dpt-side-hint' }, t('envForNew'))),
1232
1138
  h('div', { className: 'dpt-seg', role: 'radiogroup', 'aria-label': t('environment') },
@@ -1248,10 +1154,9 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
1248
1154
  !editingBash && effective !== 'wsl' && familyChoices.length > 0 ? h('div', { className: 'dpt-field' },
1249
1155
  h('select', { className: 'dpt-select', value: value.shellExecutable ?? '', disabled, 'aria-label': t('shell'), title: t('shellHint'),
1250
1156
  onChange: event => { const item = familyChoices.find(choice => choice.id === event.target.value);
1251
- void save([{ op: 'set', path: ['shellExecutable'], value: event.target.value }], item ? item.label : t('shellAuto')); } },
1252
- h('option', { value: '' }, t('shellAuto')), ...familyChoices.map(item => h('option', { key: item.id, value: item.id }, item.label)))) : null,
1253
- h('p', { className: 'dpt-side-note', role: 'status', 'data-tone': message?.tone },
1254
- message ? message.text : !state.writable ? t('readOnly') : environment === 'auto' ? tf(t, 'envAutoNow', { env: envLabel(effective, t) }) : t('envThisSession')));
1157
+ void save([{ op: 'set', path: ['shellExecutable'], value: event.target.value }], item ? { shell: item.label } : { key: 'shellAuto' }); } },
1158
+ h('option', { value: '' }, t('shellAuto')), ...familyChoices.map(item => h('option', { key: item.id, value: item.id }, shellLabel(item.label, t))))) : null,
1159
+ h('p', { className: 'dpt-side-note', role: 'status', 'data-tone': message?.tone }, note));
1255
1160
  }
1256
1161
 
1257
1162
  const JOB_STATUS = new Map([
@@ -1304,74 +1209,80 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
1304
1209
  React.useEffect(() => watchJobs(sessionId), [sessionId, watchJobs]);
1305
1210
  return h(BackgroundJobs, { jobs, t });
1306
1211
  }
1212
+ // Output files: newest first, at most three positions, and overflow takes one of them.
1213
+ const OUTPUT_PREVIEW_LIMIT = 3;
1214
+ const fileName = path => String(path).split(/[\\/]/u).filter(Boolean).at(-1) ?? String(path);
1307
1215
 
1308
- function SidePanel({ sessionId, useSessions, useProjection, useJobs, watchJobs, reset, form, t }) {
1309
- const sessions = typeof useSessions === 'function' ? useSessions(state => state) : undefined;
1310
- let tools;
1311
- try { tools = typeof useProjection === 'function' ? useProjection('deepPtcTools') : undefined; } catch { tools = undefined; }
1312
- const hasTools = typeof reset === 'function';
1313
- const toolFailures = tools && typeof tools === 'object' ? (tools.report?.tools ?? []).length : 0;
1314
- PANEL.state = { tools: tools === null ? 'null' : typeof tools, reset: typeof reset, form: form ? 'yes' : 'no' };
1216
+ function OutputsSection({ outputs, t }) {
1217
+ const rows = Array.isArray(outputs) ? outputs : [];
1218
+ const overflow = rows.length > OUTPUT_PREVIEW_LIMIT;
1219
+ const visible = rows.slice(0, overflow ? OUTPUT_PREVIEW_LIMIT - 1 : OUTPUT_PREVIEW_LIMIT);
1220
+ const hidden = overflow ? rows.slice(visible.length) : [];
1221
+ const row = item => h('li', { key: item.path, className: 'dpt-file', 'data-kind': item.kind, title: item.path },
1222
+ h('span', { className: 'dpt-file-name' }, fileName(item.path)),
1223
+ h('span', { className: 'dpt-file-meta' }, item.kind === 'presented' ? t('outputPresented') : tf(t, 'outputTurn', { turn: item.turn })));
1224
+ const title = t('outputsTitle');
1225
+ return h('section', { className: 'dpt-side-section dpt-side-files', 'aria-label': title },
1226
+ h('div', { className: 'dpt-side-label' }, h('span', null, title), rows.length ? h('span', { className: 'dpt-side-hint' }, String(rows.length)) : null),
1227
+ rows.length ? h('ul', { className: 'dpt-files' }, ...visible.map(row),
1228
+ hidden.length ? h('li', { className: 'dpt-files-more' },
1229
+ h('details', null, h('summary', null, tf(t, 'outputsMore', { count: hidden.length })),
1230
+ h('ul', { className: 'dpt-files' }, ...hidden.map(row)))) : null)
1231
+ : h('p', { className: 'dpt-side-note' }, t('outputsEmpty')));
1232
+ }
1233
+
1234
+ // SSH: the configured host aliases and the hosts this conversation reached, most recent first.
1235
+ function SshSection({ form, ssh, t }) {
1315
1236
  const settings = useSettingsForm(form);
1237
+ const configured = settings.status === 'ready' && Array.isArray(settings.value?.sshHosts) ? settings.value.sshHosts : [];
1238
+ const client = settings.status === 'ready' ? settings.value?.sshClient : undefined;
1239
+ const used = Array.isArray(ssh) ? ssh : [];
1240
+ const names = new Set(used.map(row => row.host));
1241
+ const rows = [...used.map(row => ({ host: row.host, used: row, config: configured.find(item => item.alias === row.host) })),
1242
+ ...configured.filter(item => !names.has(item.alias)).map(item => ({ host: item.alias, config: item }))];
1243
+ const endpoint = config => config ? [config.user ? `${config.user}@` : '', config.hostName || '', config.port && config.port !== '22' ? `:${config.port}` : ''].join('') : '';
1244
+ const title = t('sshTitle');
1245
+ return h('section', { className: 'dpt-side-section dpt-side-ssh', 'aria-label': title },
1246
+ h('div', { className: 'dpt-side-label' }, h('span', null, title),
1247
+ h('span', { className: 'dpt-side-hint', 'data-tone': client === '' ? 'warn' : undefined }, client === '' ? t('sshNoClient') : t('sshHint'))),
1248
+ rows.length ? h('ul', { className: 'dpt-files' }, ...rows.slice(0, 8).map(item => h('li', { key: item.host, className: 'dpt-file dpt-host',
1249
+ 'data-state': item.used ? (item.used.ok ? 'ok' : 'failed') : 'idle', title: endpoint(item.config) || item.host },
1250
+ h('span', { className: 'dpt-agent-dot', 'aria-hidden': 'true' }),
1251
+ h('span', { className: 'dpt-file-name' }, item.host),
1252
+ h('span', { className: 'dpt-file-meta' }, item.used
1253
+ ? tf(t, item.used.ok ? 'sshUsed' : 'sshFailed', { count: item.used.count, turn: item.used.turn })
1254
+ : endpoint(item.config) || t('sshConfigured')))))
1255
+ : h('p', { className: 'dpt-side-note' }, t('sshEmpty')));
1256
+ }
1257
+
1258
+ function projectionValue(useProjection, key) {
1259
+ try { return typeof useProjection === 'function' ? useProjection(key) : undefined; } catch { return undefined; }
1260
+ }
1261
+
1262
+ // The Deep PTC panel: one conversation's environment, subagents, jobs, outputs, SSH and tool state.
1263
+ // It is the right sidebar tab, or opens under the composer where the host has no right sidebar.
1264
+ function DeepPtcPanel({ sessionId, useSessions, useProjection, useJobs, watchJobs, reset, form, inline, t }) {
1265
+ const sessions = typeof useSessions === 'function' ? useSessions(state => state) : undefined;
1266
+ const preset = projectionValue(useProjection, 'agentPreset');
1267
+ const activity = projectionValue(useProjection, 'deepPtcActivity');
1316
1268
  const [now, setNow] = React.useState(() => Date.now());
1317
- const [collapsed, setCollapsed] = React.useState(readCollapsed);
1318
- const [peek, setPeek] = React.useState(false);
1319
- const rows = subagentRows(sessions, sessionId, now);
1269
+ const deep = preset === 'deep-ptc';
1270
+ const rows = deep ? subagentRows(sessions, sessionId, now) : [];
1320
1271
  const running = rows.filter(row => row.state === 'running').length;
1321
1272
  const completed = rows.filter(row => row.state === 'completed').length;
1322
- const hasEnvironment = !!form && settings.status !== 'unavailable';
1323
- const layout = useChatRegion(sessionId, canPortal());
1324
- const docked = !!layout && layout.wide && !collapsed;
1325
1273
  React.useEffect(() => {
1326
1274
  if (running === 0) return undefined;
1327
1275
  const timer = setInterval(() => setNow(Date.now()), 1000);
1328
1276
  return () => clearInterval(timer);
1329
1277
  }, [running > 0]);
1330
- React.useEffect(() => {
1331
- SESSIONS.setWorking(sessionId, running > 0);
1332
- return () => SESSIONS.setWorking(sessionId, false);
1333
- }, [sessionId, running > 0]);
1334
- React.useEffect(() => {
1335
- const region = layout?.region;
1336
- if (!region) return undefined;
1337
- region.toggleAttribute('data-dpt-docked', docked);
1338
- return () => region.removeAttribute('data-dpt-docked');
1339
- }, [layout?.region, docked]);
1340
- React.useEffect(() => {
1341
- PANEL.toggle = () => {
1342
- if (layout && !layout.wide) { setPeek(value => !value); return; }
1343
- setCollapsed(value => { writeCollapsed(!value); return !value; });
1344
- };
1345
- return () => { PANEL.toggle = () => {}; };
1346
- }, [layout?.wide]);
1347
- if (!layout || !canPortal()) return null;
1348
- const position = { top: `${layout.top}px`, right: `${layout.right}px` };
1349
1278
  const summary = [running ? tf(t, 'agentsRunning', { count: running }) : null, completed ? tf(t, 'agentsCompleted', { count: completed }) : null,
1350
1279
  rows.length - running - completed > 0 ? tf(t, 'agentsIdle', { count: rows.length - running - completed }) : null].filter(Boolean).join(' · ');
1351
- const environment = settings.status === 'ready' && settings.value ? envLabel(settings.value.environment ?? 'auto', t) : undefined;
1352
- if (!docked && !peek) {
1353
- const expand = () => { if (layout.wide) { writeCollapsed(false); setCollapsed(false); } else setPeek(true); };
1354
- const label = [environment, rows.length ? `${t('agentsTitle')} ${rows.length}` : null, toolFailures ? `${t('toolFailures')} ${toolFailures}` : null].filter(Boolean).join(' · ');
1355
- return ReactDOM.createPortal(h('button', { type: 'button', className: 'dpt-agents-pill', style: position, 'data-state': running ? 'running' : 'idle',
1356
- 'aria-label': t('agentsExpand'), title: summary || t('agentsExpand'), onClick: expand },
1357
- h('span', { className: 'dpt-agent-dot', 'aria-hidden': 'true' }), label || t('sideTitle')), document.body);
1358
- }
1359
1280
  const stateText = row => row.state === 'running' ? t('agentRunning') : row.state === 'completed' ? t('agentCompleted') : row.state === 'external' ? t('agentExternal') : t('agentIdle');
1360
- const collapse = () => { if (layout.wide) { writeCollapsed(true); setCollapsed(true); } setPeek(false); };
1361
- const frame = docked
1362
- ? { top: `${layout.split.top}px`, right: `${layout.split.right}px`, height: `${layout.split.height}px`, width: `${SPLIT_WIDTH}px` }
1363
- : { ...position, maxHeight: `${layout.maxHeight}px`, width: `${PANEL_WIDTH}px` };
1364
- return ReactDOM.createPortal(h('aside', { className: 'dpt-agents', 'data-split': docked ? '' : undefined, 'aria-label': t('sideTitle'), style: frame },
1365
- h('header', { className: 'dpt-agents-head' },
1366
- h('span', { className: 'dpt-agents-title' }, t('sideTitle')),
1367
- h('span', { className: 'dpt-agents-count' }),
1368
- h('button', { type: 'button', className: 'dpt-icon-btn', 'aria-label': t('agentsCollapse'), title: t('agentsCollapse'), onClick: collapse },
1369
- h('svg', { width: 14, height: 14, viewBox: '0 0 16 16', fill: 'none', 'aria-hidden': 'true' },
1370
- h('path', { d: 'M6 4l4 4-4 4', stroke: 'currentColor', strokeWidth: 1.5, strokeLinecap: 'round', strokeLinejoin: 'round' })))),
1281
+ return h('div', { className: 'dpt-panel', 'data-inline': inline ? '' : undefined, 'aria-label': t('sideTitle') },
1371
1282
  h('div', { className: 'dpt-side-body' },
1372
- hasEnvironment ? h(EnvironmentSection, { form, t }) : null,
1373
- h(VisualEffectsSection, { t }),
1374
- rows.length ? h('section', { className: 'dpt-side-section dpt-side-agents', 'aria-label': t('agentsTitle') },
1283
+ form ? h(EnvironmentSection, { form, t }) : null,
1284
+ !deep ? h('section', { className: 'dpt-side-section' }, h('p', { className: 'dpt-side-note' }, t('sideOtherMode'))) : null,
1285
+ deep && rows.length ? h('section', { className: 'dpt-side-section dpt-side-agents', 'aria-label': t('agentsTitle') },
1375
1286
  h('div', { className: 'dpt-side-label' }, h('span', null, t('agentsTitle')), h('span', { className: 'dpt-side-hint', title: summary }, summary)),
1376
1287
  h('ol', { className: 'dpt-agents-list' }, ...rows.map(row => {
1377
1288
  const meta = [stateText(row), row.duration !== undefined ? formatDuration(row.duration, t) : null,
@@ -1382,13 +1293,42 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
1382
1293
  h('span', { className: 'dpt-agent-main' }, h('span', { className: 'dpt-agent-name', title: row.label }, row.label),
1383
1294
  h('span', { className: 'dpt-agent-meta' }, meta))));
1384
1295
  }))) : null,
1385
- typeof useJobs === 'function' && typeof watchJobs === 'function'
1386
- ? h(LiveBackgroundJobs, { key: sessionId, sessionId, useJobs, watchJobs, t })
1387
- : h(BackgroundJobs, { key: sessionId, jobs: sessions?.jobsBySession?.[sessionId], t }),
1388
- hasTools ? h(ToolStateControls, { sessionId, useProjection, reset, t }) : null)), document.body);
1296
+ deep ? (typeof useJobs === 'function' && typeof watchJobs === 'function'
1297
+ ? h(LiveBackgroundJobs, { key: `jobs:${sessionId}`, sessionId, useJobs, watchJobs, t })
1298
+ : h(BackgroundJobs, { key: `jobs:${sessionId}`, jobs: sessions?.jobsBySession?.[sessionId], t })) : null,
1299
+ deep ? h(OutputsSection, { outputs: activity?.outputs, t }) : null,
1300
+ h(SshSection, { form, ssh: deep ? activity?.ssh : undefined, t }),
1301
+ deep && typeof reset === 'function' ? h(ToolStateControls, { sessionId, useProjection, reset, t }) : null,
1302
+ h(VisualEffectsSection, { t })));
1389
1303
  }
1390
1304
 
1391
- // A boundary keeps a failing bridge or panel from taking the conversation header with it.
1305
+ // The capsule under the composer: a glance at the environment, subagents and tool notices. It opens
1306
+ // the Deep PTC tab in the right sidebar, so it sits in the composer's own dock and never over messages.
1307
+ function Capsule(props) {
1308
+ const { sessionId, useSessions, useProjection, form, openPanel, t } = props;
1309
+ const sessions = typeof useSessions === 'function' ? useSessions(state => state) : undefined;
1310
+ const tools = projectionValue(useProjection, 'deepPtcTools');
1311
+ const settings = useSettingsForm(form);
1312
+ const [open, setOpen] = React.useState(false);
1313
+ const rows = subagentRows(sessions, sessionId, Date.now());
1314
+ const running = rows.filter(row => row.state === 'running').length;
1315
+ React.useEffect(() => {
1316
+ SESSIONS.setWorking(sessionId, running > 0);
1317
+ return () => SESSIONS.setWorking(sessionId, false);
1318
+ }, [sessionId, running > 0]);
1319
+ const failures = tools && typeof tools === 'object' ? (tools.report?.tools ?? []).length : 0;
1320
+ const environment = settings.status === 'ready' && settings.value ? envLabel(settings.value.environment ?? 'auto', t) : undefined;
1321
+ const label = [environment, rows.length ? `${t('agentsTitle')} ${rows.length}` : null, failures ? `${t('toolFailures')} ${failures}` : null]
1322
+ .filter(Boolean).join(' · ') || t('sideTitle');
1323
+ const toggle = () => { if (!openPanel?.()) setOpen(value => !value); };
1324
+ return h('div', { className: 'dpt-capsule-row' },
1325
+ h('button', { type: 'button', className: 'dpt-capsule', 'data-state': running ? 'running' : 'idle', 'aria-expanded': open,
1326
+ title: t('capsuleOpen'), onClick: toggle },
1327
+ h('span', { className: 'dpt-agent-dot', 'aria-hidden': 'true' }), h('span', null, label)),
1328
+ open ? h(DeepPtcPanel, { ...props, inline: true }) : null);
1329
+ }
1330
+
1331
+ // A boundary keeps a failing bridge or panel from taking the conversation with it.
1392
1332
  class Boundary extends React.Component {
1393
1333
  constructor(props) { super(props); this.state = { failed: false }; }
1394
1334
  static getDerivedStateFromError() { return { failed: true }; }
@@ -1399,28 +1339,62 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
1399
1339
  function SessionBridge(props) {
1400
1340
  const { sessionId } = props;
1401
1341
  const marker = React.useRef(null);
1402
- let preset;
1403
- try { preset = typeof props.useProjection === 'function' ? props.useProjection('agentPreset') : undefined; } catch { preset = undefined; }
1342
+ const preset = projectionValue(props.useProjection, 'agentPreset');
1404
1343
  const statuses = typeof props.useSessionStatus === 'function' ? props.useSessionStatus(state => state) : undefined;
1405
1344
  const busy = statuses?.get?.(sessionId)?.running === true;
1406
1345
  React.useEffect(() => { SESSIONS.set(sessionId, { id: sessionId, preset, busy, el: marker.current }); }, [sessionId, preset, busy]);
1407
1346
  React.useEffect(() => () => SESSIONS.del(sessionId), [sessionId]);
1347
+ React.useEffect(() => SESSIONS.watch(marker.current?.parentElement), []);
1408
1348
  return h('span', { ref: marker, hidden: true, 'aria-hidden': 'true', 'data-dpt-bridge': sessionId });
1409
1349
  }
1410
1350
 
1411
- function SideCardHost(props) {
1412
- // Registered for every session; only Deep PTC sessions read their projections or draw the card.
1413
- let preset;
1414
- try { preset = props.useProjection('agentPreset'); } catch { return null; }
1415
- if (preset !== 'deep-ptc') return null;
1416
- return h(Boundary, null, h(SidePanel, props));
1351
+ function DockHost(props) {
1352
+ // Registered for every session; only Deep PTC sessions draw the capsule.
1353
+ if (projectionValue(props.useProjection, 'agentPreset') !== 'deep-ptc') return null;
1354
+ return h(Boundary, null, h(Capsule, props));
1417
1355
  }
1418
1356
 
1357
+ function TabHost(props) {
1358
+ return h(Boundary, null, h(DeepPtcPanel, props));
1359
+ }
1360
+
1361
+ function TabTitle({ t }) {
1362
+ return h('span', { className: 'dpt-tab-title' }, t('sideTitle'));
1363
+ }
1364
+
1365
+ function DiagnosticsSection({ t }) {
1366
+ const [text, setText] = React.useState('');
1367
+ const [copied, setCopied] = React.useState(false);
1368
+ async function copy() {
1369
+ const value = diagnostics();
1370
+ setText(value);
1371
+ try { await navigator.clipboard?.writeText(value); setCopied(true); } catch { setCopied(false); }
1372
+ }
1373
+ return h('section', { 'aria-label': t('diagTitle') },
1374
+ h('h3', null, t('diagTitle')),
1375
+ h('div', { className: 'dpt-settings-row' }, h('p', { className: 'dpt-side-note' }, t('diagHint')),
1376
+ h('button', { type: 'button', className: 'dpt-btn', onClick: () => { void copy(); } }, copied ? t('diagCopied') : t('diagCopy'))),
1377
+ text ? h('pre', { className: 'dpt-diag' }, text) : null);
1378
+ }
1379
+
1380
+ // The Deep PTC settings page: the environment form, the effects switch and diagnostics.
1381
+ function SettingsPage({ form, t }) {
1382
+ return h('div', { className: 'dpt-settings' },
1383
+ // The form labels its own environment field.
1384
+ h('section', { 'aria-label': t('environment') },
1385
+ form ? h(Card, { form, t }) : h('p', { className: 'dpt-side-note' }, t('readOnly'))),
1386
+ h('section', { 'aria-label': t('visualEffects') }, h('h3', null, t('appearance')), h(VisualEffectsSection, { t })),
1387
+ h(DiagnosticsSection, { t }));
1388
+ }
1389
+
1390
+ const SettingsIcon = ({ size = 16 }) => h('svg', { width: size, height: size, viewBox: '0 0 16 16', fill: 'none', 'aria-hidden': 'true' },
1391
+ h('path', { d: 'M2.5 4.5h6M2.5 8h11M2.5 11.5h8', stroke: 'currentColor', strokeWidth: 1.4, strokeLinecap: 'round' }),
1392
+ h('circle', { cx: 11.5, cy: 4.5, r: 1.6, stroke: 'currentColor', strokeWidth: 1.3 }));
1419
1393
  // The skill switches run a host command, and the host logs every command. The log keeps it; the
1420
1394
  // conversation shows nothing for a success and a short line for a failure.
1421
- function SkillCommandRow({ node }) {
1395
+ function SkillCommandRow({ node, t }) {
1422
1396
  const outcome = node?.outcome;
1423
- if (outcome?.kind === 'error') return h('div', { className: 'dpt-command-error', role: 'status' }, outcome.text);
1397
+ if (outcome?.kind === 'error') return h('div', { className: 'dpt-command-error', role: 'status' }, commandText(outcome.text, t));
1424
1398
  return h('span', { hidden: true, 'data-dpt-hidden-command': SKILL_COMMAND_NAME });
1425
1399
  }
1426
1400
 
@@ -1431,25 +1405,83 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
1431
1405
  // The remote command API takes the full line plus attachments. The JSON payload is command input.
1432
1406
  return execute(sessionId, `/${SKILL_COMMAND_NAME} ` + JSON.stringify(payload), []);
1433
1407
  }
1408
+ const TAB_KIND = 'deep-ptc';
1409
+
1410
+ // Per-conversation props shared by the composer capsule and the right sidebar tab.
1411
+ function sessionTools(child) {
1412
+ return sessionId => {
1413
+ const jobs = child.get?.('jobs');
1414
+ const props = {
1415
+ reset: () => {
1416
+ const execute = child.remote?.commands?.execute;
1417
+ if (typeof execute !== 'function') return Promise.resolve({ ok: true, value: undefined });
1418
+ return execute(sessionId, '/deep-ptc-reset-tools', []);
1419
+ },
1420
+ };
1421
+ if (jobs?.state && typeof jobs.watchRows === 'function') {
1422
+ props.hooks = { jobs: jobs.state };
1423
+ props.watchJobs = id => jobs.watchRows(id);
1424
+ }
1425
+ return props;
1426
+ };
1427
+ }
1428
+
1429
+ // Opens the Deep PTC tab in the right sidebar; false when this host has none, so the capsule
1430
+ // opens the panel under the composer instead.
1431
+ let tabRegistered = false;
1432
+ function openPanel() {
1433
+ const sidebar = hostCtx?.get?.('sidebarRight');
1434
+ if (!tabRegistered || typeof sidebar?.openTab !== 'function') return false;
1435
+ try {
1436
+ sidebar.openTab(TAB_KIND);
1437
+ // Revealing a page that is already open does not expand a collapsed column; check once the
1438
+ // open has rendered, so an open that did expand it is not toggled closed again.
1439
+ if (typeof sidebar.isExpanded === 'function' && typeof sidebar.toggleExpanded === 'function') {
1440
+ setTimeout(() => { if (!sidebar.isExpanded()) sidebar.toggleExpanded(); }, 0);
1441
+ }
1442
+ return true;
1443
+ } catch { return false; }
1444
+ }
1434
1445
 
1435
1446
  function apply(ctx) {
1436
1447
  hostCtx = ctx;
1437
1448
  const t = ctx.locale.bind('deep-ptc');
1438
- T = key => t(key);
1449
+ const subscribeLocale = listener => ctx.locale.subscribe?.(listener) ?? noSubscribe();
1450
+ const readLocale = () => ctx.locale.getSnapshot?.()?.revision ?? 0;
1451
+ const useLocaleRevision = () => React.useSyncExternalStore(subscribeLocale, readLocale, readLocale);
1452
+ function LocalizedSlot({ component, ...props }) {
1453
+ useLocaleRevision();
1454
+ return h(component, { ...props, t: props.t ?? t });
1455
+ }
1439
1456
  ctx.effect(() => ctx.locale.register('deep-ptc', dictionaries));
1457
+ installPresetLabels(ctx.slots, t, useLocaleRevision);
1440
1458
  ctx.effect(() => injectCss(), `${PLUGIN}: style`);
1441
1459
  ctx.effect(() => watchActiveSession(), `${PLUGIN}: active session`);
1442
- ctx.effect(() => watchDiagnostics(), `${PLUGIN}: diagnostics`);
1443
1460
  const form = ctx.configForms.get(NS);
1444
- ctx.effect(() => ctx.configForms.whileServed([NS], () =>
1445
- ctx.slots.inject('plugins.item', () => ctx.slots.register({
1446
- name: 'plugins.item', id: 'deep-ptc', order: 41,
1447
- label: () => t('title'), locale: 'deep-ptc',
1448
- }, props => h(Card, { ...props, form, t })))));
1461
+ ctx.effect(() => ctx.configForms.whileServed([NS], () => {
1462
+ const disposers = [
1463
+ // The plugin manager row keeps its settings card.
1464
+ ctx.slots.inject('plugins.item', () => ctx.slots.register({
1465
+ name: 'plugins.item', id: 'deep-ptc', order: 41,
1466
+ label: () => t('title'), locale: 'deep-ptc',
1467
+ }, props => h(LocalizedSlot, { ...props, form, component: Card }))),
1468
+ // Deep PTC's own settings page, under its own id: no other entry is shadowed.
1469
+ ctx.slots.inject('settings.section', () => ctx.slots.register({
1470
+ name: 'settings.section', id: 'deep-ptc', order: 24,
1471
+ label: () => t('title'), locale: 'deep-ptc',
1472
+ }, props => h(LocalizedSlot, { ...props, form, component: SettingsPage }))),
1473
+ ];
1474
+ try {
1475
+ disposers.push(ctx.slots.inject('settings.section.icon', () => ctx.slots.register({
1476
+ name: 'settings.section.icon', id: 'deep-ptc',
1477
+ }, SettingsIcon)));
1478
+ } catch { /* the nav keeps its default icon */ }
1479
+ return () => disposers.reverse().forEach(dispose => dispose?.());
1480
+ }));
1449
1481
  try {
1450
1482
  ctx.slots.inject('conversation.chat.commandview', () => ctx.slots.register({
1451
- name: 'conversation.chat.commandview', key: SKILL_COMMAND_NAME,
1452
- }, SkillCommandRow));
1483
+ name: 'conversation.chat.commandview', key: SKILL_COMMAND_NAME, locale: 'deep-ptc',
1484
+ }, props => h(LocalizedSlot, { ...props, component: SkillCommandRow })));
1453
1485
  } catch { /* without the renderer the host shows its generic command row */ }
1454
1486
  try {
1455
1487
  // Each conversation header reports which session is on screen and whether it works.
@@ -1461,36 +1493,42 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
1461
1493
  ctx.inject?.(['remote', 'remote.commands'], child => {
1462
1494
  try {
1463
1495
  child.slots.inject('conversation.chat.turnTail', () => child.slots.register({
1464
- name: 'conversation.chat.turnTail', id: 'deep-ptc-skills', order: 20,
1496
+ name: 'conversation.chat.turnTail', id: 'deep-ptc-skills', order: 20, locale: 'deep-ptc',
1465
1497
  inject: sessionId => ({
1466
1498
  setSkill: (name, enabled) => runSkillCommand(child, sessionId, { action: 'set', name, enabled }),
1467
1499
  setAll: enabled => runSkillCommand(child, sessionId, { action: 'all', enabled }),
1468
1500
  }),
1469
- }, props => h(SkillTail, { ...props, t })));
1501
+ }, props => h(LocalizedSlot, { ...props, component: SkillTail })));
1470
1502
  } catch { /* a broken card must not take the conversation with it */ }
1471
1503
  try {
1472
- // The side card draws beside the conversation through a portal; nothing shows under the composer.
1504
+ // The capsule renders in the composer's own dock, in the page flow.
1473
1505
  child.slots.inject('conversation.composer.dock', () => child.slots.register({
1474
- name: 'conversation.composer.dock', id: 'deep-ptc-side', order: 89,
1475
- inject: sessionId => {
1476
- const jobs = child.get?.('jobs');
1477
- const props = {
1478
- reset: () => {
1479
- const execute = child.remote?.commands?.execute;
1480
- if (typeof execute !== 'function') return Promise.resolve({ ok: false, error: { message: 'unavailable' } });
1481
- return execute(sessionId, '/deep-ptc-reset-tools', []);
1482
- },
1483
- };
1484
- if (jobs?.state && typeof jobs.watchRows === 'function') {
1485
- props.hooks = { jobs: jobs.state };
1486
- props.watchJobs = id => jobs.watchRows(id);
1487
- }
1488
- return props;
1489
- },
1490
- }, props => h(SideCardHost, { ...props, form, t })));
1506
+ name: 'conversation.composer.dock', id: 'deep-ptc-side', order: 89, locale: 'deep-ptc',
1507
+ inject: sessionTools(child),
1508
+ }, props => h(LocalizedSlot, { ...props, form, openPanel, component: DockHost })));
1491
1509
  } catch { /* the composer stays usable when this slot cannot register */ }
1492
1510
  });
1493
1511
  } catch { /* the composer stays usable when this slot cannot register */ }
1512
+ try {
1513
+ // The panel is a page type of the official right sidebar: the host places, docks, floats and
1514
+ // hides it, and lists it on the sidebar's new-tab guide.
1515
+ ctx.inject?.(['remote', 'remote.commands', 'sidebarRightTabs'], child => {
1516
+ child.effect(() => {
1517
+ const dispose = child.sidebarRightTabs.register({
1518
+ id: PLUGIN, kind: TAB_KIND, title: () => t('sideTitle'),
1519
+ guide: [{ id: TAB_KIND, order: 60, title: () => t('sideTitle'), description: () => t('sideGuide') }],
1520
+ });
1521
+ tabRegistered = true;
1522
+ return () => { tabRegistered = false; dispose(); };
1523
+ }, `${PLUGIN}: sidebar tab type`);
1524
+ child.slots.inject('sidebar.right.pane.tab', () => child.slots.register({
1525
+ name: 'sidebar.right.pane.tab', key: PLUGIN, locale: 'deep-ptc', inject: sessionTools(child),
1526
+ }, props => h(LocalizedSlot, { ...props, form, component: TabHost })));
1527
+ child.slots.inject('sidebar.right.pane.tab.title', () => child.slots.register({
1528
+ name: 'sidebar.right.pane.tab.title', key: PLUGIN,
1529
+ }, props => h(LocalizedSlot, { ...props, component: TabTitle })));
1530
+ });
1531
+ } catch { /* without a right sidebar the capsule opens the panel in place */ }
1494
1532
  }
1495
1533
  return { apply, inject };
1496
1534
  } });