Skip to content

Fix LMTerminal streaming and preserve config reads#6

Open
sderev wants to merge 2 commits into
mainfrom
streaming-hotfix
Open

Fix LMTerminal streaming and preserve config reads#6
sderev wants to merge 2 commits into
mainfrom
streaming-hotfix

Conversation

@sderev

@sderev sderev commented Apr 14, 2026

Copy link
Copy Markdown
Owner

What changed

  • Use model-aware streamed reasoning_effort for the gpt-5* family: keep minimal for gpt-5/gpt-5-mini/gpt-5-nano, use low for gpt-5.1/gpt-5.2, and omit the argument for gpt-5-chat-latest.
  • Detect when streamed output cannot use a refreshable rich.Live surface and fall back to plain flushed chunk writes.
  • Force per-chunk Rich redraws with auto_refresh=False and live.update(..., refresh=True) in refreshable terminals.
  • Stop rewriting ~/.config/lmt/config.json during theme reads; malformed or missing config now falls back to defaults without modifying disk state.
  • Add regression coverage for GPT-5-family streamed request args, raw and Rich streaming presentation, dumb-terminal fallback, and non-destructive config reads.
  • Add changelog fragments for the streaming and config-preservation fixes.

Why

  • The first hotfix pass still failed for real GPT-5-family usage: gpt-5.1 and gpt-5.2 reject streamed reasoning_effort="minimal", while gpt-5-chat-latest rejects reasoning_effort entirely.
  • Visible streaming responsiveness still depends on terminal capabilities, so non-refreshable terminals need a plain flushed fallback.
  • LMTerminal also had a config-read bug where theme reads could rewrite ~/.config/lmt/config.json when the file was malformed or missing.

How to test

  • Automated:
    • uv run pytest -q tests/lib_test.py tests/gpt_integration_test.py
    • gate
  • Manual:
    • uv run lmt prompt "count from 1 to 10" and confirm visible output starts before full completion.
    • uv run lmt prompt --raw "count from 1 to 10" and confirm raw chunks appear progressively.
    • TERM=dumb uv run lmt prompt "count from 1 to 10" and confirm output still streams progressively.
    • If your account has access, run streaming prompts with --model gpt-5.1 and --model gpt-5-chat-latest and confirm no reasoning_effort request errors.
    • Put malformed JSON in ~/.config/lmt/config.json, run uv run lmt prompt --no-stream "hello", and confirm LMTerminal falls back to defaults without rewriting the file.

Risk/comp notes

  • Streaming behavior changed in lmterminal/gpt_integration.py and lmterminal/lib.py.
  • GPT-5-family streamed requests now branch on model prefix to avoid unsupported reasoning_effort values.
  • Rich output in non-refreshable environments degrades to plain streamed text instead of trying to live-refresh.
  • Config reads are fail-soft and read-only; only explicit saves write config.json.

Changelog fragment

  • yes
  • These are user-visible streaming and config-preservation fixes.

@sderev sderev changed the title Fix streaming in dumb terminals Fix LMTerminal streaming and preserve config reads Apr 15, 2026
@sderev

sderev commented Apr 15, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

sderev and others added 2 commits April 15, 2026 17:10
* Fall back to plain flushed writes when `rich.Live` cannot refresh streamed output.
* Force per-chunk rich redraws with `live.update(..., refresh=True)` in refreshable terminals.
* Use model-aware streamed `reasoning_effort`: keep `minimal` for `gpt-5`/`gpt-5-mini`/`gpt-5-nano`, use `low` for `gpt-5.1`/`gpt-5.2`, and skip it for `gpt-5-chat-latest`.
* Add regression tests for terminal streaming behavior and GPT-5-family streamed request args.
* Update changelog fragments for both streaming fixes.

Summary: This keeps streamed output visible across terminal types and avoids streamed GPT-5-family request failures while preserving low-latency token delivery where supported.

Co-authored-by: AI <ai@sderev.com>
* Keep `load_config()` read-only and fail-soft for missing, invalid, or non-object JSON.
* Return default markdown theme values in getters without writing to disk.
* Add regression tests for malformed and missing `config.json` scenarios.
* Add a changelog fragment for the user-facing bug fix.

Summary: This prevents theme reads from overwriting `~/.config/lmt/config.json` during normal usage.

Co-authored-by: AI <ai@sderev.com>
@sderev sderev force-pushed the streaming-hotfix branch 3 times, most recently from e9a5b63 to 13f6bf4 Compare April 15, 2026 21:42
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.

1 participant