@restregular/dsh-powerup 0.10.6 → 0.10.7

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 (2) hide show
  1. package/client.js +55 -15
  2. package/package.json +1 -1
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.6';
86
+ const VERSION = '0.10.7';
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. */
@@ -8922,9 +8922,11 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
8922
8922
  const [collapsedGroups, setCollapsedGroups] = useState(() => new Set());
8923
8923
  // Group create/rename: { scopeId, id:'', name:'' } (id='' => create).
8924
8924
  const [groupDraft, setGroupDraft] = useState(null);
8925
- // Prompt id currently being dragged, for move-to-group drops.
8925
+ // Prompt id currently being dragged. Hover highlight is applied with
8926
+ // direct DOM classes, never React state: dragover/dragleave fire
8927
+ // continuously and a setState on each one re-renders the whole page,
8928
+ // which makes the drop target flash.
8926
8929
  const dragRef = useRef(null);
8927
- const [dragOver, setDragOver] = useState(null);
8928
8930
  const t = (key, params) => translateCurrent(key, params);
8929
8931
  useEffect(() => {
8930
8932
  const locale = ctx.get('locale');
@@ -9014,11 +9016,29 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
9014
9016
  ...prompts.map((p) => (p.groupId === group.id ? { ...p, groupId: '' } : p)),
9015
9017
  ]);
9016
9018
  };
9019
+ /** Clear every drag highlight without touching React state. */
9020
+ const clearDragHighlight = () => {
9021
+ try {
9022
+ for (const node of document.querySelectorAll('[data-drop-highlight].drop-target')) {
9023
+ node.classList.remove('drop-target');
9024
+ }
9025
+ } catch { /* no document in tests */ }
9026
+ };
9027
+ /** Add the highlight to one node, removing it from all others. */
9028
+ const markDropTarget = (node) => {
9029
+ if (node === null || node === undefined) return;
9030
+ try {
9031
+ for (const other of document.querySelectorAll('[data-drop-highlight].drop-target')) {
9032
+ if (other !== node) other.classList.remove('drop-target');
9033
+ }
9034
+ node.classList.add('drop-target');
9035
+ } catch { /* no document in tests */ }
9036
+ };
9017
9037
  /** Move the dragged prompt into a group ('' = ungrouped) of a scope. */
9018
9038
  const movePrompt = (groupId, scopeId) => {
9019
9039
  const id = dragRef.current;
9020
9040
  dragRef.current = null;
9021
- setDragOver(null);
9041
+ clearDragHighlight();
9022
9042
  if (typeof id !== 'string' || id === '') return;
9023
9043
  writeAll([
9024
9044
  ...groups,
@@ -9027,14 +9047,27 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
9027
9047
  : p)),
9028
9048
  ]);
9029
9049
  };
9030
- const dropProps = (key, groupId, scopeId) => ({
9050
+ const dragOverProps = () => ({
9031
9051
  onDragOver: (event) => {
9032
9052
  event.preventDefault();
9033
- if (dragOver !== key) setDragOver(key);
9053
+ // Cards handle their own reorder hover; let their event bubble here
9054
+ // but keep the highlight on the innermost (card) target.
9055
+ markDropTarget(event.currentTarget);
9034
9056
  },
9035
- onDragLeave: () => setDragOver((current) => (current === key ? null : current)),
9057
+ onDragLeave: (event) => {
9058
+ // Only clear when the pointer truly leaves this node, not when it
9059
+ // moves into a child (relatedTarget is contained in currentTarget).
9060
+ const next = event.relatedTarget;
9061
+ if (next !== null && typeof event.currentTarget.contains === 'function'
9062
+ && event.currentTarget.contains(next)) return;
9063
+ event.currentTarget.classList.remove('drop-target');
9064
+ },
9065
+ });
9066
+ const dropProps = (groupId, scopeId) => ({
9067
+ ...dragOverProps(),
9036
9068
  onDrop: (event) => {
9037
9069
  event.preventDefault();
9070
+ event.stopPropagation();
9038
9071
  movePrompt(groupId, scopeId);
9039
9072
  },
9040
9073
  });
@@ -9046,7 +9079,7 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
9046
9079
  const reorderBefore = (targetId) => {
9047
9080
  const id = dragRef.current;
9048
9081
  dragRef.current = null;
9049
- setDragOver(null);
9082
+ clearDragHighlight();
9050
9083
  if (typeof id !== 'string' || id === '' || id === targetId) return;
9051
9084
  const moving = prompts.find((p) => p.id === id);
9052
9085
  const target = prompts.find((p) => p.id === targetId);
@@ -9126,18 +9159,24 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
9126
9159
  key: prompt.id,
9127
9160
  draggable: !isExpanded,
9128
9161
  'data-prompt-drag': prompt.id,
9129
- className: 'dsh-powerup-prompt-card' + (isExpanded ? '' : ' folded')
9130
- + (dragOver === 'card:' + prompt.id ? ' drop-target' : ''),
9162
+ 'data-drop-highlight': '',
9163
+ className: 'dsh-powerup-prompt-card' + (isExpanded ? '' : ' folded'),
9131
9164
  onDragStart: (event) => {
9132
9165
  dragRef.current = prompt.id;
9133
9166
  try { event.dataTransfer?.setData?.('text/plain', prompt.id); } catch { /* best effort */ }
9134
9167
  },
9135
- onDragEnd: () => { dragRef.current = null; setDragOver(null); },
9168
+ onDragEnd: () => { dragRef.current = null; clearDragHighlight(); },
9136
9169
  onDragOver: (event) => {
9137
9170
  event.preventDefault();
9138
- if (dragOver !== 'card:' + prompt.id) setDragOver('card:' + prompt.id);
9171
+ event.stopPropagation();
9172
+ markDropTarget(event.currentTarget);
9173
+ },
9174
+ onDragLeave: (event) => {
9175
+ const next = event.relatedTarget;
9176
+ if (next !== null && typeof event.currentTarget.contains === 'function'
9177
+ && event.currentTarget.contains(next)) return;
9178
+ event.currentTarget.classList.remove('drop-target');
9139
9179
  },
9140
- onDragLeave: () => setDragOver((current) => (current === 'card:' + prompt.id ? null : current)),
9141
9180
  onDrop: (event) => {
9142
9181
  event.preventDefault();
9143
9182
  event.stopPropagation();
@@ -9169,13 +9208,14 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
9169
9208
  const key = scopeId + ':' + section.id;
9170
9209
  const collapsed = collapsedGroups.has(key);
9171
9210
  const isUngrouped = section.isUngrouped;
9172
- const drop = dropProps(key, section.id, scopeId);
9211
+ const drop = dropProps(section.id, scopeId);
9173
9212
  const editingThis = groupDraft !== null && groupDraft.scopeId === scopeId
9174
9213
  && groupDraft.id === (isUngrouped ? '' : section.group.id);
9175
9214
  return h('section', {
9176
9215
  key,
9216
+ 'data-drop-highlight': '',
9177
9217
  className: 'dsh-powerup-prompt-group' + (isUngrouped ? ' dsh-powerup-prompt-ungrouped' : '')
9178
- + (collapsed ? ' is-collapsed' : '') + (dragOver === key ? ' drop-target' : ''),
9218
+ + (collapsed ? ' is-collapsed' : ''),
9179
9219
  ...drop,
9180
9220
  },
9181
9221
  h('div', { className: 'dsh-powerup-prompt-group-head' },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@restregular/dsh-powerup",
3
- "version": "0.10.6",
3
+ "version": "0.10.7",
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",