@restregular/dsh-powerup 0.10.0 → 0.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +2 -1
  2. package/client.js +197 -128
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -189,7 +189,8 @@ Save reusable prompts and drop one into a new session without retyping it.
189
189
  picker also appears in the composer's bottom tool row, just right of the
190
190
  permission dropdown; there its menu opens **upward**. **Clicking a prompt
191
191
  fills the composer** so you can keep editing before sending. Each row also has
192
- a **Send now** button that fills and submits immediately.
192
+ a **Send now** button that fills and submits immediately, and an **Edit** icon
193
+ button that opens the prompt dialog to change its title, scope and text.
193
194
  - **Create a new prompt…** in the dropdown opens an in-conversation dialog. A
194
195
  prompt created here is pinned to the current workspace — you may only keep
195
196
  that scope or switch to **All workspaces**, never pick another workspace.
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.10.0';
86
+ const VERSION = '0.10.2';
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. */
@@ -382,6 +382,8 @@
382
382
  'prompts.createNew': '创建新的提示词…',
383
383
  'prompts.noPrompts': '这个工作区还没有提示词',
384
384
  'prompts.createTitle': '新建提示词',
385
+ 'prompts.editTitle': '编辑提示词',
386
+ 'prompts.editHint': '修改这条提示词的标题、可见范围与正文。',
385
387
  'prompts.createScopeHint': '这个提示词会自动归属到当前工作区;你也可以改为「所有工作区」。',
386
388
  'prompts.createFailed': '创建失败:{message}',
387
389
  'prompts.workspaceCurrent': '当前工作区',
@@ -674,6 +676,8 @@
674
676
  'prompts.createNew': 'Create a new prompt…',
675
677
  'prompts.noPrompts': 'No prompts for this workspace yet',
676
678
  'prompts.createTitle': 'New prompt',
679
+ 'prompts.editTitle': 'Edit prompt',
680
+ 'prompts.editHint': 'Change this prompt\'s title, scope and text.',
677
681
  'prompts.createScopeHint': 'This prompt will belong to the current workspace automatically; you can also choose "All workspaces".',
678
682
  'prompts.createFailed': 'Could not create: {message}',
679
683
  'prompts.workspaceCurrent': 'Current workspace',
@@ -2856,7 +2860,7 @@
2856
2860
  * Open the prompt picker next to the hero control. Returns a disposer.
2857
2861
  * DOM-based like the session switcher so it survives host re-renders.
2858
2862
  */
2859
- function openPromptPopover({ anchor, t, items, onPick, onSend, onCreate, onDispose, placement }) {
2863
+ function openPromptPopover({ anchor, t, items, onPick, onSend, onEdit, onCreate, onDispose, placement }) {
2860
2864
  if (anchor === null || anchor === undefined || typeof document === 'undefined') return () => {};
2861
2865
  const element = document.createElement('div');
2862
2866
  element.className = 'dsh-powerup-prompt-pop';
@@ -2926,7 +2930,25 @@
2926
2930
  dispose();
2927
2931
  onSend(prompt);
2928
2932
  });
2929
- row.append(main, send);
2933
+ row.append(main);
2934
+ if (typeof onEdit === 'function') {
2935
+ const edit = document.createElement('button');
2936
+ edit.type = 'button';
2937
+ edit.className = 'dsh-powerup-prompt-pop-edit';
2938
+ edit.setAttribute('data-prompt-edit', prompt.id);
2939
+ edit.setAttribute('aria-label', t('prompts.edit'));
2940
+ edit.setAttribute('title', t('prompts.edit'));
2941
+ // Icon-only edit action; label moved to title/aria-label above.
2942
+ edit.innerHTML = '<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true" focusable="false"><path d="M11.2 2.6a1.3 1.3 0 0 1 1.8 1.8L6 11.4l-2.4.6.6-2.4 7-7Z" stroke="currentColor" stroke-width="1.2" stroke-linejoin="round"/><path d="M3 14h10" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"/></svg>';
2943
+ edit.addEventListener('click', (event) => {
2944
+ event.preventDefault();
2945
+ event.stopPropagation();
2946
+ dispose();
2947
+ onEdit(prompt);
2948
+ });
2949
+ row.append(edit);
2950
+ }
2951
+ row.append(send);
2930
2952
  list.appendChild(row);
