Keep global actions visible and follow each platform's title bar

Phase 5-4.

- The workspace button sits at the left end of the header. It shows
  the workspace name and opens the workspace list below it.
- The left ribbon is always present: plugin views at the top, Help and
  Settings at the bottom. The left pane footer is gone.
- Tabs keep 120 pixels and scroll. Fades show tabs out of view, and a
  list button names all tabs, with pinned and unsaved marks. The
  active tab now scrolls into view with its close button.
- A drag area of 120 pixels follows the tabs. In a narrow header, the
  tabs shrink first, and the drag area keeps at least 48 pixels.
- Caption buttons are square, 46 pixels wide, and full height. When the
  pointer rests on maximize, the new window_snap_layouts command opens
  Snap Layouts with Win+Z for the focused window.
- macOS keeps its native traffic lights: tauri.macos.conf.json and the
  runtime window builders use an overlay title bar. Title bars leave
  --rs-titlebar-inset-start free for the traffic lights.
- 3 new catalog rows and 1 removed row, in French, Japanese, and
  Simplified Chinese.
- Docs: UI-050, the user guide, and ui-design.md.

Tests: the new layout/titleBar. Tests that used the left pane footer,
the rounded caption buttons, the 600-pixel theme editor pane, or a
ribbon of no width now follow the new layout.
This commit is contained in:
Knotty Wyvern
2026-10-28 20:21:20 -07:00
parent 9cf82503d0
commit c8cf56b224
31 changed files with 438 additions and 125 deletions
+16
View File
@@ -934,3 +934,19 @@ Native shell, background image, and desktop acceptance remain open.
- Evidence: `tests/smoke/layout/viewModes.smoke.mjs`, `tests/unit/layout/documentPanes.spec.ts`, and `tests/unit/layout/settings.spec.ts`.
- Replaces / replaced by: `ModeSwitcher.svelte` and its hover test.
- Limits: Split now shows Write beside Read when Write is the editor. Choose Source for the former source and preview layout. Browser checks use desktop service mocks.
### UI-050 — Global actions, tabs, and platform title bars
- Type: Rule change
- Date: 2026-10-28
- Status: Implemented for user review
- Decision source: Owner decisions 3, 7, and 12 of 2026-10-27 (interface review issues 3, 8, and 15), stage 5-4.
- Previous rule: The workspace button, Help, and Settings sat in the footer of the left pane, so they left the window with the pane. The plugin ribbon had no width without plugin entries. Tabs could shrink to 69 pixels, with no list and no sign of hidden tabs. The fixed drag area was 40 pixels. Every platform got rounded 40-pixel caption buttons, and macOS got Windows caption buttons.
- New rule: The workspace button sits at the left end of the header. It shows the workspace name and opens the workspace list below it. The left ribbon is always present: plugin views at the top, Help and Settings at the bottom. Tabs keep 120 pixels and scroll, with fades at the ends and a ⌄ list of all tabs that marks pinned and unsaved tabs. The header keeps a drag area of 120 pixels after the tabs. In a narrow header, the tabs shrink first, and the drag area keeps at least 48 pixels. Windows and Linux get square caption buttons, 46 pixels wide and full height. macOS keeps its native traffic lights through an overlay title bar, and each title bar leaves `--rs-titlebar-inset-start` (78 pixels) free for them.
- Snap Layouts: The custom title bar has no native caption buttons, so a hit test cannot show the flyout. When the pointer rests 500 ms on maximize, the host presses Win+Z for the focused window. This is the method of the existing Win+H dictation command.
- Reason: Global actions must stay reachable when the side pane closes. A tab label must stay readable. Each platform keeps its own window conventions.
- Scope: The main header, the left ribbon, the tab bars, the Settings and Browser window title bars, and the window builders of the host.
- Shared implementation: `WorkbenchHeader.svelte`, `PluginRibbon.svelte`, `TabBar.svelte`, `WindowControls.svelte`, `src-tauri/src/window_frame.rs`, `src-tauri/tauri.macos.conf.json`, and the `--rs-titlebar-inset-start` token.
- Evidence: `tests/smoke/layout/titleBar.smoke.mjs` and the Rust command list test.
- Replaces / replaced by: The left pane footer, and the ribbon rule "The ribbon has no width when it has no entries."
- Limits: Browser checks use desktop service mocks. Snap Layouts, the native drag area, and the macOS title bar need native acceptance. The macOS code path was not compiled here. On Windows 10, Win+Z does nothing.
+3 -3
View File
@@ -112,10 +112,10 @@
},
"RuneStone/src/lib/layout/TabBar.svelte": {
"counts": {
"action": 1
"action": 2
},
"design": "Shared action menu",
"check": "tests/smoke/menus/consistency.smoke.mjs"
"design": "Shared action menu for tab actions and the list of all tabs",
"check": "tests/smoke/menus/consistency.smoke.mjs; tests/smoke/layout/titleBar.smoke.mjs"
},
"RuneStone/src/lib/layout/Workbench.svelte": {
"counts": {
+5 -2
View File
@@ -139,9 +139,12 @@ Decisions: [UI-002](design-decisions.md#ui-002--share-the-requested-dropdown-des
## Window and navigation
- The main header holds navigation, document tabs, actions, and window controls.
- The main header holds the workspace button, navigation, document tabs, actions, and window controls. The workspace button names the window and opens the workspace list.
- The left ribbon stays visible when the side pane is closed. It holds plugin views at the top and Help and Settings at the bottom.
- Tabs keep a minimum width of 120 pixels and scroll. Fades show tabs out of view, and ⌄ lists all tabs. A drag area of 120 pixels sits after the tabs. In a narrow header, the tabs shrink first, and the drag area keeps at least 48 pixels.
- Windows and Linux title bars use square caption buttons, 46 pixels wide and full height. Rest the pointer on maximize for Snap Layouts on Windows 11. macOS keeps its native traffic lights, and title bars leave `--rs-titlebar-inset-start` free for them.
- Files, Search, Bookmarks, and installed sidebar views such as Git share the top navigation group. The active navigation button shows which view fills the left pane.
- Plugin editor views can use the vertical plugin ribbon. The ribbon has no width when it has no entries.
- Plugin editor views can use the left ribbon.
- The built-in browser opens from its own toolbar action. Project Management opens from Plug-in views. Keep Plug-in views in the toolbar, away from the new-tab button.
- Document and plugin tabs share the tab bar. The new-tab button follows the tabs. Tabs keep their order and pin state when a plugin replaces its view.
- The main window keeps an empty New tab after its last tab closes. A secondary window closes with its last tab. The unsaved-edit and active-terminal confirmations still apply, and Cancel keeps the tab open.
+4 -3
View File
@@ -22,7 +22,7 @@ This guide explains how to work with files, documents, tabs, settings, and the b
A workspace is a folder on your computer. RuneStone reads and writes its files directly.
1. Select the folder button at the bottom of the sidebar, or press Ctrl+O.
1. Select the workspace name at the left end of the title bar, or press Ctrl+O.
2. Choose a recent workspace, **Open another folder…**, or **New workspace…**.
Each workspace opens in its own window. The current window keeps its documents and terminals.
@@ -145,6 +145,7 @@ Each open tab keeps its undo history, cursor, and scroll position.
| Close the tab | Ctrl+W |
| Reorder | Drag the tab. Press Escape to cancel. With a tab focused, press Alt+Shift+Left or Alt+Shift+Right. |
| Pin, close others, or close all | Right-click the tab. |
| Find a tab | Select ⌄ after the tabs for a list of all tabs. The list marks pinned and unsaved tabs. Fades at the ends of the tab strip show that more tabs are out of view. |
| Move to a new window | Drag the tab out of the tab strip, or right-click it and choose **Open in new window**. |
| Move to another window | Drag the tab to the tab strip of the other window. |
@@ -187,7 +188,7 @@ If a write fails, your edits stay in the tab. RuneStone does not lock files, so
## Change settings
Select the gear at the bottom of the sidebar, or press Ctrl+,. Use the search field to find a setting.
Select the gear at the bottom of the left ribbon, or press Ctrl+,. Use the search field to find a setting.
Settings apply to all workspaces on this computer and update all open windows.
| Category | Settings |
@@ -248,6 +249,6 @@ The [Terminal guide](guides/terminal.md) lists the terminal shortcuts.
## Get help
Press F1, or select the question mark at the bottom of the sidebar, for **Help and about**. It shows the app version, basic steps, and every shortcut.
Press F1, or select the question mark at the bottom of the left ribbon, for **Help and about**. It shows the app version, basic steps, and every shortcut.
When you report a problem, include the app version, operating system, steps, expected result, and error text.
+1
View File
@@ -25,6 +25,7 @@ fn main() {
"spelling_menu_select",
"spelling_menu_uninstall",
"settings_open_window",
"window_snap_layouts",
"settings_read",
"settings_write",
"settings_migrate",
+1
View File
@@ -11,6 +11,7 @@
"allow-browser-stop",
"allow-plugins-snapshot",
"allow-settings-read",
"allow-window-snap-layouts",
"allow-settings-write",
"allow-settings-migrate",
"allow-spelling-menu-install",
+1
View File
@@ -14,6 +14,7 @@
"allow-spelling-menu-select",
"allow-spelling-menu-uninstall",
"allow-settings-open-window",
"allow-window-snap-layouts",
"allow-settings-read",
"allow-settings-write",
"allow-settings-migrate",
+1
View File
@@ -9,6 +9,7 @@
"permissions": [
"allow-theme-export",
"allow-settings-read",
"allow-window-snap-layouts",
"allow-settings-write",
"allow-settings-migrate",
"core:default",
@@ -0,0 +1,11 @@
# Automatically generated - DO NOT EDIT!
[[permission]]
identifier = "allow-window-snap-layouts"
description = "Enables the window_snap_layouts command without any pre-configured scope."
commands.allow = ["window_snap_layouts"]
[[permission]]
identifier = "deny-window-snap-layouts"
description = "Denies the window_snap_layouts command without any pre-configured scope."
commands.deny = ["window_snap_layouts"]
+2 -2
View File
@@ -479,8 +479,8 @@ impl BrowserState {
url.query_pairs_mut().append_pair("browserWindow", "true");
url.query_pairs_mut().append_pair("browserTab", id);
if args["pinned"] == true { url.query_pairs_mut().append_pair("browserPinned", "true"); }
let result = tauri::WebviewWindowBuilder::new(app, &label, tauri::WebviewUrl::App(format!("?{}", url.query().unwrap_or_default()).into()))
.title("RuneStone Browser").inner_size(1100.0, 750.0).min_inner_size(500.0, 300.0).decorations(false).disable_drag_drop_handler().build();
let result = crate::window_frame::title_bar(tauri::WebviewWindowBuilder::new(app, &label, tauri::WebviewUrl::App(format!("?{}", url.query().unwrap_or_default()).into())))
.title("RuneStone Browser").inner_size(1100.0, 750.0).min_inner_size(500.0, 300.0).disable_drag_drop_handler().build();
if let Err(error) = result {
worker.routing.lock()?.close(&label);
return Err(Error::from(error));
+2
View File
@@ -15,6 +15,7 @@ mod spelling;
mod theme;
mod backgrounds;
mod folders;
mod window_frame;
use pty::PtyState;
use tauri::Manager;
@@ -54,6 +55,7 @@ pub fn run() {
spelling::spelling_menu_select,
spelling::spelling_menu_uninstall,
settings::settings_open_window,
window_frame::window_snap_layouts,
preferences::settings_read,
preferences::settings_write,
preferences::settings_migrate,
+2 -3
View File
@@ -86,13 +86,12 @@ pub async fn settings_open_window(
let title = root.as_ref()
.and_then(|root| root.file_name().map(|name| format!("Settings — {} — RuneStone", name.to_string_lossy())))
.unwrap_or_else(|| "Settings — RuneStone".into());
match tauri::WebviewWindowBuilder::new(
match crate::window_frame::title_bar(tauri::WebviewWindowBuilder::new(
&app, &label, tauri::WebviewUrl::App("?settingsWindow=true".into()),
)
))
.title(title)
.inner_size(920.0, 650.0)
.min_inner_size(540.0, 420.0)
.decorations(false)
.resizable(true)
.visible(false)
.disable_drag_drop_handler()
+31
View File
@@ -0,0 +1,31 @@
//! The window frame: the title bar style of each platform, and Snap Layouts on Windows 11.
use crate::error::Result;
/// Give a window that RuneStone builds at run time the title bar of its platform.
/// Windows and Linux windows draw their own title bar. macOS keeps its native traffic lights over the web content.
pub fn title_bar<'a, R: tauri::Runtime, M: tauri::Manager<R>>(builder: tauri::WebviewWindowBuilder<'a, R, M>) -> tauri::WebviewWindowBuilder<'a, R, M> {
#[cfg(target_os = "macos")]
{ builder.title_bar_style(tauri::TitleBarStyle::Overlay).hidden_title(true) }
#[cfg(not(target_os = "macos"))]
{ builder.decorations(false) }
}
/// Open the Snap Layouts flyout of the focused window, as a native maximize button does on hover.
/// The custom title bar has no native caption buttons, so the host presses Win+Z. A window without focus does nothing.
#[tauri::command]
pub fn window_snap_layouts(window: tauri::Window) -> Result<()> {
#[cfg(windows)]
{
use windows_sys::Win32::UI::Input::KeyboardAndMouse::{keybd_event, KEYEVENTF_KEYUP, VK_LWIN};
if !window.is_focused().map_err(crate::error::Error::from_display)? { return Ok(()); }
unsafe {
keybd_event(VK_LWIN as u8, 0, 0, 0);
keybd_event(b'Z', 0, 0, 0);
keybd_event(b'Z', 0, KEYEVENTF_KEYUP, 0);
keybd_event(VK_LWIN as u8, 0, KEYEVENTF_KEYUP, 0);
}
}
#[cfg(not(windows))]
{ let _ = window; }
Ok(())
}
+17
View File
@@ -0,0 +1,17 @@
{
"$schema": "https://schema.tauri.app/config/2",
"app": {
"windows": [
{
"title": "RuneStone",
"width": 1400,
"height": 900,
"minWidth": 880,
"minHeight": 560,
"titleBarStyle": "Overlay",
"hiddenTitle": true,
"dragDropEnabled": false
}
]
}
}
+3 -6
View File
@@ -941,12 +941,6 @@ export const messageRows: [string, string, string, string][] = [
"フォルダーを開く",
"打开文件夹"
],
[
"No workspace",
"Aucun espace de travail",
"ワークスペースなし",
"无工作区"
],
[
"Help and about ({shortcut})",
"Aide et à propos ({shortcut})",
@@ -3464,6 +3458,9 @@ export const messageRows: [string, string, string, string][] = [
["Split: Read beside the editor", "Diviser : Lire à côté de l’éditeur", "分割: エディターの横に閲覧を表示", "分栏:在编辑器旁显示阅读"],
["Switch between Write and Source", "Alterner entre Écrire et Source", "「書く」と「ソース」を切り替え", "在写作和源码之间切换"],
["Switch between Read and the editor", "Alterner entre Lire et l’éditeur", "「閲覧」とエディターを切り替え", "在阅读和编辑器之间切换"],
["Unsaved", "Non enregistré", "未保存", "未保存"],
["All tabs", "Tous les onglets", "すべてのタブ", "所有标签页"],
["Open folder ({shortcut})", "Ouvrir un dossier ({shortcut})", "フォルダーを開く ({shortcut})", "打开文件夹 ({shortcut})"],
];
export const catalogs: Record<Exclude<Locale, 'en'>, Record<string, string>> = {
fr: Object.fromEntries(messageRows.map(row => [row[0], row[1]])),
+2 -2
View File
@@ -110,9 +110,9 @@
<style>
.browser-window { height: 100vh; display: flex; flex-direction: column; background: var(--rs-bg); }
.header { display: flex; align-items: center; height: 36px; flex-shrink: 0; background: var(--rs-bg-elevated); border-bottom: 1px solid var(--rs-border); }
.header { display: flex; align-items: center; height: 36px; flex-shrink: 0; padding-left: var(--rs-titlebar-inset-start); background: var(--rs-bg-elevated); border-bottom: 1px solid var(--rs-border); }
.header :global(.tabs) { flex: 0 1 auto; min-width: 80px; height: 100%; border-bottom: 0; }
.window-drag-space { flex: 1; min-width: 40px; align-self: stretch; }
.window-drag-space { flex: 1; min-width: 120px; align-self: stretch; }
.pages { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.pane { position: absolute; display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
.pane.inactive { display: none; }
+3 -49
View File
@@ -1,7 +1,6 @@
<script lang="ts">
// The left pane: a plugin sidebar view, or the files, search, and bookmarks views, and the workspace footer.
// The left pane: a plugin sidebar view, or the files, search, and bookmarks views.
import { t } from "$lib/i18n";
import IconButton from "$lib/ui/IconButton.svelte";
import PluginEditor from "$lib/plugins/PluginEditor.svelte";
import BrowserSlot from "$lib/plugins/BrowserSlot.svelte";
import { pluginSidebar } from "$lib/plugins/external";
@@ -10,7 +9,6 @@
import FileTree from "./FileTree.svelte";
import SearchPane from "./SearchPane.svelte";
import BookmarksPane from "./BookmarksPane.svelte";
import { commandShortcut } from "./workbenchKeys";
type Props = {
workspace: WorkspaceInfo | null;
@@ -21,18 +19,14 @@
activePath: string | null;
searchRequest: { text: string; id: number } | null;
fileTree?: FileTree;
workspaceAnchor?: HTMLDivElement;
onOpenFile: (entry: TreeEntry, line?: number, target?: "current" | "new") => void;
onCreated: (entry: TreeEntry) => void;
onSaveTemplate: (entry: TreeEntry) => void;
onManageTemplates: () => void;
onStatus: (message: string) => void;
onChooseWorkspace: () => void;
onHelp: () => void;
onSettings: () => void;
};
let { workspace, session, leftView, keysActive, showInternal, activePath, searchRequest, fileTree = $bindable(), workspaceAnchor = $bindable(),
onOpenFile, onCreated, onSaveTemplate, onManageTemplates, onStatus, onChooseWorkspace, onHelp, onSettings }: Props = $props();
let { workspace, session, leftView, keysActive, showInternal, activePath, searchRequest, fileTree = $bindable(),
onOpenFile, onCreated, onSaveTemplate, onManageTemplates, onStatus }: Props = $props();
</script>
<aside class="left">
@@ -69,16 +63,6 @@
{/if}
</div>
</div>
<div class="left-footer">
<div class="footer-start" bind:this={workspaceAnchor}>
<IconButton icon="folder-open" label={$t("Open folder")} onclick={onChooseWorkspace} />
<span class="ws">{workspace ? workspace.name : $t("No workspace")}</span>
</div>
<div class="footer-actions">
<IconButton icon="help" label={$t("Help and about ({shortcut})", { shortcut: commandShortcut("help") })} onclick={onHelp} />
<IconButton icon="settings" label={$t("Settings ({shortcut})", { shortcut: commandShortcut("settings") })} onclick={onSettings} />
</div>
</div>
</aside>
<style>
@@ -135,36 +119,6 @@
min-height: 0;
}
.left-footer {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
padding: 4px 6px;
border-top: 1px solid var(--rs-border);
flex: 0 0 auto;
}
.footer-start {
flex: 1;
display: flex;
align-items: center;
gap: 2px;
min-width: 0;
}
.footer-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.footer-actions :global(.icon-btn) { width: 32px; height: 32px; flex-basis: 32px; }
.ws {
color: var(--rs-text-dim);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
min-width: 0;
flex: 1;
}
.placeholder {
margin: 12px;
color: var(--rs-text-dim);
+29 -15
View File
@@ -1,23 +1,34 @@
<script lang="ts">
// The left ribbon of plugin views. The shell gives it width only when a plugin uses it.
// The left ribbon. It stays visible when the side pane is closed: plugin views at the top, Help and Settings at the bottom.
import { t } from "$lib/i18n";
import IconButton from "$lib/ui/IconButton.svelte";
import { openPluginView, pluginEditorActive, pluginSidebar, pluginView } from "$lib/plugins/external";
import { commandShortcut } from "./workbenchKeys";
let { items }: { items: { owner: string; id: string; title: string; icon?: string }[] } = $props();
let { items, onHelp, onSettings }: {
items: { owner: string; id: string; title: string; icon?: string }[];
onHelp: () => void;
onSettings: () => void;
} = $props();
</script>
<nav class="plugin-ribbon" aria-label={$t("Plugin shortcuts")} hidden={items.length === 0}>
{#each items as item (`${item.owner}:${item.id}`)}
<IconButton
icon={item.icon === "list" || item.icon === "kanban" || item.icon === "globe" || item.icon === "git" ? item.icon : "puzzle"}
label={item.title}
side="right"
active={($pluginSidebar?.owner === item.owner && $pluginSidebar?.id === item.id) || $pluginView?.owner === item.owner && $pluginView?.id === item.id && !$pluginView?.document && ($pluginView?.placement === "dialog" || $pluginEditorActive)}
onclick={() => openPluginView(item.owner, item.id)}
/>
{/each}
</nav>
<div class="plugin-ribbon">
<nav aria-label={$t("Plugin shortcuts")} hidden={items.length === 0}>
{#each items as item (`${item.owner}:${item.id}`)}
<IconButton
icon={item.icon === "list" || item.icon === "kanban" || item.icon === "globe" || item.icon === "git" ? item.icon : "puzzle"}
label={item.title}
side="right"
active={($pluginSidebar?.owner === item.owner && $pluginSidebar?.id === item.id) || $pluginView?.owner === item.owner && $pluginView?.id === item.id && !$pluginView?.document && ($pluginView?.placement === "dialog" || $pluginEditorActive)}
onclick={() => openPluginView(item.owner, item.id)}
/>
{/each}
</nav>
<div class="ribbon-actions">
<IconButton icon="help" label={$t("Help and about ({shortcut})", { shortcut: commandShortcut("help") })} side="right" onclick={onHelp} />
<IconButton icon="settings" label={$t("Settings ({shortcut})", { shortcut: commandShortcut("settings") })} side="right" onclick={onSettings} />
</div>
</div>
<style>
.plugin-ribbon {
@@ -26,14 +37,17 @@
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
gap: 4px;
min-height: 0;
padding: 6px 5px;
overflow-y: auto;
background: var(--rs-workarea-sidebar-bg);
border-right: 1px solid var(--rs-border);
}
.plugin-ribbon[hidden] { display: block; visibility: hidden; padding: 0; border: 0; }
nav, .ribbon-actions { display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 0; }
nav { overflow-y: auto; }
nav[hidden] { display: none; }
.ribbon-actions { margin-top: auto; flex-shrink: 0; }
.plugin-ribbon :global(.icon-btn) { width: 32px; height: 32px; flex-basis: 32px; }
</style>
+1 -1
View File
@@ -203,7 +203,7 @@
dialog.standalone { width: 100vw; height: 100dvh; margin: 0; border: 0; border-radius: 0; box-shadow: none; }
dialog.help { width: min(650px, calc(100vw - 32px)); }
header { height: var(--rs-titlebar-height); padding: 0 4px 0 12px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--rs-border); background: var(--rs-bg-elevated); }
header.window-header { padding-right: 0; user-select: none; }
header.window-header { padding-right: 0; padding-left: calc(12px + var(--rs-titlebar-inset-start)); user-select: none; }
h1 { font-size: 13px; font-weight: 600; margin: 0; }
.body { display: flex; height: calc(100% - var(--rs-titlebar-height)); min-height: 0; }
aside { width: 220px; flex-shrink: 0; padding: 12px 8px; background: var(--rs-bg-elevated); border-right: 1px solid var(--rs-border); display: flex; flex-direction: column; overflow: auto; }
+63 -2
View File
@@ -149,9 +149,40 @@
$effect(() => {
const path = activePath;
if (path) void tick().then(() => tabButton(path)?.scrollIntoView({ block: "nearest", inline: "nearest" }));
// Scroll the whole tab into view, with its close button.
if (path) void tick().then(() => tabButton(path)?.closest(".tab")?.scrollIntoView({ block: "nearest", inline: "nearest" }));
});
// Fades at the ends of the tab strip show that more tabs are out of view.
let fadeStart = $state(false), fadeEnd = $state(false);
function measureOverflow() {
fadeStart = bar.scrollLeft > 1;
fadeEnd = bar.scrollLeft + bar.clientWidth < bar.scrollWidth - 1;
}
$effect(() => {
void tabs.length;
const observer = new ResizeObserver(measureOverflow);
observer.observe(bar);
measureOverflow();
return () => observer.disconnect();
});
// The list of all tabs: the current tab is checked, and the rows name pinned and unsaved tabs.
let allTabsButton = $state<HTMLButtonElement>();
function showAllTabs() {
if (menu && menuAnchor === allTabsButton) { closeMenu(true); return; }
cancelDrag();
closeMenu();
menuAnchor = allTabsButton;
const bounds = allTabsButton!.getBoundingClientRect();
menu = actionMenu(bounds.left, bounds.bottom + 2, tabs.map(tab => ({
label: tab.name, radio: true, checked: tab.relPath === activePath, icon: tab.pinned ? "pin" as const : undefined,
shortcut: tab.dirty ? $t("Unsaved") : undefined,
// As with a click on the tab, the workbench then focuses the document.
run: () => { closeMenu(); onSelect(tab.relPath); },
})), () => closeMenu(true), $t("All tabs"));
}
async function move(path: string, index: number) {
onMove(path, index);
await tick();
@@ -321,7 +352,7 @@
ondragleave={(event) => { if (!event.relatedTarget) clearTransferTarget(); }}
ondragend={clearTransferTarget} />
<div bind:this={bar} class="tabs" class:receiving role="tablist" aria-label={$t("Working tabs")} tabindex="-1"
<div bind:this={bar} class="tabs" class:receiving class:fade-start={fadeStart} class:fade-end={fadeEnd} onscroll={measureOverflow} role="tablist" aria-label={$t("Working tabs")} tabindex="-1"
ondragover={dragOver} ondrop={dropTab}
ondragleave={(event) => { if (!(event.relatedTarget instanceof Node) || !bar.contains(event.relatedTarget)) { receiving = false; dropBefore = dropAfter = null; } }}>
{#each tabs as tab (tab.id)}
@@ -370,6 +401,12 @@
</div>
{/each}
</div>
{#if tabs.length > 1}
<button bind:this={allTabsButton} type="button" class="all-tabs" aria-label={$t("All tabs")} aria-haspopup="menu" use:tabTooltip={$t("All tabs")}
onpointerdown={(event) => event.stopPropagation()} onclick={showAllTabs}>
<svg viewBox="0 0 24 24" aria-hidden="true">{@html actionIcons.chevron}</svg>
</button>
{/if}
<span class="sr-only" role="status">{announcement}</span>
<style>
@@ -381,12 +418,20 @@
box-shadow: inset 0 -1px var(--rs-border);
}
.tabs:empty { min-width: 80px; }
.tabs.fade-start, .tabs.fade-end {
--fade-start: 0px;
--fade-end: 0px;
mask-image: linear-gradient(to right, transparent, #000 var(--fade-start), #000 calc(100% - var(--fade-end)), transparent);
}
.tabs.fade-start { --fade-start: 24px; }
.tabs.fade-end { --fade-end: 24px; }
.tabs.receiving, .tabs.receiving .tab { box-shadow: inset 0 -2px var(--rs-accent); }
.tab {
position: relative;
display: flex;
align-items: center;
min-width: 120px;
max-width: 220px;
flex-shrink: 0;
border-radius: var(--rs-item-selection-radius) var(--rs-item-selection-radius) 0 0;
@@ -462,4 +507,20 @@
color: var(--rs-text-strong);
background: var(--rs-bg);
}
.all-tabs {
display: inline-flex;
flex: 0 0 28px;
align-items: center;
justify-content: center;
align-self: center;
height: 28px;
padding: 0;
border: 1px solid transparent;
border-radius: var(--rs-control-radius);
background: transparent;
color: var(--rs-text-dim);
}
.all-tabs:hover { background: var(--rs-bg-active); border-color: var(--rs-border); color: var(--rs-text-strong); }
.all-tabs svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transform: rotate(90deg); }
</style>
+7 -8
View File
@@ -89,7 +89,7 @@
}
let settings = $state<AppSettings>({ ...DEFAULT_SETTINGS });
let settingsReady = $state(false);
let workspaceAnchor: HTMLDivElement | undefined = $state();
let workspaceAnchor: HTMLButtonElement | undefined = $state();
const desktop = isTauri();
const transferredWindow = /^[0-9a-f-]{36}$/i.test(new URLSearchParams(location.search).get("tabTransfer") ?? "");
// The documents of the open workspace. Their buffers are reactive, so the tabs read them directly.
@@ -1093,7 +1093,7 @@
const shell = event.currentTarget as HTMLElement;
const rect = shell.getBoundingClientRect();
if (dragging === "left") {
leftWidth = Math.min(480, Math.max(160, event.clientX - rect.left - (ribbonNavigation.length ? 44 : 0)));
leftWidth = Math.min(480, Math.max(160, event.clientX - rect.left - 44));
}
if (dragging === "right") {
rightWidth = Math.min(480, Math.max(160, rect.right - event.clientX));
@@ -1209,7 +1209,7 @@
<div
class="shell"
class:detached={transferredWindow}
class:has-ribbon={!transferredWindow && ribbonNavigation.length > 0}
class:has-ribbon={!transferredWindow}
class:left-open={!transferredWindow && leftOpen}
class:right-open={!transferredWindow && rightOpen}
role="application"
@@ -1225,6 +1225,9 @@
<WorkbenchHeader
detached={transferredWindow}
{desktop}
workspaceName={workspace?.name ?? null}
bind:workspaceAnchor
onChooseWorkspace={chooseWorkspace}
{leftOpen}
{leftView}
{sidebarNavigation}
@@ -1244,12 +1247,11 @@
onError={(message) => error = message}
/>
{#if !transferredWindow}<PluginRibbon items={ribbonNavigation} />{/if}
{#if !transferredWindow}<PluginRibbon items={ribbonNavigation} onHelp={() => preferences = "help"} onSettings={() => void openSettings()} />{/if}
{#if leftOpen && !transferredWindow}
<LeftPane
bind:fileTree
bind:workspaceAnchor
{workspace}
{session}
{leftView}
@@ -1262,9 +1264,6 @@
onSaveTemplate={(entry) => { void saveTemplate(entry); }}
onManageTemplates={() => templateManager = true}
onStatus={(message) => { status = message; error = null; }}
onChooseWorkspace={chooseWorkspace}
onHelp={() => preferences = "help"}
onSettings={() => void openSettings()}
/>
<div
+51 -8
View File
@@ -1,8 +1,10 @@
<script lang="ts">
// The workbench header: the side pane buttons, the working tabs, the actions, and the window controls.
// The workbench header: the workspace button, the side pane buttons, the working tabs, the actions, and the window controls.
import type { ComponentProps } from "svelte";
import { t } from "$lib/i18n";
import Icon from "$lib/ui/Icon.svelte";
import IconButton from "$lib/ui/IconButton.svelte";
import { attachTooltip } from "$lib/ui/tooltip";
import WindowControls from "$lib/ui/WindowControls.svelte";
import PluginTools from "$lib/plugins/PluginTools.svelte";
import PluginAccessMenu from "$lib/plugins/PluginAccessMenu.svelte";
@@ -14,6 +16,9 @@
type Props = {
detached: boolean;
desktop: boolean;
workspaceName: string | null;
workspaceAnchor?: HTMLButtonElement;
onChooseWorkspace: () => void;
leftOpen: boolean;
leftView: LeftView;
sidebarNavigation: { owner: string; id: string; title: string; icon?: string }[];
@@ -32,13 +37,24 @@
onToggleRight: () => void;
onError: (message: string) => void;
};
let { detached, desktop, leftOpen, leftView, sidebarNavigation, onSelectLeft, tabBar, onNewTab, canOpenBrowser, browserOpening, onOpenBrowser,
let { detached, desktop, workspaceName, workspaceAnchor = $bindable(), onChooseWorkspace, leftOpen, leftView, sidebarNavigation, onSelectLeft, tabBar, onNewTab, canOpenBrowser, browserOpening, onOpenBrowser,
saveDisabled, onSave, terminalEnabled, terminalOpen, onToggleTerminal, rightOpen, onToggleRight, onError }: Props = $props();
function tooltip(node: HTMLElement, text: string) {
let current = text;
const dispose = attachTooltip(node, () => current);
return { update(value: string) { current = value; }, destroy: dispose };
}
</script>
<header class="header" data-tauri-drag-region>
<div class="header-left" data-tauri-drag-region>
{#if !detached}
<!-- The workspace button names the window and opens the workspace list. -->
<button class="workspace-button" bind:this={workspaceAnchor} onclick={onChooseWorkspace}
use:tooltip={$t("Open folder ({shortcut})", { shortcut: commandShortcut("open-workspace") })}>
<Icon icon="folder-open" /><span class="ws">{workspaceName ?? $t("Open folder")}</span><Icon icon="chevron-down" />
</button>
<IconButton icon="files" label={$t("Files")} active={leftOpen && !$pluginSidebar && leftView === "files"} onclick={() => onSelectLeft("files")} />
<IconButton icon="search" label={$t("Search")} active={leftOpen && !$pluginSidebar && leftView === "search"} onclick={() => onSelectLeft("search")} />
<IconButton icon="bookmark" label={$t("Bookmarks")} active={leftOpen && !$pluginSidebar && leftView === "bookmarks"} onclick={() => onSelectLeft("bookmarks")} />
@@ -55,7 +71,7 @@
<div class="header-center" data-tauri-drag-region>
<TabBar {...tabBar} />
<IconButton icon="plus" label={$t("New tab ({shortcut})", { shortcut: commandShortcut("new-tab") })} onclick={onNewTab} />
{#if desktop}<div class="window-drag-space" data-tauri-drag-region></div>{/if}
{#if desktop}<div class="window-drag-space" data-tauri-drag-region aria-hidden="true"></div>{/if}
</div>
<div class="header-right" data-tauri-drag-region>
{#if canOpenBrowser}<IconButton icon="globe" label={$t("New browser tab")} disabled={browserOpening} onclick={onOpenBrowser} />{/if}
@@ -91,8 +107,33 @@
min-width: 0;
padding: 0 4px;
}
/* The macOS traffic lights sit at the start of the header (src/lib/theme/tokens.css). */
.header-left { justify-content: flex-start; padding-left: calc(4px + var(--rs-titlebar-inset-start)); }
.workspace-button {
display: inline-flex;
flex: 0 1 auto;
align-items: center;
gap: 6px;
min-width: 32px;
max-width: 180px;
height: 28px;
margin-right: 4px;
padding: 0 6px;
border: 1px solid transparent;
border-radius: var(--rs-control-radius);
background: transparent;
color: var(--rs-text);
font: 600 12px var(--rs-font-ui);
}
.workspace-button:hover { background: var(--rs-bg-active); border-color: var(--rs-border); }
.workspace-button :global(svg) { width: 16px; height: 16px; flex-shrink: 0; color: var(--rs-text-dim); }
.workspace-button :global(svg:last-child) { width: 12px; height: 12px; }
.ws { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* In a window below the minimum width, the center clips its content instead of drawing under the right group. */
.header-center {
overflow: hidden;
display: flex;
align-items: center;
justify-content: flex-start;
@@ -105,15 +146,17 @@
.header-left, .header-center, .header-right { height: 100%; }
/* The left group spans the ribbon and the open left pane (the shell sets the widths). */
:global(.shell.left-open) .header-left { width: calc(var(--ribbon-width) + var(--left) + 1px); padding-left: calc(var(--ribbon-width) + 4px); }
:global(.shell.left-open) .header-left { width: calc(var(--ribbon-width) + var(--left) + 1px); }
.header-left :global(.icon-btn), .header-right :global(.icon-btn) { flex-shrink: 0; }
.header-right { justify-content: flex-end; }
.window-drag-space { flex: 0 0 40px; align-self: stretch; }
/* A drag area keeps the window movable when the tabs fill the header: 120 pixels, and at least 48 in a narrow header. */
.window-drag-space { flex: 0 1 120px; min-width: 48px; align-self: stretch; }
/* The tab strip keeps room for one readable tab. It shrinks first, so the drag area shrinks only after it. */
.header-center :global(.tabs) {
flex: 0 1 auto;
flex: 0 1000 auto;
align-self: stretch;
min-width: 0;
min-width: 120px;
min-height: 28px;
background: transparent;
border-bottom: 0;
@@ -121,7 +164,7 @@
.header-center :global(.tab) {
flex: 0 1 180px;
width: 180px;
min-width: 96px;
min-width: 120px;
max-width: 180px;
background: transparent;
}
+4 -1
View File
@@ -46,7 +46,10 @@
function position() {
const rect = anchor?.getBoundingClientRect();
menu.style.left = `${Math.max(8, Math.min(rect?.left ?? (innerWidth - menu.offsetWidth) / 2, innerWidth - menu.offsetWidth - 8))}px`;
menu.style.top = `${Math.max(8, (rect?.top ?? (innerHeight + menu.offsetHeight) / 2) - menu.offsetHeight - 8)}px`;
// The list opens below an anchor in the title bar, and above an anchor lower in the window.
const below = rect ? rect.bottom + 4 : (innerHeight - menu.offsetHeight) / 2;
const top = rect && rect.top > innerHeight / 2 ? rect.top - menu.offsetHeight - 8 : below;
menu.style.top = `${Math.max(8, Math.min(top, innerHeight - menu.offsetHeight - 8))}px`;
}
function close() { menu.hidePopover(); returnFocus?.focus(); }
+5
View File
@@ -21,6 +21,8 @@
--rs-workarea-surface-opacity: 100%;
--rs-workarea-plugin-bg: var(--rs-bg);
--rs-titlebar-height: 36px;
/* The space at the start of a title bar for the macOS traffic lights (src/routes/+layout.svelte). */
--rs-titlebar-inset-start: 0px;
--rs-settings-row-padding: 10px;
--rs-settings-control-height: 28px;
--rs-settings-heading-size: 18px;
@@ -101,3 +103,6 @@
--rs-caption-close-bg: #c42b1c;
--rs-image-viewer-bg: #090a0de8;
}
/* macOS draws its traffic lights over the start of each title bar. */
:root[data-title-bar="mac"] { --rs-titlebar-inset-start: 78px; }
+34 -13
View File
@@ -1,12 +1,19 @@
<script lang="ts">
// The caption buttons of a window title bar. Windows and Linux get square, full-height buttons.
// macOS shows its own traffic lights at the left, so this control is empty there.
import { t } from "$lib/i18n";
import { onMount } from "svelte";
import { invoke } from "@tauri-apps/api/core";
import { getCurrentWindow } from "@tauri-apps/api/window";
import IconButton from "./IconButton.svelte";
import { isMac } from "./shortcuts";
let { onError }: { onError: (message: string) => void } = $props();
let maximized = $state(false);
const appWindow = getCurrentWindow();
const mac = isMac();
const windows = typeof navigator !== "undefined" && /Windows/.test(navigator.userAgent);
let snapTimer: ReturnType<typeof setTimeout> | undefined;
async function syncMaximized() {
maximized = await appWindow.isMaximized();
@@ -20,7 +27,16 @@
} catch (error) { onError(String(error)); }
}
// Windows 11 shows Snap Layouts when the pointer rests on the maximize button. The host opens them for this window.
function startSnap() {
if (!windows) return;
clearTimeout(snapTimer);
snapTimer = setTimeout(() => { void invoke("window_snap_layouts").catch(() => { /* Snap Layouts are optional. */ }); }, 500);
}
function stopSnap() { clearTimeout(snapTimer); }
onMount(() => {
if (mac) return;
let disposed = false;
let unlisten: (() => void) | undefined;
void syncMaximized().catch(error => onError(String(error)));
@@ -29,18 +45,22 @@
}).then(off => {
if (disposed) off(); else unlisten = off;
}).catch(error => onError(String(error)));
return () => { disposed = true; unlisten?.(); };
return () => { disposed = true; unlisten?.(); stopSnap(); };
});
</script>
<div class="window-controls" role="group" aria-label={$t("Window controls")}>
<IconButton icon="minimize" label={$t("Minimize window")} onclick={() => void run("minimize")} />
<IconButton icon={maximized ? "window-restore" : "window-maximize"}
label={maximized ? $t("Restore window") : $t("Maximize window")} onclick={() => void run("toggleMaximize")} />
<div class="window-close">
<IconButton icon="close" label={$t("Close window")} onclick={() => void run("close")} />
{#if !mac}
<div class="window-controls" role="group" aria-label={$t("Window controls")}>
<IconButton icon="minimize" label={$t("Minimize window")} onclick={() => void run("minimize")} />
<div class="window-maximize" role="presentation" onpointerenter={startSnap} onpointerleave={stopSnap} onpointerdown={stopSnap}>
<IconButton icon={maximized ? "window-restore" : "window-maximize"}
label={maximized ? $t("Restore window") : $t("Maximize window")} onclick={() => void run("toggleMaximize")} />
</div>
<div class="window-close">
<IconButton icon="close" label={$t("Close window")} onclick={() => void run("close")} />
</div>
</div>
</div>
{/if}
<style>
.window-controls {
@@ -48,15 +68,16 @@
align-self: stretch;
flex-shrink: 0;
margin-left: 8px;
border-left: 1px solid var(--rs-border);
}
.window-close { display: flex; }
.window-maximize, .window-close { display: flex; }
/* Caption buttons are square, 46 pixels wide, and fill the title bar height. */
.window-controls :global(.icon-btn) {
width: 40px;
flex-basis: 40px;
width: 46px;
flex-basis: 46px;
height: 100%;
border: 0;
border-radius: var(--rs-control-radius);
border-radius: 0;
}
.window-controls :global(.icon-btn:hover) { color: var(--rs-text-strong); }
.window-close :global(.icon-btn:hover) { background: var(--rs-caption-close-bg); color: white; }
</style>
+4
View File
@@ -2,10 +2,14 @@
import "../app.css";
import ThemeSync from "$lib/theme/ThemeSync.svelte";
import { onMount } from "svelte";
import { isTauri } from "@tauri-apps/api/core";
import { isMac } from "$lib/ui/shortcuts";
import { isSpellingTarget, mountSpellingMenu } from "$lib/editor/spellingMenu";
let { children } = $props();
onMount(mountSpellingMenu);
// On macOS the native traffic lights sit over the title bar (src-tauri/tauri.macos.conf.json).
if (isTauri() && isMac()) document.documentElement.dataset.titleBar = "mac";
</script>
<svelte:window oncontextmenu={(event) => { if (!isSpellingTarget(event.target)) event.preventDefault(); }} />
+8 -4
View File
@@ -88,12 +88,16 @@ await runSmoke("appearance/themeEditor", async ({ browser }) => {
await settings.waitForFunction(() => document.documentElement.dataset.palette === "custom:runestone-dark-copy-copy");
assert.equal((await main.evaluate(() => window.__TEST__.settings("customThemes"))).length, 2);
// Narrow windows keep the editor inside the window, and keyboard focus is visible.
await main.setViewportSize({ width: 600, height: 760 });
// A narrow pane keeps the editor inside the window, and keyboard focus is visible.
// A 520-pixel window without the outline leaves the editor about 215 pixels, below its 240-pixel breakpoint.
await main.getByRole("button", { name: "Hide outline", exact: true }).click();
await main.setViewportSize({ width: 520, height: 760 });
assert.ok(await editor.evaluate(node => node.clientWidth <= 240));
await hex("accent").focus();
assert.equal(await editor.evaluate(node => node.scrollWidth <= node.clientWidth + 1), true, "The editor does not scroll sideways at 600 pixels");
assert.equal(await editor.evaluate(node => node.scrollWidth <= node.clientWidth + 1), true, "The editor does not scroll sideways in a narrow pane");
assert.notEqual(await hex("accent").evaluate(node => getComputedStyle(node).outlineStyle), "none");
await main.screenshot({ path: path.join(output, "editor-600.png") });
await main.screenshot({ path: path.join(output, "editor-narrow.png") });
await main.setViewportSize({ width: 1200, height: 820 });
await settings.setViewportSize({ width: 360, height: 640 });
assert.equal(await settings.evaluate(() => document.documentElement.scrollWidth <= innerWidth), true, "Narrow settings do not overflow");
const box = await cards.boundingBox();
+2 -1
View File
@@ -54,7 +54,8 @@ await runSmoke("layout/outline", async ({ browser }) => {
console.log("PASS: hidden outline survives reload and window reopen");
await page.getByRole("button", { name: "Show outline", exact: true }).click();
await resize(0, 330);
// The left ribbon is 44 pixels wide, so the gutter at 374 gives a 330-pixel side pane.
await resize(0, 374);
await resize(1, 970);
const resized = await widths();
assert.deepEqual(resized, ["330px", "310px"]);
+121
View File
@@ -0,0 +1,121 @@
// The title bar: the workspace button, the left ribbon, readable tabs with a list of all tabs, the drag area, caption buttons, Snap Layouts, and the macOS layout.
import assert from "node:assert/strict";
import { mockTauri, openPage, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
const names = ["meeting-notes", "research-plan", "inbox", "field-notes", "weekly-review", "reading-list", "project-ideas", "travel", "budget", "journal", "recipes"];
await runSmoke("layout/titleBar", async ({ browser }) => {
const output = await outputDir("layout/titleBar");
const context = await browser.newContext({ viewport: { width: 1280, height: 720 } });
await mockTauri(context, {
state: { names },
commands: test => ({
...test.workspace({ root: "C:\\Users\\me\\Documents\\Field work", files: Object.fromEntries(test.state.names.map(name => [`notes/${name}.md`, `# ${name}\n\nText.\n`])) }),
plugins_snapshot: () => ({ root: "C:/plugins", plugins: [] }),
"plugin:window|is_maximized": () => false,
window_snap_layouts: () => null,
}),
});
const page = await openPage(context);
async function open(name) {
await page.keyboard.press("Control+p");
await page.getByRole("textbox", { name: "Find a file" }).fill(`${name}.md`);
await page.getByRole("dialog").getByRole("button").filter({ hasText: `${name}.md` }).first().click();
await page.getByRole("tab", { name: `${name}.md`, exact: true, selected: true }).waitFor();
}
const box = locator => locator.evaluate(node => { const rect = node.getBoundingClientRect(); return { x: rect.x, right: rect.right, width: rect.width, height: rect.height, bottom: rect.bottom }; });
await page.goto(smokeUrl);
// The workspace button is the first control of the header. It opens the workspace list below it.
const workspace = page.getByRole("button", { name: "Field work", exact: true });
await workspace.waitFor();
// Auto-save stays off, so the edited tab keeps its unsaved mark.
await page.evaluate(() => window.__TEST__.writeSettings("general", { autosaveEnabled: false, autosaveSeconds: 5 }));
assert.equal(await page.locator("header.header button").first().evaluate(node => node.classList.contains("workspace-button")), true);
await workspace.click();
const picker = page.getByRole("dialog", { name: "Workspaces" });
await picker.waitFor();
assert.ok(await picker.evaluate((node, bottom) => node.getBoundingClientRect().top >= bottom, (await box(workspace)).bottom));
await page.keyboard.press("Escape");
// Help and Settings stay in the left ribbon when the side pane closes.
await page.keyboard.press("Control+\\");
await page.locator("aside.left").waitFor({ state: "detached" });
const ribbon = page.locator(".plugin-ribbon");
await ribbon.getByRole("button", { name: "Help and about (F1)", exact: true }).click();
await page.getByRole("dialog", { name: "Help and about" }).waitFor();
await page.getByRole("button", { name: "Close help", exact: true }).click();
assert.equal(await ribbon.getByRole("button", { name: "Settings (Ctrl+,)", exact: true }).isVisible(), true);
assert.equal((await box(ribbon)).width, 44);
await page.keyboard.press("Control+\\");
await page.locator("aside.left").waitFor();
// Tabs keep a readable width and scroll. Fades show hidden tabs, and the list names every tab.
for (const name of names) await open(name);
const widths = await page.locator("header .tab").evaluateAll(tabs => tabs.map(tab => tab.getBoundingClientRect().width));
assert.ok(widths.every(width => width >= 120), JSON.stringify(widths));
const strip = page.locator("header .tabs");
assert.equal(await strip.evaluate(node => node.classList.contains("fade-start")), true);
assert.equal(await strip.evaluate(node => node.classList.contains("fade-end")), false, "The active last tab is in view with its close button");
await page.locator(".cm-content").click();
await page.keyboard.type("Edit ");
// An unsaved tab adds " •" to its name.
await page.getByRole("tab", { name: /^recipes.md/ }).click({ button: "right" });
await page.getByRole("menuitem", { name: "Pin", exact: true }).click();
await page.getByRole("button", { name: "All tabs", exact: true }).click();
const list = page.getByRole("menu", { name: "All tabs", exact: true });
await list.waitFor();
assert.equal(await list.getByRole("menuitemradio").count(), names.length);
const recipes = list.getByRole("menuitemradio", { name: /^recipes\.md/ });
assert.equal(await recipes.getAttribute("aria-checked"), "true");
assert.match(await recipes.innerText(), /Unsaved/);
assert.equal(await recipes.locator("svg").count(), 1, "The pinned tab shows the pin icon");
await page.screenshot({ path: `${output}/all-tabs.png` });
await list.getByRole("menuitemradio", { name: "inbox.md", exact: true }).click();
await page.getByRole("tab", { name: "inbox.md", exact: true, selected: true }).waitFor();
await list.waitFor({ state: "detached" });
assert.equal(await strip.evaluate(node => node.classList.contains("fade-end")), true);
// A fixed drag area follows the tabs. Caption buttons are square and fill the title bar height.
const drag = page.locator(".window-drag-space");
assert.equal(Math.round((await box(drag)).width), 120);
assert.equal(await drag.getAttribute("data-tauri-drag-region"), "");
const captions = await page.locator(".window-controls .icon-btn").evaluateAll(buttons => buttons.map(button => ({ width: button.getBoundingClientRect().width, height: button.getBoundingClientRect().height, radius: getComputedStyle(button).borderRadius })));
const height = (await box(page.locator("header.header"))).height;
assert.deepEqual(captions, Array(3).fill({ width: 46, height, radius: "0px" }));
// Resting on maximize asks the host for Snap Layouts. A short pass does not.
const calls = () => page.evaluate(() => window.__TEST__.calls.filter(call => call.command === "window_snap_layouts").length);
await page.getByRole("button", { name: "Maximize window", exact: true }).hover();
await page.mouse.move(600, 400);
await page.waitForTimeout(700);
assert.equal(await calls(), 0);
await page.getByRole("button", { name: "Maximize window", exact: true }).hover();
await page.waitForFunction(() => window.__TEST__.calls.some(call => call.command === "window_snap_layouts"));
await page.mouse.move(600, 400);
for (const theme of ["dark", "light"]) {
await page.evaluate(async mode => { const { saveAppearance } = await import("/src/lib/theme/appearance.ts"); saveAppearance({ theme: "default", mode }); window.dispatchEvent(new Event("focus")); }, theme);
await page.waitForFunction(mode => document.documentElement.dataset.theme === mode, theme);
await page.locator("header.header").screenshot({ path: `${output}/header-${theme}.png` });
}
await page.setViewportSize({ width: 880, height: 560 });
assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth));
assert.ok((await box(page.locator(".window-controls"))).right <= 880);
await page.screenshot({ path: `${output}/narrow.png` });
// macOS keeps its native traffic lights: no caption buttons, and room at the start of the title bar.
const mac = await openPage(context);
await mac.addInitScript(() => {
Object.defineProperty(navigator, "platform", { get: () => "MacIntel" });
Object.defineProperty(navigator, "userAgentData", { get: () => ({ platform: "macOS" }) });
});
await mac.goto(smokeUrl);
await mac.getByRole("button", { name: "Field work", exact: true }).waitFor();
assert.equal(await mac.evaluate(() => document.documentElement.dataset.titleBar), "mac");
assert.equal(await mac.locator(".window-controls").count(), 0);
assert.equal(await mac.locator(".header-left").evaluate(node => getComputedStyle(node).paddingLeft), "82px");
assert.match(await mac.getByRole("button", { name: "Settings (⌘,)", exact: true }).getAttribute("aria-label"), /⌘/);
await mac.locator("header.header").screenshot({ path: `${output}/header-mac.png` });
assert.deepEqual([...page.errors, ...mac.errors], []);
console.log("PASS: workspace button, permanent ribbon, readable tabs with fades and a list, fixed drag area, square caption buttons, Snap Layouts request, macOS layout, both themes, narrow window.");
});
+2 -1
View File
@@ -60,7 +60,8 @@ await runSmoke("settings/titlebar", async ({ browser }) => {
const control = dialog.getByRole("button", { name: label, exact: true });
const bounds = await control.boundingBox();
assert(bounds.x >= 0 && bounds.x + bounds.width <= size.width && bounds.height >= 28);
assert.notEqual(await control.evaluate(element => getComputedStyle(element).borderTopLeftRadius), "0px");
// Caption buttons are square (src/lib/ui/WindowControls.svelte).
assert.equal(await control.evaluate(element => getComputedStyle(element).borderTopLeftRadius), "0px");
}
await page.screenshot({ path: path.join(output, `${theme}-${size.width}.png`) });
}
@@ -53,7 +53,8 @@ await runSmoke("workspace/openAndCreate", async ({ page }) => {
const view = window.__EditorView.findFromDOM(document.querySelector(".source-editor .cm-content"));
view.dispatch({ changes: { from: 0, to: view.state.doc.length, insert: "My pending edit" } });
});
const trigger = page.getByRole("button", { name: "Open folder", exact: true });
// The workspace button at the left of the header names the workspace (src/lib/layout/WorkbenchHeader.svelte).
const trigger = page.locator(".workspace-button");
const menu = page.getByRole("dialog", { name: "Workspaces", exact: true });
await page.evaluate(() => window.__TEST__.reorder());
await trigger.click();