update the UI
This commit is contained in:
@@ -24,7 +24,7 @@ public struct TooBigNotice: Equatable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Everything the editor keeps for one path, so a rename or a delete moves or drops it in one step.
|
/// Everything the editor keeps for one path, so a rename or a delete moves or drops it in one step.
|
||||||
/// It outlives the file being open, so switching back finds unsaved edits where they were.
|
/// Only the open file holds a buffer: opening a file asks about unsaved edits first, then reads disk.
|
||||||
struct FileState: Equatable {
|
struct FileState: Equatable {
|
||||||
/// The mode the file asked for; `presentation(for:)` resolves it against the file.
|
/// The mode the file asked for; `presentation(for:)` resolves it against the file.
|
||||||
var mode: ViewMode?
|
var mode: ViewMode?
|
||||||
@@ -339,13 +339,41 @@ public final class EditorStore {
|
|||||||
|
|
||||||
// MARK: The open file
|
// MARK: The open file
|
||||||
|
|
||||||
/// Opens a file in place of the current one: history, mode, side, a read from disk, and a line jump with a flash.
|
/// Opens a file in place of the current one, always reading it fresh from disk. Unsaved edits in the open
|
||||||
/// A changed file lands in Actual unless `showDiff`; `defaultMode` only covers a file without a stored mode.
|
/// file (the same path too) are auto-saved, or ask save, discard or cancel; `accepted` runs once the open
|
||||||
public func open(_ path: String, _ options: OpenOptions = OpenOptions()) {
|
/// goes ahead, at once or after the save. Returns true when it went ahead at once.
|
||||||
|
@discardableResult
|
||||||
|
public func open(_ path: String, _ options: OpenOptions = OpenOptions(),
|
||||||
|
accepted: (@MainActor () -> Void)? = nil) -> Bool {
|
||||||
if FileType.tooBigNames.contains(PathUtils.basename(path)) {
|
if FileType.tooBigNames.contains(PathUtils.basename(path)) {
|
||||||
tooBig = TooBigNotice(path: path)
|
tooBig = TooBigNotice(path: path)
|
||||||
return
|
accepted?()
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
if let active = activePath, isDirty(active) {
|
||||||
|
let silent = editorConfig.autoSave && !isDeleted(active)
|
||||||
|
switch silent ? .save : confirmUnsavedClose?(active) ?? .cancel {
|
||||||
|
case .cancel:
|
||||||
|
return false
|
||||||
|
case .discard:
|
||||||
|
dropBuffer(active)
|
||||||
|
case .save:
|
||||||
|
track { store in
|
||||||
|
do { try await store.save(path: active, announce: !silent) } catch { return }
|
||||||
|
store.show(path, options)
|
||||||
|
accepted?()
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
show(path, options)
|
||||||
|
accepted?()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
/// History, mode, side, a read from disk that wins over any buffer, and a line jump with a flash.
|
||||||
|
/// A changed file lands in Actual unless `showDiff`; `defaultMode` only covers a file without a stored mode.
|
||||||
|
private func show(_ path: String, _ options: OpenOptions) {
|
||||||
history = RecentLists.pushing(path, onto: history)
|
history = RecentLists.pushing(path, onto: history)
|
||||||
activePath = path
|
activePath = path
|
||||||
selection = nil
|
selection = nil
|
||||||
@@ -360,19 +388,23 @@ public final class EditorStore {
|
|||||||
flashLine(path: path, line: line)
|
flashLine(path: path, line: line)
|
||||||
}
|
}
|
||||||
if options.showDiff && changed { setMode(.diff, for: path) }
|
if options.showDiff && changed { setMode(.diff, for: path) }
|
||||||
track { await $0.load(path, discardEdits: false) }
|
track { await $0.load(path, discardEdits: true) }
|
||||||
persistSoon()
|
persistSoon()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Drops a file's unsaved edits without asking and, when it is the open file, shows the empty state.
|
private func dropBuffer(_ path: String) {
|
||||||
/// `requestCloseActive` asks first.
|
|
||||||
public func close(_ path: String) {
|
|
||||||
cancelAutoSave(path)
|
cancelAutoSave(path)
|
||||||
if states[path]?.buffer != nil {
|
if states[path]?.buffer != nil {
|
||||||
states[path]?.buffer = nil
|
states[path]?.buffer = nil
|
||||||
bumpRevision(path)
|
bumpRevision(path)
|
||||||
}
|
}
|
||||||
if states[path]?.isDeleted == true { states[path] = nil }
|
if states[path]?.isDeleted == true { states[path] = nil }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Drops a file's unsaved edits without asking and, when it is the open file, shows the empty state.
|
||||||
|
/// `requestCloseActive` asks first.
|
||||||
|
public func close(_ path: String) {
|
||||||
|
dropBuffer(path)
|
||||||
if cursor?.path == path { cursor = nil }
|
if cursor?.path == path { cursor = nil }
|
||||||
if selection?.path == path { selection = nil; selectedCode = nil }
|
if selection?.path == path { selection = nil; selectedCode = nil }
|
||||||
if activePath == path { activePath = nil }
|
if activePath == path { activePath = nil }
|
||||||
|
|||||||
@@ -201,11 +201,13 @@ public final class WorkspaceModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Opens a file in the editor, reveals it in the Explorer and gives the editor the wide columns.
|
/// Opens a file in the editor, reveals it in the Explorer and gives the editor the wide columns.
|
||||||
|
/// Nothing moves when the editor's unsaved-edits prompt is cancelled or its save fails.
|
||||||
public func open(_ path: String, _ options: OpenOptions = OpenOptions()) {
|
public func open(_ path: String, _ options: OpenOptions = OpenOptions()) {
|
||||||
guard let editor else { return }
|
guard let editor else { return }
|
||||||
explorer?.select(path)
|
editor.open(path, options) { [weak self] in
|
||||||
editor.open(path, options)
|
self?.explorer?.select(path)
|
||||||
layout.setFocusZone(.editor)
|
self?.layout.setFocusZone(.editor)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Inserts text into the agent's composer without submitting it, and confirms with a toast.
|
/// Inserts text into the agent's composer without submitting it, and confirms with a toast.
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import Testing
|
|||||||
await h.store.settle()
|
await h.store.settle()
|
||||||
h.store.edit("a edited")
|
h.store.edit("a edited")
|
||||||
h.store.open("b.txt")
|
h.store.open("b.txt")
|
||||||
|
await h.store.settle()
|
||||||
h.store.edit("b edited")
|
h.store.edit("b edited")
|
||||||
await h.store.settle()
|
await h.store.settle()
|
||||||
#expect(h.files.current("a.txt") == "a edited")
|
#expect(h.files.current("a.txt") == "a edited")
|
||||||
@@ -141,9 +142,7 @@ import Testing
|
|||||||
asked.append(path)
|
asked.append(path)
|
||||||
return path == "a.txt" ? .save : .discard
|
return path == "a.txt" ? .save : .discard
|
||||||
}
|
}
|
||||||
h.store.open("a.txt")
|
h.strand("a.txt", disk: "a", buffer: "a2")
|
||||||
await h.store.settle()
|
|
||||||
h.store.edit("a2")
|
|
||||||
h.store.open("b.txt")
|
h.store.open("b.txt")
|
||||||
await h.store.settle()
|
await h.store.settle()
|
||||||
h.store.edit("b2")
|
h.store.edit("b2")
|
||||||
@@ -158,9 +157,7 @@ import Testing
|
|||||||
@Test func cancellingThePromptKeepsEveryEdit() async {
|
@Test func cancellingThePromptKeepsEveryEdit() async {
|
||||||
let h = EditorHarness(files: ["a.txt": "a", "b.txt": "b"])
|
let h = EditorHarness(files: ["a.txt": "a", "b.txt": "b"])
|
||||||
h.store.confirmUnsavedClose = { $0 == "a.txt" ? .discard : .cancel }
|
h.store.confirmUnsavedClose = { $0 == "a.txt" ? .discard : .cancel }
|
||||||
h.store.open("a.txt")
|
h.strand("a.txt", disk: "a", buffer: "a2")
|
||||||
await h.store.settle()
|
|
||||||
h.store.edit("a2")
|
|
||||||
h.store.open("b.txt")
|
h.store.open("b.txt")
|
||||||
await h.store.settle()
|
await h.store.settle()
|
||||||
h.store.edit("b2")
|
h.store.edit("b2")
|
||||||
|
|||||||
@@ -24,32 +24,13 @@ import Testing
|
|||||||
#expect(h.store.history == ["b.php", "a.php"])
|
#expect(h.store.history == ["b.php", "a.php"])
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test func switchingAwayKeepsADirtyBufferAndItIsStillDirtyOnReturn() async {
|
|
||||||
let h = EditorHarness(files: ["a.php": "a", "b.php": "b"])
|
|
||||||
var asked = false
|
|
||||||
h.store.confirmUnsavedClose = { _ in asked = true; return .cancel }
|
|
||||||
h.store.open("a.php")
|
|
||||||
await h.store.settle()
|
|
||||||
h.store.edit("my edit")
|
|
||||||
h.store.open("b.php")
|
|
||||||
await h.store.settle()
|
|
||||||
#expect(!asked)
|
|
||||||
#expect(h.store.dirtyPaths == ["a.php"])
|
|
||||||
h.store.open("a.php")
|
|
||||||
await h.store.settle()
|
|
||||||
#expect(h.store.activePath == "a.php")
|
|
||||||
#expect(h.store.text(for: "a.php") == "my edit")
|
|
||||||
#expect(h.store.isDirty("a.php"))
|
|
||||||
#expect(h.files.writes.isEmpty)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test func theOpenFileComesFirstAmongTheDirtyPaths() async {
|
@Test func theOpenFileComesFirstAmongTheDirtyPaths() async {
|
||||||
let h = EditorHarness(files: ["a": "a", "b": "b", "c": "c"])
|
let h = EditorHarness(files: ["a": "a", "b": "b", "c": "c"])
|
||||||
for path in ["c", "a", "b"] {
|
h.strand("c", disk: "c", buffer: "c!")
|
||||||
h.store.open(path)
|
h.strand("a", disk: "a", buffer: "a!")
|
||||||
|
h.store.open("b")
|
||||||
await h.store.settle()
|
await h.store.settle()
|
||||||
h.store.edit(path + "!")
|
h.store.edit("b!")
|
||||||
}
|
|
||||||
#expect(h.store.dirtyPaths == ["b", "a", "c"])
|
#expect(h.store.dirtyPaths == ["b", "a", "c"])
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,6 +83,116 @@ import Testing
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MainActor
|
||||||
|
@Suite struct EditorStoreSwitchTests {
|
||||||
|
private func dirty(_ files: [String: String] = ["a.txt": "a", "b.txt": "b"]) async -> EditorHarness {
|
||||||
|
let h = EditorHarness(files: files)
|
||||||
|
h.store.open("a.txt")
|
||||||
|
await h.store.settle()
|
||||||
|
h.store.edit("a edited")
|
||||||
|
return h
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func reopeningACleanFileReadsWhatChangedOnDisk() async {
|
||||||
|
let h = EditorHarness(files: ["a.txt": "one", "b.txt": "b"])
|
||||||
|
h.store.open("a.txt")
|
||||||
|
await h.store.settle()
|
||||||
|
h.store.open("b.txt")
|
||||||
|
await h.store.settle()
|
||||||
|
h.files.set("a.txt", "agent wrote this")
|
||||||
|
h.store.open("a.txt")
|
||||||
|
await h.store.settle()
|
||||||
|
#expect(h.store.text(for: "a.txt") == "agent wrote this")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func switchingAwayFromADirtyFileAsks() async {
|
||||||
|
let h = await dirty()
|
||||||
|
var asked: [String] = []
|
||||||
|
h.store.confirmUnsavedClose = { asked.append($0); return .cancel }
|
||||||
|
h.store.open("b.txt")
|
||||||
|
#expect(asked == ["a.txt"])
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func cancelKeepsTheFileAndItsEdits() async {
|
||||||
|
let h = await dirty()
|
||||||
|
var accepted = false
|
||||||
|
h.store.confirmUnsavedClose = { _ in .cancel }
|
||||||
|
let opened = h.store.open("b.txt") { accepted = true }
|
||||||
|
await h.store.settle()
|
||||||
|
#expect(!opened && !accepted)
|
||||||
|
#expect(h.store.activePath == "a.txt")
|
||||||
|
#expect(h.store.text(for: "a.txt") == "a edited")
|
||||||
|
#expect(h.store.history == ["a.txt"])
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func discardDropsTheEditsAndOpensTheNewFile() async {
|
||||||
|
let h = await dirty()
|
||||||
|
h.store.confirmUnsavedClose = { _ in .discard }
|
||||||
|
#expect(h.store.open("b.txt"))
|
||||||
|
await h.store.settle()
|
||||||
|
#expect(h.store.activePath == "b.txt")
|
||||||
|
#expect(h.store.dirtyPaths.isEmpty)
|
||||||
|
#expect(h.store.text(for: "a.txt") == "a")
|
||||||
|
#expect(h.files.writes.isEmpty)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func saveWritesThenOpens() async {
|
||||||
|
let h = await dirty()
|
||||||
|
var accepted = false
|
||||||
|
h.store.confirmUnsavedClose = { _ in .save }
|
||||||
|
h.store.open("b.txt") { accepted = true }
|
||||||
|
await h.store.settle()
|
||||||
|
#expect(h.files.current("a.txt") == "a edited")
|
||||||
|
#expect(h.store.activePath == "b.txt")
|
||||||
|
#expect(accepted)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func aFailedSaveKeepsTheDirtyFileOpen() async {
|
||||||
|
let h = await dirty()
|
||||||
|
var accepted = false
|
||||||
|
var toasts: [String] = []
|
||||||
|
h.store.showToast = { title, _ in toasts.append(title) }
|
||||||
|
h.store.confirmUnsavedClose = { _ in .save }
|
||||||
|
h.files.failWrites = true
|
||||||
|
h.store.open("b.txt") { accepted = true }
|
||||||
|
await h.store.settle()
|
||||||
|
#expect(!accepted)
|
||||||
|
#expect(h.store.activePath == "a.txt")
|
||||||
|
#expect(h.store.isDirty("a.txt"))
|
||||||
|
#expect(toasts == ["Save failed"])
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func reopeningTheSameDirtyFileAsksThenReadsDisk() async {
|
||||||
|
let h = await dirty()
|
||||||
|
var asked: [String] = []
|
||||||
|
h.store.confirmUnsavedClose = { asked.append($0); return .discard }
|
||||||
|
h.files.set("a.txt", "agent wrote this")
|
||||||
|
h.store.open("a.txt")
|
||||||
|
await h.store.settle()
|
||||||
|
#expect(asked == ["a.txt"])
|
||||||
|
#expect(h.store.text(for: "a.txt") == "agent wrote this")
|
||||||
|
#expect(!h.store.isDirty("a.txt"))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func withAutoSaveTheDirtyFileIsSavedWithoutAsking() async {
|
||||||
|
let h = EditorHarness(files: ["a.txt": "a", "b.txt": "b"])
|
||||||
|
h.store.editorConfig.autoSave = true
|
||||||
|
var asked = false
|
||||||
|
var toasts: [String] = []
|
||||||
|
h.store.confirmUnsavedClose = { _ in asked = true; return .cancel }
|
||||||
|
h.store.showToast = { title, _ in toasts.append(title) }
|
||||||
|
h.store.open("a.txt")
|
||||||
|
await h.store.settle()
|
||||||
|
h.store.edit("a edited")
|
||||||
|
h.store.open("b.txt")
|
||||||
|
await h.store.settle()
|
||||||
|
#expect(!asked)
|
||||||
|
#expect(toasts.isEmpty)
|
||||||
|
#expect(h.files.current("a.txt") == "a edited")
|
||||||
|
#expect(h.store.activePath == "b.txt")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
@Suite struct EditorStoreDirtyTests {
|
@Suite struct EditorStoreDirtyTests {
|
||||||
@Test func anEditMakesTheFileDirtyAndTypingBackCleansIt() async {
|
@Test func anEditMakesTheFileDirtyAndTypingBackCleansIt() async {
|
||||||
@@ -218,25 +309,9 @@ import Testing
|
|||||||
#expect(!asked)
|
#expect(!asked)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test func closingAsksOnlyAboutTheOpenFile() async {
|
|
||||||
let h = EditorHarness(files: ["a.txt": "one", "b.txt": "b"])
|
|
||||||
h.store.open("a.txt")
|
|
||||||
await h.store.settle()
|
|
||||||
h.store.edit("two")
|
|
||||||
h.store.open("b.txt")
|
|
||||||
await h.store.settle()
|
|
||||||
var asked = false
|
|
||||||
h.store.confirmUnsavedClose = { _ in asked = true; return .cancel }
|
|
||||||
#expect(await h.store.requestCloseActive())
|
|
||||||
#expect(!asked)
|
|
||||||
#expect(h.store.isDirty("a.txt"))
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test func resolvingUnsavedSeesABufferThatIsNoLongerOpen() async {
|
@Test func resolvingUnsavedSeesABufferThatIsNoLongerOpen() async {
|
||||||
let h = EditorHarness(files: ["a.txt": "one", "b.txt": "b"])
|
let h = EditorHarness(files: ["a.txt": "one", "b.txt": "b"])
|
||||||
h.store.open("a.txt")
|
h.strand("a.txt", disk: "one", buffer: "two")
|
||||||
await h.store.settle()
|
|
||||||
h.store.edit("two")
|
|
||||||
h.store.open("b.txt")
|
h.store.open("b.txt")
|
||||||
await h.store.settle()
|
await h.store.settle()
|
||||||
var asked: [String] = []
|
var asked: [String] = []
|
||||||
|
|||||||
@@ -406,6 +406,50 @@ import Testing
|
|||||||
#expect(harness.model.editor?.activePath == nil)
|
#expect(harness.model.editor?.activePath == nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test func cancellingTheUnsavedPromptLeavesTheExplorerAndFocusAlone() async {
|
||||||
|
let harness = WorkspaceHarness(contents: ["a.php": "one", "b.php": "b"])
|
||||||
|
await harness.start()
|
||||||
|
harness.model.open("a.php")
|
||||||
|
await harness.model.settle()
|
||||||
|
harness.model.editor?.edit("two")
|
||||||
|
harness.model.layout.setFocusZone(.terminal)
|
||||||
|
harness.system.unsavedCloseChoice = .cancel
|
||||||
|
harness.model.open("b.php")
|
||||||
|
await harness.model.settle()
|
||||||
|
#expect(harness.system.unsavedCloseQuestions == ["a.php"])
|
||||||
|
#expect(harness.model.editor?.activePath == "a.php")
|
||||||
|
#expect(harness.model.explorer?.selectedPath == "a.php")
|
||||||
|
#expect(harness.model.layout.focusZone == .terminal)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func aFailedSaveLeavesTheExplorerOnTheDirtyFile() async {
|
||||||
|
let harness = WorkspaceHarness(contents: ["a.php": "one", "b.php": "b"])
|
||||||
|
await harness.start()
|
||||||
|
harness.model.open("a.php")
|
||||||
|
await harness.model.settle()
|
||||||
|
harness.model.editor?.edit("two")
|
||||||
|
harness.system.unsavedCloseChoice = .save
|
||||||
|
harness.files.failWrites = true
|
||||||
|
harness.model.open("b.php")
|
||||||
|
await harness.model.settle()
|
||||||
|
#expect(harness.model.editor?.activePath == "a.php")
|
||||||
|
#expect(harness.model.explorer?.selectedPath == "a.php")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func savingOnTheUnsavedPromptThenRevealsTheNewFile() async {
|
||||||
|
let harness = WorkspaceHarness(contents: ["a.php": "one", "b.php": "b"])
|
||||||
|
await harness.start()
|
||||||
|
harness.model.open("a.php")
|
||||||
|
await harness.model.settle()
|
||||||
|
harness.model.editor?.edit("two")
|
||||||
|
harness.system.unsavedCloseChoice = .save
|
||||||
|
harness.model.open("b.php")
|
||||||
|
await harness.model.settle()
|
||||||
|
#expect(harness.files.current("a.php") == "two")
|
||||||
|
#expect(harness.model.editor?.activePath == "b.php")
|
||||||
|
#expect(harness.model.explorer?.selectedPath == "b.php")
|
||||||
|
}
|
||||||
|
|
||||||
@Test func commandWWithoutAnOpenFileClosesTheWindow() async {
|
@Test func commandWWithoutAnOpenFileClosesTheWindow() async {
|
||||||
let harness = WorkspaceHarness()
|
let harness = WorkspaceHarness()
|
||||||
await harness.start()
|
await harness.start()
|
||||||
|
|||||||
@@ -76,3 +76,10 @@ struct EditorHarness {
|
|||||||
store.dismissDiffOverlay = { overlays.diffDismissals += 1 }
|
store.dismissDiffOverlay = { overlays.diffDismissals += 1 }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension EditorHarness {
|
||||||
|
/// Unsaved edits on a file that is not open; opening another file never leaves these behind.
|
||||||
|
func strand(_ path: String, disk: String, buffer: String) {
|
||||||
|
store.states[path] = FileState(buffer: buffer, disk: disk)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -22,12 +22,12 @@ Helder (executable) → HelderUI → HelderServices → HelderCore
|
|||||||
- **One entry point.** Views, the menu bar and the key router all call `WorkspaceModel.perform(Command)` (`Shell/Command.swift`). Context-menu items arrive as `.context(ContextAction)`; the model asks `SourceControlStore.confirmation(for:)` / `ExplorerStore.confirmation(for:)` first and shows the confirm overlay, and `.confirmPending` runs the action. The name prompt submits with `.submitName`, the pass-on prompt with `.passToAgent`, the note's ⌘P with `.passNote`.
|
- **One entry point.** Views, the menu bar and the key router all call `WorkspaceModel.perform(Command)` (`Shell/Command.swift`). Context-menu items arrive as `.context(ContextAction)`; the model asks `SourceControlStore.confirmation(for:)` / `ExplorerStore.confirmation(for:)` first and shows the confirm overlay, and `.confirmPending` runs the action. The name prompt submits with `.submitName`, the pass-on prompt with `.passToAgent`, the note's ⌘P with `.passNote`.
|
||||||
- **Overlays never stack.** `OverlayStore.current` is one `Overlay` enum; only the model presents or dismisses it. `OverlayStore.onChange` lets the model run closing behaviour however an overlay went away (the note saves, the Diff gives back the mode it covered). `OverlayHost` draws the current overlay. `.launcher` is the ⇧⌘O "Open recent project" list; the bare window's launcher is part of the shell, not an overlay. The key router only sees `OverlayKind` (`none`, `note`, `diff(busy:)`, `other`): over the Diff the workspace keys keep working unless its own menu or prompt is open (`busy`). Toasts (`ToastStore`) may sit on top. The Diff draws its own right-click menu and pass-on prompt inside itself, so it stays open.
|
- **Overlays never stack.** `OverlayStore.current` is one `Overlay` enum; only the model presents or dismisses it. `OverlayStore.onChange` lets the model run closing behaviour however an overlay went away (the note saves, the Diff gives back the mode it covered). `OverlayHost` draws the current overlay. `.launcher` is the ⇧⌘O "Open recent project" list; the bare window's launcher is part of the shell, not an overlay. The key router only sees `OverlayKind` (`none`, `note`, `diff(busy:)`, `other`): over the Diff the workspace keys keep working unless its own menu or prompt is open (`busy`). Toasts (`ToastStore`) may sit on top. The Diff draws its own right-click menu and pass-on prompt inside itself, so it stays open.
|
||||||
- **Stores report, the model shows.** Stores raise toasts through `notify`/`showToast` hooks the model wires to `ToastStore`; the model never toasts a second time for the same action.
|
- **Stores report, the model shows.** Stores raise toasts through `notify`/`showToast` hooks the model wires to `ToastStore`; the model never toasts a second time for the same action.
|
||||||
- **Closing.** A window close, a project switch and ⌘Q all run `prepareToClose()` first: every unsaved file is asked about, and a cancel keeps everything open. Then `closeProject()` waits for running work, writes the note and session and ends the terminals.
|
- **Closing.** A window close, a project switch and ⌘Q all run `prepareToClose()` first: every unsaved file (at most the open one plus a vanished-file buffer) is asked about, and a cancel keeps everything open. Then `closeProject()` waits for running work, writes the note and session and ends the terminals.
|
||||||
- **Lifecycle.** `start()`: recents → config (applied to every store and the terminals) → git, tree and note in parallel → `editor.restore` → watcher → git polling (`git.refreshInterval`) → the PHP class list 1.5 s later. Watcher events: `.project` re-reads git, the tree, the open file and every unsaved buffer (the edits kept), invalidates the symbol index and reloads the class list 2 s after the last change; `.git` re-reads git; `.config` re-resolves and re-applies the config. ⌘R re-reads git and the tree and lets the disk win in the open file. A project switch or window close saves the note and the session, stops the watcher and polling, and ends both terminals.
|
- **Lifecycle.** `start()`: recents → config (applied to every store and the terminals) → git, tree and note in parallel → `editor.restore` → watcher → git polling (`git.refreshInterval`) → the PHP class list 1.5 s later. Watcher events: `.project` re-reads git, the tree, the open file and every unsaved buffer (the edits kept), invalidates the symbol index and reloads the class list 2 s after the last change; `.git` re-reads git; `.config` re-resolves and re-applies the config. ⌘R re-reads git and the tree and lets the disk win in the open file. A project switch or window close saves the note and the session, stops the watcher and polling, and ends both terminals.
|
||||||
- **Terminals.** `TerminalStore` owns both panes' handles. Ending a pane goes through the store (`terminateAll`, `restart`, or `release` when a pane's window closes), which signals the child and lets `ChildReaper` collect it, so no zombie or orphan is left. A pane whose child exited restarts on the next key press. Right-click raises `contextMenuRequested`; the model shows the app's own menu (`.terminal` target: Copy with a selection, Paste). Font size follows `layout.textScale` (⌘0/⌘+/⌘−) live.
|
- **Terminals.** `TerminalStore` owns both panes' handles. Ending a pane goes through the store (`terminateAll`, `restart`, or `release` when a pane's window closes), which signals the child and lets `ChildReaper` collect it, so no zombie or orphan is left. A pane whose child exited restarts on the next key press. Right-click raises `contextMenuRequested`; the model shows the app's own menu (`.terminal` target: Copy with a selection, Paste). Font size follows `layout.textScale` (⌘0/⌘+/⌘−) live.
|
||||||
- **Git and files.** Git gets paths as literal pathspecs (`GIT_LITERAL_PATHSPECS=1`, so `pages/[id].vue` is one file). A changed file over `FileLimits.maxDiffFileBytes` (1 MB) keeps its row but loads no text: `GitFileChange.isTooBig` → `Diff.isTooBig`, and the Diff shows "Too big.". Saves are atomic (temp file, then rename, keeping permissions). Writes, creates, renames and deletes are refused when the entry's folder resolves (symlinks included) outside the project (`containedURL`). The watcher drops `IgnoreRules.walkIgnoredNames`, framework caches (`storage/framework/`, `bootstrap/cache/`, `.phpunit*`) and `files.exclude`.
|
- **Git and files.** Git gets paths as literal pathspecs (`GIT_LITERAL_PATHSPECS=1`, so `pages/[id].vue` is one file). A changed file over `FileLimits.maxDiffFileBytes` (1 MB) keeps its row but loads no text: `GitFileChange.isTooBig` → `Diff.isTooBig`, and the Diff shows "Too big.". Saves are atomic (temp file, then rename, keeping permissions). Writes, creates, renames and deletes are refused when the entry's folder resolves (symlinks included) outside the project (`containedURL`). The watcher drops `IgnoreRules.walkIgnoredNames`, framework caches (`storage/framework/`, `bootstrap/cache/`, `.phpunit*`) and `files.exclude`.
|
||||||
- **Processes.** Every new window (⇧⌘N, the Dock's New Window, Open Folder or Open Recent with no key window) is a new Helder process via `SystemActing.openNewInstance`: `NSWorkspace` with `createsNewApplicationInstance` in the bundle, `InstanceLauncher` (Foundation `Process`) under `swift run`. The folder travels as `-HelderProject <path>`, which `ProjectLocator.initialRoot` reads as its directory argument; a bare path could reach AppKit as a file to open. Switching projects (⌘O, Open Recent in a window) stays in the process. `AppName` renames the process to the project's title (the launcher is "Helder"), so Mission Control, the Dock and ⌘Tab tell projects apart. Windows are not restorable and `NSQuitAlwaysKeepsWindows` is off, so a launch opens exactly one window.
|
- **Processes.** Every new window (⇧⌘N, the Dock's New Window, Open Folder or Open Recent with no key window) is a new Helder process via `SystemActing.openNewInstance`: `NSWorkspace` with `createsNewApplicationInstance` in the bundle, `InstanceLauncher` (Foundation `Process`) under `swift run`. The folder travels as `-HelderProject <path>`, which `ProjectLocator.initialRoot` reads as its directory argument; a bare path could reach AppKit as a file to open. Switching projects (⌘O, Open Recent in a window) stays in the process. `AppName` renames the process to the project's title (the launcher is "Helder"), so Mission Control, the Dock and ⌘Tab tell projects apart. Windows are not restorable and `NSQuitAlwaysKeepsWindows` is off, so a launch opens exactly one window.
|
||||||
- **Editor.** `EditorStore` shows exactly one file (`activePath`); opening another replaces it, and there are no tabs. Unsaved buffers live per path in `states` and outlive the file being open, so switching away never prompts and coming back shows the edits; `dirtyPaths` and the close/quit flow see every one. ⌘W closes the open file (asking first when dirty) and shows the empty state. `EditorBar` above the code shows the type badge, the path, the unsaved dot and `+N`/`−N`, then a Preview button for Markdown and a Diff button for a changed file (`EditorPresentation.barButtons`). A changed file shows Actual (the live buffer with changed lines marked), an unchanged one plain code; ⌘M only flips Markdown between code and preview. The session stores the open file and its mode and side; a stored `openTabs` list and unknown modes are ignored.
|
- **Editor.** `EditorStore` shows exactly one file (`activePath`); opening another replaces it, and there are no tabs. Every `open` (Git column, Explorer, search, recent files, links) re-reads the file from disk; the disk wins. Unsaved edits do not outlive switching: opening any file, the same one included, while the open file is dirty asks Save / Don't Save / Cancel (with `editor.autoSave` on it saves silently). Cancel moves nothing, Explorer selection included; a failed save keeps the dirty file open. `dirtyPaths` is therefore at most the open file plus a vanished-file buffer, and the close/quit flow asks about each. ⌘W closes the open file (asking first when dirty) and shows the empty state. `EditorBar` above the code shows the type badge, the path, the unsaved dot and `+N`/`−N`, then a Preview button for Markdown and a Diff button for a changed file (`EditorPresentation.barButtons`). A changed file shows Actual (the live buffer with changed lines marked), an unchanged one plain code; ⌘M only flips Markdown between code and preview. The session stores the open file and its mode and side; a stored `openTabs` list and unknown modes are ignored.
|
||||||
- **Focus.** `WorkspaceModel.focusRequest` names where the keyboard should go (a column, the commit box); the view that takes it calls `focusTaken(_:)`. The editor's text view follows `EditorStore.textFocusRequest`, which also moves when the Diff closes.
|
- **Focus.** `WorkspaceModel.focusRequest` names where the keyboard should go (a column, the commit box); the view that takes it calls `focusTaken(_:)`. The editor's text view follows `EditorStore.textFocusRequest`, which also moves when the Diff closes.
|
||||||
|
|
||||||
## Where things live
|
## Where things live
|
||||||
|
|||||||
+1
-1
@@ -111,7 +111,7 @@ The second column. A standard project file tree.
|
|||||||
|
|
||||||
## 5. Editor
|
## 5. Editor
|
||||||
|
|
||||||
The third and widest column. It shows exactly one file: a bar on top and the code below. Opening another file replaces it. Unsaved edits are kept per file, so switching away never prompts and coming back shows the edits.
|
The third and widest column. It shows exactly one file: a bar on top and the code below. Opening another file replaces it. Opening a file always reads it fresh from disk. Edits are written only with `Cmd+S` (or by `editor.autoSave`). Opening a file, the same one included, while the open file has unsaved edits asks **Save**, **Don't Save** or **Cancel**: Save writes and then opens, Don't Save drops the edits and opens, Cancel keeps the current file, its edits and the Explorer selection. A failed save keeps the file open. With `editor.autoSave` on, the file saves silently instead of asking.
|
||||||
|
|
||||||
### Editor bar
|
### Editor bar
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user