@qzsy/dsh-workspace-combobox 0.2.1 → 0.2.3

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
@@ -5,7 +5,7 @@ Workspace combobox plus a Git branch picker for DeepSeek Harness.
5
5
  ## Install
6
6
 
7
7
  ~~~bash
8
- dsh plugin add @qzsy/dsh-workspace-combobox@0.2.1
8
+ dsh plugin add @qzsy/dsh-workspace-combobox@0.2.3
9
9
  ~~~
10
10
 
11
11
  ## Features
@@ -32,7 +32,7 @@ shortcuts.
32
32
  ### Git branch picker
33
33
 
34
34
  When the selected workspace is a Git repository, a branch chip appears in the
35
- New Session hero row, to the right of the agent preset (标准模式):
35
+ New Session hero row, immediately beside the workspace chip (like Cursor):
36
36
 
37
37
  - shows the current branch, or detached HEAD with the short commit
38
38
  - local and remote tabs, each with a count and search
@@ -49,7 +49,7 @@ New Session hero row, to the right of the agent preset (标准模式):
49
49
  | Surface | Mechanism |
50
50
  | --- | --- |
51
51
  | New Session workspace dropdown | <code>conversation.hero.workspace</code> occupant at <code>priority: -1</code>; the slot registry renders the lowest priority, shadowing the shipped picker panel. The trigger chip, open state, <code>selectedId</code>, and <code>onPick</code> still come from the conversation owner. |
52
- | Branch chip beside the agent preset | <code>conversation.hero.options</code> list entry <code>workspace-combobox.branch</code>, after the agent-preset seat. The selected workspace path is shared through a small client store written by the workspace picker. |
52
+ | Branch chip beside the workspace trigger | Rendered from the same <code>conversation.hero.workspace</code> slot, directly after the shipped workspace chip; the selected path comes from the slot's <code>selectedId</code>. |
53
53
  | Frame-wide switcher | <code>shell.overlay</code> entry driven by the <code>workspace.combobox</code> shortcut. |
54
54
  | Host capability | Two authenticated <code>/api</code> routes registered on <code>ctx.connection.fetch</code>: <code>/api/workspace-git</code> and <code>/api/workspace-git/switch</code>. |
55
55
 
@@ -91,5 +91,5 @@ additions.
91
91
  replaceable; typing happens inside the opened panel.
92
92
  - Remote branch lists use already-fetched remote-tracking refs, not a live
93
93
  network fetch.
