Repository navigation
Read Stats through remote functions - #45
Open
vivecuervo7 wants to merge 8 commits into
Open
vivecuervo7 wants to merge 8 commits into
vivecuervo7 wants to merge 8 commits into
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The page no longer fetches, polls or tracks loading and errors itself: navigating to it waits for its data, the analysis updates as it changes, and the polling that carried on after leaving the page is gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hile one runs The live read now listens before it reads, so a change made while a value is on its way isn't missed, and the analysis state is wrapped afresh each time its module loads, so a dev server keeps telling those waiting after an edit. A reset that fails for any other reason is an error, not a conflict. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An open Stats page held each shutdown for the full half-minute. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…error page Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
vivecuervo7
commented
Nov 7, 2026
…n, and style the error page's heading A failed stream keeps its last value, so a run's frozen progress, or results just reset, went on showing in place of the error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
vivecuervo7
commented
Nov 7, 2026
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.
What
The Stats page reads and changes its data through SvelteKit's remote functions, as the trial of whether the rest of Docent should.
stats.remote.ts:getStats(query),getAnalysis(query.live, yielding the analysis whenever it changes), andstartAnalysis/resetAnalysis(command; reset while a run is going is a 409).getAnalysis().current/.error), so an analysis failure shows inline beside the stats rather than replacing the page. Its fetches, its polling, its loading and error flags and template branches, the nativeconfirm()and the/api/statsroutes are gone.messageOfreads a remote function's error, which isn't anError: its message is in its body.+error.svelte, so a failing query, or an unknown URL, shows on a page of Docent's own with its header and a way back.server.jsends live streams straight away on shutdown, as an open page would otherwise hold it for the full half-minute.experimental.remoteFunctionsandcompilerOptions.experimental.asyncare on, each with a comment on why.Why
Remote functions are where SvelteKit is heading, and this page has every shape the rest of Docent needs: reads, changes, and a value that changes while a job runs. What it shows decides how the remaining pages move off their hand-written fetching.
How
What the trial found, all on a production build (
npm start) with a copy of the data:await, as it would for a load. From the start page, the URL changes at 51 ms with the old page still showing, and Stats appears whole at 76–102 ms, with no loading flash and no placeholder to write. A cold load is blank until the stats arrive (94 ms here), as with any load; the old page showed a spinner.query.livestreams. The response istext/event-stream, carries the guard'sframe-ancestorsheader without trouble, and a reset updates the open page in about 290 ms, with no reload.Lines: the page loses 44 and gains 25 (ignoring whitespace), and the two routes lose 25. The new remote module, change notification and error helper add about 65, with their tests. The gain is behaviour more than size: no leaking poll, no hand-written loading states, live updates, and a real error page.
Not checked: starting an analysis for real, as it costs model calls. The command's error path was checked by answering it with SvelteKit's error envelope in the browser.
🤖 Generated with Claude Code