Repository navigation
feat: allow to drag tabs into new windows and move tabs between windows - #6147
Gentle-Code0 wants to merge 12 commits into
Conversation
Implement the tab-bar visibility prerequisite from marktext#6112 so a fresh window exposes its single document as a tab without requiring the user to enable View > Tab Bar first. - Enable the shared default window layout's tab bar. - Match the View menu's initial checkbox to that default. - Exercise the default single-tab visibility in the existing marktext#5581 E2E suite instead of forcing visibility through the test fixture. Keep explicit visibility toggles and persisted layout choices intact. Tab detachment and cross-window transfers remain follow-up work for marktext#6112. No new settings, state migrations, or tab-count conditions are needed. Validation: - git diff --check passed. - Reviewed the default layout, renderer visibility, and menu sync paths. - Lint, typecheck, build and E2E execution were not completed: local tool dependencies were absent, and pnpm's automatic dependency provisioning encountered slow registry requests and was stopped before checks ran. Refs: marktext#6112
Complete the remaining tab-window interactions from marktext#6112 on top of the existing default-visible tab bar change. - Drag a tab outside its window to create a window near the drop position, or onto another window's tab bar to insert it at the highlighted position. Keep local sorting, tolerate pointer drift and cancel on Escape. - Prepare and checkpoint both renderers, acknowledge the destination's staged editor state, then durably migrate document and recovery ownership. Remove the source tab only after destination confirmation, and create a blank tab when the source becomes empty. - Preserve unsaved drafts, disk baselines, save formats, read-only state, selection, scroll and native undo/redo history. Rebuild undo boundaries from portable text snapshots when crossing editor engines. - Reject every canonical same-path conflict without overwriting either document. Keep separate untitled documents and same-name files at different locations independent. - Retain window-scoped editing modes: incoming tabs follow their destination, while detached windows inherit their source layout and modes. Persist an untitled document's resource base so links and its initial save directory continue to resolve against its origin after a workspace transfer. - Add Move Tab to New Window and Move Tab to Window to every tab context menu, including Shift+F10 access. Use these actions on Wayland, where global coordinates are unavailable, while retaining local drag sorting. - Keep source recovery on failed preparation or metadata replacement, reject stale received state, and restore committed ownership after a renderer failure. Move file watchers with durable ownership. Validation on Linux/X11: - pnpm run lint: passed; 135 existing warnings, unchanged from baseline. - pnpm run typecheck and pnpm run build:unpack: passed. - pnpm run test: 1,764 passed, 2 skipped; includes 15 new unit tests. - Transfer and tab-click E2E: 17 passed, including real X11 pointer input, Escape cancellation, cross-mode undo/redo, scroll restoration, duplicate conflicts, destination closure, origin paths and simulated Wayland menus. - Expanded related E2E: 54/57 passed initially. The startup-cycle timeout passed in isolation (16 seconds). The two remaining failures also occurred before this change: session-recovery-multi.spec.ts:398 and startup-review-regressions.spec.ts:172. Native Windows/macOS and Wayland compositor sessions were not available for validation. Refs: marktext#6112
Remove the redundant document-retention sentence from all 13 locales while keeping conflict and failure notifications. Validation: 70 locale tests, lint (0 errors; 135 existing warnings), and desktop typecheck passed.
Create a new window when releasing over editor content, another window body or the desktop. Preserve local sorting, tab-strip insertion and cancellation. Validation: 23 related unit tests and 19 Electron E2E tests passed; build, lint (135 existing warnings), and typecheck passed. Refs marktext#6112.
Show a non-focusing, mouse-transparent outline outside tab strips. Share fitted screen geometry with the actual detached window and remove the preview on completion or cancellation. Validation: 31 related unit tests and 20 Electron E2E tests passed, including preview/drop bounds, focus, native pointer capture and Escape. Build, lint (135 existing warnings), and typecheck passed. Refs marktext#6112.
…cross renders A cloned DOM Range remains live and can collapse to an empty origin rectangle when editor content is rebuilt. Preserve the last valid viewport coordinates and avoid opening the toolbar without rendered selection bounds. This positioning defect predates marktext#6112; tab-transfer history capture also rebuilds editor DOM. Three regression tests failed before the fix. Validation: 153 Muya UI unit tests, 7 Chromium toolbar tests and 24 Electron selection/transfer E2E tests passed. Desktop and Muya typechecks, build, Muya CI lint and root lint (135 existing warnings) passed.
…ansfers Cache the exact Muya block tree with its native history so trailing empty paragraphs survive history export, tab switches and destination mounting. Restore folds after history capture and validate cached Markdown against the document newline policy before restoring history. Propagate transfer failure reasons to the source window, including after renderer recovery. Show error reasons as plain text without appended advice, and suppress duplicate checkpoint notifications during transfers. Cover saved drafts, newline policies, inactive tabs, structural undo/redo across editor engines, notification routing and committed recovery. Validation: - Desktop unit tests: 1,780 passed, 2 skipped. - Tab transfer E2E: 26 passed; session error E2E: 2 passed. - Lint: 0 errors, 135 existing warnings; typecheck and build:unpack passed. - Four performance comparison rounds per scenario: median input processing increased 2.4% for a 2 MiB document and 0.6% for eight 512 KiB documents; retained JS heap increased about 2.1 MiB and 4.2 MiB respectively. - Windows x64 test ZIP packaged and integrity verified. Refs: marktext#6112
…ew bounds Pass the fitted position and size to the detached window constructor so Windows can select the destination monitor DPI during native creation. Keep automatic positioning for menu-driven transfers without a drop point. Check initial and final window bounds against the drag preview in the Electron regression test. Fill the four missing Polish tab-transfer locale keys with the original English text. Validation: 24 related unit tests and 4 Electron E2E tests passed on Linux. The initial-bounds regression fails with the previous constructor options. Typecheck, build:unpack and lint (0 errors, 135 existing warnings) passed. Locale validation passed for all 14 locales. Windows 11 visual behavior still requires verification on Windows. Refs: marktext#6112
|
The test case "uses local sorting and menus on Wayland without querying global coordinates" doesn't stub the platform — const originalPlatform = process.platform
Object.defineProperty(process, 'platform', { value: 'linux' })
try {
// ... assertions
} finally {
Object.defineProperty(process, 'platform', { value: originalPlatform })
} |
|
Hi! I've been testing this PR and really like the tab transfer feature. One small UX thing I noticed: when I drag a window's last tab into another window, the source window stays open with a blank tab. Would it be possible to close it automatically instead, like browsers do? Or maybe make it an option in the settings? Either way, thanks for the great work! |
|
@Azusa-299 Thank you for your reply. Yes, the source window is intentionally left open. However, I will consider making it optional. Regarding the testing issue, I will amend it so that Wayland tests are specifically set to |
Closes #6112
Summary
(0, 0)with zero width and height. The positioning code still used this result, placing the toolbar at(0, 0)and preventing the fallback position from taking effect. The fix ignores invalid rectangles and retains the last valid position.Basic tab splitting and merging demo
https://github.com/user-attachments/assets/56d8f657-c5ae-46e8-804f-e6831d032e73
Prevent the merging of same files (the same name and the same path)
https://github.com/user-attachments/assets/a5e09852-a59e-4637-8024-004eb6311441
Moving unsaved tab
https://github.com/user-attachments/assets/2be61c82-ed56-4fd5-b28a-89d0856af661
Moving tabs using right-click menu
https://github.com/user-attachments/assets/bbe4be96-ba51-43dd-a697-80179f46fe6d
Type of change
Test plan
pnpm run lint— no errors; 135 existing warnings remain.pnpm run typecheck— passed.pnpm run test:unit— 1,786 tests passed; 2 tests skipped because no executable Pandoc is available in my environment.pnpm run build:unpackAdded unit tests:
tab-drag-drop.spec.ts: detachment when dropping over editor content, unrelated windows, the desktop, and tab-strip boundaries; local sorting; insertion into another window’s tab strip; and cancellation.tab-drag-platform.spec.ts: local sorting and menu actions on Wayland.tab-transfer-checkpoint.spec.ts: dirty-draft transfer and insertion order, durable recovery ownership, metadata replacement failure, missing renderers, distinct untitled documents, canonical-path conflicts, stale staged snapshots, and renderer failure during ownership commit.tab-window-preview.spec.ts: multi-monitor layouts with negative coordinates and different scale factors, work-area fitting, cursor offsets, window previews, delayed loading, cleanup, and preview load failures.selectionPosition.spec.ts: retaining valid toolbar coordinates after DOM replacement, following valid selection coordinates during scrolling, and keeping the toolbar closed when no rendered selection bounds exist.Added Electron E2E tests:
tab-window-transfer.spec.ts: unsaved-document transfers with a blank replacement source tab; source-mode detachment; drops over source and destination editor bodies; preview and actual window bounds and focus; same-path conflict protection; cancellation; cross-mode undo/redo; destination closure during preparation; untitled document origin and Save As paths; native pointer capture across windows; Escape cancellation; Wayland menu actions and local sorting; scroll restoration; preservation of trailing empty paragraphs after detachment; undo/redo history validation; failure notifications shown only in the source window; special characters in failure messages rendered as plain text; and transfers of inactive tabs.selection-toolbar-position.spec.ts: keeping the toolbar near the selection after its previous DOM Range is replaced.Updated existing tests:
issue-5581-tabbar-visibility.spec.ts: verify default single-tab visibility without forcing the tab bar visible through the test fixture.session-recovery-multi.spec.ts: expect the tab bar to be visible after window restoration, instead of hidden.Manual testing:
Notes for reviewers [optional]
The breaking changes are:
Additional considerations:
closeWindowrequests are temporarily ignored while the transfer is in progress. Ignored requests are not replayed after the transfer completes.By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.