94
- - The branch chip lives in the conversation hero row, so it is visible while
95
- the new-session hero is shown.
94
+ - The branch chip lives beside the workspace trigger in the conversation hero
95
+ row, so it is visible while the new-session hero is shown.
package/dist/client.js CHANGED
@@ -546,7 +546,7 @@ window.__ModuleLoader__.load({
546
546
  * trigger chip and hands over open/close state, the anchor, and the
547
547
  * selection; this panel adds pinyin-aware search over names and paths.
548
548
  */
549
- function HeroWorkspaceCombobox({ open, anchorRef, selectedId, onPick, onClose, actions, getHome, shortcutLabel, selection, useWorkspaces, useSessions, t }) {
549
+ function HeroWorkspaceCombobox({ open, anchorRef, selectedId, onPick, onClose, actions, getHome, shortcutLabel, useWorkspaces, useSessions, t }) {
550
550
  const home = typeof getHome === 'function' ? getHome() : '';
551
551
  const rows = useWorkspaceRows(useWorkspaces, useSessions, home, false);
552
552
  const [query, setQuery] = useState('');
@@ -559,9 +559,7 @@ window.__ModuleLoader__.load({
559
559
  const items = useWorkspaceSearch(rows, query);
560
560
  const selectedRow = selectedId === undefined || selectedId === null ? undefined : rows.find((row) => String(row.id) === String(selectedId));
561
561
  const selectedPath = selectedRow === undefined ? '' : String(selectedRow.path ?? '');
562
- useEffect(() => {
563
- if (selection !== undefined && typeof selection.set === 'function') selection.set(selectedPath);
564
- }, [selection, selectedPath]);
562
+ const branch = selectedPath.length === 0 ? null : h(BranchSelector, { path: selectedPath, t });
565
563
 
566
564
  useEffect(() => {
567
565
  if (!open) return undefined;
@@ -646,7 +644,7 @@ window.__ModuleLoader__.load({
646
644
  .finally(() => setAdding(false));
647
645
  };
648
646
 
649
- if (!open || position === null) return null;
647
+ if (!open || position === null) return branch;
650
648
  const activeOption = items.length === 0 ? undefined : Math.min(Math.max(activeIndex, 0), items.length - 1);
651
649
  const panel = h('div', {
652
650
  className: 'wsc-card wsc-heroCard',
@@ -698,8 +696,8 @@ window.__ModuleLoader__.load({
698
696
  );
699
697
  // The shipped picker portals its menu out of the Hero tree; mirror that so
700
698
  // no transformed or clipped ancestor can displace the panel.
701
- if (createPortal !== null && typeof document !== 'undefined') return createPortal(panel, document.body);
702
- return panel;
699
+ if (createPortal !== null && typeof document !== 'undefined') return h(React.Fragment, null, branch, createPortal(panel, document.body));
700
+ return h(React.Fragment, null, branch, panel);
703
701
  }
704
702
 
705
703
  //#region git branch
@@ -747,8 +745,8 @@ window.__ModuleLoader__.load({
747
745
  return body.value === null || typeof body.value !== 'object' ? {} : body.value;
748
746
  }
749
747
 
750
- function BranchSelector({ selection, t }) {
751
- const path = usePathValue(selection);
748
+ function BranchSelector({ path: activePath, t }) {
749
+ const path = typeof activePath === 'string' ? activePath : '';
752
750
  const [status, setStatus] = useState(null);
753
751
  const [loading, setLoading] = useState(false);
754
752
  const [open, setOpen] = useState(false);
@@ -812,12 +810,17 @@ window.__ModuleLoader__.load({
812
810
  const button = buttonRef.current;
813
811
  if (button === null) return;
814
812
  const rect = button.getBoundingClientRect();
815
- const width = Math.max(280, Math.min(360, window.innerWidth - 16));
816
- const left = Math.max(8, Math.min(rect.right - width, window.innerWidth - width - 8));
817
- const estimated = Math.min(420, window.innerHeight * 0.72);
818
- const below = rect.bottom + 6;
819
- const top = below + estimated > window.innerHeight ? Math.max(8, rect.top - estimated - 6) : below;
820
- setPosition({ left, top, width });
813
+ const margin = 8;
814
+ const gap = 6;
815
+ const width = Math.max(280, Math.min(360, window.innerWidth - margin * 2));
816
+ const left = Math.max(margin, Math.min(rect.left, window.innerWidth - width - margin));
817
+ const below = rect.bottom + gap;
818
+ const spaceBelow = window.innerHeight - below - margin;
819
+ const spaceAbove = rect.top - gap - margin;
820
+ const placeAbove = spaceBelow < 220 && spaceAbove > spaceBelow;
821
+ const maxHeight = Math.max(120, Math.min(420, placeAbove ? spaceAbove : spaceBelow));
822
+ const top = placeAbove ? Math.max(margin, rect.top - gap - maxHeight) : below;
823
+ setPosition({ left, top, width, maxHeight });
821
824
  };
822
825
  update();
823
826
  window.addEventListener('resize', update);
@@ -900,7 +903,7 @@ window.__ModuleLoader__.load({
900
903
  className: 'wsc-branch-menu',
901
904
  role: 'dialog',
902
905
  'aria-label': t('branch.title'),
903
- style: position === null ? { visibility: 'hidden' } : { left: position.left + 'px', top: position.top + 'px', width: position.width + 'px' }
906
+ style: position === null ? { visibility: 'hidden' } : { left: position.left + 'px', top: position.top + 'px', width: position.width + 'px', maxHeight: position.maxHeight + 'px' }
904
907
  },
905
908
  h('div', { className: 'wsc-branch-head' },
906
909
  h('span', { className: 'wsc-branch-headIcon' }, loading ? h('span', { className: 'wsc-spinner' }) : h(GitBranchIcon, null)),
@@ -1169,7 +1172,6 @@ window.__ModuleLoader__.load({
1169
1172
  ctx.effect(() => installStyles(), 'workspace-combobox: styles');
1170
1173
  const t = ctx.locale.bind(NS);
1171
1174
  const store = createStore({ open: false });
1172
- const selectedPathStore = createPathStore();
1173
1175
  const workspaces = ctx.get('workspaces');
1174
1176
  const uiWorkspace = ctx.get('uiWorkspace');
1175
1177
  const remote = ctx.get('remote');
@@ -1231,7 +1233,6 @@ window.__ModuleLoader__.load({
1231
1233
  createWorkspace: actions.createWorkspace
1232
1234
  },
1233
1235
  getHome,
1234
- selection: selectedPathStore,
1235
1236
  shortcutLabel
1236
1237
  })
1237
1238
  }, HeroWorkspaceCombobox);
@@ -1240,20 +1241,6 @@ window.__ModuleLoader__.load({
1240
1241
  return () => {};
1241
1242
  }
1242
1243
  });
1243
- ctx.slots.inject('conversation.hero.options', () => {
1244
- try {
1245
- return ctx.slots.register({
1246
- name: 'conversation.hero.options',
1247
- id: 'workspace-combobox.branch',
1248
- order: 20,
1249
- locale: NS,
1250
- inject: () => ({ selection: selectedPathStore })
1251
- }, BranchSelector);
1252
- } catch (error) {
1253
- console.warn('workspace combobox: branch selector registration failed', error);
1254
- return () => {};
1255
- }
1256
- });
1257
1244
  }
1258
1245
  //#endregion
1259
1246
 
package/locale/en.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "Workspace Combobox",
4
- "description": "Turns the New Session workspace picker into a combobox with mixed Chinese/English pinyin search, adds a Git branch picker beside the agent preset with local/remote search and a visible switching state, and opens a frame-wide workspace switcher with Ctrl+."
4
+ "description": "Turns the New Session workspace picker into a combobox with mixed Chinese/English pinyin search, adds a Git branch picker beside the workspace chip with local/remote search and a visible switching state, and opens a frame-wide workspace switcher with Ctrl+."
5
5
  }
6
6
  }
package/locale/zh.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "工作区组合框",
4
- "description": "把新会话的工作区选择器换成支持中英混拼(汉字 / 全拼 / 首字母)检索的组合框,并在标准模式右侧显示 Git 分支选择器;支持本地/远程分支搜索与带加载状态的快速切换,Ctrl+. 随时打开全局工作区切换器。"
4
+ "description": "把新会话的工作区选择器换成支持中英混拼(汉字 / 全拼 / 首字母)检索的组合框,并在工作区选择器旁边显示 Git 分支选择器;支持本地/远程分支搜索与带加载状态的快速切换,Ctrl+. 随时打开全局工作区切换器。"
5
5
  }
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qzsy/dsh-workspace-combobox",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Pinyin-aware workspace combobox for the New Session picker, plus a Git branch picker with local/remote branch switching and a Ctrl+. frame-wide workspace switcher.",
5
5
  "type": "module",
6
6
  "license": "MIT",