Skip to content

feat(desktop): #5685 draggable sash to resize Opened files - #5807

Merged
Jocs merged 5 commits into
marktext:developfrom
VictorVow:feat/opened-files-resize
Oct 21, 2026
Merged

Jocs merged 5 commits into
marktext:developfrom
VictorVow:feat/opened-files-resize

Conversation

@VictorVow

@VictorVow VictorVow commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Closes #5685

Related: #5353, #5473

Summary

Add a draggable, keyboard-accessible separator below Opened files when more than four files are open. The list defaults to four rows and never leaves empty space when tabs close.

The list remembers the user's chosen height across sidebar view changes and application restarts. Automatic viewport and content limits only affect the rendered height: shrinking the window and restoring it brings back the chosen height. An explicit drag or keyboard adjustment starts from the currently visible height and saves the new choice. Dragging beyond either bound does not accumulate hidden distance, so reversing direction responds immediately.

Reserve 150px for the project section, including the separator's height. In very short windows, allow the file list to show fewer than four rows to preserve that space. Recalculate the limit after expanding the list, enabling Opened files in preferences, showing the sidebar, or returning from Search.

Pointer capture handles dragging, cancellation, and cleanup. The separator supports Arrow keys, Shift+Arrow for four rows, Home/End, a visible focus indicator, and current ARIA bounds. Resize state and interaction live in useOpenedFilesResize.ts; tree.vue owns the layout.

Merged current develop and resolved conflicts while retaining its multi-folder sidebar.

Before / after:

pr-resize-before pr-resize-after

Type of change

  • New feature (non-breaking, adds functionality)

Validation

  • macOS: production build (pnpm build:unpack)
  • pnpm lint: no errors (existing warnings)
  • pnpm typecheck
  • Unit tests: 113 files, 1182 tests passed. The isolated worktree used a temporary Vite filesystem allowlist for its shared dependency directory.
  • Resize E2E: 15 tests passed, covering handle visibility, view changes, keyboard controls, both drag bounds, viewport restoration, explicit resizing while constrained, collapse/expand, preference and sidebar visibility, tiny windows, app restart, closing/reopening tabs, and pointer cancellation.
  • Adjacent sidebar E2E: 3 tests passed for persisted sidebar state and the multi-folder workflow.

The previous narrow-window nudge test now checks the agreed interaction: an explicit adjustment replaces the remembered height; passive viewport changes preserve it.

@Jocs Jocs left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes: the common path works, but I reproduced two runtime cases that violate the stated resize behavior, and the new E2E coverage is stateful.

  1. High: reopening the list can remove the project tree entirely. tree.vue:364 sets listHeightLimit to Infinity while the list is hidden. Shrinking the window then produces a ResizeObserver callback, but expanding the list does not change the observed tree-view size, so the limit is never recomputed. Reproduction: choose a 448px list, collapse Opened files, shrink the window to 420px, then expand it. The list returns at 448px and the project tree is 0px high. Recalculate the limit after showOpenedFiles changes, ideally after nextTick, and cover this sequence in E2E.

  2. Medium: a narrow-window drag overwrites the remembered height. tree.vue:377 clamps listHeight to the temporary viewport limit, then tree.vue:382 persists that clamped value. Reproduction: choose 448px, shrink the window, nudge the handle, restore the window. The list remains around 136px instead of returning to 448px. Keep the requested height separate from the rendered and viewport-clamped height.

  3. Medium: the new tests are order-dependent. issue-5685-opened-files-resize.spec.ts:78 relies on the preceding test to open more than four tabs. Running only the dragging test with -g times out waiting for the handle. The final test also relies on state from earlier tests. Each test should establish its own tabs and starting height.

  4. Suggestion: the sash is mouse-only. The handle at tree.vue:71 is a non-focusable div with only mousedown. Consider role=separator, aria-orientation, tabindex=0, and Arrow Up/Down resizing.

CI is green, but the added tests do not exercise cases 1 and 2. The branch is also currently conflicting with develop; merge-tree reports a conflict in tree.vue, primarily from the later comment-removal changes. Please rebase while addressing the findings.

Once more than four files are open, a handle under the sidebar Opened
files list lets it be dragged taller. The height is clamped between four
rows and the rows' own height, always leaves room for the project tree
(also when the window shrinks), and is kept in localStorage.
@VictorVow
VictorVow force-pushed the feat/opened-files-resize branch from 6bdd445 to e902873 Compare October 21, 2026 10:31
@VictorVow

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review, all four points addressed in the rebased branch (e902873a):

  1. Stale limit on re-expand: updateListHeightLimit now no-ops while the list is hidden instead of writing Infinity, and a watch on showOpenedFiles recomputes the limit after nextTick on expand. Covered by a new E2E test replaying your exact sequence (448px → collapse → shrink to 420px → expand → project tree keeps >100px).
  2. Clamped drag overwriting the stored height: drag deltas now apply to the requested height, not the rendered one, and the persisted value is only bounded by the 4-row minimum; the viewport and content clamps are render-only. A nudge while clamped leaves the remembered height intact; covered by a dedicated test.
  3. Order-dependent tests: moved to beforeEach/afterEach so each test launches its own app and opens its own tabs; every test passes standalone under -g now.
  4. Keyboard access: the handle is role="separator" with tabindex="0", aria-orientation, aria-valuenow, and an aria-label; Arrow Up/Down resize by one row (Shift for four), Home/End jump to min/max. E2E coverage included.

Rebased onto current develop; the tree.vue conflict from the comment cleanup is resolved. CI green pending.

@Jocs
Jocs merged commit 2c5a95c into marktext:develop Oct 21, 2026
11 checks passed
@VictorVow
VictorVow deleted the feat/opened-files-resize branch October 21, 2026 20:34
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.

[Feature] Draggable sash to resize the sidebar "Opened files" section

2 participants