Sessions

A session is a conversation between you and an agent. Each session tracks the full history of prompts you send and the responses the agent generates.

Session Modes

Every session runs in one of three modes, which determine the working directory the agent operates in. The mode is chosen when the session is created and cannot be changed afterwards.

ModeWorking directoryUse for
Worktree (default)A fresh git worktree on a dedicated branchFeature work, experiments, anything you want isolated from your other sessions
Project RootThe project's root directory itselfCross-branch operations like merging or rebasing session branches back into main
ScratchAn empty ephemeral directory under the session dirUsing the agent as a general assistant without exposing your project's sources

You choose a mode from the New Session split button in the sidebar — see Creating a Session for the UI, and the sub-sections below for the semantics.

Worktree Mode (default)

Each worktree session runs inside its own git worktree — an isolated copy of the project's repository. This means:

  • No cross-session interference — File changes made by one session's agent do not affect any other session or your main working directory.
  • Independent branches — Each session gets its own branch (named acp-session/<session-id>) created from the project's current HEAD at the time the session starts.
  • Safe experimentation — You can let agents modify, create, and delete files freely. The changes are confined to the session's worktree directory.
  • Diff tracking — Braide tracks all file changes within a session's worktree and can display a diff summary of what the agent has changed. The built-in diff viewer supports unified, split (side-by-side), and raw views with word-level change highlighting and a full-screen modal for detailed review. See the Running a Session guide for details.

For more details on working with worktrees, including how to commit, rebase, and merge changes, see the Worktrees guide.

Projects Without a Git Repository

If the project's root path is not a git repository, worktree creation is impossible and every new session falls back to Project Root mode automatically — the agent runs in the project root directly and the session is badged with the orange ROOT pill, just like an explicitly-created project-root session.

Worktrees are the recommended way to work: they keep each session isolated on its own branch, let you review per-session diffs, and make the commit / merge / pull-request actions meaningful. To encourage that, the sidebar behaves differently when the project root is not a git repo:

  • The New Session split button's primary action is relabelled to New Session in Project Root, and clicking it creates a project-root session rather than attempting (and silently falling back from) a worktree.
  • The New Session in Project Root entry is hidden from the caret-menu because it would duplicate the primary action. The New Session in Scratch Directory entry remains available.
  • Because project-root is singleton per project, the primary button is disabled once one such session exists. The caret-menu still lets you start a scratch session.
  • Beneath the split button, a dashed-bordered banner appears with a short explanation and an Initialise Git Repository button.

Clicking Initialise Git Repository runs three git commands in the project root, in order:

  1. git init — create the .git directory.
  2. git add -A — stage every file already in the project root (respecting any existing .gitignore). If you had sources in the folder before adding it to Braide, they are captured by the initial commit so worktree sessions inherit them.
  3. git commit --allow-empty -m "Initial commit" — seed HEAD so git worktree add has something to branch from. --allow-empty means the step still succeeds on a truly empty project folder. If no git identity is configured globally, the commit is retried with a placeholder Braide <acp@local> author so a freshly-installed machine isn't blocked.

Once init completes, the sidebar re-queries the git status, the banner disappears, and the split button reverts to its normal worktree-first behaviour. You can amend the initial commit (for instance to change the author or message) from any session or from your own terminal.

If the init fails — for example because the project root is inside another non-writable git repository, or git isn't on $PATH — the error message is shown in red inside the banner and the UI stays in the non-git state so you can retry.

Project Root Mode

A project-root session runs the agent directly in the project's root path, with no worktree and no dedicated branch. It is designed for actions that need to see the real repository state, such as merging a session branch back into main.

Project-root sessions are marked with an orange ROOT pill in the sidebar and behave differently from worktree sessions:

  • Singleton per project — Only one project-root session may exist at a time. The menu option is disabled until the existing one is deleted, and the API rejects a second creation attempt with a 400 error.
  • Cannot be archived — The archive action is hidden in the context menu. Project-root sessions can still be deleted.
  • No base branch tracked — Since there is no session branch, the branch selector in the prompt toolbar is hidden and branch-related sidebar actions (commit, merge, PR) do not apply.
  • No session branch operations — Labelling or archiving a project-root session does not attempt to rename a git branch, because none was ever created. This applies equally when the project root itself has no git repository.
  • Changes hit your working tree directly — Any files the agent writes land in the project root, exactly as if you had made them yourself. Review them with git status / git diff before committing.

Scratch Mode

A scratch session runs in an empty directory created under the session storage (~/.braide/projects/<project-id>/sessions/<session-id>/worktree/). There is no git repository and no project source — the agent starts with an empty slate.

Scratch sessions are marked with a blue SCRATCH pill in the sidebar and are useful for:

  • Asking the agent general questions without risking accidental edits to project files
  • Prototyping a snippet or scaffold in isolation before copying it into the project
  • Experimenting with an agent's tools against a clean directory

Like project-root sessions, scratch sessions have no git repository, so the branch selector, branch-related sidebar actions, and session-branch rename/archive operations are all suppressed.

When a scratch session is deleted, its directory is removed with the rest of the session storage — nothing persists in the project.

Session Lifecycle

  1. Created — You create a session by selecting an agent. Creation is two-phase: the server persists the session record immediately (so a row appears in the sidebar at initializing status with a "Setting up…" subtitle), then provisions the working directory for the chosen mode and completes the agent handshake. The row transitions to ready once both steps succeed. If either step fails, the session is marked failed instead — see Failed Session Setup.
  2. Prompting — You type and send a prompt. The session transitions to a running state.
  3. Streaming — The agent processes your prompt and streams back events in real time.
  4. Idle — The agent finishes responding. You can send another prompt or end the session.
  5. Cancelled — You can cancel a running session at any time using the cancel button.

Failed Session Setup

If the worktree cannot be created or the agent handshake fails (agent not running, protocol error, timeout, etc.), the session's setup is aborted. Rather than disappearing silently, the session is kept in the sidebar at failed status so you can see what went wrong:

  • A failureReason is persisted on the session's meta and surfaced as the row subtitle ("Setup failed: {reason}").
  • The row icon is the red-X-on-tinted-disk glyph from the status table above.
  • The session has no acpId, so commit / merge / pull-request actions are disabled in the context menu.
  • Failed sessions are only removed by explicit user action — Permanently Delete or Archive from the context menu. They survive page reloads and server restarts.

Session Recovery

When an agent is upgraded or restarted, the ACP session ID that the agent previously knew may no longer exist. Braide handles this transparently so you can keep working without manually recreating the session.

How it works

When you send a prompt to a session whose agent has restarted:

  1. Load attempt — Braide first tries loadSession to restore the session on the agent side. If the agent supports this capability and the session ID is still valid, the session resumes normally.

  2. Fallback to new session — If loadSession fails (the agent no longer recognises the session ID), Braide automatically creates a new session via newSession and remaps the app-level session to the new ACP ID. All in-memory state (listeners, config options, project mappings) and on-disk metadata are updated so subsequent operations use the new ID.

  3. History compression — The conversation history from the original session is compressed into a summary and prepended to your prompt. This gives the agent enough context to continue where it left off.

History compression strategy

The history summary is built from the persisted event stream (events.jsonl) and uses a tiered approach to fit within an 8 KB budget:

Per-round extraction — Events are grouped into prompt-response rounds. Each round captures:

  • The user's prompt text
  • The agent's message (reconstructed from streaming chunks)
  • A structured list of tool calls (using rawInput fields rather than full output)
  • The outcome (completed, cancelled, or error)
  • Any diff summary

Tiered detail levels — All rounds start at full detail. If the total exceeds the budget, the oldest rounds are progressively downgraded:

LevelIncludes
FullPrompt (400 chars), agent message (600 chars), verbose tool list, diff summary, outcome
CompactPrompt (200 chars), tool counts only, outcome
MinimalOne-line summary with prompt snippet and tool count
DroppedOmitted entirely, with a count shown in the header

Tool call de-duplication — Within each round, file-oriented tool calls are de-duplicated to reduce noise:

ScenarioRule
Write to a fileDiscard all prior Read, Edit, and Write for that file
Read before a WriteDiscard the Read (the Write replaces the entire file)
Read before Edit(s)Keep both — the Read provides context, but de-duplicate if the same file was read multiple times (keep only the latest Read)
Multiple Edits to the same fileKeep all (edits may target non-overlapping regions)
Multiple Reads with no subsequent Edit or WriteKeep only the latest Read
Grep / Glob searchesAlways kept — the file system may have changed between searches

The summary uses structured rawInput fields (file paths, commands, patterns) rather than tool output, which is typically much larger.

Visual indicator

When a session is recreated, a context compressed card appears in the event stream at the boundary between old and new history. It shows an amber indicator with the total number of rounds and a breakdown of how many were rendered at each detail level (full, compact, minimal, omitted).

Session Status Indicators

Each session in the sidebar displays a status icon that reflects its current state:

StatusIndicatorDescription
InitializingRotating dashed arcServer has created the session record but the worktree or agent handshake is still in progress. The sidebar subtitle reads "Setting up…"
Not startedHollow circleSession is fully set up but no prompt has been sent yet
RunningAnimated spinnerAgent is actively processing a prompt
Running with planSegmented donut chartAgent is working through a plan — shows completed (green), in-progress (blue), and pending (grey) segments with a count (e.g. 2/5)
PausedOrange pause iconSession is waiting for user input (e.g. a permission request)
CompletedGreen checkmarkAgent has finished and the session is idle
ErrorRed XSomething went wrong mid-session — check the session for error details
FailedRed X on a tinted diskSession setup did not complete (worktree or agent handshake failed). The subtitle reads "Setup failed: {reason}" and the row stays in the sidebar until you delete or archive it

When a session is running with a plan, the donut chart animates with a rotating glow to indicate active work, and the segment proportions update in real time as tasks are completed.

Real-Time Events

While a session is running, you'll see a stream of events in the event history.

  • Chat messages — The agent's text responses, rendered as markdown
  • Tool calls — Actions the agent takes (reading files, running commands, searching code)
  • Tool results — The output of those actions
  • Permission requests — When the agent needs your approval before executing certain tools
  • Config updates — Changes to session configuration options

Cost and Context Usage

As the agent works, the session tracks cumulative cost and context window usage. This information is displayed in a status bar anchored to the bottom of the session view, above the prompt input, rather than inline in the event stream.

  • Cost — The total spend for the session so far, displayed as a dollar amount (e.g. $0.2819).
  • Context usage — The number of tokens consumed out of the model's context window, shown as used / total (percentage) (e.g. 37,120 / 1,000,000 (3.7%)).

When the agent is actively working, the cost info appears right-aligned on the same line as the "Working..." status indicator. When the agent is idle, the cost info remains visible on its own as long as usage data has been reported for the session.

Sub-agent and Skill Usage

On the same status bar, to the left of the cost and context figures, two optional pill buttons summarise the delegation activity that has happened in the session:

  • Sub-agents N — the total number of sub-agent invocations the agent has made during the session (i.e. Agent/Task tool calls spawned by the main agent to delegate a subtask).
  • Skills N — the total number of skill invocations the agent has loaded via the Skill tool.

Each pill is hidden when its count is zero, so a session with no delegation shows only the running cost/context figures. The count comes from the same tool-call events that populate the Tool Calls area — no separate instrumentation is needed, and the figures update live as new calls arrive.

Clicking a pill opens a popover anchored above the button with a grouped breakdown:

  • The Sub-agents popover lists each distinct sub-agent type that was invoked (e.g. Explore, Plan, general-purpose), the number of times it was called, and the unique descriptions passed to each call. Sub-agents without an explicit type fall back to general-purpose.
  • The Skills popover lists each distinct skill name (e.g. likec4-dsl, tdd) and the number of times it was loaded.

In both popovers, groups are sorted by call count (most-used first), then alphabetically. Press Escape or click outside the popover to dismiss it; click the originating pill again to toggle it closed.

File Activity

A third pill — Files N — appears on the same status bar, to the right of the sub-agent and skill pills. It surfaces where the agent's Read / Write / Edit / MultiEdit / NotebookEdit tool calls have landed in the worktree, giving you three signals at a glance: hotspots, coverage, and the balance between reads and writes.

  • N is the number of distinct file paths the agent has touched so far. Only tool calls with status: "completed" are counted — pending and failed calls are ignored.
  • The pill is hidden when no files have been touched, so fresh sessions show nothing until the first file operation completes.
  • The figure is recomputed from the live event stream, so it updates as the agent works and survives session reload in the same way as the other counters.

Clicking the pill opens an anchored popover whose bottom edge sits just above the pill. As you expand or collapse rows, the popover's top edge grows or shrinks while its bottom stays pinned — so the relationship between the popover and the pill remains stable. When there isn't enough room above (e.g. the session view is short), the popover flips below the pill instead.

Compact popover

The popover shows a condensed activity tree — only directories on the path to a touched file plus the touched files themselves.

  • Directories start collapsed. Click a directory row to expand it and reveal its touched descendants. Click again to collapse.
  • Each row ends with a stacked mini-bar (reads vs. writes) and the total call count. Hovering the bar shows a tooltip like 3 reads, 2 writes. Reads are rendered in the accent colour; writes share a second, warmer hue. All write-style tools (Write, Edit, MultiEdit, NotebookEdit) share the write colour — the UI does not distinguish between them.
  • File icons reuse the File Browser badge palette (two-letter extension label coloured per language) so the visual cue matches.
  • Directory counts aggregate descendants. A directory's mini-bar and count are the sum of every touched file beneath it, so a large total on a parent directory flags a hotspot even when its immediate children are collapsed.
  • Below each expanded directory, a greyed +N untouched files summary counts the direct siblings in that directory the agent has not touched. It's display-only in the compact view — it helps you see coverage without widening the popover.
  • If any file the agent touched lies outside the session worktree root, a distinct Outside worktree branch appears at the bottom with a warning icon and its own expandable list of files.
  • Clicking a file row opens that file in the existing file editor overlay and closes the popover.

A maximise icon in the popover header opens the full File activity modal.

Expanded modal

The modal renders the same tree on a larger canvas with two additional capabilities:

  • Filename search. A search input filters the tree by filename or path substring (case-insensitive). When a filter is active, every directory whose descendants match is auto-expanded so matches are visible; clearing the filter restores your previous expand/collapse state.
  • Interactive untouched-aggregate rows. In the modal the +N untouched files rows are clickable. Expanding one reveals the specific untouched siblings inline at low opacity, so you can see which files were skipped — useful for judging whether the agent missed something it should have considered.

A tab bar is reserved at the top of the modal for future visualisations (treemaps, timelines, etc.); in the current version only the tree tab is implemented.

Press Escape or click outside the modal to dismiss it; clicking a file row inside the modal opens it in the editor and closes the modal.

Data sources

  • Touched files come from the live tool-call event stream, filtered to the five tracked tool names above.
  • Untouched siblings are derived from the worktree file listing (git ls-files via the session worktree tree API — the same source the File Browser uses). If the listing hasn't loaded or fails, the +N untouched files rows simply don't render; the touched-file tree still works.
  • Path classification uses a straight prefix match against the session's worktree root. Paths that don't start with that root land in the Outside worktree branch.

Plan Block

Some agents break their work into a structured plan — a list of tasks with progress tracking. When a plan is active, it appears as an anchored bar at the bottom of the session view.

What the Plan Shows

Each plan item has a status icon:

  • Green checkmark — Completed
  • Amber circle — In progress
  • Grey dot — Pending

The plan bar updates in real time as the agent works through tasks.

Collapsed View

By default, the plan bar is collapsed. In this state it shows:

  • A "Plan" label
  • A progress count (e.g. 2/5) indicating how many items are completed out of the total
  • A preview of the currently in-progress items

Expanding and Collapsing

Click anywhere on the plan bar to expand it. The expanded view shows the full list of all plan items with their status icons, scrollable if the list is long. Click the bar again to collapse it back to the summary view. The toggle arrow rotates to indicate the current state.

Session Features

Prompt Input

The prompt input supports several features:

  • Slash commands — Type / to see available commands with fuzzy matching autocomplete
  • File references — Type @ to autocomplete file paths for attaching context
  • Image attachments — Click the paperclip icon or drag image files onto the session to attach screenshots and other local images to your next prompt. See Image Attachments for details
  • Config options — Dynamic options bar above the input for adjusting agent behavior
  • Multi-line input — The textarea auto-grows as you type
  • Queued prompts — Submit additional prompts while the agent is still working; they are held in a queue and sent automatically when the agent finishes

Queued Prompts

You can continue typing and submitting prompts while the agent is processing a previous one. Instead of blocking input, the prompt is added to a queue that is displayed as a row of removable chips above the input area.

When the agent completes its current task, all queued prompts are automatically sent together as a single prompt submission. Each queued prompt becomes a separate content block so the agent sees them as distinct instructions.

  • Queue while running — The textarea stays enabled during agent execution. Press Enter to add a prompt to the queue.
  • Visual indicator — Queued prompts appear as labelled chips with a "Queued" heading. Click the × on any chip to remove it before it is sent, or click the chip to edit its text.
  • Drag to reorder — Drag and drop chips to change the order in which prompts are sent. Prompts are submitted left to right.
  • Automatic flush — When the agent finishes, the queue is flushed immediately without any manual action.
  • Button hint — While the agent is running, the send button changes to a + icon and its tooltip reads "Queue prompt" to indicate that submissions are queued rather than sent immediately.

Session Sidebar

The left sidebar lists all sessions for the current project:

  • Status icon — Shows the current state of each session (see Session Status Indicators above)

  • Auto-labeling — Sessions are automatically labeled based on the first prompt text

  • Rename — Click a session name to rename it

  • Subtitle — Below each session label, a subtitle line shows the persona name (when the session was created with a persona) or the agent name (for sessions without a persona, or when the original persona has since been deleted), followed by the session creation date. The agent ID is used as a last resort if the agent is not currently known to the client. See Using Personas in Sessions for how personas are associated with sessions.

  • Mode pill — Sessions in a non-default mode display a coloured pill next to the agent/date line: orange ROOT for project-root, blue SCRATCH for scratch sessions

  • Context menu — Click the kebab menu (three dots) on a session item to access actions:

    • Archive / Unarchive — Move the session to or from the archived section (hidden for project-root sessions, which cannot be archived)
    • Permanently Delete — Remove the session and its worktree
    • Commit actions — Configured commit actions from project settings, enabled when the worktree has staged, unstaged, or untracked files
    • Merge actions — Configured merge actions from project settings, enabled when the session branch has commits ahead of its base branch
    • Status info — Shows commits ahead of the base branch and a summary of file changes (staged, modified, untracked)

    For a failed session the menu is still available but the commit, merge, and pull-request entries are disabled — there's no agent connection or session branch to act on. Archive and Permanently Delete are the only meaningful actions and are how you remove the row from the list.

For details on configuring commit and merge actions, see the Actions guide.

Cancelling

Click the cancel button (visible while the agent is running) to stop the agent mid-response. The session remains open and you can send new prompts.

Multiple Sessions

You can have multiple sessions open within a project. The sidebar lets you switch between them. Each session maintains its own independent conversation history and isolated worktree with its assigned agent.