Skip to content

feat(types): multi-chat sessions (ahp-chat: channel)#197

Draft
sandy081 wants to merge 7 commits into
mainfrom
sandy081/multi-chat-impl
Draft

feat(types): multi-chat sessions (ahp-chat: channel)#197
sandy081 wants to merge 7 commits into
mainfrom
sandy081/multi-chat-impl

Conversation

@sandy081
Copy link
Copy Markdown
Member

@sandy081 sandy081 commented Jun 5, 2026

Implements the multi-chat sessions proposal (design discussion, approved).

Splits the AHP session model: a session becomes a shared coordination scope (workspace, project, model/agent defaults, tools, config), and a session can hold multiple chats, each its own independently subscribable conversation over the shared scope.

What ships in this PR (Phase 1: protocol types)

  • New ahp-chat: channel. types/channels-chat/{state,commands,actions,reducer}.ts.
  • ChatState carries the turn / input / pending-message state today living on SessionState.
  • ChatSummary with optional per-chat model / agent overrides and an origin?: ChatOrigin provenance field.
  • ChatOrigin discriminated union: User / Fork / Tool (per-call discussion with @connor4312Tool carries { chat, toolCallId } so tool-spawned chats reference their spawning tool call).
  • SessionState changes:
    • Removed: turns, activeTurn, steeringMessage, queuedMessages, inputRequests.
    • Added: chats: ChatSummary[], defaultChat?: URI (UI input-routing hint — not a hierarchy marker).
  • New commands: createChat (with optional ChatForkSource { chat, turnId }), disposeChat.
  • Retargeted commands: fetchTurns / completions now take an ahp-chat: channel URI.
  • Reducer split: turn / input / pending-message handling moved to the chat reducer; session reducer gains chats[] / defaultChat handling.
  • Version bump: PROTOCOL_VERSION 0.3.00.4.0 (allowed pre-1.0 per versioning.md).
  • CHANGELOGs: root + every client.

Subsequent phases (will land in follow-up commits on this branch)

  • Phase 2: regenerate JSON schema.
  • Phase 3: per-client codegen + manual updates (rust / kotlin / swift / typescript / go).
  • Phase 4: docs (chat-channel reference, session↔chat relationship, URI scheme) + integration tests.
  • Phase 5: address surviving open implementation questions from the proposal; finalize release notes.

Verification

  • npm run test passes: 241/241, 100% branch coverage on types/reducers.ts.

Notes for reviewers

  • Proposal lives at docs/proposals/multi-chat-sessions.md on PR docs: add multi-chat sessions proposal #184; design discussion is captured there.
  • Doc updates (chat-channel reference, session↔chat docs) intentionally deferred to Phase 4 so this PR stays a clean type-shape diff.

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

sandy081 and others added 7 commits June 5, 2026 15:39
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The Go generator was missing the ChatToolCallApproved/Denied/Confirmed
discriminated union variants and the ChatAction top-level union from its
explicit-skip list, causing exhaustiveness warnings during codegen.
Kotlin regeneration picked up trivial drift in State.generated.kt.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
_meta?: Record<string, unknown>;
}

export interface ChatSummary {
Copy link
Copy Markdown
Member

@connor4312 connor4312 Jun 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aligned with learnings from #187 I suggest we have a distinct ChatSummary and just denormalize the data on the ChatState as appropriate, instead of having ChatSummary embedded within the ChatState

export interface SessionChatsChangedAction {
type: ActionType.SessionChatsChanged;
/** Updated chat catalog. */
chats: ChatSummary[];
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will also likely want upsert semantics and updates replacing Partial<ChatSummary>. Have your agent look at what we do for sessions/session summaries and mirror that here

/** Human-readable description of what the chat is currently doing */
activity?: string;
/** Last modification timestamp */
modifiedAt: number;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's have this be an ISO timestamp string instead (also a callout from #187)

defaultChat?: URI;
/** Session configuration schema and current values */
config?: SessionConfigState;
/**
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Down below on SessionSummary we should note how that data is expected to be derived from chat data. E.g. activity may be the activity of the primary chat, status should include input needed if any session needs input. Does not need to be too Opus-style lengthy, but just a guide for implementors

/** Optional per-chat agent override (defaults to the session's agent) */
agent?: AgentSelection;
/** How this chat came into existence */
origin?: ChatOrigin;
Copy link
Copy Markdown
Member

@connor4312 connor4312 Jun 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In discussion this morning we brought up the notion of chats in a session having their own working directories. I think this is probably valid and models how some orchestration systems work (agent swarms operating on worktrees and PRing/merging to each other when finishes). We can retain the default/primary workingDirectory on the session level but also should defined them for specific chats

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants