Repository navigation
Description
The gap
docs/architecture/issue-reports.md lists this under Known gaps:
The main process's own warnings, such as a preference file it could not read, still go to the terminal only.
Why it matters
The session log is meant to be "what this run of the app has logged" — every sidecar's output, the renderer's console warnings and errors, and electron-updater's log. Main's own warnings are the one source missing, and a packaged app has no terminal for them to go to instead, so they go nowhere at all.
These are exactly the lines that explain a puzzling report. A window that opens in the wrong place, a theme that reverts to system every launch, an interface that ignores the chosen language: each of those has a one-line warning from main saying the preference file could not be read or written, and the user filing the issue will never see it and never send it.
Where
surfsense_local/electron/src/main/sidecars/supervisor.ts— the pattern already exists here. Itsnote()helper writes the line toprocess.stderrand tosessionLog.append(...)in one call. Reuse that shape rather than inventing a logger.surfsense_local/electron/src/main/session-log/session-log.ts—sessionLog.append(source, text)already strips colour codes, replaces the home directory with~, and caps line length, so nothing extra is needed to make these lines safe to paste into a public issue.- The call sites that write to
process.stderrand nowhere else:i18n/locale-prefs.tswindow-state.tstheme-prefs.tsindex.ts—onSidecarCrash(), and the startup failure near the bottom of the file
Three of those already write [main] at the front of the line by hand, which is what the log's source argument is for.
What done looks like
- A warning main writes appears in Report issue's log, tagged as coming from main, and still appears on the terminal in development.
- One helper, used by every site, rather than a
sessionLog.appendadded beside eachprocess.stderr.write. Two ways to log is how the next one gets missed. - The startup failure in
index.tsfires before any window exists, so it can reach the log but nobody will read it there. Leaving it on stderr alone is a defensible answer; say which you chose. - Update the The session log bullet in
docs/architecture/issue-reports.md, which lists the sources the log carries, and delete the Known gaps line in the same PR.
How to verify
surfsense_local/electron/src/main/session-log/session-log.test.ts covers the log's cleaning rules and is the file to extend. Write the failing test first: call the helper and assert the line is in lines() with its source.
cd surfsense_local/electron
pnpm test
pnpm typecheckBefore you start
Read CONTRIBUTING.md and the issue reports doc. These lines are written by the main process and are never translated — the log is not interface text. Open your PR against dev, not main. Comment here to claim this.
Activity
nisatsama commentedon Sep 29, 2026
I'd like to work on this issue. I'll add a shared main-process logging helper, update the affected call sites and tests, and update the issue-report documentation. I'll target the
devbranch.Ehaan-Dadarkar commentedon Oct 8, 2026
Claiming this — I'll pick it up.
feat(desktop): route main process warnings into the session log
MODSetter commentedon Oct 8, 2026
Fixed by #2205, merged into
dev, by @Ehaan-Dadarkar.The main process's warnings now go through one helper. In development it still writes them to the terminal, and it also adds them to the session log, tagged
main, so Report issue carries them too. That covers a preference or window-state file it couldn't save, a sidecar that crashed, and a failed startup.The Known gaps line this issue quoted is deleted in the same PR. Closing by hand: GitHub only auto-closes on a merge to the default branch, and we merge through
dev.