In the DSH plugin ecosystem, developers sometimes need to experiment with different prompt, model, or tool combinations under the current session context without polluting the main conversation history. Existing approaches often require manually creating a new session or editor, and the session remains in the list. dsh-sidebar-branch-chat solves this problem by adding a standalone “Branch Chat” tab to dsh-better-sidebar. This tab allows creating immediately archived sessions, automatically injects a context summary, and uses the same toolset as the main agent.

What It Is

This is a companion tab plugin that runs on top of dsh-better-sidebar. It does not fork or install a copy of Better Sidebar; instead, it injects a new tab through the API.

  • Maintainer: kuanfu0430
  • License: MIT
  • Dependency: dsh-better-sidebar >= 0.11.0 (provides the ctx.betterSidebar.registerTab capability)

Installation and Activation

The installation command is as follows:

dsh plugin --profile web add github:kuanfu0430/dsh-sidebar-branch-chat

After installation, restart dsh web, then open the “Branch Chat” tab from the Better Sidebar tab bar.

Core Features

The plugin implements the following core capabilities:

  1. Standalone Tab and Blank Editor: Provides a blank input box. When the first message is sent, a new branch session is created; subsequent sends continue that branch.
  2. Context Inheritance (Sandwich Structure): The branch session is a brand-new empty session and does not copy the main chat’s history events. Context inheritance uses a “head/middle/tail” sandwich structure:
    • Head: the first original user text.
    • Middle: user questions interspersed in between.
    • Tail: the last completed turn, including tool calls and results.
    • Note: Incomplete turns are omitted.
  3. Tools and Permissions: The branch agent generates tools using the main agent’s currently active preset and has the same tool list as the main agent. Permission presets (including full-access sandbox) are copied from the main chat.
  4. Immediate Archiving and Isolation: The branch is archived immediately after creation (archiveSession), invisible in the main session list and search, and exists only within the sidebar tab.
  5. UI and Interaction: The tab contains a toolbar for switching existing branches (●/○) and selecting the model/reasoning effort. Auxiliary bubbles use the official MarkdownText seed; the summary and framing prompt are visible only to the model and are stripped from the UI projection.

Typical Usage

  1. Create a Branch: Open the Branch Chat tab, type a message, and send it. This creates a new branch, and the tab name is taken from the first 20 characters of the message.
  2. Switching and Model Selection: Click an existing branch dot in the toolbar to switch, or select the model and reasoning effort dedicated to that branch.
  3. Stop and Continue: The Stop button is at the bottom (available in the empty state or busy state). Pressing Enter when the input box is empty refreshes pending queued messages without stopping the current turn.

Applicable Scenarios and Considerations

  • Session Lifecycle: The branch lifecycle is bound to the main session. Branches can be created or continued only while the main chat page is open. Closing the main page pauses the branch, but the transcript content remains saved in persistent storage.
  • Event Polling: Branch transcripts are fetched via JSON polling (1.5 seconds when idle, 300 milliseconds when busy). A cold branch stops polling after live: false until the next send or manual switch.
  • Workspace Isolation: Chat isolation is not workspace isolation. Branch sessions reuse the main session’s cwd (current working directory); file, Shell, and Git side effects share the main working tree. Framework prompts are model-visible soft constraints, not permission boundaries.
  • Permission Handling: If the main chat preset is “Ask,” sandbox elevation is answered inside the tab (allowed-once / deny). allowed-once authorizations are not inherited, and ask_user_question is not answered inside the tab.

Summary

dsh-sidebar-branch-chat provides a lightweight way to perform context-isolated testing and exploration without affecting the main chat record. It mounts the tab through the API and leverages sandwich context inheritance and immediate archiving to provide branch-like session management.