M1.6: tabs and CodeMirror editor

- Editor area with tab bar, CodeMirror 6 view, close question and notices
  (ui/src/components/editor/, ui/src/stores/editor.ts), mounted in App.vue;
  the project tree opens files through the editor store.
- BufferSync: local edits to buffer.edit against the confirmed version,
  one call in flight, resync on stale_version or newer bufferChanged with
  rebase of unsent changes; EngineText maps CodeMirror positions to engine
  UTF-16 offsets for CRLF text.
- Save, save all and close from engine default shortcuts via listCommands.
- Dirty marker, Save / Don't Save / Cancel, non-blocking notice when a
  dirty file changes or disappears on disk.
- Vitest: keystroke bursts with stale versions and remote edits (LF and
  CRLF), mapping, store and component tests against a fake engine.
- Progress docs: Editor core 8% (est.), depth ~1.4%, G2, ui-parity tabs,
  M1 row, architecture, README status.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
danny 2026-10-15 18:26:32 +02:00
parent 0fb7e33fc7
commit 9fa6028335
25 changed files with 2958 additions and 22 deletions

View file

@ -0,0 +1,135 @@
<script setup lang="ts">
/**
* The question shown when a tab with unsaved changes closes: Save,
* Don't Save or Cancel. Escape cancels; Save has the focus.
*/
import { nextTick, ref, watch } from "vue";
import { useEditorStore } from "../../stores/editor";
const editor = useEditorStore();
/** The Save button, focused when the question appears. */
const saveButton = ref<HTMLButtonElement | null>(null);
watch(
() => editor.closePrompt,
async (prompt) => {
if (prompt) {
await nextTick();
saveButton.value?.focus();
}
},
{ immediate: true },
);
/**
* Cancels on Escape.
*
* @param event - the key event inside the dialog.
*/
function onKeydown(event: KeyboardEvent): void {
if (event.key === "Escape") {
event.preventDefault();
void editor.resolveClose("cancel");
}
}
</script>
<template>
<div
v-if="editor.closePrompt"
class="close-prompt"
data-test="close-prompt"
>
<div
class="close-prompt__dialog"
role="alertdialog"
aria-modal="true"
aria-labelledby="lt-close-prompt-title"
@keydown="onKeydown"
>
<p
id="lt-close-prompt-title"
class="close-prompt__text"
>
Save changes to {{ editor.closePrompt.name }} before closing?
</p>
<div class="close-prompt__buttons">
<button
ref="saveButton"
type="button"
class="close-prompt__button close-prompt__button--primary"
data-test="close-save"
@click="editor.resolveClose('save')"
>
Save
</button>
<button
type="button"
class="close-prompt__button"
data-test="close-discard"
@click="editor.resolveClose('discard')"
>
Don't Save
</button>
<button
type="button"
class="close-prompt__button"
data-test="close-cancel"
@click="editor.resolveClose('cancel')"
>
Cancel
</button>
</div>
</div>
</div>
</template>
<style scoped>
.close-prompt {
position: absolute;
inset: 0;
display: flex;
align-items: flex-start;
justify-content: center;
padding-top: 15%;
background: color-mix(in srgb, var(--lt-bg) 50%, transparent);
z-index: 10;
}
.close-prompt__dialog {
min-width: 320px;
padding: 16px;
background: var(--lt-bg);
color: var(--lt-fg);
border: 1px solid var(--lt-border);
border-radius: 6px;
}
.close-prompt__text {
margin: 0 0 16px;
}
.close-prompt__buttons {
display: flex;
justify-content: flex-end;
gap: 8px;
}
.close-prompt__button {
padding: 4px 12px;
font: inherit;
color: var(--lt-fg);
background: var(--lt-editor-bg);
border: 1px solid var(--lt-border);
border-radius: 4px;
}
.close-prompt__button--primary {
border-color: var(--lt-accent);
}
.close-prompt__button:focus-visible {
outline: 1px solid var(--lt-accent);
}
</style>