UAT: tui-state.yaml missing fields: last_preset, last_session_id, sidebar_state, theme_override, window dimensions #1357

Open
opened 2026-04-02 16:58:05 +00:00 by freemo · 0 comments
Owner

Bug Report: [tui/persona] — tui-state.yaml only persists last_persona, missing 6 other spec-required fields

Severity Assessment

  • Impact: Medium. TUI state is not fully persisted across sessions. Users lose their last preset selection, sidebar state, window dimensions, and theme override every time they restart the TUI.
  • Likelihood: 100% reproducible — the fields are simply not written.
  • Priority: Medium

Location

  • File: src/cleveragents/tui/persona/registry.pysave_state() and set_last_persona() (lines 186–203)

Description

The specification (ADR-045 §Persona Storage Format) defines the tui-state.yaml file as containing:

# ~/.config/cleveragents/tui-state.yaml
last_persona: "feature-dev"
last_preset: "think: high"
last_session_id: "01HXM8C2..."
sidebar_state: "visible"            # hidden | visible | fullscreen
theme_override: null                # null = use config.toml setting
window_width: 180
window_height: 50

Actual Behavior

The PersonaRegistry only saves and reads last_persona. The save_state() method is a generic dict writer, but set_last_persona() only writes one key:

def set_last_persona(self, name: str) -> None:
    lock = self._lock_file(self.state_lock_path)
    try:
        state = self.load_state()
        state["last_persona"] = name
        self.save_state(state)
    finally:
        ...

Verified via runtime test:

reg = PersonaRegistry(config_dir=tmp)
reg.set_last_persona('test-persona')
state = reg.load_state()
print(list(state.keys()))
# Output: ['last_persona']
# Missing: last_preset, last_session_id, sidebar_state, theme_override, window_width, window_height

Expected Behavior (from spec)

The PersonaRegistry (or a dedicated TuiStateManager) should:

  1. Persist last_preset when the user cycles presets
  2. Persist last_session_id when the session changes
  3. Persist sidebar_state when the sidebar state changes
  4. Persist theme_override when the user changes the theme
  5. Persist window_width and window_height when the window is resized
  6. Restore all these values on startup

The load_state() method should return these fields (with sensible defaults when absent), and the TUI app should use them to restore state on startup.

Steps to Reproduce

import tempfile, shutil
from pathlib import Path
from cleveragents.tui.persona.registry import PersonaRegistry

tmp = Path(tempfile.mkdtemp())
try:
    reg = PersonaRegistry(config_dir=tmp)
    reg.set_last_persona('my-persona')
    state = reg.load_state()
    
    expected_fields = ['last_persona', 'last_preset', 'last_session_id', 
                       'sidebar_state', 'theme_override', 'window_width', 'window_height']
    missing = [f for f in expected_fields if f not in state]
    print(f"Missing fields: {missing}")
    # Output: Missing fields: ['last_preset', 'last_session_id', 'sidebar_state', 
    #                          'theme_override', 'window_width', 'window_height']
finally:
    shutil.rmtree(str(tmp))
  • #1315 (Refactor TUI to Align with ADR-44 and ADR-45)

References

  • ADR-045 §Persona Storage Format
  • src/cleveragents/tui/persona/registry.py lines 186–203
## Bug Report: [tui/persona] — `tui-state.yaml` only persists `last_persona`, missing 6 other spec-required fields ### Severity Assessment - **Impact**: Medium. TUI state is not fully persisted across sessions. Users lose their last preset selection, sidebar state, window dimensions, and theme override every time they restart the TUI. - **Likelihood**: 100% reproducible — the fields are simply not written. - **Priority**: Medium ### Location - **File**: `src/cleveragents/tui/persona/registry.py` — `save_state()` and `set_last_persona()` (lines 186–203) ### Description The specification (ADR-045 §Persona Storage Format) defines the `tui-state.yaml` file as containing: ```yaml # ~/.config/cleveragents/tui-state.yaml last_persona: "feature-dev" last_preset: "think: high" last_session_id: "01HXM8C2..." sidebar_state: "visible" # hidden | visible | fullscreen theme_override: null # null = use config.toml setting window_width: 180 window_height: 50 ``` ### Actual Behavior The `PersonaRegistry` only saves and reads `last_persona`. The `save_state()` method is a generic dict writer, but `set_last_persona()` only writes one key: ```python def set_last_persona(self, name: str) -> None: lock = self._lock_file(self.state_lock_path) try: state = self.load_state() state["last_persona"] = name self.save_state(state) finally: ... ``` Verified via runtime test: ```python reg = PersonaRegistry(config_dir=tmp) reg.set_last_persona('test-persona') state = reg.load_state() print(list(state.keys())) # Output: ['last_persona'] # Missing: last_preset, last_session_id, sidebar_state, theme_override, window_width, window_height ``` ### Expected Behavior (from spec) The `PersonaRegistry` (or a dedicated `TuiStateManager`) should: 1. Persist `last_preset` when the user cycles presets 2. Persist `last_session_id` when the session changes 3. Persist `sidebar_state` when the sidebar state changes 4. Persist `theme_override` when the user changes the theme 5. Persist `window_width` and `window_height` when the window is resized 6. Restore all these values on startup The `load_state()` method should return these fields (with sensible defaults when absent), and the TUI app should use them to restore state on startup. ### Steps to Reproduce ```python import tempfile, shutil from pathlib import Path from cleveragents.tui.persona.registry import PersonaRegistry tmp = Path(tempfile.mkdtemp()) try: reg = PersonaRegistry(config_dir=tmp) reg.set_last_persona('my-persona') state = reg.load_state() expected_fields = ['last_persona', 'last_preset', 'last_session_id', 'sidebar_state', 'theme_override', 'window_width', 'window_height'] missing = [f for f in expected_fields if f not in state] print(f"Missing fields: {missing}") # Output: Missing fields: ['last_preset', 'last_session_id', 'sidebar_state', # 'theme_override', 'window_width', 'window_height'] finally: shutil.rmtree(str(tmp)) ``` ### Related Issues - #1315 (Refactor TUI to Align with ADR-44 and ADR-45) ### References - ADR-045 §Persona Storage Format - `src/cleveragents/tui/persona/registry.py` lines 186–203
freemo self-assigned this 2026-04-02 18:45:19 +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#1357
No description provided.