Repository navigation
telemetry: mirror every UI toast to the logger at DEBUG (issue #194) - #205
Merged
Merged
Conversation
…T /api/logs/client Phase 1 (issue #194): ServerState.record_external_event — the single choke point for config-handoff UI events — now mirrors every event to the logger as a structured TOAST record at DEBUG via the new events.toast() emitter (source=server kind=... applied=... msg=...). Phase 2 backend: POST /api/logs/client accepts a frontend toast (message 1..500 chars, kind info|error) and logs TOAST source=web at DEBUG. Logging only — never buffers an external event, so no toast feedback loop. New tests/server/test_state.py fills the documented 1:1 test-tree gap for state.py.
…lient showToast — the single choke point behind all ~70 toast call sites — now relays each toast (message + kind) to the new fire-and-forget postClientLog, which the server logs as a DEBUG TOAST source=web record (issue #194). The call is never awaited and every fetch failure is swallowed: telemetry must never break the UI. Server-originated toasts (config handoff via useExternalEvents) pass { mirror: false } — the server already logged them at the record_external_event choke point, so relaying would duplicate the record. The new exported ShowToast type keeps the 3-param signature explicit; existing 2-param deps-bag declarations stay valid. dist/ rebuilt (ships with the package); check-added-large-files now excludes src/profiles/web/dist/ — the minified bundle legitimately exceeds 1 MB and dist is committed on purpose. Web: 397 tests pass, tsc clean.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #194.
What
UI toasts are now traceable in
profiles.logthrough one structured telemetry event:The leading
TOASTtoken makes the records first-class in the Log Viewer's event filter.Phase 1 — server choke point
events.toast()emitter (core/telemetry/events.py), house style (logger first arg, lazy %-args,_quote/_boolparts).ServerState.record_external_eventemits it at DEBUG after buffering — one choke point covering every current and future producer (odoc applier, instance handoff route) with zero call-site changes. Signature unchanged.Phase 2 — frontend mirror
POST /api/logs/client(server/routes/logs.py): Pydantic body (message1–500 chars,kindinfo|error), logsTOAST source=webat DEBUG. Logging only — it never buffers an external event, so there is no toast feedback loop (covered by a dedicated test and verified live:/api/notificationsstays empty after a client-log POST).postClientLog()(web/src/api/client.ts): the codebase's first deliberately error-swallowing call — fire-and-forget, failures silent, per the issue's "logging must never break the UI" guard.showToast(web/src/hooks/useToast.ts) relays every toast unless suppressed. Server-originated toasts (useExternalEvents) pass{ mirror: false }— the server already logged those at Phase 1; relaying would duplicate the record. The new exportedShowToasttype documents the 3-param signature; existing 2-param deps-bag declarations remain valid.Visibility note (from the issue's design note)
DEBUG by design ("nice to have, zero noise"): these records reach
profiles.logwhen the config setsverbose: DEBUG. At the default INFO the log is unchanged (asserted by a regression test).Incidental
tests/server/test_state.pyfills the 1:1 test-tree gap forserver/state.pydocumented intests/AGENTS.md(buffer cap, monotonic ids,external_events_after, telemetry).check-added-large-filesnow exemptssrc/profiles/web/dist/: the minified bundle legitimately crossed 1 MB and dist is committed on purpose (src/profiles/web/.gitignore).tests/AGENTS.md+tests/README.mdsynced with the new test file.Verification
ruff format --check✓,ruff check✓, pylint 9.89/10 ✓, pytest 1588 passed (1 skipped), coverage 87.96% ✓tsc --noEmitclean ✓, dist rebuilt--server-only,verbose: DEBUG):curl POST /api/logs/client→{"status":"ok"}, invalid bodies → 422, andTOAST source=web kind=error msg="smoke toast from curl"confirmed in~/.profiles/profiles.log