TUI session persistence missing — no SQLite database at ~/.local/state/cleveragents/tui.db created or used #8500

Open
opened 2026-04-13 20:12:57 +00:00 by HAL9000 · 0 comments
Owner

Metadata

  • Commit message: feat(tui): implement SQLite session persistence at ~/.local/state/cleveragents/tui.db
  • Branch name: feat/tui-sqlite-session-persistence

Background and Context

The v3.7.0 milestone scope explicitly requires:

"Session persistence (SQLite at ~/.local/state/cleveragents/tui.db)"

The TUI architecture ADR-044 specifies that TUI session state must be persisted to a SQLite database at ~/.local/state/cleveragents/tui.db. This is a foundational requirement for session resumption across TUI restarts and is a prerequisite for the multi-session tab feature (#8445).

Code evidence of the gap:

Inspection of src/cleveragents/tui/app.py and the entire src/cleveragents/tui/ directory confirms:

  • No SQLite import or database initialization anywhere in the TUI codebase
  • No ~/.local/state/cleveragents/tui.db path reference
  • SessionView is a minimal in-memory dataclass with no persistence:
@dataclass(slots=True)
class SessionView:
    """Minimal per-session TUI view model."""
    session_id: str
    transcript: list[str]
    # No persistence — lost on TUI exit
  • PersonaState uses only in-memory dicts with no SQLite backing
  • The only TUI persistence is the last-used persona name in ~/.config/cleveragents/tui-state.yaml (YAML, not SQLite, and only for persona config — not session state)

Commit: c5820266fd5b63e1dbfce833159e6d9791d530f4
Branch: main

Current Behavior

The TUI has no SQLite session persistence. When the TUI exits:

  • All session conversation state (transcript, active session ID, session history) is lost
  • No ~/.local/state/cleveragents/tui.db file is created or used
  • The TUI always starts with a fresh SessionView(session_id="default", transcript=[])
  • Session resumption is impossible

Expected Behavior

Per the v3.7.0 spec and ADR-044:

  • A SQLite database must be created at ~/.local/state/cleveragents/tui.db on first TUI launch
  • TUI session state (session IDs, conversation transcripts, active session) must be persisted to this database
  • On TUI restart, the last active session must be restored from the database
  • The database path must follow XDG Base Directory Specification (~/.local/state/)
  • The database must be created automatically if it does not exist

Acceptance Criteria

  • ~/.local/state/cleveragents/tui.db is created on first TUI launch
  • TUI session state is persisted to the SQLite database during a session
  • Restarting the TUI restores the last active session from the database
  • The database path follows XDG Base Directory Specification
  • The database is created automatically if it does not exist
  • BDD tests from the TDD issue pass (no longer @tdd_expected_fail)
  • Existing TUI BDD tests continue to pass

Subtasks

  • Create src/cleveragents/tui/persistence/ module with SQLite-backed session store
  • Implement TuiSessionStore class that creates and manages ~/.local/state/cleveragents/tui.db
  • Define SQLite schema for TUI session state (session_id, transcript, active_session, timestamps)
  • Wire TuiSessionStore into CleverAgentsTuiApp.__init__() and on_mount()
  • Persist session state on TUI exit (or incrementally on each message)
  • Restore last active session on TUI startup from the database
  • Write BDD scenarios verifying persistence and restoration
  • Verify coverage >= 97% via nox -s coverage_report
  • Run nox (all default sessions), fix any errors

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly.
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly.
  • The commit is submitted as a pull request to main, reviewed, and merged before this issue is marked done.

Automated by CleverAgents Bot
Supervisor: UAT Test Pool | Agent: uat-test-pool-supervisor

## Metadata - **Commit message**: `feat(tui): implement SQLite session persistence at ~/.local/state/cleveragents/tui.db` - **Branch name**: `feat/tui-sqlite-session-persistence` ## Background and Context The v3.7.0 milestone scope explicitly requires: > "Session persistence (SQLite at ~/.local/state/cleveragents/tui.db)" The TUI architecture ADR-044 specifies that TUI session state must be persisted to a SQLite database at `~/.local/state/cleveragents/tui.db`. This is a foundational requirement for session resumption across TUI restarts and is a prerequisite for the multi-session tab feature (#8445). **Code evidence of the gap:** Inspection of `src/cleveragents/tui/app.py` and the entire `src/cleveragents/tui/` directory confirms: - No SQLite import or database initialization anywhere in the TUI codebase - No `~/.local/state/cleveragents/tui.db` path reference - `SessionView` is a minimal in-memory dataclass with no persistence: ```python @dataclass(slots=True) class SessionView: """Minimal per-session TUI view model.""" session_id: str transcript: list[str] # No persistence — lost on TUI exit ``` - `PersonaState` uses only in-memory dicts with no SQLite backing - The only TUI persistence is the last-used persona name in `~/.config/cleveragents/tui-state.yaml` (YAML, not SQLite, and only for persona config — not session state) **Commit:** `c5820266fd5b63e1dbfce833159e6d9791d530f4` **Branch:** `main` ## Current Behavior The TUI has no SQLite session persistence. When the TUI exits: - All session conversation state (transcript, active session ID, session history) is lost - No `~/.local/state/cleveragents/tui.db` file is created or used - The TUI always starts with a fresh `SessionView(session_id="default", transcript=[])` - Session resumption is impossible ## Expected Behavior Per the v3.7.0 spec and ADR-044: - A SQLite database must be created at `~/.local/state/cleveragents/tui.db` on first TUI launch - TUI session state (session IDs, conversation transcripts, active session) must be persisted to this database - On TUI restart, the last active session must be restored from the database - The database path must follow XDG Base Directory Specification (`~/.local/state/`) - The database must be created automatically if it does not exist ## Acceptance Criteria - [ ] `~/.local/state/cleveragents/tui.db` is created on first TUI launch - [ ] TUI session state is persisted to the SQLite database during a session - [ ] Restarting the TUI restores the last active session from the database - [ ] The database path follows XDG Base Directory Specification - [ ] The database is created automatically if it does not exist - [ ] BDD tests from the TDD issue pass (no longer `@tdd_expected_fail`) - [ ] Existing TUI BDD tests continue to pass ## Subtasks - [ ] Create `src/cleveragents/tui/persistence/` module with SQLite-backed session store - [ ] Implement `TuiSessionStore` class that creates and manages `~/.local/state/cleveragents/tui.db` - [ ] Define SQLite schema for TUI session state (session_id, transcript, active_session, timestamps) - [ ] Wire `TuiSessionStore` into `CleverAgentsTuiApp.__init__()` and `on_mount()` - [ ] Persist session state on TUI exit (or incrementally on each message) - [ ] Restore last active session on TUI startup from the database - [ ] Write BDD scenarios verifying persistence and restoration - [ ] Verify coverage >= 97% via `nox -s coverage_report` - [ ] Run `nox` (all default sessions), fix any errors ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly. - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly. - The commit is submitted as a **pull request** to `main`, reviewed, and **merged** before this issue is marked done. --- **Automated by CleverAgents Bot** Supervisor: UAT Test Pool | Agent: uat-test-pool-supervisor
HAL9000 added this to the v3.7.0 milestone 2026-04-13 20:13:01 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#8500
No description provided.