Introduction¶
Managing multiple code projects simultaneously in DSH and orchestrating conversations, previews, explorers, and the shared blackboard on a single screen can quickly make the workspace feel cramped; handing all solution-exploration tasks to the main agent consumes a large number of tokens. The tokensave plugin adds two new tabs—Project Center and Workspace—to the DSH Web interface, integrating card-based project management, a dockview multi-panel layout, agent collaboration notifications and automation, and a unified “exploration pipeline” into a single experience.
Plugin Overview¶
- Name: dsh-tokensave
- Maintainer: weifengit
- Type: DSH multi-project workspace plugin
- What it solves: Unified management of multiple code projects, panel orchestration (main chat, project preview, free-model explorers, shared blackboard, etc.) within the workspace, and automated notification handling and retry logic—saving tokens for the main agent.
Installation & Activation¶
After cloning the source from git, install with a single command (requires Node ≥ 22, pnpm, and the dsh CLI):
git clone https://github.com/weifengit/tokensave.git && cd tokensave && node scripts/install.mjs
By default, both the dsh web and desktop profiles are installed. To install only one:
node scripts/install.mjs --profile web # dsh web only
node scripts/install.mjs --profile desktop # desktop only
node scripts/install.mjs --dry-run # report only, no files written
The installer resolves dependencies, builds dist/client.js, and registers the profile. If any step is skipped, the plugin may “install but not activate.” See docs/INSTALL.md for details.
After installation, launch with dsh web (port mode) or open the desktop app directly. To uninstall:
dsh plugin --profile web remove dsh-tokensave
Project Center¶
- Register frequently used code directories as projects. Supports card and list views, sortable by name / created time / updated time, with preferences persisted.
- Clone projects from GitHub: supports both public and private repositories via the local
ghlogin session. Credentials are injected through a URL-scoped environment variable—never passed via argv or written to disk. Real-time clone stage and progress display. - “My Repository List”: lists all repositories under your GitHub account (including private ones), sorted by most recent push. Searchable; clicking a repository fills in the address.
- Cards display active conversation sequence dots and a “● Running” debug badge (appears when the dev server is active). Clicking a card opens the workspace and automatically arranges the project preview + main chat side by side.
- Each project supports new sessions. Switching between projects sorts by “most recent conversation update time,” with the most active first.
Workspace (dockview Multi-Panel Layout)¶
- Three dockview instance skeleton: main sidebar / editor + panel area / auxiliary sidebar. Panels carry tabs, support drag-to-reorder, cross-instance dragging (drop-target overlay previews in real time), minimize / maximize. While a session is running, panel tabs show a blue pulsing dot.
- Dockable panels:
- Main chat (the host-native input bar docks to its bottom)
- Project preview (devUrl iframe, refreshable / open in new window)
- Explorer windows (one slot per free model, minimizable / maximizable / double-click for fullscreen)
- Shared blackboard
- Collaboration timeline
- Collaboration savings (tokens and cost saved, calculated from actual usage)
- Image viewing in conversations: images in the main chat / explorer windows render with a unified thumbnail style; single images capped at 240px on the long edge, aspect ratio clamped to [0.25, 4], no upscaling; multiple images collapse into 64px squares. Clicking opens a document-level lightbox with pagination (← / →, PageUp / PageDown) and a bottom counter.
- Status bar: left side shows real-time hints (blue pulse for in-progress, grey for completed, red text for errors); right side provides history session switching / new session / save layout (yellow dirty indicator when differing from default) / one-click restore to default. On narrow screens, it wraps to two lines automatically.
- Save / restore layout: each project stores its own panel arrangement + region collapse state + sidebar widths. An auto-snapshot mechanism restores the exact scene after refresh / hot reload.
- Explorer settings: a button in the title row opens a panel listing available explorer models in three zones (default / free / paid). Toggle individually or in groups; selections persist immediately. The panel position and the gear “Settings” panel share the same popPlacement, width 300px, max height 72vh.
- Title bar position: Gear → “Title Bar → Position,” three options (top / left / right). When side-placed, it collapses into a 44px vertical rail, returning the full top row height to content. Preference is stored globally (
tokensave:desk-chrome.v1); on narrow screens it always renders at the top.
Sidebar Notification System¶
- Breathing dot: a small dot at the Project Center entry. Lights up only when conversations are alive (running / awaiting confirmation / previous turn ended abnormally). Green = normal, yellow = pending (yellow overrides green); when a conversation is running, it flickers sequentially like a marquee.
- Yellow / blue badges: yellow = number of conversations needing attention (awaiting confirmation + abnormal termination), blue = number of unread normal completions. On new devices / after refresh, state is restored from the last 6 hours of outcomes. Clicking opens the marquee notification panel (pinned), which contains three sections (notification sound settings + auto-continue settings + conversation list); each entry jumps directly to the corresponding workspace.
- Notification sound engine: two independent sound categories (completion / interruption), each with 5 options (2 recorded + 2 synthesized + mute), four duration modes (single beep / one minute / continuous / custom minutes) + volume adjustment. The badge appears on screen first; sound follows half a beat later. When the tab is hidden, a 120ms timer fallback ensures delivery.
- Auto-continue engine: always resident, decides whether to send “continue” on behalf of the user based on interruption type—output truncation always auto-continues; transient failures (network / timeout / 5xx / 429) auto-retry; permanent failures (auth / balance / context overflow) do not auto-continue, left to the user; awaiting confirmation / user-initiated stop does not auto-continue. Retry keywords are customizable.
Theme & Appearance¶
- Three-state theme (follow system / dark / light) is switchable directly in the gear panel, sharing a single preference (
ctx.theme) with the host’s “Settings → Appearance”; changing either side updates the other. When set to “follow system,” the panel also displays the currently resolved light/dark state. - Title bar position, theme, skin (base color + background image), and font are all adjustable from a single gear entry. Font size has four tiers: Small 12.5 / Standard 13.5 / Large 15 / Extra Large 16.5.
- Skin covers the entire page: all four tabs—[Chat / Trace / Project Center / Workspace]—change together (including the top tab row).
- The docked native input bar matches the workspace color scheme: the border is preserved, the background is muted, and hover / focus states remain unobtrusive. Switching back to the host’s “Chat” tab automatically restores the native style.
Main Chat Experience Optimization¶
- Input box height adjustment: height grows automatically with content (capped at viewport height − 160px); a grab handle on the top edge allows manual drag to fix any height (persisted, survives refresh, does not shrink when content decreases); double-clicking the handle returns to auto mode.
- Process folding: tool calls and intermediate steps per turn are folded into a single line “Process N steps · M tool calls”; context injection is folded into “Context Injection ▸”. Only the final Markdown answer for that turn is expanded; the UI renders only the most recent 40 turns.
- Timestamps & copy: each message’s timestamp and copy button scale with the UI font size; the body-width handle’s hit area is fully moved to the outer whitespace of the content column, so clicking copy no longer accidentally triggers “drag to resize width.”
- Model retry reminder: replicates the host “Chat” tab behavior—receiving streaming increments / persisted messages / tool calls in the same turn counts as a successful retry, and this reminder no longer occupies a line.
- Editable queued messages: when the session is busy, messages entering the host inbox queue can be edited—text-only messages edit in place with queue position unchanged; image + text mixed messages first read back the original image, then re-queue as “original image + new text” (cost: moves to the back of the queue, with a pre-save warning); queue items containing file attachments are explicitly marked “not editable.”
- Reading view three-tier filter: All / My messages only / AI replies only. Filter state is shared as a module-level source of truth; switching in either the workspace card or the maximized overlay syncs immediately to the other, and the state persists.
- Task list auto-collapse: when the current turn completes (running → stopped and not awaiting confirmation), the host’s expanded task planning panel collapses automatically.
- Stick-to-bottom + scroll lock: scrolling up to read during streaming output is not interrupted; switching tabs and coming back preserves the scroll position exactly.
tokensave Exploration Pipeline¶
Say “please invoke tokensave” in any conversation to trigger:
- Scenario detection: Based on the presence of project marker files in cwd and user phrasing, determines “create from scratch” vs. “modify existing code.”
- Parallel dispatch: Creates sessions with multiple free-model explorers (default preset: 3, configurable in Explorer Settings) and issues tasks with different emphases.
- Shared blackboard accumulation: Explorers write pitfalls / solutions / requirements to the plugin’s own blackboard (three tools:
board_post/board_list/board_clear, workspace-isolated, TTL-based expiry). - Cross-validation & review: After all members have posted (or timeout), a review and summary is produced, generating a task brief returned to the main chat. The main agent then executes file operations per the brief.
The savings calculation is not an estimate: the “Collaboration Savings” panel reads the actual usage from each session’s assistant messages. Explorers run on free models with zero actual cost; the savings amount is calculated using the main agent’s unit price.
Mobile Adaptation (dsh-remote-mobile)¶
- Responsive narrow-screen workspace (breakpoint 900px): the center area is always full-width; left and right sidebars become overlay drawers (only one open at a time, three-button toggle + mask tap to close). On touchscreens, grab handles are hidden, title row / status bar / tabs are enlarged for touch (buttons ≥ 32px), and the status bar wraps to two lines. Narrow-screen default is “one window fills the editor area”—on phone entry, the main chat auto-maximizes; when switching back to wide screen, only that auto-maximized window is restored.
- Cross-device data sync: the mobile client accesses via the dsh-remote-mobile gateway using LAN / virtual-network IP, a different origin from the desktop’s 127.0.0.1, so localStorage is mutually unreadable. The project registry’s source of truth is changed to a host-server-side file store (
~/.dsh/tokensave/), so all clients read/write the same data, keeping desktop and mobile project lists automatically in sync.
Architecture & Maintenance¶
- Server-side (
src/): mounted as a composite package viacordis.patch.yml; registers tools (4), systemPrompt, and Web routes (/plugins/dsh-tokensave/board|fs|explorers|scope|project-info|mkdir|explorer-settings|clone|clone-status). - Client-side (
client/src/): React workspace frontend, including Project Center, DeskDock layout, panels, theme/skin, notification sounds, and scroll memory. - Data storage: plugin data stored in
~/.dsh/tokensave/(explorer selections, etc.); blackboard data is managed by the plugin’s own storage. - Maintenance conventions (see docs/MAINTENANCE.md):
- Behavior changes must be accompanied by assertion updates:
scripts/check-*.mjspins old patterns; changing behavior without updating assertions guaranteespnpm testwill FAIL. - Client source changes require a rebuild: run
pnpm build:clientthen refresh the page; to diagnose “fix not taking effect,” first check the mtime ofdist/client.js.
Typical Usage¶
- After installation, open the Workspace tab—no configuration needed.
- Register frequently used code directories in Project Center, or clone a project from GitHub.
- In the Workspace, dock panels such as Main Chat, Project Preview, Explorer Windows, and Shared Blackboard; drag to rearrange the layout.
- In any conversation, say “please invoke tokensave” to trigger the exploration pipeline for parallel solution exploration; the main agent executes file operations per the brief.
- Use the sidebar breathing dot / badges, notification sounds, and the auto-continue engine to continuously track conversation status and retries.
Use Cases & Notes¶
Suitable for developers who need to manage multiple code projects simultaneously, orchestrate conversations and previews in a workspace, and offload exploration-type tasks to free models to save tokens. The plugin runs with the current dsh process’s permissions; verify the source code and license before installing.