Skip to content

fix(editor): GET /api/config/content returns empty text for a live session-trial config #97

Closed

Description

@falbany

Follow-up to the YAML config editor (#95), identified in the post-implementation review (brainstorm 2026-11-04).

Problem

Edit the file in the Config Editor → click Apply → close the modal → reopen it (StatusBar "Config"). The editor shows an empty document with the header note "session trial (not anchored to disk)" instead of the live in-memory configuration that was just applied.

Root cause

GET /api/config/content (src/profiles/server/routes/config.py:362-380) answers content: "" + session_trial: true whenever has_disk_path(state) is false. Configs applied via POST /load-content (the editor's Apply action, and dropped .profiles files) swap state.config but the raw YAML text is discarded during parsing — there is nothing to echo back to a reopened editor.

Proposed solution

  • Add a field to ServerState (src/profiles/server/state.py): trial_content: str | None = None.
  • In /load-content (src/profiles/server/routes/config.py): store state.trial_content = payload.content alongside state.config = loaded.
  • In the session-trial branch of /content: return {"filename": ..., "content": state.trial_content or "", "config_path": None, "session_trial": True} instead of the empty content.
  • Clear state.trial_content = None on every disk anchoring path: _apply_config_from_disk (covers /load, /save, /save-as, /create) and /reload — a recorded disk anchor invalidates the trial text.

Acceptance criteria

  • Editor reopened after Apply shows the exact applied text; header still reads "session trial (not anchored to disk)".
  • After /save, /save-as, /load, /create or /reload, /content returns the disk file content with session_trial: false.
  • A recorded-but-missing file still answers 404 (unchanged).
  • No state change on GET /content (read-only remains read-only).

Tests

  • tests/server/routes/test_config_editor.py:
    • apply content via /load-content → GET /content returns the same text, session_trial=True, config_path=None;
    • then /load a disk config → /content returns the file text, trial content cleared;
    • update the existing "empty body for session trial" assertion accordingly.
  • Vitest (src/profiles/web/src/components/ConfigEditorModal.test.tsx): modal reopened after a mocked Apply shows the applied text, not an empty document.

Activity

  1. added
    bug
    on Nov 4, 2026
  2. added a commit that references this issue on Nov 4, 2026
  3. added this to the v1.0.0 milestone on Nov 4, 2026
  4. added a commit that references this issue on Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions