Skip to content

Studio: add a Download all logs button to Settings > Logs - #10719

Merged
danielhanchen merged 13 commits into
mainfrom
feat/logs-download-all
Sep 13, 2026
Merged

danielhanchen merged 13 commits into
mainfrom
feat/logs-download-all

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Sep 10, 2026 •

Copy link
Copy Markdown
Member

Settings > Logs could only copy the visible tail of one file. Sharing a problem meant collecting the server log and each runner's log by hand, and the desktop app had no way to reach the log folder at all.

One button now packs every log into a ZIP. On desktop it saves straight to the Downloads folder and the toast shows the full path of the file, with a Show in folder action. In a browser it downloads the normal way, into the browser's own downloads folder.

This is a deliberately small version of what #9714 and #10271 set out to do. Most of what those need already exists on main, so this reuses it instead: require_loopback_url and stream_url_to_path for the desktop transfer, browserDownload for the web one, debug_log_sources.list_sources for the allowlist, and redact_log_text for the masking. open_logs_dir in particular was already a registered Tauri command that opens ~/.unsloth/studio and had simply never been called from the UI, so wiring it up needed no Rust at all.

What changed

Backend

  • utils/debug_log_export.py: every log the picker already lists, packed as <family>/<filename> with no host path in the member names, each record through the existing redact_log_text. Sources are opened with O_NOFOLLOW | O_NONBLOCK and the descriptor's device and inode are compared against the pre-open stat, so an entry swapped for a link, a FIFO or another file between the walk and the read is refused rather than followed.
  • GET /api/settings/debug/logs/export in routes/settings.py: the same get_current_subject plus _require_ui_session pair as the two debug log routes above it, so an API key or keyless caller gets 403 exactly as it does for the single file viewer.

Desktop

  • download_logs_to_downloads in native_file_dialogs.rs streams the archive into dirs::download_dir() and returns the real path. It mints its own session inside the command rather than accepting a token over IPC, and rewrites host, port and path before minting, so the webview names the endpoint but never chooses it.
  • open_logs_dir is used exactly as it is on main.

Frontend

  • Two buttons beside Copy visible log, with Open logs folder gated on isTauri. No redesign of the tab.
  • Eleven new settings.debugging keys across all twelve locales.

How the archive is bounded

The 10 per family cap in debug_log_sources bounds files, not bytes, and the active session log is never rotated, so it is routinely many GB on its own. Three limits, all of which name what they left out in EXPORT_WARNINGS.txt rather than dropping it silently:

Limit Value Why
Tail per file 8 MB The end of a log is the part that explains a problem
Total source bytes 32 MB A browser export lands in a Blob in the tab's memory
Build wall clock 15 s Well inside the desktop downloader's 30 s header timeout

Families are taken round robin rather than in list order, so a large server log cannot spend the whole budget before the runner logs are reached. The route also holds a process wide semaphore and answers 429 rather than queueing, because it is a sync def on the shared 40 thread pool and a second concurrent build would starve every other sync endpoint.

Safety properties

Each of these has a regression test that was confirmed to fail without its fix.

  • A tail seek never begins mid record. redact_log_text is anchored on a key name sitting next to its value, so a read starting in the middle of a record hands out a credential whose key was in the part that got skipped. The seek scans forward to a real newline, bounded by the size taken from the descriptor, and refuses the file if the tail holds no boundary at all. An aws_secret_access_key has no prefix for a shape rule to catch, so that anchor is the only defence it has.
  • A record the redactor cannot read is refused, not replaced. A UTF-16 log decoded with errors="replace" keeps a NUL between every character, so HF_TOKEN=hf_... becomes H\x00F\x00_\x00T..., every masking rule stops matching, and the record is copied through with the credential still readable to anyone who opens the archive or runs strings on it. PowerShell redirection writes UTF-16LE by default.
  • A record over 32 KiB is dropped whole with a marker rather than split, for the same anchoring reason. That is the same per line cap the viewer already uses, which also keeps the redactor's per call cost in the same range as the tab's.
  • Member names are family and basename only, and EXPORT_WARNINGS.txt carries neither a host path nor a wall clock. Warnings are built from type(exc).__name__ and errno rather than str(exc), since OSError.__str__ appends the filename.

