Preface¶
As DSH sessions grow longer, the context approaches its limit, and the model begins to lose early information. The conventional approach is to manually open a new session and copy-paste key conclusions, which is prone to missing items; or opening multiple windows to patch them together, but it’s unclear exactly which round the old context folds back to.
xiacqi1/dsh-at-handoff is tailored for this issue. It is a “workflow” type plugin that monitors the current session’s context size. After crossing the set “Smart Line”, it presents a capsule prompt. Click once to have the model write this round into a handoff document, click again to open a new session in the same project and send the document as an unsent opening message, leaving the old session in the sidebar.
What is this¶
One-sentence definition: Add a layer of context handoff entry to DSH, making long session switching justifiable.
- Name:
dsh-at-handoff(npm package name, version0.1.0) - Maintainer: Xiacqi1
- GitHub: https://github.com/Xiacqi1/dsh-at-handoff
- Directory: https://www.skillhub.cn/plugins/Xiacqi1/dsh-at-handoff
- Category: Workflow
- Stars: 1
- License: MIT
Its approach follows the three steps of “Monitor — Handoff — Continue”: It does not seize session control, but only provides a clickable entry when the context crosses a threshold. Whether to initiate the handoff is decided by you pressing Enter.
Core Features¶
Context Monitoring¶
The plugin reads the context value calculated by the host side, i.e., tokenMeter.measure(session).totalTokens, which shares the same source as the interface display. It is not the usage in the provider’s billing stats, nor a third-party number estimated by characters, and it only counts for the root session; sessions with a parent id are skipped.
Smart Line and Stepping¶
The default Smart Line is 120k. When not crossed, a capsule is displayed centered above the input box, content resembling 121k / Smart Line 120k, accompanied by a thin progress bar that fits the content width without occupying the whole line. After crossing the Smart Line, the capsule turns amber, the progress bar is replaced by a line of prompt text, and a button is always present on the right. Crossing only changes the color; no breathing or bouncing animations are added.
Stepping rules: Every additional 30k prompts a level up (120k / 150k / 180k…), and the warning text becomes more prominent; it only recalculates the step when falling back below 92% of the threshold.
Handoff Actions¶
The button on the right side of the capsule has two states:
- When no handoff document has been written yet, it is “Go to Handoff”. Clicking it places the handoff instruction as a draft in the input box. You send it yourself by pressing Enter; the plugin does not submit for you.
- After writing, the button becomes “Go to New Session”. Clicking it opens a new session in the same project, with the handoff document serving as its unsent opening message.
The handoff instruction is a request, not a command: the skill is not registered in the command registry. The model will load the built-in at-handoff skill, write this round into a document, call write_handoff to save it to <Project>/.scratch/handoff/, and then stop. Old documents are archived to .scratch/handoff/archive/.
File Naming¶
Handoff documents are named:
<YYYYMMDD>-<HHmm>-<session id last 8 digits>-<slug>-<N>.md
N is the nth handoff for that specific session, so clicking twice consecutively will not overwrite each other.
Installation and Enablement¶
The plugin is published to npm: dsh-at-handoff@0.1.0. After installing, you need to restart the host once (Web side: dsh web, Desktop side: use the official plugin management page) for the client capsule to appear.
Install from Marketplace (Recommended)
Search for at-handoff or Context Handoff in the market panel and click install.
Install via CLI
dsh plugin --profile web add dsh-at-handoff
Desktop
Plugin management page → Install → Enter dsh-at-handoff.
Development from Source
plugin_manager install_bundle({ target: "<path to this repo>" })
When dsh-at-handoff points to this repo as a dependency, the host side needs to restart the plugin (plugin_manager set_plugin), and the client side just needs to refresh the page.
Typical Usage¶
- Run the session normally and pay attention to the capsule above the input box. When the context hasn’t crossed the line, it only shows the current value and the progress bar, so it can be ignored.
- When the context crosses the Smart Line, the capsule turns amber and the “Go to Handoff” button appears on the right. Click it, and the handoff instruction will be filled into the input box as a draft.
- Confirm the draft content matches your expectations, then press Enter to send. The model calls the built-in
at-handoffskill, writes this round into a document and saves it to<Project>/.scratch/handoff/, then stops. - The capsule button becomes “Go to New Session”. Click it, the plugin opens a new session in the same project, places the handoff document as an unsent opening message in the input box, and archives the old document to
.scratch/handoff/archive/. - When you need to review the old session, it remains in the sidebar.
Configuration¶
The plugin is currently configured via environment variables:
| Variable | Default | Meaning |
|---|---|---|
AT_HANDOFF_THRESHOLD |
120000 |
Smart Line |
AT_HANDOFF_STEP_TOKENS |
30000 |
How many more tokens trigger a level up |
AT_HANDOFF_HYSTERESIS_RATIO |
0.92 |
Percentage below which it re-calculates the step when falling back |
Host Side Interface¶
The plugin exposes three HTTP interfaces to facilitate external viewing and advancing the handoff status:
GET /at-handoff/state?op=state[&session=<id>] Current measurement, levels, and whether a handoff document exists
POST /at-handoff/state?op=take Mark document as ready to be taken
POST /at-handoff/state?op=consume Take and archive
Code Structure¶
lib/index.js— Host side: measuring, level-based state machine,write_handoffutility, HTTP routes.lib/client.js— Client side: the capsule onconversation.input.dock, and a component onconversation.composer.dockthat only runs the state machine and doesn’t render pixels (only it has access toinputActions.setDraftanduiWorkspace).lib/handoff.js— Naming, writing, and archiving of handoff documents.lib/skill.js— Registersskills/at-handoff/SKILL.mdas a built-in skill, re-reading from disk every time it is read.cordis.patch.yml— Hooks the host side into the host plane in the profile.
Applicable Scenarios and Notes¶
Who is it for: DSH users with long sessions prone to context truncation who need to frequently hand off work from one session to another, especially those already using DSH for continuous development and are accustomed to storing process artifacts in the .scratch directory. It does not decide when to hand off for you, but only provides an entry at the threshold, making it friendly to scenarios where “handoff timing must be controllable”.
A few points to note:
- The plugin runs with the permissions of the current dsh process. Before installing, you should check the source code and license (MIT) to confirm trust.
- Errors on the client side can cause the entire interface to disappear and a white screen to appear; on desktop, it is especially hard to get the console reason; the design document
at-handoff-DESIGN.mdrecords the method to rebuild the error reporting channel at the end, but it has not been implemented yet. conversation.composer.baris not a slot registered by the client, nothing will be displayed if hooked there; currently onlyconversation.input.dockandconversation.composer.dockare available.- Uninstalling will not delete
.scratch/handoff/in the project; the written handoff documents are still there.
dsh plugin --profile web remove dsh-at-handoff
Conclusion¶
The value of dsh-at-handoff lies not in replacing your existing handoff method, but in providing a context monitoring and continuation entry in the interface that doesn’t interrupt the rhythm: monitoring values share the source with the interface, handoff documents are saved to the project with non-overlapping names, and old sessions remain in the sidebar. See the directory page at https://www.skillhub.cn/plugins/Xiacqi1/dsh-at-handoff, and the source code at https://github.com/Xiacqi1/dsh-at-handoff.