2931
2953
  }
2932
2954
  element.appendChild(list);
@@ -2986,28 +3008,34 @@
2986
3008
  }
2987
3009
 
2988
3010
  /**
2989
- * In-conversation create dialog. The workspace is pinned to the session's
2990
- * own workspace: the user may only keep it or switch to "all workspaces",
2991
- * never pick another workspace.
3011
+ * In-conversation prompt dialog: creates a new prompt, or edits an
3012
+ * existing one when `prompt` is passed. For creation the workspace is
3013
+ * pinned to the session's own workspace: the user may only keep it or
3014
+ * switch to "all workspaces", never pick another workspace.
2992
3015
  */
2993
- function PromptCreateModal({ workspaceId, workspaceTitle, onClose, onCreated }) {
3016
+ function PromptCreateModal({ workspaceId, workspaceTitle, onClose, onCreated, prompt, onUpdated }) {
2994
3017
  const t = (key, params) => translateCurrent(key, params);
2995
- const fixedScope = typeof workspaceId !== 'string' || workspaceId === '';
2996
- // Reopening the dialog for the same workspace restores the previous
2997
- // draft; switching to another workspace starts from a clean slate.
2998
- const sameWorkspace = promptCreateDraft.workspaceId === (fixedScope ? '' : workspaceId);
2999
- if (!sameWorkspace) {
3000
- promptCreateDraft.workspaceId = fixedScope ? '' : workspaceId;
3001
- promptCreateDraft.title = '';
3002
- promptCreateDraft.text = '';
3003
- promptCreateDraft.scope = fixedScope ? 'all' : 'current';
3004
- }
3005
- const [title, setTitle] = useState(promptCreateDraft.title);
3006
- const [text, setText] = useState(promptCreateDraft.text);
3007
- const [scope, setScope] = useState(promptCreateDraft.scope);
3018
+ const editing = prompt !== null && prompt !== undefined && typeof prompt === 'object';
3019
+ const fixedScope = !editing && (typeof workspaceId !== 'string' || workspaceId === '');
3020
+ if (!editing) {
3021
+ // Reopening the dialog for the same workspace restores the previous
3022
+ // draft; switching to another workspace starts from a clean slate.
3023
+ const sameWorkspace = promptCreateDraft.workspaceId === (fixedScope ? '' : workspaceId);
3024
+ if (!sameWorkspace) {
3025
+ promptCreateDraft.workspaceId = fixedScope ? '' : workspaceId;
3026
+ promptCreateDraft.title = '';
3027
+ promptCreateDraft.text = '';
3028
+ promptCreateDraft.scope = fixedScope ? 'all' : 'current';
3029
+ }
3030
+ }
3031
+ const [title, setTitle] = useState(editing ? (prompt.title || '') : promptCreateDraft.title);
3032
+ const [text, setText] = useState(editing ? (prompt.text || '') : promptCreateDraft.text);
3033
+ const [scope, setScope] = useState(editing
3034
+ ? (prompt.workspaceId && prompt.workspaceId === workspaceId ? 'current' : 'all')
3035
+ : promptCreateDraft.scope);
3008
3036
  const titleRef = useRef(null);
3009
3037
  // Close plays an exit animation first, so the dialog does not vanish
3010
- // abruptly; the draft is already persisted by the effect below.
3038
+ // abruptly; the create draft is already persisted by the effect below.
3011
3039
  const [closing, setClosing] = useState(false);
3012
3040
  const closingRef = useRef(false);
3013
3041
  const requestClose = () => {
@@ -3023,10 +3051,11 @@
3023
3051
  }, 140);
3024
3052
  };
3025
3053
  useEffect(() => {
3054
+ if (editing) return;
3026
3055
  promptCreateDraft.title = title;
3027
3056
  promptCreateDraft.text = text;
3028
3057
  promptCreateDraft.scope = scope;
3029
- }, [title, text, scope]);
3058
+ }, [title, text, scope, editing]);
3030
3059
  useEffect(() => {
3031
3060
  try {
3032
3061
  // preventScroll keeps the focus from scrolling the page mid-animation.
@@ -3048,19 +3077,34 @@
3048
3077
  const save = () => {
3049
3078
  const body = typeof text === 'string' ? text.trim() : '';
3050
3079
  if (body === '') return;
3051
- const record = {
3052
- id: newId(),
3053
- title: typeof title === 'string' ? title.trim() : '',
3054
- text: body,
3055
- workspaceId: scope === 'current' && typeof workspaceId === 'string' ? workspaceId : '',
3056
- };
3057
3080
  const list = readPrompts();
3058
- list.push(record);
3081
+ let record;
3082
+ if (editing) {
3083
+ record = {
3084
+ id: prompt.id,
3085
+ title: typeof title === 'string' ? title.trim() : '',
3086
+ text: body,
3087
+ workspaceId: scope === 'current' && typeof workspaceId === 'string' ? workspaceId : '',
3088
+ };
3089
+ const index = list.findIndex((p) => p.id === record.id);
3090
+ if (index === -1) list.push(record);
3091
+ else list[index] = record;
3092
+ } else {
3093
+ record = {
3094
+ id: newId(),
3095
+ title: typeof title === 'string' ? title.trim() : '',
3096
+ text: body,
3097
+ workspaceId: scope === 'current' && typeof workspaceId === 'string' ? workspaceId : '',
3098
+ };
3099
+ list.push(record);
3100
+ }
3059
3101
  writePrompts(list);
3060
- // The draft became a real prompt: the next dialog starts empty.
3061
- promptCreateDraft.title = '';
3062
- promptCreateDraft.text = '';
3063
- promptCreateDraft.scope = fixedScope ? 'all' : 'current';
3102
+ if (!editing) {
3103
+ // The draft became a real prompt: the next dialog starts empty.
3104
+ promptCreateDraft.title = '';
3105
+ promptCreateDraft.text = '';
3106
+ promptCreateDraft.scope = fixedScope ? 'all' : 'current';
3107
+ }
3064
3108
  // Play the exit animation before telling the parent to unmount.
3065
3109
  if (!closingRef.current) {
3066
3110
  closingRef.current = true;
@@ -3068,7 +3112,11 @@
3068
3112
  }
3069
3113
  setTimeout(() => {
3070
3114
  try {
3071
- onCreated(record);
3115
+ if (editing) {
3116
+ if (typeof onUpdated === 'function') onUpdated(record);
3117
+ } else if (typeof onCreated === 'function') {
3118
+ onCreated(record);
3119
+ }
3072
3120
  } catch {
3073
3121
  /* The parent owns unmounting. */
3074
3122
  }
@@ -3088,13 +3136,13 @@
3088
3136
  className: 'dsh-powerup-prompt-modal' + (closing ? ' is-closing' : ''),
3089
3137
  role: 'dialog',
3090
3138
  'aria-modal': 'true',
3091
- 'aria-label': t('prompts.createTitle'),
3139
+ 'aria-label': t(editing ? 'prompts.editTitle' : 'prompts.createTitle'),
3092
3140
  },
3093
3141
  h('div', { className: 'dsh-powerup-prompt-modal-head' },
3094
3142
  h('div', null,
3095
- h('div', { className: 'dsh-powerup-prompt-modal-heading' }, t('prompts.createTitle')),
3143
+ h('div', { className: 'dsh-powerup-prompt-modal-heading' }, t(editing ? 'prompts.editTitle' : 'prompts.createTitle')),
3096
3144
  h('p', { className: 'dsh-powerup-prompt-modal-sub' },
3097
- fixedScope ? t('prompts.workspaceNone') : t('prompts.createScopeHint')),
3145
+ editing ? t('prompts.editHint') : (fixedScope ? t('prompts.workspaceNone') : t('prompts.createScopeHint'))),
3098
3146
  ),
3099
3147
  h('button', {
3100
3148
  type: 'button',
@@ -3150,7 +3198,7 @@
3150
3198
  className: 'dsh-powerup-prompt-modal-save',
3151
3199
  disabled: text.trim() === '',
3152
3200
  onClick: save,
3153
- }, t('prompts.create')),
3201
+ }, t(editing ? 'prompts.save' : 'prompts.create')),
3154
3202
  ),
3155
3203
  ),
3156
3204
  ));
@@ -3174,6 +3222,7 @@
3174
3222
  const prompts = usePrompts(workspaceId);
3175
3223
  const [, forceLocale] = useState(0);
3176
3224
  const [creating, setCreating] = useState(false);
3225
+ const [editing, setEditing] = useState(null);
3177
3226
  const anchorRef = useRef(null);
3178
3227
  const disposeRef = useRef(null);
3179
3228
  const t = (key, params) => translateCurrent(key, params);
@@ -3263,6 +3312,7 @@
3263
3312
  placement: (node) => popoverPlacement(node, 360, 340, { preferUp: compact }),
3264
3313
  onPick: (prompt) => apply(prompt, false),
3265
3314
  onSend: (prompt) => apply(prompt, true),
3315
+ onEdit: (prompt) => setEditing(prompt),
3266
3316
  onCreate: () => setCreating(true),
3267
3317
  onDispose: () => {
3268
3318
  disposeRef.current = null;
@@ -3299,6 +3349,15 @@
3299
3349
  },
3300
3350
  })
3301
3351
  : null,
3352
+ editing
3353
+ ? h(PromptCreateModal, {
3354
+ workspaceId,
3355
+ workspaceTitle,
3356
+ prompt: editing,
3357
+ onClose: () => setEditing(null),
3358
+ onUpdated: () => setEditing(null),
3359
+ })
3360
+ : null,
3302
3361
  );
3303
3362
  }
3304
3363
 
@@ -3939,9 +3998,6 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
3939
3998
  .dsh-powerup-send[data-kind="interrupt"]{color:var(--dsw-alias-state-warn-label,var(--dsw-alias-label-secondary))}
3940
3999
  .dsh-powerup-send svg{width:16px;height:16px}
3941
4000
  .dsh-powerup-dual-send{display:inline-flex;align-items:center;gap:4px}
3942
- /* Our buttons replace the host's primary button while the draft has text. The
3943
- component marks the host button with data-powerup-send-hidden. */
3944
- [data-powerup-send-hidden]{display:none!important}
3945
4001
  .dsh-powerup-mask-editor{display:flex;flex-direction:column;gap:10px}
3946
4002
  .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)}
3947
4003
  .dsh-powerup-mask-default.on{background:var(--dsw-alias-brand-primary);color:var(--dsw-alias-bg-layer-1);border-color:var(--dsw-alias-brand-primary)}
@@ -3979,10 +4035,10 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
3979
4035
  .dsh-powerup-prompt-pop-main{flex:1 1 auto;display:flex;flex-direction:column;gap:1px;min-width:0;padding:3px 0;border:0;background:transparent;color:inherit;font:inherit;text-align:left;cursor:pointer}
3980
4036
  .dsh-powerup-prompt-pop-name{display:block;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12.5px;line-height:18px}
3981
4037
  .dsh-powerup-prompt-pop-preview{display:block;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--dsw-alias-label-tertiary);font-size:10.5px;line-height:15px}
3982
- .dsh-powerup-prompt-pop-send{flex:none;display:inline-flex;align-items:center;justify-content:center;width:26px;height:26px;padding:0;border:.5px solid var(--dsw-alias-border-l2);border-radius:7px;background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-secondary);font:inherit;line-height:1;cursor:pointer;transition:background .12s ease,color .12s ease,border-color .12s ease}
3983
- .dsh-powerup-prompt-pop-send svg{width:14px;height:14px}
3984
- .dsh-powerup-prompt-pop-send:hover{border-color:var(--dsw-alias-state-business-primary);background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-brand-primary)}
3985
- .dsh-powerup-prompt-pop-send:focus-visible,.dsh-powerup-prompt-pop-main:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:-1px}
4038
+ .dsh-powerup-prompt-pop-send,.dsh-powerup-prompt-pop-edit{flex:none;display:inline-flex;align-items:center;justify-content:center;width:26px;height:26px;padding:0;border:.5px solid var(--dsw-alias-border-l2);border-radius:7px;background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-secondary);font:inherit;line-height:1;cursor:pointer;transition:background .12s ease,color .12s ease,border-color .12s ease}
4039
+ .dsh-powerup-prompt-pop-send svg,.dsh-powerup-prompt-pop-edit svg{width:14px;height:14px}
4040
+ .dsh-powerup-prompt-pop-send:hover,.dsh-powerup-prompt-pop-edit:hover{border-color:var(--dsw-alias-state-business-primary);background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-brand-primary)}
4041
+ .dsh-powerup-prompt-pop-send:focus-visible,.dsh-powerup-prompt-pop-edit:focus-visible,.dsh-powerup-prompt-pop-main:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:-1px}
3986
4042
  .dsh-powerup-prompt-pop-sep{flex:none;height:1px;margin:4px 6px;background:var(--dsw-alias-border-l1)}
3987
4043
  .dsh-powerup-prompt-pop-create{flex:none;display:flex;align-items:center;gap:7px;width:100%;min-height:32px;padding:0 10px;border:0;border-radius:var(--dsw-radius-md,8px);background:transparent;color:var(--dsw-alias-brand-primary);font:inherit;font-size:12px;line-height:18px;cursor:pointer}
3988
4044
  .dsh-powerup-prompt-pop-create:hover{background:var(--dsw-alias-interactive-bg-hover)}
@@ -8437,6 +8493,55 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
8437
8493
  return running;
8438
8494
  }
8439
8495
 
8496
+ /**
8497
+ * The host's live "busy Enter" preference: 'queue' or 'steer'. The host
8498
+ * composer resolves plain Enter (and its single Send button) with this
8499
+ * value, so knowing it tells us which delivery mode the native button
8500
+ * already covers. Reads the Host config form for the ui-conversation
8501
+ * namespace and subscribes, so a Settings change applies immediately.
8502
+ */
8503
+ function useHostBusyEnter(ctx) {
8504
+ const formOf = useCallback(() => {
8505
+ try {
8506
+ return ctx.get('configForms')?.get?.('ui-conversation');
8507
+ } catch {
8508
+ return undefined;
8509
+ }
8510
+ }, [ctx]);
8511
+ const read = useCallback(() => {
8512
+ try {
8513
+ const value = formOf()?.getSnapshot?.()?.value;
8514
+ const behavior = value !== null && typeof value === 'object' ? value.busyEnter : undefined;
8515
+ return behavior === 'steer' ? 'steer' : 'queue';
8516
+ } catch {
8517
+ return 'queue';
8518
+ }
8519
+ }, [formOf]);
8520
+ const [behavior, setBehavior] = useState(read);
8521
+ useEffect(() => {
8522
+ setBehavior(read());
8523
+ let off;
8524
+ let timer;
8525
+ // The settings service may be provided after this plugin applies;
8526
+ // keep looking briefly instead of latching onto a missing service.
8527
+ const attach = (attempt) => {
8528
+ const form = formOf();
8529
+ if (form !== undefined && typeof form.subscribe === 'function') {
8530
+ off = form.subscribe(() => setBehavior(read()));
8531
+ return;
8532
+ }
8533
+ if (attempt >= 20) return;
8534
+ timer = setTimeout(() => attach(attempt + 1), 500);
8535
+ };
8536
+ attach(0);
8537
+ return () => {
8538
+ if (timer !== undefined) clearTimeout(timer);
8539
+ if (typeof off === 'function') off();
8540
+ };
8541
+ }, [read, formOf]);
8542
+ return behavior;
8543
+ }
8544
+
8440
8545
  function DualSendButtons({ sessionId, useInput, inputActions, ctx, t }) {
8441
8546
  const settings = useSettings();
8442
8547
  const draft = typeof useInput === 'function' ? useInput((s) => s.draft) : '';
@@ -8457,6 +8562,8 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
8457
8562
  // "queue" vs "interrupt" is meaningless on an idle session, where the
8458
8563
  // host's single Send button is the correct affordance.
8459
8564
  const sessionRunning = useSessionRunning(ctx, sessionId);
8565
+ // Which strategy the host's own Send button already covers while busy.
8566
+ const busyEnter = useHostBusyEnter(ctx);
8460
8567
  const currentDraft = { trimmed, sessionId, inputActions, ctx };
8461
8568
  const send = (mode, text) => {
8462
8569
  const value = typeof text === 'string' ? text.trim() : trimmed;
@@ -8476,10 +8583,10 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
8476
8583
  console.warn('[dsh-powerup] dual send failed:', error?.message ?? error);
8477
8584
  }
8478
8585
  };
8479
- // Capture-phase keymap overrides the host's busy-time send behavior:
8480
- // Enter always queues, Ctrl/Cmd+Shift+Enter always interrupts. Plain
8481
- // Shift+Enter (newline), IME composition, and an open command listbox
8482
- // are left to the host.
8586
+ // Accelerated Enter (Ctrl/Cmd+Shift+Enter) delivers the strategy the
8587
+ // host's plain Enter does NOT use — the same split as the button pair.
8588
+ // Plain Enter and Shift+Enter stay entirely with the host so the
8589
+ // "busy Enter" setting keeps its meaning.
8483
8590
  useEffect(() => {
8484
8591
  if (!settings.dualSend || typeof document === 'undefined' || document === null) return undefined;
8485
8592
  const onKeyDown = (event) => {
@@ -8500,95 +8607,51 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
8500
8607
  if (openMenu !== null && openMenu !== undefined) return;
8501
8608
  if (editor.hasAttribute('data-composer-chip-selected')) return;
8502
8609
  const interrupt = event.shiftKey && (event.ctrlKey || event.metaKey);
8503
- if (event.shiftKey && !interrupt) return; // plain Shift+Enter = newline
8504
- if (!interrupt && (event.ctrlKey || event.metaKey || event.altKey)) return;
8610
+ if (!interrupt) return; // plain Enter / Shift+Enter belong to the host
8611
+ if (!sessionRunning) return;
8505
8612
  event.preventDefault();
8506
8613
  event.stopPropagation();
8507
- send(interrupt ? 'steer' : 'queue');
8614
+ send(busyEnter === 'steer' ? 'queue' : 'steer');
8508
8615
  };
8509
8616
  document.addEventListener('keydown', onKeyDown, true);
8510
8617
  return () => document.removeEventListener('keydown', onKeyDown, true);
8511
- }, [settings.dualSend, sessionId, draft, ctx, inputActions]);
8618
+ }, [settings.dualSend, sessionId, draft, ctx, inputActions, sessionRunning, busyEnter]);
8512
8619
  void currentDraft;
8513
- // Replace the host's single primary button with our two only while the
8514
- // composer holds text AND the session is working. An idle session (or
8515
- // an empty draft) keeps the native button, where it is Send or Stop.
8620
+ // Our extra button only appears while the session is actually working and
8621
+ // the draft has text: that is when queue-vs-steer is a real choice. An
8622
+ // idle session (or an empty draft) keeps just the native button.
8516
8623
  const active = settings.dualSend && trimmed !== '' && sessionRunning;
8517
8624
  const wrapRef = useRef(null);
8518
- useEffect(() => {
8519
- if (!settings.dualSend || typeof document === 'undefined' || document === null) return undefined;
8520
- const clearAll = () => {
8521
- for (const node of document.querySelectorAll('[data-powerup-send-hidden]')) {
8522
- node.removeAttribute('data-powerup-send-hidden');
8523
- }
8524
- };
8525
- if (!active) {
8526
- clearAll();
8527
- return undefined;
8528
- }
8529
- // Walk up from our own slot to the row that directly holds the host's
8530
- // send buttons, then take its LAST direct button child — that is the
8531
- // primary send/stop control (the optional interrupt-stop precedes it).
8532
- const findScope = () => {
8533
- let node = wrapRef.current;
8534
- for (let depth = 0; node !== null && depth < 8; depth += 1) {
8535
- const direct = typeof node.querySelectorAll === 'function'
8536
- ? node.querySelectorAll(':scope > button')
8537
- : [];
8538
- if (direct.length > 0) return node;
8539
- node = node.parentElement;
8540
- }
8541
- return null;
8542
- };
8543
- const mark = () => {
8544
- const scope = findScope();
8545
- if (scope === null) return;
8546
- const direct = [...scope.querySelectorAll(':scope > button')];
8547
- const primary = direct[direct.length - 1];
8548
- if (primary === undefined) return;
8549
- primary.setAttribute('data-powerup-send-hidden', '');
8550
- };
8551
- mark();
8552
- let scheduled = false;
8553
- const schedule = () => {
8554
- if (scheduled) return;
8555
- scheduled = true;
8556
- queueMicrotask(() => {
8557
- scheduled = false;
8558
- mark();
8559
- });
8560
- };
8561
- const observer = typeof MutationObserver === 'function' ? new MutationObserver(schedule) : null;
8562
- observer?.observe(document.body, { childList: true, subtree: true });
8563
- return () => {
8564
- observer?.disconnect();
8565
- clearAll();
8566
- };
8567
- }, [settings.dualSend, active]);
8568
8625
  if (!active) return null;
8626
+ // The host's own Send button already delivers `busyEnter` (that is the
8627
+ // value plain Enter resolves to while busy). So we only contribute the
8628
+ // OTHER strategy — one button, never both, and never a duplicate of what
8629
+ // the native button does.
8630
+ const ours = busyEnter === 'steer' ? 'queue' : 'steer';
8569
8631
  return h('div', { className: 'dsh-powerup-dual-send', ref: wrapRef },
8570
- h('button', {
8571
- type: 'button',
8572
- className: 'dsh-powerup-send',
8573
- 'data-kind': 'wait',
8574
- 'aria-label': t('send.waitHint'),
8575
- title: t('send.waitHint'),
8576
- disabled: trimmed === '',
8577
- onMouseDown: (event) => event.preventDefault(),
8578
- onClick: () => send('queue'),
8579
- }, h('svg', { viewBox: '0 0 16 16', width: 16, height: 16, 'aria-hidden': 'true' },
8580
- 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' }))),
8581
- h('button', {
8582
- type: 'button',
8583
- className: 'dsh-powerup-send',
8584
- 'data-kind': 'interrupt',
8585
- 'aria-label': t('send.interruptHint'),
8586
- title: t('send.interruptHint'),
8587
- disabled: trimmed === '',
8588
- onMouseDown: (event) => event.preventDefault(),
8589
- onClick: () => send('steer'),
8590
- }, h('svg', { viewBox: '0 0 16 16', width: 16, height: 16, 'aria-hidden': 'true' },
8591
- h('path', { d: 'M8 2v12M3 6l5-4 5 4', fill: 'none', stroke: 'currentColor', strokeWidth: 1.4, strokeLinecap: 'round', strokeLinejoin: 'round' }))),
8632
+ ours === 'queue'
8633
+ ? h('button', {
8634
+ type: 'button',
8635
+ className: 'dsh-powerup-send',
8636
+ 'data-kind': 'wait',
8637
+ 'aria-label': t('send.waitHint'),
8638
+ title: t('send.waitHint'),
8639
+ disabled: trimmed === '',
8640
+ onMouseDown: (event) => event.preventDefault(),
8641
+ onClick: () => send('queue'),
8642
+ }, h('svg', { viewBox: '0 0 16 16', width: 16, height: 16, 'aria-hidden': 'true' },
8643
+ 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' })))
8644
+ : h('button', {
8645
+ type: 'button',
8646
+ className: 'dsh-powerup-send',
8647
+ 'data-kind': 'interrupt',
8648
+ 'aria-label': t('send.interruptHint'),
8649
+ title: t('send.interruptHint'),
8650
+ disabled: trimmed === '',
8651
+ onMouseDown: (event) => event.preventDefault(),
8652
+ onClick: () => send('steer'),
8653
+ }, h('svg', { viewBox: '0 0 16 16', width: 16, height: 16, 'aria-hidden': 'true' },
8654
+ h('path', { d: 'M8 2v12M3 6l5-4 5 4', fill: 'none', stroke: 'currentColor', strokeWidth: 1.4, strokeLinecap: 'round', strokeLinejoin: 'round' }))),
8592
8655
  );
8593
8656
  }
8594
8657
 
@@ -9177,6 +9240,10 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
9177
9240
  }
9178
9241
 
9179
9242
  return {
9243
+ // `configForms` is optional: it carries the Host "busy Enter" preference.
9244
+ // Read through ctx.get with a defensive fallback instead of a hard
9245
+ // inject dependency, so a deployment without the settings service still
9246
+ // gets every other Power-Up feature.
9180
9247
  inject: ['slots', 'locale'],
9181
9248
  apply,
9182
9249
  // Exported for smoke tests only; the host never reads this.
@@ -9197,6 +9264,8 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
9197
9264
  readLastPrompt,
9198
9265
  writeLastPrompt,
9199
9266
  resolveWorkspaceIdFromSnapshot,
9267
+ openPromptPopover,
9268
+ PromptCreateModal,
9200
9269
  HeroPromptsControl,
9201
9270
  PromptManager,
9202
9271
  runningSessionRows,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@restregular/dsh-powerup",
3
- "version": "0.10.0",
3
+ "version": "0.10.2",
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",