@qzsy/dsh-command-palette
v1.5.0
Published
Command+K palette for recent sessions, workspaces, files, and actions with pinyin search and live session status.
Readme
@qzsy/dsh-command-palette
Packaged from the local DSH plugin dsh-command-palette; published under the @qzsy scope.
Install
dsh plugin add @qzsy/dsh-command-paletteUpstream README
Command Palette for DSH
A persistent DeepSeek Harness Client plugin that turns Command+K into a command
palette for the Web/Desktop GUI: recent sessions with live status, workspaces,
files, and actions — searchable in Chinese, English, full pinyin, pinyin
initials, or any mixed form.
What it does
- Command+K on the Desktop app opens a floating palette; the same chord toggles
it closed. In the browser profile it adopts the browser-safe chord that
session.searchused before (Mod+Alt+K on macOS). - Sections and filters: All / Sessions / Workspaces / Files / Actions.
- Sessions: every non-blank, non-archived Session ordered by
updatedAt, with its Workspace label, a compact relative age, and a live status badge:工作中(pulsing blue dot),待批准/待审阅/待回答(amber),出错(red, failed run), or已完成(green, unread completion). A success that has already been viewed shows no badge. The section label counts Sessions by state, e.g.近期会话 · 2 个进行中 · 1 个出错 · 3 个未读(only nonzero segments), and updates live while the palette stays open. When the Git badge bundle is installed, the Workspace name under each thread title also carries that Workspace's+N −M/干净/无 Gitbadge. Choosing a Session also reveals it in the left Workspace sidebar: a folded Workspace (and every folded Workspace Tree ancestor) expands, the Session row watermark rises, the group smooth-scrolls into view, and the Workspace header flashes. - Sub-agent threads are hidden by default. Sessions whose
origin === "subagent"are excluded from rows, search results, workspace activity badges and counts. When any exist, the footer shows显示 N 个子代理会话; the toggle includes them for the current palette session and returns to the hidden default on the next open, so teammate and research threads never crowd the list unless asked for. - Workspaces: Workspaces ordered by their most recent Session activity, with
an abbreviated path and an aggregate status badge that reports one state by
priority pending > failed > running > unread (
N 个待处理/N 个出错/N 个工作中/N 个未读). When the@qzsy/dsh-git-badgebundle is installed, each workspace name also carries its Git badge:+N −Mline changes,干净for a clean repository,无 Gitoutside a repository, or the file count when only untracked files changed. Git data comes from the Host'sPOST /api/git-badgeroute (8 s palette cache); without that route the badges are simply absent. Enter opens the newest Session in the Workspace, or a fresh blank Session when it has none. - Files: live, debounced Host file-reference lookup scoped to the Session in
the main panel; choosing a row opens the file in the right-hand preview.
Every file row carries a
项目 · <Workspace>badge below its path so the search scope stays visible, and the Files placeholder names the same project. Opened files are remembered locally (origin-scopedlocalStorage) and listed as Recent files when the search box is empty; recent files resolve their project from the Session's Workspace. File matching stays Host-ranked path matching (see limitations). - Actions: every registered shortcut command (labels and keys come from the live shortcut catalog, so plugin commands appear automatically). Enter invokes the command through the shortcut registry; Settings and the keyboard shortcut reference open from here.
- Sessions: every non-blank, non-archived Session ordered by
- Mixed Chinese/English search through
text-search-engine: one query covers Han characters (登录), full pinyin (denglu), pinyin initials (dl), English subsequences (nextjs), space-separated terms, and mixed forms (qunxingerp,群erp,qxkf). Matched ranges are highlighted in titles and subtitles. Ranking prefers tighter, earlier title hits, then detail hits, then recency. - Keyboard: Up/Down move the selection, Enter opens, Escape closes. The filter switches with bare ← / → (both directions, wrapping) or Tab / Shift+Tab; holding Alt/Ctrl/Cmd with an arrow keeps native caret or word movement inside the query. IME composition is never intercepted, so pinyin candidate selection keeps working. Focus returns to whatever had it before opening.
- Mobile: at
(max-width: 720px), (pointer: coarse) and (max-width: 1024px)the palette becomes a bottom sheet at 90% of the layer height. It opens without focusing the search input, so the soft keyboard stays closed until the user taps the field. All keyboard hints (Esc key, row shortcuts, footer key legend) are hidden; the footer only remains for the subagent toggle. - Unread count: the sidebar row shows the number of Sessions that finished successfully but have not been viewed (the green 已完成 badge; failed, archived, blank and subagent Sessions are excluded). The collapsed rail shows a dot instead. The always-mounted overlay computes the count and mirrors it into a plugin-local store read by the sidebar glyph.
- Sidebar entry: the 命令面板 / Command palette row joins the global panel stack directly below 自动化任务 / Automations (glyph-only in the collapsed rail). Choosing it opens the overlay without switching the main panel: the row is an action, so the plugin answers that one panel id in the layout selection and delegates every other id to the layout owner.
- Light/dark themes follow
--dsw-*tokens; all copy is registered in the Client locale service (zh/en).
Search engine integration
DSH's browser module table only resolves its own platform modules and
client-plugin rows, so a plain-JS plugin cannot require('text-search-engine')
at runtime. The package's minified browser IIFE is therefore vendored and
injected into the client bundle:
vendor/text-search-engine.min.js— exact browser build from the pinned[email protected]dependency (MIT; license invendor/text-search-engine.LICENSE).scripts/sync-vendor-engine.mjs— rewrites the marked region inclient.jsfrom the vendored file; runnode scripts/sync-vendor-engine.mjsafter updating the vendored build.client.js— the generated region captures the engine exports in a factory scope constant and usescreateSearcher()withtitle/detailfields, custom ranking, and hit ranges for highlighting. If the engine fails to initialize, a built-in subsequence matcher keeps the palette usable.
File search is delegated to the Host (ctx.remote.fileReferences.list), which
retrieves and ranks paths from the current Session workspace; pinyin is applied
to sessions, workspaces, and actions, where titles are user-facing Chinese text.
Session status
The palette reads the root useSessionStatus hook of the shell.overlay slot
(provided by dsh-client-ui-session). That observable snapshot carries
running, pendingInteraction.kind, and completionUnread per Session, so
badges and counts change live as agents start, wait for input, and finish.
A Session settles into one of three terminal states:
- Viewed success — no badge. The completion has been acknowledged, so the row is a plain Session and the badge clears.
- Unread success — green
已完成. Shown while the snapshot still reportscompletionUnread; the tooltip reads已完成,尚未查看. - Failed run — red
出错. The tooltip reads运行出错:<message>, or运行出错(尚未查看):<message>when the same Session is also an unread completion. An empty failure message falls back to未知错误.
The unified snapshot answers whether a run is going, waiting, or finished
unread; it does not say why a run ended. Failures therefore come from the
forwarded Host event api-session/error, which carries Agent failures —
including network and provider errors. The palette keeps the latest message
per Session and drops it when the next turn starts (api-session/status with
running true), when a new user prompt arrives (api-session/activity), or
when the Session is removed (api-session/removed). Aborted runs and
transient tool errors never reach that event, so they never raise the badge.
The map is in-memory for the app session — the same lifetime as unread
completions — so a reload starts clean. A failure that predates the palette
stays clear until the Host forwards a new api-session/error.
When several states apply, one badge wins in this order: pending interaction > running > failure > unread completion. A stale failure can therefore never mask a Session that is working or waiting for the user.
Workspace badges aggregate their Sessions with the priority pending > failed >
running > unread, counting each Session once (N 个待处理 / N 个出错 /
N 个工作中 / N 个未读). The Sessions group label appends the counts in
running/pending/error/unread order, keeping only nonzero segments:
近期会话 · N 个进行中 · N 个待处理 · N 个出错 · N 个未读.
Error excerpts are whitespace-collapsed onto one line and capped at 180 characters with an ellipsis.
scripts/verify-status.mjs is the browser-free node harness that verifies this
state matrix. docs/palette-statuses.png renders the five states above from the
same component (running, pending, failed, unread, viewed).
Sidebar reveal
Selecting a Session or Workspace closes the palette, navigates, and then reveals
the target in the left Workspace browser. The browser owns reveal for its own
search in private React state, so the palette drives the stable DOM markers the
browser publishes instead: data-row-key identifies Workspace / Session /
watermark rows, aria-expanded reports a folded Workspace, and role="tree"
is the scrolling list. The persisted dsh.workspace.view.v5 store supplies the
grouping mode, which distinguishes sibling Workspace groups from Workspace Tree
ancestry.
The reveal is bounded (about 2.4 s of retries): it expands the owning group and
its tree ancestors, raises hidden session rows through the same Show more
control the browser owns, then scrolls the group and chosen row into view with
behavior: "smooth" (or auto under reduced motion) and briefly rings the
Workspace header with a --dsw-* token outline. If the sidebar is a collapsed
rail, or the target is hidden by the current archive filter, the reveal is a
silent no-op — navigation still succeeds.
Marketplace palette
The DSH Market landing page in this repository (apps/market) mounts the same
keyboard-first interaction as a live demo: ⌘K / Ctrl+K searches the plugin
directory, opens plugin pages, and offers the install command. The palette footer
credits this package, and @qzsy packages stay pinned ahead of upstream
duplicates so the command palette itself is always one keystroke away.
Shortcut ownership
session.search already owns Command+K in the shipped UI. The palette registers
with the free Command+Shift+P default and, once per device preference document,
uses the public ctx.shortcuts.edit() API to:
- clear
session.search's binding, and - bind
palette.opento the chordsession.searchhad (Command+K on Desktop, Mod+Alt+K in the browser).
That is a normal, visible override in Settings → Keyboard shortcuts: both rows
show as modified, and Restore All Defaults restores the palette to
Command+Shift+P and search to Command+K. On the next launch the plugin
re-adopts the chord while both rows are still at their unmodified defaults, so
Command+K keeps opening the palette. Session search itself stays available from
the palette's Actions list and from the sidebar search icon.
Install
The bundle is installed into the current profile with
plugin_manager install_bundle (absolute package directory). It needs no build
step at install time: client.js is a plain-JS __ModuleLoader__ module that
only requires react from the browser module table, with the vendored engine
already inlined.
Files
package.json— bundle manifest (dsh.bundle.patch,dsh.client, display resources)cordis.patch.yml— inserts the Host rowindex.js— Host half (no-op; the palette is client-only)client.js— shortcut adoption, overlay palette, live status badges, ranked mixed-script search, sidebar trigger, zh/en dictionariesvendor/— vendored engine build and its MIT licensescripts/sync-vendor-engine.mjs— regenerates the vendored engine regionlocale/en.json,locale/zh.json— Plugin Manager title/descriptionicon.svg— original artworkdocs/— verification screenshots
