Skip to content

feat(gui): Keep each session's operation log on disk - #109

Merged
miner7222 merged 3 commits into
miner7222:mainfrom
foXaCe:feat/persist-operation-log
Sep 27, 2026
Merged

miner7222 merged 3 commits into
miner7222:mainfrom
foXaCe:feat/persist-operation-log

Conversation

@foXaCe

@foXaCe foXaCe commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The operation log ([Country] …, [ADB] …, [Flash] …) lives in LogHistory, whose archive is an anonymous tempfile(). It disappears when LTBox exits. ltbox.log only carries tracing records from dependencies, not LTBox's own operation lines. So once the app is closed, a failed operation leaves no readable trace unless the user pressed Save Log beforehand.

This came up diagnosing a Change Country Code attempt: nothing in ltbox.log, no backup folder, no way to tell which gate stopped it.

Change

  • LogHistory::persist_to(dir, stamp) mirrors every archived line into logs/sessions/session-YYYY-MM-DD_HH-MM-SS.log (next to ltbox.log), seeded with whatever was archived before the mirror opened (the "Ready" line).
  • App::new turns it on for real sessions. App::default(), used by tests, and demo mode stay in memory only.
  • Clear Log now uses LogHistory::cleared(), which first flushes pending progress and then hands the session file to the fresh history, so clearing the screen does not end the on-disk transcript.
  • Retention: the 30 newest session-*.log files are kept, and older ones are removed when a new session starts. Other files in the folder are left alone.
  • A write error drops the mirror only; the temp-file transcript and Save Log export behave as before.
  • log_dir() is factored out of init_tracing so both use the same folder (same %TEMP%\ltbox-logs fallback for a missing or non-UTF-8 config dir).

Same content as Save Log, including [Debug] lines and the 5-second progress samples.

Testing

  • Regression coverage verifies that unsampled and sampled progress survive Clear Log, repeated clears do not duplicate records, and subsequent lines still reach the same session file.
  • New tests: the session file holds the full transcript (initial line, info, debug) and survives a clear; pruning keeps exactly 30 sessions and ignores unrelated files.
  • cargo test -p ltbox-gui and cargo clippy -p ltbox-gui --all-targets --features demo pass.

Follow-up validation on Windows: workspace clippy with warnings denied, workspace tests, and cargo deny --locked check all pass.

foXaCe and others added 3 commits September 27, 2026 15:07
The operation log (the [Country], [ADB], [Flash] lines) was archived in
an anonymous temp file that vanished when LTBox closed. After a failed
operation the only trace left was ltbox.log, which carries third-party
records but none of LTBox's own lines, so a failure could not be read
back unless the user had pressed Save Log in time.

The archive now also mirrors into logs/sessions/session-<local
time>.log next to ltbox.log, seeded with the lines logged before the
mirror opened. Clearing the on-screen log keeps writing to the same
file. The 30 newest sessions are kept; older ones are removed when a
new session starts. A write error drops the mirror without touching
the in-memory transcript or export. Demo mode stays off disk.
Flush the current progress before handing the session mirror to an empty history. Cover sampled progress and repeated clears without duplicate lines.

Co-authored-by: GPT-6 Astra <noreply@openai.com>
Keep the shared log directory helper alongside the merged iced logging filter. Preserve the session progress flush on Clear Log.

Co-authored-by: GPT-6 Astra <noreply@openai.com>
@miner7222
miner7222 merged commit 04f57da into miner7222:main Sep 27, 2026
15 checks passed
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.

2 participants