Skip to main content

Overview

A Session is a single chat conversation with an AI assistant within a worktree. Each worktree can have multiple sessions, allowing you to work on different tasks simultaneously or organize your work by topic.

Session Structure

Session Type

Chat Message

Tool Calls

Assistant messages contain tool calls representing AI actions:
Tool calls are displayed inline in the chat, showing what the AI is doing (reading files, running commands, editing code).

Session Lifecycle

1. Creation

Sessions are created automatically when you open a worktree for the first time, or manually via the “New Session” button.

2. Active Session Management

Jean tracks the active session per worktree:
When you switch tabs, Jean updates active_session_id and persists it to disk.

3. Running a Session

When you send a message:
  1. Message is added to session.messages
  2. AI backend starts streaming response
  3. Tool calls are executed in real-time
  4. Assistant message is saved when complete
  5. Session updated_at timestamp is updated
Multiple sessions can run concurrently. Jean tracks sending/waiting state per session, so you can queue work across different sessions.

4. Archiving

Archive a session to hide it from the active list:
  • Sets archived_at timestamp
  • Hidden from session tabs
  • Viewable in “Archived Sessions” modal
  • Deleted after retention period (default: 7 days)

5. Deletion

Permanently delete a session:
Deleting a session removes all messages, tool calls, and run logs permanently. This cannot be undone.

Session Naming

Jean can automatically name sessions based on your first message:
Auto-naming workflow:
  1. User sends first message
  2. AI generates a short, descriptive name (max 4-5 words)
  3. Session name is updated (e.g., “Fix login button bug”)
  4. session_naming_completed is set to true
The default naming prompt is:
You can customize this in Settings → Advanced → Magic Prompts.

Context Management

Session Context (JSONL Logs)

Each session stores full conversation logs in JSONL format:

Saving Context

Save important context for reuse:
This:
  1. Generates an AI summary of the session
  2. Saves as markdown file with frontmatter
  3. Stored in ~/Library/Application Support/<app>/session-context/
  4. Can be loaded into any future session

Loading Context

Load saved context into a session:
Context files are appended to your message as references the AI can read.

Session Recovery

Jean automatically recovers from crashes:
On startup, if a session has last_run_status: 'running':
  1. Jean detects the crash
  2. Recovers the partial message from JSONL logs
  3. Marks message with recovered: true
  4. Shows recovery banner in UI

Session Digests (Recaps)

When you return to a session that was active in the background, Jean can generate a brief recap:
Experimental feature. Enable in Settings → Advanced → Session Recap.
Digests help you quickly remember what you were working on without reading through the entire conversation.

Waiting for Input States

Sessions can wait for user input in two scenarios:

1. AskUserQuestion

The AI asks for clarification:
UI shows a question form. Session remains blocked until answered.

2. ExitPlanMode (Plan Approval)

In plan mode, the AI proposes a plan and waits for approval:
UI shows “Approve” / “Reject” buttons. On approval, plan is executed.
You can queue messages while a session is waiting. They’ll execute after you respond.

Permission Denials

When tools require approval (in plan mode or restricted tools):
UI shows a permission dialog. User can approve/deny, and the approval is sent back to the CLI.

Code Review Results

Sessions can store AI code review results:
Code reviews are triggered via the “Review” button or magic command, and results are displayed in a sidebar panel.

Labels

Organize sessions with custom labels:
Labels appear as colored badges on session cards in canvas view.

Token Usage Tracking

Jean tracks token usage per message and aggregates totals per session.

Storage Format

Sessions are stored in JSON:

Projects and Worktrees

Learn about project organization and worktree management

AI Chat

Configure AI backends, models, and chat settings