Not in this PR

studio/backend/utils/log_redaction.py, debug_log_sources.py, debug_log_reader.py, core/inference/tools.py, routes/auth.py and the loopback_http.rs, desktop_auth.rs and commands.rs Tauri files are byte identical to main. That is checked on every test run rather than assumed.

Two pre-existing gaps in log_redaction.py turned up while testing this and are worth their own change rather than being folded in here:

  • _ANSI_RE backtracks quadratically on an unterminated OSC introducer. 40k such characters take about 15.8 s against 0.005 s for the same length of ordinary text. This affects the live viewer today, not just the export. Sent separately.
  • PEM private key blocks and YAML block scalars are not masked at all, line by line or whole.

Verification

  • studio/backend: 245 pass across test_debug_log_export.py and the existing test_debug_log_redaction.py, test_debug_log_routes.py, test_debug_log_sources.py and test_debug_log_reader.py. The 203 pre-existing ones pass untouched, which is the point.
  • studio/src-tauri: cargo check --all-targets clean, 530 tests pass.
  • tests/studio/test_desktop_reliability_frontend_contract.py: 36 pass.
  • studio/frontend: tsc -b and tsc -p tsconfig.test.json clean, npm run i18n:check:strict passes, 7286 tests pass. eslint reports the same four pre-existing errors in debugging-tab.tsx as main, none on changed lines.
  • ruff clean on the changed Python.

Measured end to end on this host: 600 MB of ordinary logs across three families builds in 12.4 s and yields 32 MB kept; a 12 MB log of pathological ANSI content builds in 16.8 s where it takes about 16 minutes without the wall clock limit.

The desktop path was exercised on Linux. macOS and Windows desktop runs are still to be confirmed. No model or GPU paths are touched, so no GPU checks were run.


Screenshots

Two isolated Studio installs (install.sh --local, separate UNSLOTH_STUDIO_HOME), one at this PR's merge base 743471746 and one at head 0ba8a4bba, driven through the same scene. BEFORE is the merge base rather than main, so the pair credits this PR with its own change and nothing else that landed today.

Settings > Logs, whole tab

Settings > Logs, whole tab

The action area, same clip on both sides

The action area

Facts read from the same two servers that were photographed:

fact BEFORE AFTER
Download all logs (.zip) button absent present
note naming EXPORT_WARNINGS.txt absent present
GET /api/settings/debug/logs/export 404 200
response content type none application/zip
body really is a ZIP no yes
Cache-Control none no-store, no-cache, must-revalidate, private

Copy visible log, the pre-existing "masked in this view" note, the log pane, Location and the Mode pills are on both halves unchanged.

Open logs folder is absent from both halves and that is correct, not a missed click: it is gated on isTauri and these shots are a browser. On desktop it calls open_logs_dir, which was already registered in main.rs on main and had no call site anywhere in the frontend.

Settings > Logs could only copy the visible tail of one file. Sharing a
problem meant collecting the server log and each runner's log by hand,
and the desktop app had no way to reach the log folder at all.

Backend

- utils/debug_log_export.py packs every log the picker already lists
  into one ZIP, each record passed through the existing redact_log_text.
  The allowlist is debug_log_sources.list_sources, unchanged, so the
  bundle can never contain a file the tab would not have shown.
- GET /api/settings/debug/logs/export carries the same two dependencies
  as the debug log routes beside it, so an API key or keyless caller is
  refused with 403 exactly as it is for the single file viewer.

The archive is bounded three ways, because the 10 per family cap in
debug_log_sources caps files and not bytes and the session log is never
rotated: an 8 MB tail per file, a 32 MB budget across all of them, and a
15 second ceiling on the whole build. The tail is kept rather than the
head, and the families are taken round robin so a large server log
cannot spend the whole budget before the runner logs are reached.
Anything left out is named in EXPORT_WARNINGS.txt rather than dropped
silently.

Desktop

- download_logs_to_downloads streams the archive to the OS Downloads
  folder and returns its real path. It reuses require_loopback_url and
  stream_url_to_path, mints its own session rather than accepting one
  over IPC, and rewrites host, port and path before minting, so the
  webview names the endpoint but never chooses it.
