@restregular/dsh-powerup 0.8.18 → 0.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/README.md CHANGED
@@ -371,6 +371,33 @@ fiber is unloaded. The panel closes; refresh the page when the install finishes.
371
371
  fixed-position popovers anchored to their triggers, so they never grow the
372
372
  dialog or get clipped by its scroll area.
373
373
 
374
+ ### Conversation rendering enhancements
375
+
376
+ A feature set for more readable conversations, toggled as a whole on the
377
+ Power-Up page. Its first sub-feature is **reply masking**: each rule is a regular
378
+ expression; matching fragments in Agent reply prose are replaced with a
379
+ placeholder (`[已屏蔽]` by default, or a custom replacement). Reasoning blocks,
380
+ tool calls and user messages are never touched — only the assistant's answer
381
+ text, including the final task summary.
382
+
383
+ Global rules are managed on the Power-Up page's **Masking** tab. Workspace rules
384
+ are managed from the **Power-Up settings** tab in any conversation header (it
385
+ appears after Trajectory), and are stored in the workspace's
386
+ `.dsh/dsh-powerup/mask-rules.json` through a local Host route.
387
+
388
+ ### Dual send buttons
389
+
390
+ When enabled on the Power-Up page, two compact controls appear at the right of
391
+ the composer: a queued send and an interrupt (steer) send. They bypass the
392
+ system "busy Enter" preference:
393
+
394
+ - **Enter** always queues the message as a next turn.
395
+ - **Ctrl+Shift+Enter** (Cmd+Shift+Enter on macOS) always interrupts the running
396
+ turn with the message.
397
+
398
+ Plain Shift+Enter still inserts a newline, IME composition and slash/mention
399
+ menus are left to the host, and an empty draft keeps the host's retry behavior.
400
+
374
401
  ## Development
375
402
 
376
403
  ```bash
package/client.js CHANGED
@@ -83,7 +83,7 @@
83
83
  const promptCreateDraft = { workspaceId: null, title: '', text: '', scope: 'current' };
84
84
  /** Fallback bucket when the hero cannot resolve an owning workspace yet. */
85
85
  const UNSCOPED_WORKSPACE = '__unscoped__';
86
- const VERSION = '0.8.18';
86
+ const VERSION = '0.9.0';
87
87
  const MENU_GAP = 8;
88
88
  const MENU_WIDTH = 248;
89
89
  /** Reference scheme understood by the Host's `powerup_step_read` tool. */
@@ -130,6 +130,41 @@
130
130
  'page.locateTitle': '定位当前会话',
131
131
  'page.locateDesc': '在工作区侧边栏的按钮栏加一个定位按钮,把当前会话在工作区列表中展开、居中显示,自动展开折叠的工作区。',
132
132
  'page.locateHow': '在工作区列表顶部点击「定位当前会话」图标按钮,当前会话所在的工作区会自动展开并滚动到视图中央。',
133
+ 'page.scrollToTopTitle': '侧边栏回到顶部',
134
+ 'page.scrollToTopDesc': '在左侧边栏「新会话」按钮旁加一个回到顶部按钮:工作区列表向下滚动后才出现,点击后左侧边栏平滑滚回最顶部。',
135
+ 'page.scrollToTopHow': '在左侧边栏向下滚动工作区列表,顶部的「新会话」旁会出现向上箭头按钮,点击即可回到顶部。',
136
+ 'scrollToTop.label': '回到顶部',
137
+ 'scrollToTop.hint': '将左侧边栏滚动回最顶部',
138
+ 'page.renderingTitle': '会话内容渲染增强',
139
+ 'page.renderingDesc': '一组让会话内容更好读的增强,当前包含「回复内容屏蔽」:按正则表达式把 Agent 回复正文中匹配的片段替换成占位符,例如隐藏内部标签、水印或重复前缀。思考过程与工具调用不会被动到,只有发给你的回复正文(含最终总结)会被处理。',
140
+ 'page.renderingHow': '在 Power-Up 设置页的「内容屏蔽」标签页管理全局规则;也可以在会话顶部的「Power-Up 设置」标签页管理当前工作区的规则。每条规则填一个正则表达式和替换文本,可不填替换文本(默认 [已屏蔽])。',
141
+ 'page.dualSendTitle': '双发送按钮',
142
+ 'page.dualSendDesc': '在输入框右侧增加两个发送按钮:普通发送(等待/排队)与插话发送(立即打断当前生成)。快捷键 Enter 固定为等待发送、Ctrl+Shift+Enter 固定为插话发送,不受系统「繁忙时发送行为」设置影响。',
143
+ 'page.dualSendHow': '启用后输入框里会出现两个按钮,鼠标悬停可看到各自说明;输入文字后按 Enter 排队发送,按 Ctrl+Shift+Enter 立即插话发送。',
144
+ 'mask.tab': '内容屏蔽',
145
+ 'mask.tabFeatures': '功能',
146
+ 'mask.tabWorkspace': '工作区设置',
147
+ 'mask.globalTitle': '全局屏蔽规则',
148
+ 'mask.workspaceTitle': '工作区屏蔽规则',
149
+ 'mask.hint': '每条规则是一个正则表达式;命中的片段会被替换为占位符。思考过程与工具调用不会被处理。',
150
+ 'mask.pattern': '正则表达式',
151
+ 'mask.patternPlaceholder': '例如:\\[内部[^\\]]*\\]',
152
+ 'mask.replacement': '替换为',
153
+ 'mask.replacementPlaceholder': '留空则显示 [已屏蔽]',
154
+ 'mask.enabled': '启用',
155
+ 'mask.add': '添加规则',
156
+ 'mask.delete': '删除',
157
+ 'mask.empty': '还没有规则。',
158
+ 'mask.invalid': '正则表达式无效',
159
+ 'mask.scopeGlobal': '全局',
160
+ 'mask.scopeWorkspace': '当前工作区',
161
+ 'mask.sessionTitle': 'Power-Up 设置',
162
+ 'mask.sessionDesc': '管理当前工作区的 Power-Up 功能设置与内容屏蔽规则。',
163
+ 'send.wait': '等待发送',
164
+ 'send.waitHint': '排队发送(Enter)',
165
+ 'send.interrupt': '插话发送',
166
+ 'send.interruptHint': '立即打断并发送(Ctrl+Shift+Enter)',
167
+ 'send.empty': '输入为空',
133
168
  'launcher.groupDefault': '分组',
134
169
  'launcher.count': '{count} 个面板',
135
170
  'launcher.renameHint': '点击重命名',
@@ -382,6 +417,41 @@
382
417
  'page.locateTitle': 'Locate current session',
383
418
  'page.locateDesc': 'Adds a button to the workspace sidebar header that expands, reveals and centers the current session in the workspace list, auto-expanding collapsed workspaces.',
384
419
  'page.locateHow': 'Click the locate button in the workspace header; the workspace containing the current session expands and scrolls to the center of the view.',
420
+ 'page.scrollToTopTitle': 'Sidebar back to top',
421
+ 'page.scrollToTopDesc': 'Adds a back-to-top button next to New Session in the left sidebar: it appears once the workspace list is scrolled down, and clicking it smoothly scrolls the sidebar back to the very top.',
422
+ 'page.scrollToTopHow': 'Scroll the workspace list down in the left sidebar; an up-arrow button appears beside New Session — click it to return to the top.',
423
+ 'scrollToTop.label': 'Back to top',
424
+ 'scrollToTop.hint': 'Scroll the left sidebar back to the top',
425
+ 'page.renderingTitle': 'Conversation rendering enhancements',
426
+ 'page.renderingDesc': 'A feature set for more readable conversations. Its first sub-feature is reply masking: regular expressions replace matching fragments in Agent reply text with a placeholder, for example to hide internal tags, watermarks or repeated prefixes. Reasoning and tool calls are untouched; only reply prose (including the final summary) is processed.',
427
+ 'page.renderingHow': 'Manage global rules on the Power-Up page\'s Masking tab, or workspace rules from the Power-Up Settings tab in a session header. Each rule has a regular expression and a replacement (blank defaults to [masked]).',
428
+ 'page.dualSendTitle': 'Dual send buttons',
429
+ 'page.dualSendDesc': 'Adds two send buttons beside the composer: a normal (queued) send and an interrupt (steer) send. Enter always queues and Ctrl+Shift+Enter always interrupts, overriding the system busy-time send behavior.',
430
+ 'page.dualSendHow': 'Once enabled, two buttons appear in the composer with hover labels. Press Enter to queue a message, or Ctrl+Shift+Enter to interrupt the running turn with it.',
431
+ 'mask.tab': 'Masking',
432
+ 'mask.tabFeatures': 'Features',
433
+ 'mask.tabWorkspace': 'Workspace settings',
434
+ 'mask.globalTitle': 'Global masking rules',
435
+ 'mask.workspaceTitle': 'Workspace masking rules',
436
+ 'mask.hint': 'Each rule is a regular expression; matching fragments are replaced with a placeholder. Reasoning and tool calls are never touched.',
437
+ 'mask.pattern': 'Regular expression',
438
+ 'mask.patternPlaceholder': 'e.g. \\[internal[^\\]]*\\]',
439
+ 'mask.replacement': 'Replace with',
440
+ 'mask.replacementPlaceholder': 'Blank shows [masked]',
441
+ 'mask.enabled': 'Enabled',
442
+ 'mask.add': 'Add rule',
443
+ 'mask.delete': 'Delete',
444
+ 'mask.empty': 'No rules yet.',
445
+ 'mask.invalid': 'Invalid regular expression',
446
+ 'mask.scopeGlobal': 'Global',
447
+ 'mask.scopeWorkspace': 'This workspace',
448
+ 'mask.sessionTitle': 'Power-Up settings',
449
+ 'mask.sessionDesc': 'Manage Power-Up settings and masking rules for this workspace.',
450
+ 'send.wait': 'Send (queued)',
451
+ 'send.waitHint': 'Queue to send (Enter)',
452
+ 'send.interrupt': 'Send (interrupt)',
453
+ 'send.interruptHint': 'Interrupt and send now (Ctrl+Shift+Enter)',
454
+ 'send.empty': 'Empty input',
385
455
  'launcher.groupDefault': 'Group',
386
456
  'launcher.count': '{count} panels',
387
457
  'launcher.renameHint': 'Click to rename',
@@ -635,6 +705,9 @@
635
705
  jobStop: true,
636
706
  update: true,
637
707
  locateSession: true,
708
+ scrollToTop: true,
709
+ contentRendering: true,
710
+ dualSend: false,
638
711
  workspacePrompts: true,
639
712
  oneClickEnable: true,
640
713
  oneClickRestart: true,
@@ -654,6 +727,9 @@
654
727
  jobStop: parsed.jobStop !== false,
655
728
  update: parsed.update !== false,
656
729
  locateSession: parsed.locateSession !== false,
730
+ scrollToTop: parsed.scrollToTop !== false,
731
+ contentRendering: parsed.contentRendering !== false,
732
+ dualSend: parsed.dualSend === true,
657
733
  workspacePrompts: parsed.workspacePrompts !== false,
658
734
  oneClickEnable: parsed.oneClickEnable !== false,
659
735
  oneClickRestart: parsed.oneClickRestart !== false,
@@ -786,6 +862,125 @@
786
862
  }
787
863
  }
788
864
 
865
+ // ------------------------------------------------------------------
866
+ // Mask rules for the content-rendering enhancement.
867
+ // Global rules live in localStorage; workspace rules live in the
868
+ // workspace's `.dsh/dsh-powerup/mask-rules.json` via a Host route, exactly
869
+ // like prompts. Both lists share one normalize/compile helper.
870
+ // ------------------------------------------------------------------
871
+ const MASK_RULES_KEY = 'dsh-powerup:mask-rules:v1';
872
+ const MASK_RULES_API = '/dsh-powerup/api/mask-rules';
873
+ const MASK_PLACEHOLDER = '[已屏蔽]';
874
+ let globalMaskRules = readGlobalMaskRules();
875
+ let workspaceMaskRules = [];
876
+ let maskRulesWorkspace = '';
877
+ const maskRulesListeners = new Set();
878
+
879
+ /** Normalize one stored rule; invalid regex is kept but never compiled. */
880
+ function normalizeMaskRule(item) {
881
+ if (item === null || typeof item !== 'object') return null;
882
+ return {
883
+ id: typeof item.id === 'string' && item.id !== '' ? item.id : newId(),
884
+ pattern: typeof item.pattern === 'string' ? item.pattern : '',
885
+ replacement: typeof item.replacement === 'string' ? item.replacement : '',
886
+ enabled: item.enabled !== false,
887
+ scope: item.scope === 'workspace' ? 'workspace' : 'global',
888
+ };
889
+ }
890
+
891
+ function readGlobalMaskRules() {
892
+ try {
893
+ const parsed = JSON.parse(localStorage.getItem(MASK_RULES_KEY) || '[]');
894
+ return Array.isArray(parsed) ? parsed.map(normalizeMaskRule).filter(Boolean) : [];
895
+ } catch {
896
+ return [];
897
+ }
898
+ }
899
+
900
+ function writeGlobalMaskRules(list) {
901
+ globalMaskRules = (Array.isArray(list) ? list : []).map(normalizeMaskRule).filter(Boolean);
902
+ try {
903
+ localStorage.setItem(MASK_RULES_KEY, JSON.stringify(globalMaskRules));
904
+ } catch {
905
+ /* Private mode: the in-memory list still works this page. */
906
+ }
907
+ emitMaskRules();
908
+ }
909
+
910
+ async function loadWorkspaceMaskRules(workspaceId) {
911
+ const id = typeof workspaceId === 'string' ? workspaceId : '';
912
+ maskRulesWorkspace = id;
913
+ try {
914
+ const response = await fetch(MASK_RULES_API + '?workspaceId=' + encodeURIComponent(id), {
915
+ headers: { accept: 'application/json' },
916
+ });
917
+ const data = response.ok ? await response.json() : null;
918
+ const rules = data !== null && Array.isArray(data.rules) ? data.rules : [];
919
+ workspaceMaskRules = rules.map(normalizeMaskRule).filter(Boolean)
920
+ .map((rule) => ({ ...rule, scope: 'workspace' }));
921
+ } catch {
922
+ /* Host unavailable: keep the last known list. */
923
+ }
924
+ emitMaskRules();
925
+ return workspaceMaskRules;
926
+ }
927
+
928
+ function writeWorkspaceMaskRules(list) {
929
+ workspaceMaskRules = (Array.isArray(list) ? list : []).map(normalizeMaskRule).filter(Boolean)
930
+ .map((rule) => ({ ...rule, scope: 'workspace' }));
931
+ emitMaskRules();
932
+ fetch(MASK_RULES_API, {
933
+ method: 'POST',
934
+ headers: { 'content-type': 'application/json', accept: 'application/json' },
935
+ body: JSON.stringify({ workspaceId: maskRulesWorkspace, rules: workspaceMaskRules }),
936
+ }).catch(() => {
937
+ /* The in-memory list still works this page. */
938
+ });
939
+ }
940
+
941
+ function subscribeMaskRules(listener) {
942
+ maskRulesListeners.add(listener);
943
+ return () => maskRulesListeners.delete(listener);
944
+ }
945
+ function emitMaskRules() {
946
+ for (const listener of [...maskRulesListeners]) {
947
+ try { listener(); } catch { /* one listener must not break the rest */ }
948
+ }
949
+ }
950
+
951
+ /** Rules that apply to the current workspace: global plus its own. */
952
+ function activeMaskRules() {
953
+ return [...globalMaskRules, ...workspaceMaskRules].filter((rule) => rule.enabled && rule.pattern !== '');
954
+ }
955
+
956
+ /** Compile rules once per change into reusable RegExp objects. */
957
+ function compileMaskRules(list) {
958
+ const compiled = [];
959
+ for (const rule of Array.isArray(list) ? list : []) {
960
+ if (rule === null || rule.enabled === false || typeof rule.pattern !== 'string' || rule.pattern === '') continue;
961
+ try {
962
+ compiled.push({
963
+ re: new RegExp(rule.pattern, 'gu'),
964
+ replacement: typeof rule.replacement === 'string' && rule.replacement !== ''
965
+ ? rule.replacement : MASK_PLACEHOLDER,
966
+ });
967
+ } catch {
968
+ /* Invalid regex is skipped, never throws into rendering. */
969
+ }
970
+ }
971
+ return compiled;
972
+ }
973
+
974
+ /** Apply compiled rules to one text fragment; safe for any string. */
975
+ function applyMaskRules(text, compiled) {
976
+ if (typeof text !== 'string' || text === '' || compiled.length === 0) return text;
977
+ let out = text;
978
+ for (const rule of compiled) {
979
+ out = out.replace(rule.re, rule.replacement);
980
+ }
981
+ return out;
982
+ }
983
+
789
984
  /**
790
985
  * A prompt is visible in a workspace when it is global ('') or scoped to
791
986
  * that exact workspace. The dropdown never shows prompts of other workspaces.
@@ -2516,6 +2711,17 @@
2516
2711
  bridge.sessionId = sessionId;
2517
2712
  bridge.trajectory = snapshot;
2518
2713
  bridge.inputActions = inputActions;
2714
+ // Keep workspace masking rules loaded for the active session so the
2715
+ // DOM mask observer can use them without the settings tab being open.
2716
+ if (typeof sessionId === 'string' && sessionId !== '') {
2717
+ const workspaces = ctxRef.current?.get?.('workspaces');
2718
+ const wsId = typeof workspaces?.list?.getSnapshot === 'function'
2719
+ ? resolveWorkspaceIdFromSnapshot(workspaces.list.getSnapshot(), sessionId)
2720
+ : '';
2721
+ if (typeof wsId === 'string' && wsId !== '' && wsId !== maskRulesWorkspace) {
2722
+ void loadWorkspaceMaskRules(wsId);
2723
+ }
2724
+ }
2519
2725
  return () => {
2520
2726
  if (bridge.token === token) {
2521
2727
  bridge.token = null;
@@ -3092,6 +3298,20 @@
3092
3298
  );
3093
3299
  }
3094
3300
 
3301
+ function ScrollTopIcon({ size = 16 }) {
3302
+ return h(Icon, { size },
3303
+ h('path', {
3304
+ d: 'M8 12.5V3.5M4.2 7.3 8 3.5l3.8 3.8',
3305
+ fill: 'none', stroke: 'currentColor', strokeWidth: '1.4',
3306
+ strokeLinecap: 'round', strokeLinejoin: 'round',
3307
+ }),
3308
+ h('path', {
3309
+ d: 'M3 14h10', fill: 'none', stroke: 'currentColor',
3310
+ strokeWidth: '1.4', strokeLinecap: 'round',
3311
+ }),
3312
+ );
3313
+ }
3314
+
3095
3315
  function BrandMark({ size = 56 }) {
3096
3316
  return h('svg', {
3097
3317
  width: size, height: size, viewBox: '0 0 256 256', fill: 'none', 'aria-hidden': 'true',
@@ -3614,6 +3834,38 @@ marker is only present while our button is mounted, and the host's
3614
3834
  [data-sidebar-workspace-header] .dsh-powerup-locate:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}
3615
3835
  [data-sidebar-workspace-header] .dsh-powerup-locate:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:1px}
3616
3836
  [data-sidebar-workspace-header] .dsh-powerup-locate svg{width:16px;height:16px}
3837
+ `;
3838
+
3839
+ const SCROLL_TOP_CSS = `
3840
+ /* Back-to-top button injected next to the host's New Session row. Hidden by
3841
+ default; shown only while the sidebar workspace list is scrolled down. */
3842
+ .dsh-powerup-scrolltop{display:none;flex:none;align-items:center;justify-content:center;width:38px;height:38px;padding:0;box-sizing:border-box;border:.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-md,8px);background:var(--dsw-alias-button-elevated-fill);color:var(--dsw-alias-label-primary);font:inherit;cursor:pointer;transition:background .12s ease,color .12s ease,opacity .12s ease;opacity:0}
3843
+ .dsh-powerup-scrolltop[data-visible="true"]{display:inline-flex;opacity:1}
3844
+ .dsh-powerup-scrolltop:hover{background:var(--dsw-alias-button-floating-hover)}
3845
+ .dsh-powerup-scrolltop:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:1px}
3846
+ .dsh-powerup-scrolltop svg{width:16px;height:16px}
3847
+ html[data-platform="darwin"] .dsh-powerup-scrolltop{background:var(--dsw-specific-sidebar-glass-fill)}
3848
+ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-specific-sidebar-glass-hover)}
3849
+ @media (prefers-reduced-motion:reduce){.dsh-powerup-scrolltop{transition:none}}
3850
+ `;
3851
+
3852
+ const RENDERING_CSS = `
3853
+ /* Masked fragments get a subtle marker so the reader knows text was hidden. */
3854
+ .dsh-powerup-masked{color:var(--dsw-alias-label-caption);font-style:italic;opacity:.72}
3855
+ /* Dual send buttons injected into the composer's right slot. */
3856
+ .dsh-powerup-send{display:inline-flex;align-items:center;justify-content:center;width:34px;height:34px;padding:0;box-sizing:border-box;border:.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-md,8px);background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-secondary);font:inherit;cursor:pointer;transition:background .12s ease,color .12s ease,border-color .12s ease}
3857
+ .dsh-powerup-send:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-border-l3)}
3858
+ .dsh-powerup-send:disabled{opacity:.45;cursor:not-allowed}
3859
+ .dsh-powerup-send:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:1px}
3860
+ .dsh-powerup-send[data-kind="interrupt"]{color:var(--dsw-alias-state-warn-label,var(--dsw-alias-label-secondary))}
3861
+ .dsh-powerup-send svg{width:16px;height:16px}
3862
+ .dsh-powerup-dual-send{display:inline-flex;align-items:center;gap:4px}
3863
+ .dsh-powerup-mask-editor{display:flex;flex-direction:column;gap:10px}
3864
+ .dsh-powerup-mask-row{display:grid;grid-template-columns:minmax(0,1.4fr) minmax(0,1fr) auto auto;gap:8px;align-items:center;padding:8px;border:.5px solid var(--dsw-alias-border-l1);border-radius:var(--dsw-radius-md,8px);background:var(--dsw-alias-bg-layer-1)}
3865
+ .dsh-powerup-mask-input{width:100%;box-sizing:border-box;padding:6px 8px;border:.5px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-sm,6px);background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);font:inherit;font-size:12px;line-height:18px}
3866
+ .dsh-powerup-mask-input.invalid{border-color:var(--dsw-alias-state-error-primary)}
3867
+ .dsh-powerup-mask-empty{color:var(--dsw-alias-label-secondary);font-size:12px}
3868
+ @media (max-width:680px){.dsh-powerup-mask-row{grid-template-columns:minmax(0,1fr)}}
3617
3869
  `;
3618
3870
 
3619
3871
  const PROMPTS_CSS = `
@@ -4640,11 +4892,300 @@ marker is only present while our button is mounted, and the host's
4640
4892
  return core;
4641
4893
  }
4642
4894
 
4895
+ /**
4896
+ * Back-to-top button for the left sidebar. It is injected into the host's
4897
+ * New Session row (`[class*="newSessionRow"]`) and only becomes visible
4898
+ * once the workspace list has been scrolled away from the top. Clicking
4899
+ * it scrolls both the outer sidebar viewport and the workspace list back
4900
+ * to the very top. No host modules are imported — we observe the same
4901
+ * `data-*` contracts the other sidebar features already use.
4902
+ * @param {{t?: Function, isEnabled?: Function, threshold?: number}} deps
4903
+ */
4904
+ function createScrollToTopCore(deps) {
4905
+ const options = deps ?? {};
4906
+ const t = typeof options.t === 'function' ? options.t : (key) => key;
4907
+ const isEnabled = typeof options.isEnabled === 'function' ? options.isEnabled : () => true;
4908
+ const threshold = Number.isFinite(options.threshold) ? options.threshold : 24;
4909
+
4910
+ let button = null;
4911
+ let observer = null;
4912
+ let started = false;
4913
+ let boundContainers = [];
4914
+ let detachListeners = [];
4915
+
4916
+ function hasDocument() {
4917
+ return typeof document !== 'undefined' && document !== null
4918
+ && typeof document.querySelector === 'function' && document.body !== null;
4919
+ }
4920
+
4921
+ /** Both scrollers can carry the offset; the outer viewport wins. */
4922
+ function scrollContainers() {
4923
+ if (!hasDocument()) return [];
4924
+ const out = [];
4925
+ const outer = document.querySelector('[data-sidebar-scrollport]');
4926
+ if (outer !== null) out.push(outer);
4927
+ const inner = document.querySelector('[data-sidebar-list-area]');
4928
+ if (inner !== null && !out.includes(inner)) out.push(inner);
4929
+ return out;
4930
+ }
4931
+
4932
+ function scrolledDown() {
4933
+ return scrollContainers().some((el) => (el.scrollTop || 0) > threshold);
4934
+ }
4935
+
4936
+ function syncVisibility() {
4937
+ if (button === null) return;
4938
+ button.setAttribute('data-visible', scrolledDown() ? 'true' : 'false');
4939
+ }
4940
+
4941
+ function toTop() {
4942
+ for (const el of scrollContainers()) {
4943
+ try {
4944
+ el.scrollTo({ top: 0, behavior: 'smooth' });
4945
+ } catch {
4946
+ el.scrollTop = 0;
4947
+ }
4948
+ }
4949
+ syncVisibility();
4950
+ }
4951
+
4952
+ function row() {
4953
+ if (!hasDocument()) return null;
4954
+ return document.querySelector('[class*="newSessionRow"]');
4955
+ }
4956
+
4957
+ function bindScrollers() {
4958
+ for (const off of detachListeners) {
4959
+ try { off(); } catch { /* already detached */ }
4960
+ }
4961
+ detachListeners = [];
4962
+ boundContainers = scrollContainers();
4963
+ for (const el of boundContainers) {
4964
+ const handler = () => syncVisibility();
4965
+ el.addEventListener('scroll', handler, { passive: true });
4966
+ detachListeners.push(() => el.removeEventListener('scroll', handler));
4967
+ }
4968
+ syncVisibility();
4969
+ }
4970
+
4971
+ function ensureButton() {
4972
+ const host = row();
4973
+ if (host === null || !isEnabled()) {
4974
+ if (button !== null) {
4975
+ button.remove();
4976
+ button = null;
4977
+ }
4978
+ return;
4979
+ }
4980
+ if (button !== null && button.isConnected === true) return;
4981
+ button = document.createElement('button');
4982
+ button.type = 'button';
4983
+ button.className = 'dsh-powerup-scrolltop';
4984
+ button.setAttribute('data-powerup-scrolltop', '');
4985
+ button.setAttribute('data-visible', 'false');
4986
+ button.setAttribute('aria-label', t('scrollToTop.label'));
4987
+ button.setAttribute('title', t('scrollToTop.hint'));
4988
+ button.innerHTML = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true" focusable="false"><path d="M8 12.5V3.5M4.2 7.3 8 3.5l3.8 3.8" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/></svg>';
4989
+ button.addEventListener('click', (event) => {
4990
+ event.preventDefault();
4991
+ event.stopPropagation();
4992
+ toTop();
4993
+ });
4994
+ host.appendChild(button);
4995
+ bindScrollers();
4996
+ }
4997
+
4998
+ function sync() {
4999
+ if (!started) return;
5000
+ const containers = scrollContainers();
5001
+ if (containers.length !== boundContainers.length || containers.some((el, i) => el !== boundContainers[i])) {
5002
+ bindScrollers();
5003
+ }
5004
+ ensureButton();
5005
+ syncVisibility();
5006
+ }
5007
+
5008
+ function start() {
5009
+ if (started || !hasDocument()) return;
5010
+ started = true;
5011
+ ensureButton();
5012
+ if (typeof MutationObserver === 'function') {
5013
+ observer = new MutationObserver(() => sync());
5014
+ observer.observe(document.body, { childList: true, subtree: true });
5015
+ }
5016
+ }
5017
+
5018
+ function stop() {
5019
+ started = false;
5020
+ if (observer !== null) observer.disconnect();
5021
+ observer = null;
5022
+ for (const off of detachListeners) {
5023
+ try { off(); } catch { /* already detached */ }
5024
+ }
5025
+ detachListeners = [];
5026
+ boundContainers = [];
5027
+ if (button !== null) button.remove();
5028
+ button = null;
5029
+ }
5030
+
5031
+ return { start, stop, sync, toTop, scrollContainers, scrolledDown };
5032
+ }
5033
+
5034
+ /**
5035
+ * Install the sidebar back-to-top button.
5036
+ * @param {object} ctx client plugin context
5037
+ */
5038
+ function installScrollToTop(ctx) {
5039
+ const core = createScrollToTopCore({
5040
+ t: (key, params) => translateCurrent(key, params),
5041
+ isEnabled: () => getSettings().scrollToTop,
5042
+ });
5043
+ ctx.effect(() => {
5044
+ if (getSettings().scrollToTop) core.start();
5045
+ const off = subscribeSettings(() => {
5046
+ if (getSettings().scrollToTop) core.start();
5047
+ else core.stop();
5048
+ });
5049
+ return () => {
5050
+ off();
5051
+ core.stop();
5052
+ };
5053
+ }, 'dsh-powerup: sidebar scroll to top');
5054
+ return core;
5055
+ }
5056
+
5057
+ /**
5058
+ * DOM-based masking for assistant reply prose. We observe the Chat view's
5059
+ * assistant reply rows and replace matching text fragments in place. The
5060
+ * original text of each text node is cached in a WeakMap so a re-render
5061
+ * that restores it can be masked again, and a re-render that produces a
5062
+ * new node is picked up by the MutationObserver. Only reply rows
5063
+ * (`data-chat-flow-kind="assistant-step"` with `group-part="response"`)
5064
+ * are touched; reasoning disclosures and tool calls are left alone.
5065
+ * @param {{isEnabled?: Function, rules?: Function}} deps
5066
+ */
5067
+ function createReplyMaskCore(deps) {
5068
+ const options = deps ?? {};
5069
+ const isEnabled = typeof options.isEnabled === 'function' ? options.isEnabled : () => true;
5070
+ const rulesOf = typeof options.rules === 'function' ? options.rules : () => [];
5071
+ const originals = new WeakMap();
5072
+ let observer = null;
5073
+ let timer = null;
5074
+ let started = false;
5075
+ let compiled = [];
5076
+ let sweeping = false;
5077
+
5078
+ function hasDocument() {
5079
+ return typeof document !== 'undefined' && document !== null
5080
+ && typeof document.querySelectorAll === 'function' && document.body !== null;
5081
+ }
5082
+
5083
+ function refreshRules() {
5084
+ compiled = compileMaskRules(rulesOf());
5085
+ }
5086
+
5087
+ function maskTextNode(node) {
5088
+ if (node.nodeType !== 3) return; // Node.TEXT_NODE
5089
+ const current = node.nodeValue ?? '';
5090
+ const original = originals.get(node);
5091
+ if (original !== undefined) {
5092
+ const maskedFromOriginal = applyMaskRules(original, compiled);
5093
+ if (current === maskedFromOriginal) return; // still our masked output
5094
+ }
5095
+ // Either a fresh node, React restored the original, or streaming grew
5096
+ // the text. Treat what is on screen now as the source of truth.
5097
+ originals.set(node, current);
5098
+ const masked = applyMaskRules(current, compiled);
5099
+ if (masked !== current) node.nodeValue = masked;
5100
+ }
5101
+
5102
+ function maskRow(row) {
5103
+ // Only the assistant's answer prose; skip reasoning / tool rows.
5104
+ const kind = row.getAttribute('data-chat-flow-kind');
5105
+ const part = row.getAttribute('data-chat-group-part');
5106
+ if (kind !== 'assistant-step' || (part !== null && part !== 'response')) return;
5107
+ const body = row.querySelector('[data-streaming], .dsh-powerup-mask-root') ?? row;
5108
+ const walker = document.createTreeWalker(body, 4 /* NodeFilter.SHOW_TEXT */, null);
5109
+ let node;
5110
+ while ((node = walker.nextNode()) !== null) {
5111
+ maskTextNode(node);
5112
+ }
5113
+ }
5114
+
5115
+ function sweep() {
5116
+ if (!started || !isEnabled() || compiled.length === 0 || sweeping) return;
5117
+ // Changing nodeValue fires our own characterData observer; the flag
5118
+ // keeps that from cascading into another full sweep.
5119
+ sweeping = true;
5120
+ try {
5121
+ const rows = document.querySelectorAll('[data-chat-flow-kind="assistant-step"]');
5122
+ for (const row of rows) maskRow(row);
5123
+ } finally {
5124
+ setTimeout(() => { sweeping = false; }, 0);
5125
+ }
5126
+ }
5127
+
5128
+ function schedule() {
5129
+ if (timer !== null) return;
5130
+ timer = setTimeout(() => {
5131
+ timer = null;
5132
+ sweep();
5133
+ }, 40);
5134
+ }
5135
+
5136
+ function start() {
5137
+ if (started || !hasDocument()) return;
5138
+ started = true;
5139
+ refreshRules();
5140
+ sweep();
5141
+ if (typeof MutationObserver === 'function') {
5142
+ observer = new MutationObserver(() => schedule());
5143
+ observer.observe(document.body, { childList: true, subtree: true, characterData: true });
5144
+ }
5145
+ }
5146
+
5147
+ function stop() {
5148
+ started = false;
5149
+ if (observer !== null) observer.disconnect();
5150
+ observer = null;
5151
+ if (timer !== null) clearTimeout(timer);
5152
+ timer = null;
5153
+ }
5154
+
5155
+ return { start, stop, sweep, refreshRules, maskRow, applyMaskRules, compileMaskRules };
5156
+ }
5157
+
5158
+ /** Install the reply-mask observer and keep its compiled rules in sync. */
5159
+ function installReplyMask(ctx) {
5160
+ const core = createReplyMaskCore({
5161
+ isEnabled: () => getSettings().contentRendering,
5162
+ rules: () => activeMaskRules(),
5163
+ });
5164
+ const enabled = () => getSettings().contentRendering;
5165
+ ctx.effect(() => {
5166
+ if (enabled()) core.start();
5167
+ const offSettings = subscribeSettings(() => {
5168
+ if (enabled()) { core.refreshRules(); core.start(); core.sweep(); }
5169
+ else core.stop();
5170
+ });
5171
+ const offRules = subscribeMaskRules(() => {
5172
+ core.refreshRules();
5173
+ if (enabled()) core.sweep();
5174
+ });
5175
+ return () => {
5176
+ offSettings();
5177
+ offRules();
5178
+ core.stop();
5179
+ };
5180
+ }, 'dsh-powerup: reply mask');
5181
+ return core;
5182
+ }
5183
+
4643
5184
  function installStyles(ctx) {
4644
5185
  try {
4645
5186
  const style = document.createElement('style');
4646
5187
  style.setAttribute('data-dsh-powerup', '');
4647
- style.textContent = CSS + '\n' + LAUNCHER_CSS + '\n' + SESSION_SWITCH_CSS + '\n' + LOCATE_CSS + '\n' + PROMPTS_CSS;
5188
+ style.textContent = CSS + '\n' + LAUNCHER_CSS + '\n' + SESSION_SWITCH_CSS + '\n' + LOCATE_CSS + '\n' + SCROLL_TOP_CSS + '\n' + RENDERING_CSS + '\n' + PROMPTS_CSS;
4648
5189
  document.head.appendChild(style);
4649
5190
  ctx.effect(() => () => style.remove(), 'dsh-powerup: styles');
4650
5191
  } catch (error) {
@@ -7651,6 +8192,225 @@ marker is only present while our button is mounted, and the host's
7651
8192
  );
7652
8193
  }
7653
8194
 
8195
+ /**
8196
+ * Shared editor for a list of mask rules. `scope` is 'global' or
8197
+ * 'workspace'; writes go through the matching store functions.
8198
+ */
8199
+ function MaskRuleEditor({ scope, t }) {
8200
+ const rules = useMaskRules();
8201
+ const visible = rules.filter((rule) => (rule.scope || 'global') === scope);
8202
+ const commit = (next) => {
8203
+ if (scope === 'workspace') writeWorkspaceMaskRules(next);
8204
+ else writeGlobalMaskRules(next);
8205
+ };
8206
+ const update = (id, patch) => {
8207
+ commit(visible.map((rule) => (rule.id === id ? { ...rule, ...patch } : rule)));
8208
+ };
8209
+ const remove = (id) => {
8210
+ commit(visible.filter((rule) => rule.id !== id));
8211
+ };
8212
+ const add = () => {
8213
+ commit([...visible, { id: newId(), pattern: '', replacement: '', enabled: true, scope }]);
8214
+ };
8215
+ const title = scope === 'workspace' ? t('mask.workspaceTitle') : t('mask.globalTitle');
8216
+ return h('div', { className: 'dsh-powerup-mask-editor' },
8217
+ h('h3', { className: 'dsh-powerup-section-title' }, title),
8218
+ h('p', { className: 'dsh-powerup-card-desc' }, t('mask.hint')),
8219
+ ...visible.map((rule) => {
8220
+ let invalid = false;
8221
+ if (rule.pattern !== '') {
8222
+ try { new RegExp(rule.pattern); } catch { invalid = true; }
8223
+ }
8224
+ return h('div', { key: rule.id, className: 'dsh-powerup-mask-row' },
8225
+ h('input', {
8226
+ type: 'text',
8227
+ className: 'dsh-powerup-mask-input' + (invalid ? ' invalid' : ''),
8228
+ value: rule.pattern,
8229
+ placeholder: t('mask.patternPlaceholder'),
8230
+ 'aria-label': t('mask.pattern'),
8231
+ title: invalid ? t('mask.invalid') : t('mask.pattern'),
8232
+ onChange: (event) => update(rule.id, { pattern: event.target.value }),
8233
+ }),
8234
+ h('input', {
8235
+ type: 'text',
8236
+ className: 'dsh-powerup-mask-input',
8237
+ value: rule.replacement,
8238
+ placeholder: t('mask.replacementPlaceholder'),
8239
+ 'aria-label': t('mask.replacement'),
8240
+ onChange: (event) => update(rule.id, { replacement: event.target.value }),
8241
+ }),
8242
+ h('button', {
8243
+ type: 'button',
8244
+ role: 'switch',
8245
+ 'aria-checked': rule.enabled ? 'true' : 'false',
8246
+ className: 'dsh-powerup-switch',
8247
+ onClick: () => update(rule.id, { enabled: !rule.enabled }),
8248
+ }, invalid ? t('mask.invalid') : (rule.enabled ? t('page.enabled') : t('page.disabled'))),
8249
+ h('button', {
8250
+ type: 'button',
8251
+ className: 'dsh-powerup-prompt-new',
8252
+ onClick: () => remove(rule.id),
8253
+ }, t('mask.delete')),
8254
+ );
8255
+ }),
8256
+ visible.length === 0 ? h('p', { className: 'dsh-powerup-mask-empty' }, t('mask.empty')) : null,
8257
+ h('button', {
8258
+ type: 'button',
8259
+ className: 'dsh-powerup-prompt-new',
8260
+ onClick: add,
8261
+ }, t('mask.add')),
8262
+ );
8263
+ }
8264
+
8265
+ function useMaskRules() {
8266
+ const [revision, setRevision] = useState(0);
8267
+ useEffect(() => subscribeMaskRules(() => setRevision((v) => v + 1)), []);
8268
+ void revision;
8269
+ return [...globalMaskRules, ...workspaceMaskRules];
8270
+ }
8271
+
8272
+ /**
8273
+ * Two send buttons injected into the composer's right slot. Enter / the
8274
+ * host primary button keep their own behavior; we add explicit queued and
8275
+ * interrupt controls that bypass the system busy-time setting.
8276
+ */
8277
+ function DualSendButtons({ sessionId, useInput, inputActions, ctx, t }) {
8278
+ const settings = useSettings();
8279
+ const draft = typeof useInput === 'function' ? useInput((s) => s.draft) : '';
8280
+ // Session-scope slots usually pass sessionId; fall back to the DOM
8281
+ // contract the rest of this plugin already relies on.
8282
+ const ownerId = () => {
8283
+ if (typeof sessionId === 'string' && sessionId !== '') return sessionId;
8284
+ try {
8285
+ const el = document.querySelector('[data-conversation-session]');
8286
+ const id = el === null ? null : el.getAttribute('data-conversation-session');
8287
+ return typeof id === 'string' && id !== '' ? id : '';
8288
+ } catch {
8289
+ return '';
8290
+ }
8291
+ };
8292
+ const trimmed = typeof draft === 'string' ? draft.trim() : '';
8293
+ const currentDraft = { trimmed, sessionId, inputActions, ctx };
8294
+ const send = (mode, text) => {
8295
+ const value = typeof text === 'string' ? text.trim() : trimmed;
8296
+ const id = ownerId();
8297
+ if (value === '' || id === '') return;
8298
+ try {
8299
+ const sessions = ctx.get('sessions');
8300
+ const binding = sessions?.binding?.(id);
8301
+ const session = binding?.session;
8302
+ if (session === undefined || typeof session.prompt !== 'function') return;
8303
+ const handle = typeof session.beginSubmission === 'function'
8304
+ ? session.beginSubmission({ mode, text: value, attachments: [] })
8305
+ : null;
8306
+ void session.prompt([{ type: 'text', text: value }], mode, undefined, handle?.requestId);
8307
+ if (typeof inputActions?.setDraft === 'function') inputActions.setDraft('');
8308
+ } catch (error) {
8309
+ console.warn('[dsh-powerup] dual send failed:', error?.message ?? error);
8310
+ }
8311
+ };
8312
+ // Capture-phase keymap overrides the host's busy-time send behavior:
8313
+ // Enter always queues, Ctrl/Cmd+Shift+Enter always interrupts. Plain
8314
+ // Shift+Enter (newline), IME composition, and an open command listbox
8315
+ // are left to the host.
8316
+ useEffect(() => {
8317
+ if (!settings.dualSend || typeof document === 'undefined' || document === null) return undefined;
8318
+ const onKeyDown = (event) => {
8319
+ if (event.key !== 'Enter' || event.isComposing === true || event.repeat === true) return;
8320
+ const target = event.target;
8321
+ const editor = target !== null && typeof target.closest === 'function'
8322
+ ? target.closest('[data-composer-input]')
8323
+ : null;
8324
+ if (editor === null) return;
8325
+ if (editor.hasAttribute('data-composer-composing')) return;
8326
+ // An empty draft is the host's retry gesture; leave it alone.
8327
+ if (trimmed === '') return;
8328
+ // Let the host resolve Enter while a / or @ menu (or a selected
8329
+ // command chip) is open — the menu can be portaled outside the card.
8330
+ const openMenu = document.querySelector?.(
8331
+ '[aria-haspopup="listbox"][aria-expanded="true"], [aria-haspopup="menu"][aria-expanded="true"], [role="listbox"]:not([hidden]), [role="menu"]:not([hidden])',
8332
+ );
8333
+ if (openMenu !== null && openMenu !== undefined) return;
8334
+ if (editor.hasAttribute('data-composer-chip-selected')) return;
8335
+ const interrupt = event.shiftKey && (event.ctrlKey || event.metaKey);
8336
+ if (event.shiftKey && !interrupt) return; // plain Shift+Enter = newline
8337
+ if (!interrupt && (event.ctrlKey || event.metaKey || event.altKey)) return;
8338
+ event.preventDefault();
8339
+ event.stopPropagation();
8340
+ send(interrupt ? 'steer' : 'queue');
8341
+ };
8342
+ document.addEventListener('keydown', onKeyDown, true);
8343
+ return () => document.removeEventListener('keydown', onKeyDown, true);
8344
+ }, [settings.dualSend, sessionId, draft, ctx, inputActions]);
8345
+ void currentDraft;
8346
+ if (!settings.dualSend) return null;
8347
+ return h('div', { className: 'dsh-powerup-dual-send' },
8348
+ h('button', {
8349
+ type: 'button',
8350
+ className: 'dsh-powerup-send',
8351
+ 'data-kind': 'wait',
8352
+ 'aria-label': t('send.waitHint'),
8353
+ title: t('send.waitHint'),
8354
+ disabled: trimmed === '',
8355
+ onMouseDown: (event) => event.preventDefault(),
8356
+ onClick: () => send('queue'),
8357
+ }, h('svg', { viewBox: '0 0 16 16', width: 16, height: 16, 'aria-hidden': 'true' },
8358
+ h('path', { d: 'M3 8h9M8.5 4.5 12 8l-3.5 3.5', fill: 'none', stroke: 'currentColor', strokeWidth: 1.4, strokeLinecap: 'round', strokeLinejoin: 'round' }))),
8359
+ h('button', {
8360
+ type: 'button',
8361
+ className: 'dsh-powerup-send',
8362
+ 'data-kind': 'interrupt',
8363
+ 'aria-label': t('send.interruptHint'),
8364
+ title: t('send.interruptHint'),
8365
+ disabled: trimmed === '',
8366
+ onMouseDown: (event) => event.preventDefault(),
8367
+ onClick: () => send('steer'),
8368
+ }, h('svg', { viewBox: '0 0 16 16', width: 16, height: 16, 'aria-hidden': 'true' },
8369
+ h('path', { d: 'M8 2v12M3 6l5-4 5 4', fill: 'none', stroke: 'currentColor', strokeWidth: 1.4, strokeLinecap: 'round', strokeLinejoin: 'round' }))),
8370
+ );
8371
+ }
8372
+
8373
+ /**
8374
+ * Conversation View tab for per-workspace Power-Up settings. Registered
8375
+ * after Trajectory so it appears last in the header tab row.
8376
+ */
8377
+ function WorkspaceSettingsView({ ctx, sessionId, useWorkspaces }) {
8378
+ const settings = useSettings();
8379
+ const rules = useMaskRules();
8380
+ const [, forceLocale] = useState(0);
8381
+ const t = useCallback((key, params) => translateCurrent(key, params), []);
8382
+ useEffect(() => {
8383
+ const off = ctx.locale?.subscribe?.(() => forceLocale((v) => v + 1));
8384
+ return typeof off === 'function' ? off : undefined;
8385
+ }, [ctx]);
8386
+ // Prefer the slot's sessionId; fall back to the live DOM contract.
8387
+ let ownerId = sessionId;
8388
+ if (typeof ownerId !== 'string' || ownerId === '') {
8389
+ try {
8390
+ const el = document.querySelector('[data-conversation-session]');
8391
+ const id = el === null ? null : el.getAttribute('data-conversation-session');
8392
+ if (typeof id === 'string' && id !== '') ownerId = id;
8393
+ } catch { /* keep the empty id */ }
8394
+ }
8395
+ const workspaceSelector = useMemo(() => (snapshot) => resolveWorkspaceIdFromSnapshot(snapshot, ownerId), [ownerId]);
8396
+ const workspaceId = typeof useWorkspaces === 'function' ? useWorkspaces(workspaceSelector) ?? '' : '';
8397
+ useEffect(() => {
8398
+ if (typeof workspaceId === 'string' && workspaceId !== '') void loadWorkspaceMaskRules(workspaceId);
8399
+ }, [workspaceId]);
8400
+ void rules; void settings;
8401
+ return h('div', { className: 'dsh-powerup-page' },
8402
+ h('div', { className: 'dsh-powerup-shell' },
8403
+ h('header', { className: 'dsh-powerup-hero' },
8404
+ h('div', { className: 'dsh-powerup-hero-copy' },
8405
+ h('h1', null, t('mask.sessionTitle')),
8406
+ h('p', null, t('mask.sessionDesc')),
8407
+ ),
8408
+ ),
8409
+ h(MaskRuleEditor, { scope: 'workspace', t }),
8410
+ ),
8411
+ );
8412
+ }
8413
+
7654
8414
  function PromptManager({ ctx }) {
7655
8415
  const prompts = usePrompts();
7656
8416
  const [, forceLocale] = useState(0);
@@ -7893,7 +8653,8 @@ marker is only present while our button is mounted, and the host's
7893
8653
  }, []);
7894
8654
  useEffect(() => {
7895
8655
  if (settings.workspacePrompts === false && tab === 'prompts') setTab('features');
7896
- }, [settings.workspacePrompts, tab]);
8656
+ if (settings.contentRendering === false && tab === 'mask') setTab('features');
8657
+ }, [settings.workspacePrompts, settings.contentRendering, tab]);
7897
8658
  const t = (key, params) => translateCurrent(key, params);
7898
8659
  const actions = [
7899
8660
  { id: 'copy', icon: CopyIcon, name: t('action.copy'), hint: t('action.copyHint') },
@@ -7975,6 +8736,15 @@ marker is only present while our button is mounted, and the host's
7975
8736
  className: 'dsh-powerup-tab' + (tab === 'features' ? ' on' : ''),
7976
8737
  onClick: () => setTab('features'),
7977
8738
  }, t('prompts.tabFeatures')),
8739
+ settings.contentRendering !== false
8740
+ ? h('button', {
8741
+ type: 'button',
8742
+ role: 'tab',
8743
+ 'aria-selected': tab === 'mask' ? 'true' : 'false',
8744
+ className: 'dsh-powerup-tab' + (tab === 'mask' ? ' on' : ''),
8745
+ onClick: () => setTab('mask'),
8746
+ }, t('mask.tab'))
8747
+ : null,
7978
8748
  settings.workspacePrompts !== false
7979
8749
  ? h('button', {
7980
8750
  type: 'button',
@@ -7995,6 +8765,9 @@ marker is only present while our button is mounted, and the host's
7995
8765
  ),
7996
8766
  featureCard('sessionSwitch', QuickIcon, 'page.sessionSwitchTitle', 'page.sessionSwitchDesc', 'page.sessionSwitchHow'),
7997
8767
  featureCard('locateSession', LocateIcon, 'page.locateTitle', 'page.locateDesc', 'page.locateHow'),
8768
+ featureCard('scrollToTop', ScrollTopIcon, 'page.scrollToTopTitle', 'page.scrollToTopDesc', 'page.scrollToTopHow'),
8769
+ featureCard('contentRendering', PowerUpLineIcon, 'page.renderingTitle', 'page.renderingDesc', 'page.renderingHow'),
8770
+ featureCard('dualSend', LauncherIcon, 'page.dualSendTitle', 'page.dualSendDesc', 'page.dualSendHow'),
7998
8771
  featureCard('workspacePrompts', TagIcon, 'page.promptsTitle', 'page.promptsDesc', 'page.promptsHow'),
7999
8772
  featureCard('jobStop', StopIcon, 'page.jobStopTitle', 'page.jobStopDesc', 'page.jobStopHow'),
8000
8773
  featureCard('update', UpdateIcon, 'page.updateTitle', 'page.updateDesc', 'page.updateHow', oneClickDetail),
@@ -8010,9 +8783,11 @@ marker is only present while our button is mounted, and the host's
8010
8783
  ),
8011
8784
  ),
8012
8785
  tabs,
8013
- tab === 'prompts' && settings.workspacePrompts !== false
8014
- ? h(PromptManager, { ctx })
8015
- : featuresContent,
8786
+ tab === 'mask' && settings.contentRendering !== false
8787
+ ? h(MaskRuleEditor, { scope: 'global', t })
8788
+ : tab === 'prompts' && settings.workspacePrompts !== false
8789
+ ? h(PromptManager, { ctx })
8790
+ : featuresContent,
8016
8791
  h('footer', { className: 'dsh-powerup-foot' },
8017
8792
  h('span', null, format(t('page.footer'), { version: VERSION })),
8018
8793
  h('span', { className: 'dsh-powerup-dot' }),
@@ -8059,6 +8834,8 @@ marker is only present while our button is mounted, and the host's
8059
8834
  installLauncher(ctx);
8060
8835
  installSessionSwitcher(ctx);
8061
8836
  installLocateSession(ctx);
8837
+ installScrollToTop(ctx);
8838
+ installReplyMask(ctx);
8062
8839
 
8063
8840
  const slots = ctx.get('slots');
8064
8841
  if (slots === undefined || typeof slots.inject !== 'function' || typeof slots.register !== 'function') {
@@ -8100,6 +8877,26 @@ marker is only present while our button is mounted, and the host's
8100
8877
  order: 60,
8101
8878
  }, HeroPromptsControl, 'dsh-powerup: prompt picker');
8102
8879
 
8880
+ // Session-scope composer controls. These receive sessionId/useInput/
8881
+ // inputActions from the host's conversation slot wiring; the t() locale
8882
+ // seat is provided by the slot, so we wrap to use the plugin dictionary.
8883
+ register('conversation.input.right', {
8884
+ id: 'powerup-dual-send',
8885
+ order: 80,
8886
+ }, (props) => h(DualSendButtons, {
8887
+ ...props,
8888
+ ctx,
8889
+ t: (key, params) => translateCurrent(key, params),
8890
+ }), 'dsh-powerup: dual send buttons');
8891
+
8892
+ // Per-workspace Power-Up settings as a Conversation View tab, ordered
8893
+ // after the host's Trajectory view (order 10).
8894
+ register('conversation.view', {
8895
+ id: 'powerup-settings',
8896
+ order: 20,
8897
+ label: () => translateCurrent('mask.sessionTitle'),
8898
+ }, (props) => h(WorkspaceSettingsView, { ...props, ctx }), 'dsh-powerup: workspace settings view');
8899
+
8103
8900
  // The update control drives the built-in plugin manager through its
8104
8901
  // `remote.pluginManager` namespace. Register it in a nested inject scope
8105
8902
  // so a late-provided service is observed instead of sampled once.
@@ -8157,6 +8954,8 @@ marker is only present while our button is mounted, and the host's
8157
8954
  CSS,
8158
8955
  SESSION_SWITCH_CSS,
8159
8956
  LOCATE_CSS,
8957
+ SCROLL_TOP_CSS,
8958
+ RENDERING_CSS,
8160
8959
  PROMPTS_CSS,
8161
8960
  PROMPTS_LAST_KEY,
8162
8961
  promptCreateDraft,
@@ -8173,7 +8972,9 @@ marker is only present while our button is mounted, and the host's
8173
8972
  buildWorkspaceIndex,
8174
8973
  createSessionSwitcherCore,
8175
8974
  createLocateSessionCore,
8975
+ createScrollToTopCore,
8176
8976
  LocateIcon,
8977
+ ScrollTopIcon,
8177
8978
  LAUNCHER_CSS,
8178
8979
  LAUNCHER_STORAGE_KEY,
8179
8980
  LAUNCHER_CHAT_KEY,
@@ -8235,6 +9036,18 @@ marker is only present while our button is mounted, and the host's
8235
9036
  operationReason,
8236
9037
  restorePreviousBundle,
8237
9038
  runOneClickUpdate,
9039
+ MASK_RULES_KEY,
9040
+ MASK_PLACEHOLDER,
9041
+ readGlobalMaskRules,
9042
+ writeGlobalMaskRules,
9043
+ normalizeMaskRule,
9044
+ activeMaskRules,
9045
+ compileMaskRules,
9046
+ applyMaskRules,
9047
+ createReplyMaskCore,
9048
+ DualSendButtons,
9049
+ MaskRuleEditor,
9050
+ WorkspaceSettingsView,
8238
9051
  },
8239
9052
  };
8240
9053
  },
package/index.js CHANGED
@@ -50,9 +50,11 @@ const SELF_UPDATE_DELAY_MS = 600;
50
50
  /** Request body bound for the small JSON commands. */
51
51
  const BODY_LIMIT = 16 * 1024;
52
52
 
53
- /** Per-workspace prompts live under the workspace's own .dsh directory. */
53
+ /** Per-workspace state files live under the workspace's own .dsh directory. */
54
54
  const PROMPTS_DIR = join('.dsh', 'dsh-powerup');
55
55
  const PROMPTS_FILE = 'prompts.json';
56
+ /** Per-workspace mask rules used by the content-rendering enhancement. */
57
+ const MASK_RULES_FILE = 'mask-rules.json';
56
58
 
57
59
  /** The moment this Host process started; a profile file newer than it may await a restart. */
58
60
  const HOST_STARTED_AT = Date.now() - process.uptime() * 1000;
@@ -348,14 +350,15 @@ export async function performSelfUpdate(ctx, version, registry, options = {}) {
348
350
  }
349
351
 
350
352
  /**
351
- * Absolute path of one workspace's prompt store. The workspace path is
353
+ * Absolute path of one workspace's state file. The workspace path is
352
354
  * canonical (realpath) and the id is a uuid, so a stray id can never escape
353
355
  * into an arbitrary directory.
354
356
  * @param {import('@deepseek-ai/cordis').Context} ctx
355
357
  * @param {string} workspaceId
358
+ * @param {string} fileName
356
359
  * @returns {string | undefined}
357
360
  */
358
- function promptStorePath(ctx, workspaceId) {
361
+ function workspaceStorePath(ctx, workspaceId, fileName) {
359
362
  if (typeof workspaceId !== 'string' || workspaceId === '') return undefined;
360
363
  const registry = ctx?.get?.('workspaceRegistry');
361
364
  const workspace = registry?.get?.(workspaceId);
@@ -363,15 +366,20 @@ function promptStorePath(ctx, workspaceId) {
363
366
  return undefined;
364
367
  }
365
368
  const root = resolvePath(workspace.path);
366
- const target = resolvePath(root, PROMPTS_DIR, PROMPTS_FILE);
369
+ const target = resolvePath(root, PROMPTS_DIR, fileName);
367
370
  // The store must stay inside the workspace, whatever the registry returned.
368
371
  const prefix = root.endsWith(sep) ? root : root + sep;
369
372
  if (!target.startsWith(prefix)) return undefined;
370
373
  return target;
371
374
  }
372
375
 
373
- /** Read one workspace's prompts from disk; a missing file is an empty list. */
374
- function readPromptStore(filePath) {
376
+ /** One workspace's prompt store path. */
377
+ function promptStorePath(ctx, workspaceId) {
378
+ return workspaceStorePath(ctx, workspaceId, PROMPTS_FILE);
379
+ }
380
+
381
+ /** Read one workspace's JSON list from disk; a missing file is an empty list. */
382
+ function readJsonStore(filePath) {
375
383
  try {
376
384
  const parsed = JSON.parse(readFileSync(filePath, 'utf8'));
377
385
  return Array.isArray(parsed) ? parsed : [];
@@ -381,6 +389,11 @@ function readPromptStore(filePath) {
381
389
  }
382
390
  }
383
391
 
392
+ /** Read one workspace's prompts from disk; a missing file is an empty list. */
393
+ function readPromptStore(filePath) {
394
+ return readJsonStore(filePath);
395
+ }
396
+
384
397
  /**
385
398
  * @param {import('node:http').IncomingMessage} req
386
399
  * @param {import('node:http').ServerResponse} res
@@ -394,11 +407,51 @@ async function handle(req, res, ctx) {
394
407
 
395
408
  const url = new URL(req.url ?? ROUTE, 'http://localhost');
396
409
  const op = url.pathname.slice(ROUTE.length).replace(/^\/+/u, '') || url.searchParams.get('op') || '';
397
- if (op !== '' && op !== 'restart' && op !== 'close' && op !== 'self-update' && op !== 'audit' && op !== 'job-kill' && op !== 'prompts') {
410
+ if (op !== '' && op !== 'restart' && op !== 'close' && op !== 'self-update' && op !== 'audit' && op !== 'job-kill' && op !== 'prompts' && op !== 'mask-rules') {
398
411
  sendJson(res, { ok: false, error: 'not-found' }, 404);
399
412
  return;
400
413
  }
401
414
 
415
+ if (op === 'mask-rules') {
416
+ const targetId = req.method === 'GET'
417
+ ? (url.searchParams.get('workspaceId') ?? '')
418
+ : '';
419
+ let workspaceId = targetId;
420
+ if (req.method === 'POST') {
421
+ try {
422
+ const body = await readJsonBody(req);
423
+ workspaceId = typeof body?.workspaceId === 'string' ? body.workspaceId.trim() : '';
424
+ const filePath = workspaceStorePath(ctx, workspaceId, MASK_RULES_FILE);
425
+ if (filePath === undefined) {
426
+ sendJson(res, { ok: false, code: 'workspace-not-found', error: 'workspace not found' }, 404);
427
+ return;
428
+ }
429
+ const rules = Array.isArray(body?.rules) ? body.rules : [];
430
+ mkdirSync(dirname(filePath), { recursive: true });
431
+ writeFileSync(filePath, JSON.stringify(rules, null, 2) + '\n', 'utf8');
432
+ sendJson(res, { ok: true, workspaceId, rules });
433
+ } catch (error) {
434
+ sendJson(res, { ok: false, error: String(error?.message ?? error) }, 500);
435
+ }
436
+ return;
437
+ }
438
+ if (req.method !== 'GET') {
439
+ sendJson(res, { ok: false, error: 'method-not-allowed' }, 405);
440
+ return;
441
+ }
442
+ try {
443
+ const filePath = workspaceStorePath(ctx, workspaceId, MASK_RULES_FILE);
444
+ if (filePath === undefined) {
445
+ sendJson(res, { ok: false, code: 'workspace-not-found', error: 'workspace not found' }, 404);
446
+ return;
447
+ }
448
+ sendJson(res, { ok: true, workspaceId, rules: readJsonStore(filePath) });
449
+ } catch (error) {
450
+ sendJson(res, { ok: false, error: String(error?.message ?? error) }, 500);
451
+ }
452
+ return;
453
+ }
454
+
402
455
  if (op === 'prompts') {
403
456
  // The active workspace's directory holds the whole prompt store, including
404
457
  // prompts scoped to other workspaces and the "all workspaces" ones.
@@ -591,6 +644,9 @@ export const __test = {
591
644
  profileDirectory,
592
645
  promptStorePath,
593
646
  readPromptStore,
647
+ workspaceStorePath,
648
+ readJsonStore,
649
+ MASK_RULES_FILE,
594
650
  HOST_STARTED_AT,
595
651
  SELF_VERSION,
596
652
  ROUTE,
package/locale/en.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "Power-Up",
4
- "description": "Adds a right-click action menu to the Trajectory ledger: copy a record, copy a Markdown quote, quote it into the composer, open the record inspector, fork the session at that record, copy a step reference (session id + step id) that the read-only powerup_step_read tool resolves back into the raw session data, export the trajectory snapshot, and copy the session ID. The session header background jobs panel gains an optional stop reason when a job is stopped by hand; the reason is appended to the completion notice injected into the session. The Plugins page gains an install control on every third-party installed plugin: read versions from the registry, install the version in the input through the Add plugin path (removing the old copy first), then enable and optionally restart DSH. The install panel also offers a one-click install that installs the input version without the enable and restart questions, enabling and restarting automatically by default; both defaults are configurable on the Power-Up page. A sidebar launcher turns the left sidebar panel buttons into an adaptive icon grid (icon above label) with drag sorting and folders: drop an icon onto the middle of another to fold them into a folder like a Windows Start menu folder, click a folder to open its icons in a flyout, and switch the whole grid off on the Power-Up page. The grid also carries three built-in buttons — back to conversation, restart DSH and close DSH — and they, like the host more entry, can be dragged into a folder; restart and close reuse the install flow's confirmation dialog. Workspace prompts: once enabled on the Power-Up page, a dropdown next to the Agent preset in the New Session row lists prompts saved for the current workspace; picking one fills the composer for further editing, or a per-row Send now button submits it right away, and a new prompt can be created from the dropdown or a dedicated management tab."
4
+ "description": "Independently toggleable upgrades for DeepSeek Harness on the Power-Up page: trajectory context menu and step references, job stop reasons, one-click plugin install, sidebar icon grid and back-to-top, session switching and locating, workspace prompts, plus conversation rendering enhancements (regex reply masking) and dual send buttons (queued/interrupt)."
5
5
  }
6
6
  }
package/locale/zh.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "Power-Up",
4
- "description": "在轨迹页面为记录增加右键操作菜单:复制内容、复制 Markdown 引用、引用到输入框、查看记录详情、从该记录 Fork 会话、复制「会话 ID + 步骤 ID」的步骤引用(Agent 用只读工具 powerup_step_read 取回该步骤完整数据)、导出轨迹快照、复制会话 ID。在会话顶部的后台任务面板手动停止任务时可以填写停止原因,原因会附加在任务结束后注入会话的提示里。插件页为每个第三方已安装插件增加安装按钮:从安装源读取版本,按输入框中的版本先卸载旧版再按「添加插件」流程安装,完成后可立即启用并选择是否重启 DSH。安装面板还提供「一键安装」:按输入框版本安装并跳过启用与重启的询问,默认自动启用并重启,可在 Power-Up 页面调整默认行为。侧边栏启动器把左侧边栏的面板按钮变成随宽度自适应的图标网格(图标在上、文字在下),支持拖拽排序与分组:把一个图标拖到另一个图标的中间即可合并成分组(像 Windows 开始菜单的文件夹),点击分组会以浮层弹出其中的图标;可在 Power-Up 页面整体关闭。网格里自带「返回会话」「重启 DSH」「关闭 DSH」三个按钮,它们和「更多」一样可以拖进分组;重启与关闭沿用插件安装流程的确认对话框。工作区提示词:在 Power-Up 页启用后,新会话行的 Agent 预设右侧下拉列表列出当前工作区的提示词,点击提示词填入输入框继续编辑,也可点右侧「直接发送」立即发出;下拉里可创建新提示词,并有一个专用标签页统一管理。"
4
+ "description": "为 DeepSeek Harness 提供一组可在 Power-Up 页面独立开关的增强:轨迹右键菜单与步骤引用、后台任务停止原因、插件一键安装、侧边栏图标网格与回到顶部、会话切换与定位、工作区提示词,以及会话内容渲染增强(回复内容正则屏蔽)和双发送按钮(等待/插话)。"
5
5
  }
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@restregular/dsh-powerup",
3
- "version": "0.8.18",
3
+ "version": "0.9.0",
4
4
  "description": "为 DeepSeek Harness 提供一组可选的小型增强:轨迹右键菜单与步骤引用、后台任务停止原因、插件一键安装、侧边栏图标网格、会话切换、定位当前会话、工作区提示词;所有功能均可在 Power-Up 页面独立开关。 · Opt-in upgrades for DeepSeek Harness: Trajectory context menu and step references, job stop reasons, one-click plugin install, an adaptive sidebar launcher, session switching, locating the current session, and workspace prompts — each toggled independently on the Power-Up page.",
5
5
  "icon": "./icon.svg",
6
6
  "type": "module",