Split the workbench markup into region components

Phase 5-1.

Workbench.svelte keeps the state and the commands. Six components now
draw its regions, each with its own styles:

- WorkbenchHeader: the side pane buttons, the working tabs, the
  actions, and the window controls.
- PluginRibbon: the ribbon of plugin views.
- LeftPane: the plugin sidebar, files, search, bookmarks, and the
  workspace footer.
- DocumentArea: the plugin editor panes, the document panes, and the
  save conflict banners.
- RightPane: the outline and the backlinks.
- StatusBar: the status line.

Each component keeps the root element of its region, so the shell grid
places them as before. Workbench.svelte has about 450 fewer lines.
There is no visible change.

pnpm check passes. pnpm test: 451 of 451 pass. Full smoke suite: 95
passed, 2 known. plugins/access failed one time and passed on retry
and 3 of 3 times alone.
This commit is contained in:
Knotty Wyvern
2026-10-28 18:40:50 -07:00
parent 5483881bc2
commit b2348d0fe8
8 changed files with 677 additions and 454 deletions
+131
View File
@@ -0,0 +1,131 @@
<script lang="ts">
// The workbench header: the side pane buttons, the working tabs, the actions, and the window controls.
import type { ComponentProps } from "svelte";
import { t } from "$lib/i18n";
import IconButton from "$lib/ui/IconButton.svelte";
import WindowControls from "$lib/ui/WindowControls.svelte";
import PluginTools from "$lib/plugins/PluginTools.svelte";
import PluginAccessMenu from "$lib/plugins/PluginAccessMenu.svelte";
import { openPluginView, pluginSidebar } from "$lib/plugins/external";
import TabBar from "./TabBar.svelte";
type LeftView = "files" | "search" | "bookmarks";
type Props = {
detached: boolean;
desktop: boolean;
leftOpen: boolean;
leftView: LeftView;
sidebarNavigation: { owner: string; id: string; title: string; icon?: string }[];
onSelectLeft: (view: LeftView) => void;
tabBar: ComponentProps<typeof TabBar>;
onNewTab: () => void;
canOpenBrowser: boolean;
browserOpening: boolean;
onOpenBrowser: () => void;
saveDisabled: boolean;
onSave: () => void;
terminalEnabled: boolean;
terminalOpen: boolean;
onToggleTerminal: () => void;
rightOpen: boolean;
onToggleRight: () => void;
onError: (message: string) => void;
};
let { detached, desktop, leftOpen, leftView, sidebarNavigation, onSelectLeft, tabBar, onNewTab, canOpenBrowser, browserOpening, onOpenBrowser,
saveDisabled, onSave, terminalEnabled, terminalOpen, onToggleTerminal, rightOpen, onToggleRight, onError }: Props = $props();
</script>
<header class="header" data-tauri-drag-region>
<div class="header-left" data-tauri-drag-region>
{#if !detached}
<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")} />
{#each sidebarNavigation 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}
active={leftOpen && $pluginSidebar?.owner === item.owner && $pluginSidebar?.id === item.id}
onclick={() => openPluginView(item.owner, item.id)}
/>
{/each}
{/if}
</div>
<div class="header-center" data-tauri-drag-region>
<TabBar {...tabBar} />
<IconButton icon="plus" label={$t("New tab (Ctrl T)")} onclick={onNewTab} />
{#if desktop}<div class="window-drag-space" data-tauri-drag-region></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}
<PluginAccessMenu surface="open" compact />
<PluginTools />
<PluginAccessMenu surface="commands" compact />
<IconButton icon="save" label={$t("Save")} disabled={saveDisabled} onclick={onSave} />
{#if terminalEnabled}<IconButton icon="terminal" label={$t("Terminal")} active={terminalOpen} onclick={onToggleTerminal} />{/if}
{#if !detached}<IconButton icon="panel-right" label={rightOpen ? $t("Hide outline") : $t("Show outline")} active={rightOpen} onclick={onToggleRight} />{/if}
{#if desktop}<WindowControls {onError} />{/if}
</div>
</header>
<style>
.header {
grid-column: 1 / -1;
display: grid;
grid-template-columns: auto minmax(0, 1fr) auto;
align-items: center;
gap: 0;
padding: 0;
background: var(--rs-bg-elevated);
box-shadow: inset 0 -1px var(--rs-border);
user-select: none;
}
.header-left,
.header-right {
display: flex;
align-items: center;
justify-content: center;
gap: 2px;
min-width: 0;
padding: 0 4px;
}
.header-center {
display: flex;
align-items: center;
justify-content: flex-start;
gap: 6px;
min-width: 0;
padding: 0;
border-left: 1px solid var(--rs-border);
border-right: 1px solid var(--rs-border);
}
.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); }
.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; }
.header-center :global(.tabs) {
flex: 0 1 auto;
align-self: stretch;
min-width: 0;
min-height: 28px;
background: transparent;
border-bottom: 0;
}
.header-center :global(.tab) {
flex: 0 1 180px;
width: 180px;
min-width: 96px;
max-width: 180px;
background: transparent;
}
.header-center :global(.tab.active) {
background: var(--rs-bg);
}
</style>