@qzsy/dsh-git-badge
v1.3.0
Published
Workspace Git badge: detects Git repositories in the left-sidebar workspace directories and shows the branch with pending +/- line changes.
Readme
@qzsy/dsh-git-badge
Packaged from the local DSH plugin dsh-git-badge; published under the @qzsy scope.
Install
dsh plugin add @qzsy/dsh-git-badgeUpstream README
@qzsy/dsh-git-badge
A DeepSeek Harness bundle that senses whether the left-sidebar workspace
directories are Git repositories and shows a Git badge with the current branch
and pending +/− line changes.
Visible result
- A Workspace Git entry in the sidebar panel list, directly below the
command-palette row (
sidebar.panellist, order 30). The row's right edge carries the aggregate+/−line totals of every changed workspace repository (compact+4.7k −2.0k), with the exact totals in the hover title. The row has no trailing slot, so the badge is absolutely positioned inside the row and is only rendered in the wide column; the collapsed rail shows the branch mark plus a small amber dot while any repository has pending changes. - Each workspace (project) row in the sidebar tree also gets its own
+/−badge at the right edge: the tree has no per-row slot, so a frame-wideshell.overlayseat measures[data-row-key^="workspace:"]rows (200 ms cadence plus scroll/resize) and renders fixed badges over them. The badge hides while the row is hovered so the row's own actions keep their space, disappears when the row itself is not visible (collapsed rail or scrolled away), and never intercepts clicks. - Selecting the entry opens the Workspace Git main panel page
(
mainkeyedgit-badge): every left-sidebar workspace directory with its status dot, path, branch pill, and+N −Nline changes (untracked-only repositories show the file count), plus a segmented filter All / Changed / Clean / No Git and a manual refresh. - The page follows Harness theme tokens, light/dark, and the active locale (Chinese and English shipped).
- The installed Command Palette bundle reuses the same Host route to put a
+N −M(or干净/无 Git) badge beside every workspace name in its Workspace section, so the counts are visible fromCommand+Kas well.
How it works
- Host half (
index.js) owns the only real capability: it registers the exact authenticated Fetch routePOST /api/git-badgethroughctx.connection.fetchand runsgit status --porcelain=v2 --branchandgit diff HEAD --numstat(or the two-index fallback for a repository without a first commit) per workspace. A cached answer is reused for 25 s and an older one is still returned while it refreshes in the background. Directories with no.gitanywhere above them are rejected without spawning git. Only absolute paths are accepted and, when the Workspace registry is mounted, only directories it owns are read./apiis the single prefix every deployment forwards — the desktop app does not expose top-level plugin routes. - Client half (
client.js) is a plain-JavaScript browser module. It reads the workspace/session snapshots through the slots' standard hooks, POSTs toapi/git-badgerelative to the page base, and renders the menu row glyph, the project-row overlay, and the page. All three surfaces share one poller (statusStore): the first watcher starts it, the last one stops it, and it refreshes every 20 s while visible, on window focus, and on manual refresh. The very first read is deferred to an idle slot so the host'sgitprocesses never compete with the page's own startup requests. The overlay measures the workspace row rectangles every 200 ms plus on scroll/resize, so scrolling and group expansion stay aligned.
Requirements
gitavailable on the HostPATH.- The Host half stays inactive in profiles without
ctx.connectionand the Client half registers nothing without the sidebar slot, so the bundle is inert rather than failing elsewhere.
