dsh-edit-diff: Redraw Line-level Diff on DSH File Change Card

Introduction

In DeepSeek Harness (DSH), when an agent modifies files, the conversation interface displays tool cards labeled “Edit · Path”. The built-in UI does not render diffs for some editing tools. For scenarios where it does, it often renders identical context lines in both the red and green sections, expanding a single-line change into over a dozen lines and causing the +N -M statistics to appear inflated. If you frequently review changes under PTC (run_code sub-calls) or str_replace_editor, or wish to see a centralized view of “which files were changed” at the end of a conversation turn, the default display is often insufficient.

Below is an introduction to the community plugin dsh-edit-diff (Maintainer: senyayume, Category: Workflow). It redraws line-level diffs on file change tool cards: identical lines are rendered only once, changed lines are highlighted with full-row red/green backgrounds, and specific character changes within a line are highlighted with a deeper shade. It covers both run_code (PTC) sub-calls and str_replace_editor, provides a change summary card at the end of the turn, and supports locating or copying paths in the file explorer.

What is this

dsh-edit-diff is a standard DSH bundle: it points to cordis.patch.yml via dsh.bundle.patch in package.json and mounts automatically upon installation, requiring no manual modification of the profile entry. The plugin does not modify the DSH installation directory; instead, it utilizes the official keyed slot tool.call.toolview (priority: -1) to take over line rendering for edit, write, insert, and str_replace_editor. It also registers end-of-turn slots and host routes.

It solves three main problems: the built-in UI fails to render diffs for certain tools; the built-in DiffBlock lacks line-level matching, causing context repetition; and there is a lack of a summary view for “which files changed this turn” alongside convenient path operations.

Core Features

Line-level Deduplication & Inline Highlighting

Upon expanding a tool card, the diff body adopts line-level alignment: unchanged context lines appear only once (in a dark color); deleted lines and added lines are marked with full-row red/green backgrounds respectively; character-level differences within a line are highlighted with a darker shade over the same background color, while the text itself follows syntax highlighting (the plugin includes a local tokenizer with colors consistent with the theme’s --shiki-token-*). The header line displays colored +N -M statistics on the right.

Covered Tools & PTC Sub-calls

The plugin takes over the following tools: edit, write, insert, str_replace_editor, as well as sub-calls to these tools within run_code (PTC). The built-in diffCardModel() from @deepseek-ai/dsh-client-ui-tool returns null directly for blocks with parentCallId (PTC sub-calls) and for str_replace_editor; this plugin fills in the diff display for these scenarios.

The diff data source prioritizes the result metadata block.meta.diffs; otherwise, it deduces the changes from call arguments (e.g., old_string/new_string for edit). If a call fails (block.isError), it does not deduce hunks to avoid displaying uncommitted changes.

End-of-Turn Change Card

At the end of each conversation turn, if file changes occurred, the plugin inserts a summary card into the conversation.chat.turnTail slot: the title reads “N files changed”, with a total of +A -R, and the entire card is collapsible. Each file occupies a line containing a type icon, filename, directory, and +N -M, with “Review” and “Open” buttons at the end of the line; upon expansion, it uses the same diff body as the tool rows.

Right-Click Path Menu

On each row of the end-of-turn card, as well as on the tool rows taken over by this plugin, right-clicking offers options to “Open in Explorer”, “Copy Folder Path”, or “Copy File Path”. “Open in Explorer” is handled by the plugin host route (Windows uses explorer.exe /n,/select,…), with the official opener acting as a fallback. Paths are relativized against the current conversation workspace; absolute paths are still shown for files outside the workspace.

Installation & Activation

System Requirements

The development and test environment used DSH Desktop’s built-in harness 0.2.0-rc.1 (@deepseek-ai/dsh-client-ui-primitives of the same version). Starting from 0.2, the host compares the engine version against the bundle’s peerDependencies; if unsatisfied, the bundle is silently skipped. If the harness version is not within the plugin’s declared range, you need to use dsh plugin allow-version to grant an exemption for the exact version as described in the README. Installation is performed via dsh plugin add (internally using pnpm) and requires Node; running repository tests requires Node ≥ 18 and React 18.

Installation Command

dsh plugin add github:senyayume/dsh-edit-diff --profile desktop

Replace profile with the profile name you are actually using. After installation, dsh-edit-diff should be included in dsh.profile.bundles in the profile’s package.json.

Activation Method

The plugin consists of a “Client half” (lib/client.js) and a “Host half” (lib/index.js):

  1. Client half: Read from disk on every page load. Refreshing the DSH window is sufficient to apply changes to text or client logic.
  2. Host half: Loaded only when the harness process starts. DSH Desktop does not exit the process when the window is closed (it minimizes to the tray). After modifying host-related code or for the first installation, you must right-click the tray icon to Exit and then restart. Otherwise, host routes (such as “Open in Explorer”) may not be registered, and client POSTs might return a 405 error.

To uninstall, use:

dsh plugin remove dsh-edit-diff --profile <profile>

And restart the harness to restore DSH’s built-in rendering.

Typical Usage

After installation and confirming the harness has restarted, the plugin takes effect in the conversation without additional configuration:

  1. Have the agent modify files via edit, write, insert, or str_replace_editor, expand the corresponding tool row, and view the redrawn diff and +N -M.
  2. In PTC mode, sub-layer edits triggered via run_code will also display the same diff body.
  3. After a conversation turn ends, browse the file list in the end-of-turn summary card, click “Review” to expand the diff in place, or click “Open”. If needed, right-click on a row to copy the path or locate it in the file explorer.

The repository provides a live checklist in docs/verification.md (covering items like tool rows, end-of-turn cards, conversation assembly, etc.) which can be used to verify if the behavior is normal on your machine.

Use Cases & Notes

Who it is for: Developers who frequently review agent file modifications in DSH Desktop, especially those relying on PTC or str_replace_editor; users who want to reduce repeated context lines and review multi-file changes centrally at the end of a turn.

Permissions & Security: The plugin runs with the permissions of the current DSH process, and the host half registers routes such as reveal. Before installation, you should read the source code and MIT license at the GitHub Repository to ensure compliance with your environment policies.

Known Limitations (Summary): Line numbers in some screenshots are relative numbers within the window (fallback when host is not loaded with the process), not absolute file line numbers; on macOS / Linux, the “Open in Explorer” code exists but is not marked as verified on real hardware in the README; on lower versions of DSH lacking uiConversation.events and conversation.chat.turnTail, the plugin will degrade to only taking over tool rows without the end-of-turn card.

Conclusion

dsh-edit-diff complements diff displays for PTC and str_replace_editor without modifying the DSH core. It reduces review costs through line-level deduplication and inline highlighting, and connects “what changed” and “where the files are” into a single workflow via end-of-turn summary cards and path menus.

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

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

Xiaoye