Skip to content

Allow change the modes, models and select agents to be used #40

@wilcorrea

Description

@wilcorrea

Allow changing ACP mode, model, and agent in-session

Problem

ACP mode/model/agent are not fully controllable from the session UI.
Need runtime selectors + persistence, without breaking current planning workflow.

Goals

  • Add runtime selectors for mode, model, agent.
  • Persist per-session selections.
  • Apply workspace defaults for new/empty sessions.
  • Keep deterministic behavior while streaming.
  • Gracefully degrade when ACP does not expose model/agent options.

Out of Scope

  • Whisper model UX changes.
  • Non-ACP provider integration.

Layout Changes

Current (header has session/phase/connection only)

┌─────────────────────────────────────────────────────────────────────────────┐
│ [Session Name] [#sessionId] [Phase ▼] [Connect/Reconnect] [window actions]│
├─────────────────────────────────────────────────────────────────────────────┤
│ Chat panel                                              | Plan panel       │
└─────────────────────────────────────────────────────────────────────────────┘

Proposed (add ACP controls in header as chips)

┌─────────────────────────────────────────────────────────────────────────────┐
│ [Session Name] [#sessionId] [Phase ▼] [Mode ▼] [Model ▼] [Agent ▼] [Adv ▼]│
│ [Connect/Reconnect]                                         [window actions]│
├─────────────────────────────────────────────────────────────────────────────┤
│ Chat panel                                              | Plan panel       │
└─────────────────────────────────────────────────────────────────────────────┘

Header behavior

  • Controls disabled when:
    • streaming (isStreaming=true)
    • disconnected
  • Model/Agent hidden or disabled with “Unavailable from ACP” when options are absent.
  • Keep workflow auto-switch:
    • planning => force plan mode
    • approve => force agent mode
    • append notice message when auto-switched.

Technical Plan

1) ACP contract support (Rust + TS)

  • Extend ACP types with config options:
    • available config options
    • selected config options
  • Add Tauri command:
    • acp_set_config_option(workspace_id, session_id, config_id, option_id)
    • maps to ACP session/set_config_option
  • Register command in invoke_handler.
  • Parse config-option update events in useAcpSession.

2) Persistence

  • Add acp_preferences_json TEXT NOT NULL DEFAULT '{}' to sessions.
  • Add table workspace_acp_defaults:
    • workspace_path TEXT PRIMARY KEY
    • acp_preferences_json TEXT NOT NULL DEFAULT '{}'
    • updated_at TEXT NOT NULL
  • Add commands:
    • session_update_acp_preferences(id, acp_preferences_json)
    • workspace_acp_defaults_get(workspace_path)
    • workspace_acp_defaults_set(workspace_path, acp_preferences_json)
  • Remove workspace defaults in forget_workspace_data.

3) Preference application order

  • On session init:
    1. load ACP session info
    2. load session prefs
    3. if empty -> load workspace defaults
    4. apply mode first, then config options
    5. ignore stale/invalid selections safely
  • On successful user selection:
    • update ACP
    • persist session prefs
    • upsert workspace defaults

4) UI implementation

  • Add AcpSessionControls component in ActiveSessionView header.
  • Controls:
    • Mode selector (existing ACP modes)
    • Model selector (ACP config detected as model)
    • Agent selector (ACP config detected as agent)
    • Advanced selector for remaining config options
  • Update useAcpSession return contract:
    • expose structured modes
    • expose config options + selected values
    • add setConfigOption(configId, optionId)

5) i18n

  • EN/PT keys for:
    • labels (Mode, Model, Agent, Advanced)
    • disabled/unavailable text
    • auto-switch notice

Data Contract

acp_preferences_json

{
  "modeId": "string | null",
  "selectedConfigOptions": {
    "configId": "optionId"
  }
}

Resolution rules

  • Session prefs override workspace defaults.
  • Workspace defaults apply only when session prefs are empty.
  • Invalid IDs are dropped (no hard failure).

Acceptance Criteria

  • User can change mode at runtime.
  • User can change model/agent when ACP exposes those options.
  • Selections persist per session and restore on resume.
  • New/empty sessions inherit workspace defaults.
  • Selectors disabled during streaming.
  • Missing model/agent options do not break UI.
  • Plan workflow auto-switch still works and shows notice.

Test Plan

Frontend

  • useAcpSession parses mode/config update events correctly.
  • Preference merge logic tests:
    • session > workspace defaults
    • fallback to workspace defaults
    • stale IDs ignored
  • AcpSessionControls rendering tests:
    • normal state
    • streaming disabled state
    • unavailable model/agent state
  • selector action tests invoke expected Tauri commands.

Backend

  • migration tests for new column/table.
  • command tests for get/set prefs.
  • command test for acp_set_config_option.

References

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions