dsh-git-control: VSCode-style Git source control in the DSH right sidebar

Introduction

The philosophy of DSH is “Everything is a plugin,” but when developing daily with DSH, you still have to switch to the terminal to run git status, git log, and git diff to check the repository status. Status scattered between the terminal and the GUI, and it is not uncommon to switch to the wrong branch or miss changes. dsh-git-control (plugin name wx-98/dsh-git) brings this workflow into the right sidebar of DSH: a VSCode-like “Source Control” panel featuring a commit graph, branch switching, hunk-level staging, and file-by-file diffs.

This plugin is maintained by wx-98. It is a Cordis plugin bundle (Host half + Web Client half), not a skin, not a TUI, and not a standalone desktop client. It solves the problem of completing most common Git operations within the DSH interface.

Plugin Positioning

Plugin name: dsh-git-control (Directory page and GitHub repository name written as DSH-GIT, maintainer wx-98).

One-sentence responsibility: Provide a VSCode/IDEA-style Git Source Control panel in the DSH Web/Desktop right sidebar and session header.

  • Classification: Client plugin (Cordis bundle, browser half registers right sidebar tabs)
  • Prerequisites: DSH Web/Desktop 0.2.1-rc.5, requires extension points sidebarRightTabs + sidebar.right.pane.tab slots
  • Dependencies: Local git CLI (must be in PATH, or installed in Windows default path)
  • License: MIT
  • No build steps, no runtime dependencies

Please check the source code and license yourself before installation—the plugin runs with the permissions of the current DSH process, and the Host half calls the local git.

How Host and Client Work Together

The plugin is a dual-sided bundle:

  1. The Host half (index.js) registers /git/* HTTP routes inside the DSH process, operating on the repository solely via the git CLI, without directly reading/writing .git internal files.
  2. The Browser half (client.js) registers the git tab type in the right sidebar, providing the Git panel, commit graph, diff views, and header branch chips.
  3. Requests first pass through DSH’s connection trust fence (ctx.connection.requestRejection, Host/Origin verification + login cookie); unauthenticated requests return 401/403.
  4. Path parameters must be the repository’s relative path; .. upward jumps, absolute paths, and NUL are all rejected; discard requires explicit confirm: true.
  5. Write operations (stage/unstage/discard/commit/checkout) are executed serially to avoid concurrent interference; the plugin does not generate any model visible events.

Core Features

The following lists the capabilities from the README checklist one by one, all verified.

Session Header Branch Chips. The session title bar directly displays ● main 3 (branch + change count + ahead/behind). Clicking it opens a summary of workspace changes, so you don’t need to open the panel to know which branch you are on.

Current Branch Status. Branch name, current commit, upstream branch, ahead/behind counts; correctly displays detached HEAD and empty repositories.

VSCode Style Coloring. Status letters are colored by semantic meaning (M Amber, A/Untracked Green, D Red, R/C Blue, Conflicts Orange). Filenames follow the status color. There is a set for both dark and light themes; HEAD -> main and remote references each have their own colors.

Commit Graph (GRAPH). Colorful lanes (dots + vertical lines + merge/fork curves) are drawn on the left side of the history list. Normal branches use an 8-color palette. The branch line where HEAD resides uses an accent color with enlarged dots and a stroke ring. Column numbers are stable across rows, and branch lines do not jump colors.

Branch Panel. Clicking the chip opens it: current branch segment (upstream / ahead / behind / change summary) + branch switching (local groups, current one checked, click to checkout) + branch operations (create / rename / delete; deletion requires double confirmation and forbids deleting the current branch; unmerged requires force delete).

IDEA Style Change Tree. Collapsible/expandable by directory, each file shows +N/-N line counts, four groups (Staged / Changed / Untracked / Conflicts) remain unchanged.

Hunk-level Staging. Each block in the diff can be “Stage this block / Unstage this block,” applying only that specific block to the index.

Commit Enhancements. Amend previous commit + reuse of the last 10 commit messages (saved locally).

Stash. List / Create / Apply / Pop / Delete, operations inside a modal; deletion requires confirmation.

History Filtering and Navigation. Filter by commit message / author / path; conditions are visible and clearable. Also supports date range filtering and keyboard navigation (↑/↓/Enter). “Log Range” and “Switch to this branch” are two separate actions.

File-by-File Diff. Structured unified diff (hunk + line numbers + add/remove coloring). Supports four perspectives: Workspace / Staged / Untracked (synthetic) / Specific commit. Binary files have clear indicators; large diffs exceeding 4000 lines are truncated with a notice.

Write Operations. Stage, unstage, discard changes (double confirmation), fill commit message and commit (Ctrl/Cmd+Enter).

Commit History (IDEA Style). Left side branch tree (HEAD / Local / Remote, clicking only changes the log range, does not change HEAD) + right side columnar list (Graph / Theme+Refs / Author / Date / Short Hash). Merge commits are italicized and weakened; the HEAD line is emphasized. Commit details include full SHA, body, changed files, and added/removed lines.

Auto-refresh. The change list is polled every 4s while the panel is visible; all write operations immediately trigger a re-fetch after success.

Multi-language and Themes. Chinese/English text, follows the host theme (Dark/Light).

Note: The “Known Limitations” section at the end of the README still says “Branch creation/deletion, stash, hunk-level staging are not currently supported,” which directly conflicts with the capability list above and the package.json description. It is judged to be outdated text. Limitations that do not appear in the list remain true: pull/push/fetch, three-way conflict resolution interface, file history (blame), submodule view.

Installation and Activation

The current npm latest is dsh-git-control@0.4.6 (the README release status section still says 0.4.0).

dsh plugin --profile desktop add dsh-git-control

Installing from GitHub

dsh plugin --profile desktop add github:wx-98/DSH-GIT

Installing from Local Directory (For Development)

GUI Operation: Plugins → Add plugin → Local Absolute Path, fill in the repository directory, and enable the dsh-git-control bundle row in the Plugins page after installation, then refresh the page.

Installing via link: Changes to client.js take effect immediately upon refreshing the page; changes to the Host half take effect after restarting the application.

The desktop profile is exclusively managed by the Electron application, and the CLI will refuse operations. Use the GUI to install, or run the one-click script in the repository:

pwsh -File .\tools\install-desktop.ps1              # Install, takes effect after restarting DSH
pwsh -File .\tools\install-desktop.ps1 -LivePatch  # Additionally writes a live patch, allowing the running instance to hot-reload the Host half immediately
pwsh -File .\tools\install-desktop.ps1 -RemoveLivePatch

Typical Usage

The Git panel uses the Session CWD as the repository root, so first confirm that the opened session’s working directory is the target repository:

  1. Open any session;
  2. Open the right sidebar → Click + → In the tab wizard, select Source Control (Tab title shows Git + current branch);
  3. Changes tab: Fill in commit message → Stage/Unstage files → Commit;
  4. History tab: Browse commits, click to view details and file-by-file diffs;
  5. The refresh button on the top summary row can manually refresh, and the branch dropdown can switch branches (git checkout <branch>).

Development and verification commands:

node --test test/                                        # Host + Client tests
node tools/verify-installed.mjs "http://127.0.0.1:PORT/?token=XXXX"   # End-to-end self-check against a real running DSH instance

The self-check script exchanges the startup token for a cookie, asserts the plugin has entered the client entry graph, fetches the browser half served by /plugins, creates a temporary repository, and drives the /git/* routes one by one, finally asserting the connection fence.

Suitable Scenarios and Notes

Suitable for:

  • People who complete daily commits, staging, history checking, and branch switching within the DSH Web/Desktop interface;
  • People who need a commit graph and hunk-level staging but don’t want to leave DSH;
  • Plugin developers who want to add a Git panel to the DSH right sidebar can use docs/contract.md (Host ⇄ Client interface contract) as a reference.

Notes:

  • The target version is DSH 0.2.1-rc.5. The plugin relies on its public extension points (sidebarRightTabs, slots, webServer, connection, locale). It is recommended to revisit after DSH updates.
  • Requires local git in PATH (or installed in Windows default path).
  • Does not support pull/push/fetch, three-way conflict resolution interface, file history (blame), or submodule view.
  • Large diffs exceeding 4000 lines will be truncated.
  • The plugin runs with the permissions of the current DSH process. You should check the source code and license (MIT) before installing.
  • The Community Directory (SkillHub) is an independent site with no official affiliation with DeepSeek or 幻方, and is not part of the official app store.

Conclusion

The value of dsh-git-control lies in fully bringing the Git panel from VSCode/IDEA into the DSH right sidebar, and additionally providing session header branch chips and commit graph lanes, reducing the number of times you switch back and forth between the terminal and the GUI. Regarding the release status, npm dsh-git-control@0.4.6, MIT license, and awesome-dsh-plugin have been included (PR has been merged).

Directory page: https://www.skillhub.cn/plugins/wx-98/DSH-GIT
GitHub: https://github.com/wx-98/DSH-GIT

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye