Skip to content

fix(workspace): keep the file view and tree frame stable - #735

Merged
nixuuu merged 4 commits into
devfrom
fix/workspace-file-stability
Nov 14, 2026
Merged

nixuuu merged 4 commits into
devfrom
fix/workspace-file-stability

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

Files panel and file tab view: one stable frame. Before this, opening a file made the tree add and drop a "Loading files…" row, notices pushed the text down, and the text reflowed when highlighting arrived.

What changed

Tree (web, mobile shares the domain fix)

  • A refresh of a directory that already has entries adds no row. Watch-triggered revalidation used to append Loading files… after every open. The directory row shows a spinner in its chevron slot; for the root, the spinner sits in a reserved slot in the panel header. A state row now appears only for a directory's first read (as a skeleton row where its entries will appear) or for a next page, in place of Load more under the same key.
  • First load: skeleton rows on the tree grid, also while the tree chunk loads (with the header strip).
  • Git status, live-update status and errors are a pill over the bottom of the list. The list gets bottom scroll room, so rows never move.
  • Rows: density-chrome, a fixed chevron slot, folder/folder-open/file icons, indentation guides, inset rounded hover/selected, a fixed status-letter slot, truncated names. Extracted to WorkspaceTreeRow / WorkspaceTreeSkeleton.

File view

  • One 40px bar for every file type. The path holds the left edge and controls keep their order from the right. Source/Rendered is shown from the file name (disabled until the text loads), so it no longer pops in.
  • Notices (Plain text + Enable highlighting, preparing a large file, Showing the first 2 MB, line outside the preview + Go to line, Unsaved changes, watch status) are one compact pill in the bar (FileNoticePill), with the full sentence in its tooltip. In a narrow bar it shows the icon and a short action; at phone width the action moves to the ⋯ menu and Edit becomes an icon. Conflict and error banners stay, because they need a decision.
  • The reader fixes its frame from the first paint, using one pass over the text (@canopy/syntax/layout: line count, longest line, UTF-8 size). The gutter is at least 3 digits, so files up to 999 lines share one width, and longer files get their width from the known count. The plain-text decision and the scroll height no longer change when indexing finishes. Highlighting only recolours.
  • Preparing the file… appears only when indexing takes more than 300 ms.
  • The reader module is loaded once for all tabs, so a loaded tab mounts in the same frame (no empty {#await} flash). A file that is still loading shows an empty surface, then, after 300 ms, skeleton lines on the reader grid. Text fades in with t-rise. Reduced motion is respected.
  • Polish: 8px text inset, bg-surface behind both the gutter and the text, subtle line numbers, a selection colour, and a path:31 range with a tinted gutter and a 2px accent marker.

Mobile: the reader's notices and the tree's status and errors became an overlay pill. The plain-text decision is known before indexing. This is JS-only: the iOS/Android fingerprints match dev (138e0c6…, 906dc94…).

Layout-shift measurements

The fixture repo has 10 files, opened by clicking in the tree in this order: AGENTS.md (4 lines), CHANGENOTES.md (260 KB, plain), CLAUDE.md (modified), CURRENT_TASK.md, PROGRESS.md (1,500 lines), README.md, yarn.lock (864 KB lockfile), logo.png, src/app.ts, src/generated.ts (12,000 lines). Measured in Chromium per click over 2.5 s:

  • layout-shift entries are summed, including those with hadRecentInput.
  • rAF sampling covers the first line's y, the text x and the bar height (all within the same document), the tree row count and the last row's y.
Run CLS sum First-line y moves Text x moves Bar height changes Tree row-count changes Last tree row moves
dev, dark, 1440 0.137 60 px 45 px 0 28 1120 px
this PR, dark, 1440 0 0 0 0 0 0
dev, light, 1100 0.203 40 px 23 px 0 27 1184 px
this PR, light, 1100 0 0 0 0 0 0

Text x still changes between two different files when one has ≥1000 lines (a wider gutter). Within a file it never changes.

Browser review

Done on a review machine with a disposable stack and fixture repo, both removed afterwards. It covered light and dark at 1440 and 1100, and phone at 390:

  • small, large (plain), markdown (Source/Rendered), lockfile, binary, image and long files;
  • a 31-33 highlight;
  • Files sheet on phone.

Not in this PR's scope: at 390 px the thread header's active tab name overlaps the Files button. That belongs to the header/tabs, not the file view.

Copy audit (docs/copy.md §8)

Before After Reason
Large files are shown as plain text to keep them responsive. (row) Pill Plain text, same sentence in the tooltip Short state label; the sentence is kept
Enable highlighting Same; Highlight in a narrow bar Verb first; a short form for limited width
Preparing the rest of the file… Preparing the file… Shorter; one idea
Showing the first 2 MB. This file is read only. (row) Pill Showing the first 2 MB, full text in the tooltip Docs term kept
This line is outside the preview. Choose a visible line. (row) Pill Line outside the preview + Go to line, full text in the tooltip The action replaces the instruction
Unsaved changes (row while editing) Same text, as the pill No text change
Loading files… (row) Skeleton row, same text for screen readers No visible text change

The glossary is unchanged. Every new button starts with a verb, and no fact is repeated. Short and long paths were checked at desktop and phone widths. Status letters keep their accessible labels.

Checks

  • bun install, gen:check, typecheck, lint, format:check: clean.
  • Tests: packages/syntax/src/layout.test.ts (new, pure layout logic), tests/integration/thread-directory.test.ts and tests/integration/thread-watch.test.ts pass.
  • The web build passes.
  • expo export passes for iOS and Android.
  • I did not run the full check:tmp.

Related: #640, #711

@nixuuu
nixuuu force-pushed the fix/workspace-file-stability branch from afbaeab to a475514 Compare November 14, 2026 16:35
@nixuuu
nixuuu marked this pull request as ready for review November 14, 2026 16:35
@nixuuu
nixuuu merged commit fa377d5 into dev Nov 14, 2026
13 checks passed
@nixuuu
nixuuu deleted the fix/workspace-file-stability branch November 14, 2026 16:47
nixuuu added a commit that referenced this pull request Nov 14, 2026
Long active file names could extend outside the workspace tab strip and
overlap Files at phone widths. The non-shrinking active tab was
introduced in #711.

The title now gives space to tabs first. Thread keeps its slot, file
names truncate within the available strip, and extra tabs collapse into
+N using a rem-based width budget. Files uses an icon with an accessible
name and tooltip below 40 rem. Its slot and the existing thread actions
stay fixed when tabs open or close. The responsive Files control is
extracted into WorkspaceFilesToggle; workspace documentation reflects
the behavior.

Fixes: #711

### Validation

- Passed with nice and TMPDIR under /var/tmp: bun install, bun run
typecheck (including Svelte: 0 errors/warnings), bun run lint, bun run
format:check, bun run --filter @canopy/web build. Ran bun run format
after edits.
- Browser review against a disposable remote stack: light and dark at
320, 390, 768, 1100 and 1440 px, plus 1920 px bounds. Checked
short/typical/164-character titles, 11 kept file tabs, the long active
filename, Thread and its summary pill. No page-level horizontal
overflow; active tabs stay inside the strip.
- Files x positions before/after closing/reopening a tab were unchanged:
280, 350, 684.5, 1016.5, 1356.5 and 1836.5 px respectively at
320/390/768/1100/1440/1920 px. The +N menu selects the long file and
returns focus to its visible tab.
- No UI test suites added or run. Review servers, database container,
tunnel and temporary directories cleaned up.

### Copy audit (§8)

Files text button → Files icon-only on phones; the same English
accessible name is preserved and becomes the tooltip. Desktop copy is
unchanged. No new error or empty-state text. Checked short and long
labels at phone and desktop widths; the icon is not the only accessible
cue.

Based on dev including #734. #735 was still open during validation; its
files-view changes are not included in this PR.
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.

1 participant