Skip to content

refactor: extract document loading session - #274

Merged
alecdotdev merged 1 commit into
sftwrdotdev:masterfrom
PathGao:agent/extract-document-load-session
Jul 30, 2026
Merged

refactor: extract document loading session#274
alecdotdev merged 1 commit into
sftwrdotdev:masterfrom
PathGao:agent/extract-document-load-session

Conversation

@PathGao

@PathGao PathGao commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • move document loading, tab selection, preview loading, and large-file completion guards into documentSession
  • keep rendering, viewport measurement, recent-file UI, and error presentation as MarkdownViewer callbacks
  • preserve the clean revision, dirty-state, and view-mode guard before a deferred full-file result can apply

Depends on #273 (and #272/#271). Merge after #273. This starts the document-session extraction; save, task mutation, watcher, and close flows remain separate follow-up steps.

Validation

  • npm run check
  • npm test (117 passing)
  • cargo test (18 passing)

@PathGao

PathGao commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator Author

@alecdotdev This is the first document-session PR, dependent on #273. It moves loading and the deferred large-file completion guard without changing document mutation behavior; save, task, watcher, and close ownership will follow in smaller dependent PRs.

@PathGao
PathGao force-pushed the agent/extract-document-load-session branch from 110a3c2 to f2b10b8 Compare July 30, 2026 04:00
@PathGao

PathGao commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator Author

@alecdotdev Rebased after #271 merged; its direct parent is the updated #273 branch.

@PathGao
PathGao force-pushed the agent/extract-document-load-session branch from f2b10b8 to 024e831 Compare July 30, 2026 04:54
@PathGao
PathGao force-pushed the agent/extract-document-load-session branch from 024e831 to 80118b6 Compare July 30, 2026 05:04
@alecdotdev
alecdotdev merged commit bb8dbf3 into sftwrdotdev:master Jul 30, 2026
5 checks passed
@PathGao
PathGao deleted the agent/extract-document-load-session branch July 30, 2026 06:28
PathGao pushed a commit that referenced this pull request Aug 3, 2026
`MarkdownViewer.svelte` declares six top-level bindings that the file
never mentions again. They read as live state — a container element, a
render debounce and its timer handle, a per-tab load revision map, a
caret element and its measured offset — so anyone tracing how rendering
or scroll sync works has to prove each one is inert before ruling it
out.

Five were never used at all. `containerEl`, `renderTimeout` and
`renderDebounceMs` arrive in b46a283 and `caretEl`/`caretAbsoluteTop` in
ef219cf, each already at exactly one occurrence in the commit that adds
them: the declaration, and nothing else. `renderDebounceMs = 50` in
particular suggests a debounce that does not exist.

One is refactor residue. `loadRevisionByTab` had four occurrences when
41de13b (#247) added it here. bb8dbf3 (#274) moved document loading into
`documentSession.svelte.ts`, which carries its own map and the three
call sites; the declaration here stayed behind. Two identically named
maps in two files, one of them dead, is worse than either alone —
`scripts/largeFileLoadRevision.test.ts` pins the live one in
`documentSession.svelte.ts` and is unaffected.

Nothing else changes. `npm run check` and `npm run build` were the
check that matters: an unreferenced binding is only safe to remove if
the compiler agrees nothing reaches it, including through Svelte's
`bind:this`, which is why this is verified by a build rather than by
grep alone.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
PathGao pushed a commit that referenced this pull request Aug 3, 2026
`MarkdownViewer.svelte` declares six top-level bindings that the file
never mentions again. They read as live state — a container element, a
render debounce and its timer handle, a per-tab load revision map, a
caret element and its measured offset — so anyone tracing how rendering
or scroll sync works has to prove each one is inert before ruling it
out.

Five were never used at all. `containerEl`, `renderTimeout` and
`renderDebounceMs` arrive in b46a283 and `caretEl`/`caretAbsoluteTop` in
ef219cf, each already at exactly one occurrence in the commit that adds
them: the declaration, and nothing else. `renderDebounceMs = 50` in
particular suggests a debounce that does not exist.

One is refactor residue. `loadRevisionByTab` had four occurrences when
41de13b (#247) added it here. bb8dbf3 (#274) moved document loading into
`documentSession.svelte.ts`, which carries its own map and the three
call sites; the declaration here stayed behind. Two identically named
maps in two files, one of them dead, is worse than either alone —
`scripts/largeFileLoadRevision.test.ts` pins the live one in
`documentSession.svelte.ts` and is unaffected.

Nothing else changes. `npm run check` and `npm run build` were the
check that matters: an unreferenced binding is only safe to remove if
the compiler agrees nothing reaches it, including through Svelte's
`bind:this`, which is why this is verified by a build rather than by
grep alone.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
PathGao added a commit that referenced this pull request Aug 3, 2026
`MarkdownViewer.svelte` declares six top-level bindings that the file
never mentions again. They read as live state — a container element, a
render debounce and its timer handle, a per-tab load revision map, a
caret element and its measured offset — so anyone tracing how rendering
or scroll sync works has to prove each one is inert before ruling it
out.

Five were never used at all. `containerEl`, `renderTimeout` and
`renderDebounceMs` arrive in b46a283 and `caretEl`/`caretAbsoluteTop` in
ef219cf, each already at exactly one occurrence in the commit that adds
them: the declaration, and nothing else. `renderDebounceMs = 50` in
particular suggests a debounce that does not exist.

One is refactor residue. `loadRevisionByTab` had four occurrences when
41de13b (#247) added it here. bb8dbf3 (#274) moved document loading into
`documentSession.svelte.ts`, which carries its own map and the three
call sites; the declaration here stayed behind. Two identically named
maps in two files, one of them dead, is worse than either alone —
`scripts/largeFileLoadRevision.test.ts` pins the live one in
`documentSession.svelte.ts` and is unaffected.

Nothing else changes. `npm run check` and `npm run build` were the
check that matters: an unreferenced binding is only safe to remove if
the compiler agrees nothing reaches it, including through Svelte's
`bind:this`, which is why this is verified by a build rather than by
grep alone.

Co-authored-by: PathGao <gaoyanbo@gaoyanbodeMacBook-Air.local>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
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