A1: tab management: preview tabs, pinning, close actions, reopen closed tab, split into two groups
Some checks are pending
ci / ci (macos-15) (push) Waiting to run
ci / ci (ubuntu-24.04) (push) Waiting to run
ci / ci (windows-2025) (push) Waiting to run

- Pure tab model (components/editor/tabs/model.ts) with Vitest coverage.
- Editor store keeps one buffer sync per buffer and a group layout; a buffer
  in both groups shares text and undo. Bulk closes ask once with a list.
- Tab context menu, tabs.* UI commands (COMMAND_IDS) in a Window menu group,
  no default shortcuts; Show Local History appears once history.show exists.
- Single click in the tree, Find and Go-to opens preview tabs.
- Layout stored through layout.set and restored on project open.
- Public API for other areas: tabOfPath, tabOf, reloadBuffer, openFile.
- Docs: ui-parity, gaps (G2), architecture.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
danny 2026-11-08 12:18:28 +01:00
parent 02922eb89d
commit 7f309dbc4e
28 changed files with 3003 additions and 211 deletions

View file

@ -1,31 +1,30 @@
<script setup lang="ts">
/**
* The editor area: tab bar, a notice line for the active tab, the editor
* and the close question. Without open tabs it shows the default slot.
* The editor area: one or two editor groups side by side or stacked
* (`EditorPane.vue`, C10 A1), the close question and the last editor
* error. Without open tabs it shows the default slot.
*
* Save, save all and close run through the global keymap and the
* palette (`commands/store.ts`): the area supplies their behaviour with the
* active buffer as context and says when they can run. It also supplies the
* UI commands `editor.reveal` (`reveal.ts`) and the assist commands
* (`assist/commands.ts`). Diff tabs (M4.3, `vcs/diff/`) share the tab bar;
* while one is active the diff view replaces the editor, and the area
* supplies the diff commands.
* (`assist/commands.ts`) and the tab management commands
* (`tabs/commands.ts`). Diff tabs (M4.3, `vcs/diff/`) share the first
* group's tab bar; while one is active the diff view replaces that group's
* editor, and the area supplies the diff commands.
*/
import { defineAsyncComponent, onBeforeUnmount, onMounted } from "vue";
import { onBeforeUnmount, onMounted } from "vue";
import { useCommandsStore } from "../../commands/store";
import { t } from "../../i18n";
import { useEditorStore } from "../../stores/editor";
import ClosePrompt from "./ClosePrompt.vue";
import CodeEditor from "./CodeEditor.vue";
import EditorTabs from "./EditorTabs.vue";
import EditorPane from "./EditorPane.vue";
import { provideTabCommands } from "./tabs/commands";
import { reveal, REVEAL_COMMAND } from "./reveal";
import * as assist from "./assist/commands";
import { provideDiffCommands } from "../vcs/diff/commands";
import { useDiffStore } from "../vcs/diff/diff";
/** The diff view, loaded on first use so `@codemirror/merge` stays out of the start bundle. */
const DiffView = defineAsyncComponent(() => import("../vcs/diff/DiffView.vue"));
const editor = useEditorStore();
const commands = useCommandsStore();
const diff = useDiffStore();
@ -45,6 +44,7 @@ onMounted(() => {
commands.provide(assist.QUICK_DOC_COMMAND, { run: assist.quickDocumentation, enabled: assist.assistEnabled }),
commands.provide(assist.PARAMETER_INFO_COMMAND, { run: assist.parameterInfo, enabled: assist.assistEnabled }),
...provideDiffCommands(commands),
...provideTabCommands(commands, editor),
];
});
@ -62,28 +62,18 @@ onBeforeUnmount(() => {
class="editor-area"
data-test="editor-area"
>
<template v-if="editor.tabs.length > 0 || diff.tabs.length > 0">
<EditorTabs />
<div
v-if="!diff.visible && editor.activeTab?.notice"
class="editor-area__notice"
:class="{ 'editor-area__notice--error': editor.activeTab.notice.kind === 'error' }"
role="status"
data-test="editor-notice"
>
<span>{{ editor.activeTab.notice.message }}</span>
<button
type="button"
class="editor-area__dismiss"
data-test="notice-dismiss"
@click="editor.dismissNotice(editor.activeTab.id)"
>
{{ t("common.dismiss") }}
</button>
</div>
<DiffView v-if="diff.visible" />
<CodeEditor v-else-if="editor.activeTab" />
</template>
<div
v-if="editor.tabs.length > 0 || diff.tabs.length > 0"
class="editor-area__groups"
:class="{ 'editor-area__groups--down': editor.orientation === 'down' }"
data-test="editor-groups"
>
<EditorPane
v-for="group in editor.groups"
:key="group.index"
:group="group.index"
/>
</div>
<div
v-else
class="editor-area__empty"
@ -120,6 +110,26 @@ onBeforeUnmount(() => {
min-height: 0;
}
.editor-area__groups {
display: flex;
flex: 1;
min-width: 0;
min-height: 0;
}
.editor-area__groups > * + * {
border-left: 1px solid var(--lt-border);
}
.editor-area__groups--down {
flex-direction: column;
}
.editor-area__groups--down > * + * {
border-left: none;
border-top: 1px solid var(--lt-border);
}
.editor-area__empty {
flex: 1;
display: flex;