- open_logs_dir was already registered and never called from the UI. It
  is now wired to a button, unchanged.

Frontend

- Two buttons beside Copy visible log, with Open logs folder gated on
  desktop. On desktop the toast shows the saved path and reveals that
  folder; in a browser the file lands in the browser's own downloads.
- Four new settings.debugging keys across all twelve locales.

Safety properties, each with a regression test that fails without its
fix: a tail seek never begins mid record, since redact_log_text is
anchored on a key name next to its value and a cut between the two hands
out the credential in the clear; a record the redactor cannot read as
UTF-8 is refused rather than decoded with replacement, because a UTF-16
log decoded that way keeps a NUL between every character and every
masking rule stops matching; archive member names are family and
basename only; EXPORT_WARNINGS.txt never carries a host path or a
wall clock.

studio/backend/utils/log_redaction.py, debug_log_sources.py,
debug_log_reader.py, core/inference/tools.py, routes/auth.py and the
loopback_http.rs, desktop_auth.rs and commands.rs Tauri files are
untouched.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-13T14:40:59.819452Z ce5ba15 Manual request
🔒 Security Review ✅ Completed 2026-09-13T12:12:41.202404Z 0ba8a4b Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

The four failing checks split into three causes, all reproduced locally
before being changed.

pre-commit.ci and Repo tests (CPU) were the same cause: debug_log_export.py
and test_debug_log_export.py were not a fixed point of the repo's own
ruff-format-with-kwargs hook, and tests/test_formatter_fixed_point.py exists
to catch exactly that. Running that guard with the pinned ruff 0.6.9 named
those two files and no others; it passes now.

CodeQL reported one new high-severity py/clear-text-storage-sensitive-data
alert on the test fixtures. The query classifies a local by its NAME --
maybeSecret() is `(?is).*((?<!is|is_)secret|...).*` -- so three locals called
`secret` were the taint source, not the synthetic AWS and HF strings they
held. Renamed to planted_value, anchor and link_target. The tests assert the
same things about the same values.

The Python 3.13 leg was not this branch. Backend CI on main was red from
09-10 to 09-12 and went green on 09-13; the same suite run here against the
merge base and against this head gives 393 failed / 38463 passed and 392
failed / 38507 passed, with no failure in any debug-log, export or settings
test, and the three test_desktop_auth.py failures present identically on
both sides.

Then three defects, each with a regression test confirmed to fail without
its fix.

A record cut short by the byte allowance was emitted as though it were
whole. Reachable rather than theoretical: when _seek_to_tail takes the
forward-scan path it starts later than size - allowance, so on a log being
appended to -- the active session log, which is live by definition while
someone is exporting it -- the read ends on the allowance instead of on EOF.
The trailing bytes are then the front of a record, and redact_log_text needs
several characters of value before it masks, so a cut landing just past a
key ships the first few in the clear. The two ways the loop ends cannot be
told apart afterwards, so it now records which one happened and emits a
marker rather than the fragment.

_member_name deduplicated case-sensitively, but the volume the archive is
EXTRACTED on decides what collides. On Windows and default APFS, Server.log
and server.log are one name, so two members landed on top of each other and
one log was silently lost, which is the failure that function exists to
prevent. The collision key is folded with .lower(); casefold over-folds for
a filename. Member names keep their real spelling.

A source whose window was shrunk by the remaining budget was reported as
"no complete record in the last N bytes", blaming the file for a condition
owned by the budget -- and because that path deliberately does not spend
remaining, the wrong message repeated for every later source. It now says
which of the two caps produced the window.

Also: Cache-Control: no-store on the export response, so a bundle of every
log on the host is not written to the browser's on-disk cache and a second
export is not answered from it (raised in review). strip_verbatim_prefix
moved its body to a function compiled on every platform, because gating the
whole thing behind cfg(windows) left the UNC branch covered on no platform
at all, and the prefix match is now case-insensitive so a lowercase \\?\unc\
cannot degrade to something that reads as a relative path.

Verification: 250 pass across test_debug_log_export.py and the four existing
debug-log suites, up from 245. cargo check --all-targets clean and 531 Rust
tests pass, up from 530. Frontend 7286/7286, tsc and i18n:check:strict
clean, and eslint reports the same four pre-existing errors as main with
none on changed lines. 500 simulation scenarios across the backend, the
cross-platform surface and the frontend all pass.

Two things this host cannot answer and which staging CI should: a real
Windows or macOS compile of src-tauri (aws-lc-sys needs MSVC lib.exe or a
macOS SDK), and the Windows filesystem cases -- os.fstat on FAT32, the ReFS
FileIdInfo fallback, and a UNC-mounted Downloads folder.

One residual is now documented rather than implied: O_NOFOLLOW does not
exist on Windows, so _open_verified cannot refuse a non-symlink file reparse
point. It is bounded by the realpath check in debug_log_sources, and a hard
link into the log directory is accepted on every platform anyway.
@danielhanchen

Copy link
Copy Markdown
Member Author

Verification of d030677

The four red checks

Three were this branch's fault, one was not. All reproduced locally before anything was changed.

Check Cause Fixed
pre-commit.ci - pr debug_log_export.py and test_debug_log_export.py were not a fixed point of the repo's own ruff-format-with-kwargs hook yes
Repo tests (CPU) same cause, caught by tests/test_formatter_fixed_point.py, which exists for exactly this yes
CodeQL 1 new high-severity py/clear-text-storage-sensitive-data on the test fixtures yes
(Python 3.13) not this branch n/a

The formatter guard is the clean proof: run with the pinned ruff 0.6.9 it fails on the head as opened, naming those two files and no others, and passes after the fix.

without: 1 failed, 5 passed   ... not a fixed point of the ruff-format-with-kwargs hook:
                                  studio/backend/tests/test_debug_log_export.py
                                  studio/backend/utils/debug_log_export.py
with:    6 passed, 0 skipped

CodeQL classifies a local by its name, not by what it holds: maybeSecret() is (?is).*((?<!is|is_)secret|...).*. Three locals called secret were the taint source. Renamed to planted_value, anchor and link_target; the synthetic AWS and HF strings and the tmp_path fixtures are unchanged, so the tests assert the same things about the same values.

The Python 3.13 leg was not this branch. Backend CI on main was red from 09-10 to 09-12 and went green on 09-13. Running the same suite against the merge base and against this head:

merge base db3e48a2a head 5b7e2659e
failed 393 392
passed 38463 38507
errors / skipped 366 / 338 366 / 338

One fewer failure, and no failure in any debug-log, export or settings test. The only PR-adjacent failures, three in test_desktop_auth.py, are present identically on both sides.

Before and after

One script, run against both trees with the same seeded log home:

merge base head
GET /debug/logs/export 404 200, application/zip
routes registered /debug/logs, /debug/logs/sources those two unchanged, plus /debug/logs/export
members n/a server/...log, llama-server/...log
seeded HF_TOKEN in the archive n/a masked
host path in member names n/a none
/debug/logs/sources 200, families [llama-server, server] identical

open_logs_dir on main is defined in commands.rs and registered in main.rs with zero call sites in the frontend, so the "no way to reach the log folder" half was dead code rather than a missing feature.

Three defects found by simulation

About 500 scenarios were written against this branch: 348 backend, 152 cross-platform, plus frontend probes. Each defect below has a regression test confirmed to fail without its fix.

A record cut short by the byte allowance was emitted as though it were whole. Reachable rather than theoretical: when _seek_to_tail takes the forward-scan path it starts later than size - allowance, so on a log being appended to -- the active session log, which is live by definition while someone is exporting it -- the read ends on the allowance instead of on EOF. The trailing bytes are then the front of a record, and redact_log_text needs several characters of value before it masks, so a cut landing just past a key ships the first few in the clear: _records(b"password=SECRETVALUE12345\n", limit=13) returned ['password=SECR']. The loop now records which of the two ways it ended and emits a marker instead of the fragment.

_member_name deduplicated case-sensitively, but the volume the archive is EXTRACTED on decides what collides. On Windows and default APFS, Server.log and server.log are one name, so two members landed on top of each other and one log was silently lost -- the exact failure that function's own docstring says it exists to prevent. The collision key is now folded with .lower(); .casefold() over-folds for a filename. Member names keep their real spelling.

A source whose window was shrunk by the remaining budget was blamed for it, reported as no complete record in the last 4 bytes when the budget, not the file, was what ran out -- and because that path deliberately does not spend remaining, the wrong message then repeated for every later source. It now says which of the two caps produced the window.

Cross-platform

The worst case I could think of was that os.fstat on Windows returns st_ino = 0, which would make the device/inode check raise ESTALE for every source and ship a Windows archive containing nothing but warnings. It does not: _Py_fstat_noraise calls GetFileInformationByHandle and GetFileInformationByHandleEx(FileIdInfo) and populates both fields on 3.10 through 3.14. The "always zero" wording is in the docs for os.DirEntry.stat(), which this code never uses.

One residual is now documented rather than implied. O_NOFOLLOW does not exist on Windows, so the getattr fallback drops it. True symlinks and junctions are still refused, but any other file reparse tag is traversed by os.stat and by the open, so before and after agree. Closing it needs CreateFileW with FILE_FLAG_OPEN_REPARSE_POINT, which os.open cannot express. It is bounded by the realpath check in debug_log_sources, and a hard link into the log directory is accepted on every platform anyway.

strip_verbatim_prefix had its body behind cfg(windows), which left the UNC branch covered on no platform at all. The rewrite now lives in a function compiled everywhere with a test that runs on Linux CI, and the prefix match is case-insensitive so a lowercase \\?\unc\ cannot degrade to unc\server\share, which reads as a relative path.

Browsers and old installs

The diff to native-files.ts is function -> export function and nothing else, so browserDownload is byte-identical to main and already ships behind downloadFile(). This introduces no new browser risk. Checked anyway: the anchor is already appended to the DOM before click() (Firefox's old requirement, fixed in FF 70), Safari has honoured download on blob: since 10.1 and WebKit ships a regression test for this exact synchronous-revoke idiom, and 32 MiB is far below any reported limit. The one live WebKit gap, download + blob: in WKWebView, does not apply because the desktop build goes through Rust.

Old installs are safe in the way that matters: a backend too old to have the route returns a real 404, because main.py raises HTTPException(404) for any unknown /api/* and has since the first Studio commit. There is no version where the button saves an HTML page named .zip. 404 maps to "outdated", 403 to "forbidden", 429 to the generic failure with the server's own detail; all verified by running. The desktop error classifier was checked against all 22 error strings reachable from download_logs_to_downloads plus 3 adversarial ones that embed the status phrase mid-string, and all 25 classify correctly.

Totals

before after
debug-log Python suites 245 250
studio/src-tauri 530, cargo check --all-targets clean 531, clean
studio/frontend 7286/7286 7286/7286
tsc -b, tsc -p tsconfig.test.json, i18n:check:strict clean
eslint on debugging-tab.tsx 4 pre-existing same 4, shifted by the +11 inserted lines, none on changed lines

No model or GPU path is touched, so no GPU checks were run.

What this host cannot answer

A real Windows or macOS compile of src-tauri: cargo check --target x86_64-pc-windows-msvc and --target aarch64-apple-darwin both fail in aws-lc-sys, which needs MSVC lib.exe or a macOS SDK. The cfg-gated helpers were type-checked per target with rustc --emit=metadata and the Windows target does select the cfg(windows) arm, but that is not a compile. Three filesystem cases also need hardware: os.fstat on FAT32, the ReFS FileIdInfo fallback, and a UNC-mounted Downloads folder. Staging CI covers Linux, Windows and Apple Silicon macOS and is the right way to close those.

Left for a separate change

The two sibling debug-log routes also set no cache directive, and /debug/logs returns log lines plus realpath, an absolute host path this export goes out of its way never to emit. That is pre-existing on main and outside this diff.

Conflict was in studio/backend/routes/settings.py, where per-account
isolation (#10588) added the three include_router calls at the end of the
module and this branch added the export route in the same place. Both kept,
with main's includes last where it put them.

Not a textual conflict, and the reason this merge needed a person: #10588
also moved /debug/logs and /debug/logs/sources onto _owner_settings_router,
which carries _require_installation_owner. Left on the bare router, the
export would have been reachable on a shared install by an account that is
refused each of those logs individually -- a bundle of every log on the host
being easier to get than one file. Moved onto the same router.

test_the_export_is_owner_gated_exactly_like_the_routes_it_sits_beside pins
it by comparing against the sibling routes rather than by naming a router,
so the three cannot drift apart again; confirmed to fail with the route back
on the bare router.

251 pass across the five debug-log suites.
The Tauri Linux build caught this and my local run did not: I ran cargo
before merging main and not after. DesktopAuthResponse is no longer a struct
with an access_token field, it is an enum, so download_logs_to_downloads
stopped compiling.

The new variant is not a formality. On a shared install desktop auth can
legitimately answer LoginRequired instead of returning tokens, and there is
no token to spend in that case, so the command stops with a message rather
than attempting an unauthenticated download. It is classified as `forbidden`
on the TypeScript side, which is the copy that already says a signed-in
Studio session is what this needs, so no new locale key is required.

The sentinel is matched by its exact text across the language boundary, the
way the existing status pattern is. A test reads debug-logs.ts and fails if
the two ever drift, since a reworded constant would otherwise silently
downgrade the toast to a generic failure.

Also marked strip_verbatim_prefix_inner dead_code off Windows: keeping it
compiled everywhere is what lets the UNC case be tested here, but the only
non-Windows caller is that test, so an ordinary build warned.

537 Rust tests pass, cargo check --all-targets clean with no warning in this
file. Frontend 7409/7409, tsc -b and tsc -p tsconfig.test.json clean,
i18n:check:strict passes.
Found by re-running the simulation suites against the merged head rather
than against the commit they were written for. Marking a size-cut record was
right, but reading the flag alone was not: the loop stops as soon as the
allowance is spent, so a file whose last byte lands exactly on that boundary
never gets the read that would have reported EOF, and its final newline-less
record is complete rather than cut. It was being replaced by the marker.

The descriptor is what separates the two. Bytes beyond what was consumed
mean the record continues into them; none means the file ended there. An
fstat that fails takes the side that cannot mislead.

The regression test now covers all three positions: an allowance inside the
record, an allowance past the end, and an allowance landing exactly on it,
which is the case that was wrong.

251 pass across the five debug-log suites. Of the 348 backend simulations,
343 pass and the 5 that fail are DEFECT PROBE tests asserting the behaviour
these commits changed, plus one that looks the export route up on the bare
router rather than the owner router it now sits on. Of the 152
cross-platform simulations, 143 pass and the 3 that fail are the ones
written to document the case-collision bug.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 0ba8a4bbab

ℹ️ 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".

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 13, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: 0ba8a4bbab

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Post-convergence comment pass. Delete first, shorten second: 346 comment and
docstring lines removed against 182 added, so the five files carry 164 fewer
lines and say the same things.

What went: restatements of the next line, measured numbers that belong in the
PR description rather than the source, and multi-paragraph rationales that
were one fact plus three sentences of throat-clearing. What stayed: every
claim a reader would otherwise get wrong. The Windows O_NOFOLLOW residual,
why the tail seek must resync forward rather than stop at the first probe,
why a NUL-bearing record is refused rather than replaced, why the collision
key is folded with lower() and not casefold(), and why the route sits on the
owner router are all still stated, just once each.

The two Rust files are deliberately untouched: comment_tools.py has no lexer
for Rust, so `check --strict-ext` reports them NOT CHECKED and the AST gate
cannot verify a pass over them. An unverifiable comment edit is worth less
than the lines it saves.

Gate: comment_tools.py check --strip-docstrings --strict-ext, 5/5 code
unchanged (comments only). 251 pass across the five debug-log suites, 48 in
the export suite alone; frontend 7409/7409 with tsc -b clean; pre-commit is a
fixed point.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

… real log folder

Two review findings, both reproduced against the code before being fixed.

The export could never run on a multi-account desktop. `desktop_login` in
routes/auth.py returns login_required UNCONDITIONALLY when
installation_is_multi_user(), because the desktop secret proves which SHELL
owns the backend, not which account is driving it. The command only ever used
that minted session, so on the configuration per-account isolation just
introduced it failed permanently, for an owner who is signed in and looking
at the owner-only tab, with no way to resolve it by signing in again.

It now falls back to the caller's own UI session. That grants the webview
nothing: the token is the one it already holds, and the command pins host,
port and path, so the only thing it can be spent on is this one route on this
install's backend. A minted desktop session is still preferred, and the mint
is still attempted either way because it is also what resolves the live port.

The folder button opened the wrong directory. `open_logs_dir` hard-codes
~/.unsloth/studio while the picker resolves UNSLOTH_STUDIO_HOME and
STUDIO_HOME, so on a custom home it opened something unrelated or errored on
a path that does not exist. It now opens the parent of the selected log's own
realpath, which is the same root the picker read, and falls back to
open_logs_dir only when no source is selected yet. That command is untouched;
this PR is simply the first caller it has ever had.

Tests: the invoke assertion now pins uiToken, so dropping it fails rather
than silently reinstating the multi-account dead end; openLogsFolder is
covered for a configured POSIX home, a Windows path, and the no-selection
fallback. A Rust test reads debug-logs.ts and fails if the tab stops sending
the token.

538 Rust tests pass, cargo check --all-targets clean. Frontend 7411/7411,
both tsc configs clean, i18n:check:strict passes.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

… without a selection

Two follow-ups on the previous fix, both reproduced before being changed, plus
the cross-platform test failures a real Windows and macOS run turned up.

Rust uses the token once and as-is; it cannot retry a 401 by refreshing the
way authFetch does. So a multi-account desktop left idle past the access-token
lifetime exported with a dead token while holding a perfectly good refresh
token. The tab now refreshes before handing it over, and ignores a failed
refresh rather than skipping the attempt, since the stored token may still be
valid and the backend is the real judge.

The folder button still had a wrong branch. Taking the directory from the
selected log fixed the common case but not the one where a custom home holds
no readable log at all, which is precisely when file logging is off: realpath
stays null and the fallback went back to the hard-coded ~/.unsloth/studio.
/debug/logs/sources now reports log_root, taken from the first candidate root
the walk itself prefers, and the button uses the selected log, then that root,
then the old command. The field is additive and optional, so an older client
ignores it.

From the Windows and macOS runs:

- The owner-gating test read `route.path` over `.routes`, which also holds
  _IncludedRouter entries with no path. It raised on both runners and passed
  here purely by FastAPI version, so this was a latent break on any upgrade.
- The seed helpers wrote with write_text, which translates \n to \r\n on
  Windows and moved every byte offset the seek and budget tests compute.
  newline = "" makes those tests mean the same thing on every platform.
- The case-collision round trip cannot be BUILT on a case-insensitive volume,
  since the second write lands on the first file. It now detects that rather
  than failing, and the unit-level test covers the property everywhere.
- Three tests assert POSIX-only premises (mkfifo, a newline in a filename, an
  undecodable filename). They skip where the premise cannot hold, gated on the
  capability rather than the platform name, because macOS has every call the
  surrogate test needs and still refuses the byte sequence.

251 pass across the five backend suites, frontend 7414/7414, both tsc configs
clean, i18n:check:strict passes.
danielhanchen added a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Sep 13, 2026
danielhanchen added a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Sep 13, 2026
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 13, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 13, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 13, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 13, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 13, 2026
chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 13, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 13, 2026
chatgpt-codex-connector[bot]

This comment was marked as resolved.

danielhanchen added a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Sep 13, 2026
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 13, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 13, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 13, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: ce5ba15a5c

ℹ️ 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".

@danielhanchen
danielhanchen merged commit a19c9bd into main Sep 13, 2026
57 checks passed
@danielhanchen
danielhanchen deleted the feat/logs-download-all branch September 13, 2026 16:02
danielhanchen added a commit to Souravrajvi0/unsloth that referenced this pull request Oct 1, 2026
Resolve conflicts with main and rescope to the logging changes:
- llama-server lines reach the INFO session log when llama.cpp tags them W or E
  (keyword fallback for builds without level letters) or on readiness, sharing
  the predicate the 64 MiB tee trim already used, instead of a keyword list.
- Open failures warn on the primary spawn path too; a failing tee warns once per
  attempt and a closed file no longer warns.
- Drop troubleshooting_source_ids and the picker markers: Download all logs
  (unslothai#10719) already collects the session and llama logs together.
- Fold the startup context into the existing startup line.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants