Skip to content

Fix bugs found in a full source audit - #1

Closed
wbgcoding wants to merge 7 commits into
mainfrom
claude/quellcode-audit-rmcrv8
Closed

wbgcoding wants to merge 7 commits into
mainfrom
claude/quellcode-audit-rmcrv8

Conversation

@wbgcoding

Copy link
Copy Markdown
Owner

What changes

These are fixes for the bugs a full source audit found and confirmed. The audit covered providers, stats, services and storage, the UI, and the installer and build. Each finding was checked against the code before it was fixed. The commits are grouped by area.

Token index (Stats)

  • Codex token usage was always empty. CodexUsageLogParser required cache_write_input_tokens, and real Codex rollouts never write that field. The repo's own fixture codex-null-windows.jsonl has the real shape. The field is now optional, and a missing value keeps the previous total.
    • Files an older build already walked are read once more. That only happens for files whose four running totals are all 0 and only while this PC has no Codex usage at all, so nothing gets counted twice. It is tracked by a meta key.
  • A file that was cut or replaced between its stat and its open is handled like a shrunk file. Before, it was read again from byte 0.
  • TryReadSchemaVersion: a non-integer version (text, real or blob from a backup zip) returns null. Before, it threw past every catch and closed the app.
  • The custom range is clamped to 2000–2099. A year-1 date threw, and the chart drew roughly 740,000 bars. Custom ranges longer than a year are now drawn per week.

Providers

  • CODEX_HOME is honored.
  • WebUsageSource: only the caller's own cancellation propagates. A hidden session that closes under a running read is now a failed read and no longer an exception out of ClaudeProvider.
  • Account names are no longer cut inside a surrogate pair.
  • The signer certificate in AuthenticodeSignature is disposed.

Services and storage

  • A null entry in hiddenWindows no longer crashes start, import or backup inspection.
  • FullscreenWatcher: with no foreground window, default.Covers(default) counted as full screen. Fixed.
  • AtomicFile flushes to disk before the rename.
  • The history CSV gains a label column at the end, so Cursor's several "Other" series can be told apart.

UI

  • A --tray start left WindowVisible = true, so the widget polled at the open-window pace and the first show skipped its catch-up refresh.
  • A double click on "Add account" for Copilot added the same login twice. The wrapper command now checks CanExecute.
  • The top resize grip now uses GrowManualHeight. Before, it had no content or screen limit and could slide the window off the screen.
  • The update notice and the tile chart captions follow a language switch.
  • The top-projects percentage uses CurrentCulture.
  • Hovering or clicking the value axis of the bar chart no longer picks bar 0.

Installer and build

  • A per-user in-app update passes /RELAUNCH, and WasAppRunning honors it. Before, the app had usually exited before Setup's FindWindow ran. A per-machine update gets no switch, because it would relaunch elevated.
  • Uninstall deletes {userdesktop}\AI-Usage.lnk. Before, it deleted {autodesktop}, which is the Public desktop on a per-machine install.
  • Portable mode no longer copies a setup log to %LOCALAPPDATA%.
  • build.bat quotes paths echoed inside blocks. Before, echo Using %ISCC% with Program Files (x86) closed the else block early.

Not changed (found, but they need a decision first)

  • Claude dedup across files: responses replayed into a new file by --resume are counted again. That needs a design change.
  • Uninstall "remove data" with a moved data folder: DelTree on a folder the user picked is too risky to do automatically.
  • Per-machine relaunch: it would run elevated, because Setup is already started elevated with runas.
  • Codex usage-limit error: it always marks the five-hour window as full, even when the weekly limit was the one hit.
  • Smaller items: the project-colour cache is pruned per call, and ExtraDiskSpaceRequired may double the size Setup asks for.

How it was tested

Every fix comes with a regression test that fails without the fix. The exceptions are App.xaml.cs, MainWindow.GrowUp, the installer and build.bat, which have no test harness.

The build with warnings as errors is green (dotnet build tests/AiUsage.Tests, built on Linux with EnableWindowsTargeting). The tests themselves need Windows/WPF, so they were not run locally; CI on windows-latest runs them.

  • dotnet test tests/AiUsage.Tests passes (CI)
  • New user-facing text is in both Strings.resx and Strings.de.resx (no new UI text)
  • No call to a chat or completion endpoint, no write to another tool's files

🤖 Generated with Claude Code

https://claude.ai/code/session_015EdKSSA9Z5o4FHYiLZajUL


Generated by Claude Code

Codex rollouts carry no cache_write_input_tokens total, so every real
token_count line was skipped and Codex token usage stayed empty. The
field is now optional; files an older build walked without counting a
line are read once more while this PC has no Codex usage yet. A file cut
between its stat and its open is no longer read again from byte 0, a
schema version that is not an integer reads as unknown instead of
throwing, and a custom range is clamped and drawn per week past a year.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015EdKSSA9Z5o4FHYiLZajUL
Codex keeps its sessions under CODEX_HOME when set. A cancellation the
caller did not ask for (a hidden session closed under a running read) is
a failed read instead of an exception out of the provider. Account names
are not cut inside a surrogate pair, and the signer certificate is
disposed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015EdKSSA9Z5o4FHYiLZajUL
A null entry in hiddenWindows threw on every start and on import. An
empty monitor rectangle no longer counts as covered by full screen.
Atomic writes flush to disk before the rename. The history CSV gains a
label column so several Other series can be told apart.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015EdKSSA9Z5o4FHYiLZajUL
A --tray start marked the window visible, so it polled at the open
window pace. A double click on Copilot's add account added the same
login twice. The top resize grip now has the same limits as the bottom
one. The update notice and tile chart captions follow a language switch,
the top projects percentage uses the number format, and the value axis
of the bar chart is no bar.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015EdKSSA9Z5o4FHYiLZajUL
A per-user in-app update passes /RELAUNCH so Setup starts the app again
even when it already closed. Uninstall removes the shortcut from the
user's desktop instead of the Public one, portable setup writes no log
to the PC, and build.bat quotes paths echoed inside blocks so the
Program Files (x86) path of Inno Setup no longer breaks it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015EdKSSA9Z5o4FHYiLZajUL
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015EdKSSA9Z5o4FHYiLZajUL
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015EdKSSA9Z5o4FHYiLZajUL

Copy link
Copy Markdown
Owner Author

build-and-test on c63fb59 failed in SettingsStoreTests.RequestSave_does_not_wait_for_a_file_write_that_is_in_progress. That test asserts a Task.Run finishes within 100 ms while another pool thread sits blocked in BeforeWrite, so its result depends on how busy the runner is.

This PR doesn't change SettingsStore or anything on the RequestSave path. The same test passed in the previous run (ab3b501), where the only difference from c63fb59 was a test string. Re-running the failed job once to confirm.


Generated by Claude Code

@wbgcoding wbgcoding closed this Oct 16, 2026
@wbgcoding
wbgcoding deleted the claude/quellcode-audit-rmcrv8 branch October 16, 2026 21:04
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