AI media harness for planning, generating, and editing locally
TypeScript
Route mouse Back to application navigation
Bitti5b6d99f3e1cf
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.mdindex 14e53c6..8d05bcb 100644--- a/RELEASE_NOTES.md+++ b/RELEASE_NOTES.md@@ -32,6 +32,7 @@ Changes since 0.3.2.- Video cards match Shot sizing and show the opening playback frame. Click to select settings; double-click or choose Edit Scenes to open scenes. Playback shares Timeline's prepared players, and returning to Video restores the open video.- Video card and popout playback preserve full rendered scene ranges and keep decoders running through background updates.- Application Back returns from scenes to Video and from image versions to their parent bar.+- The mouse Back button follows the global Back action, including Settings and nested views.- Editing generated music creates a separate draft; cards distinguish drafts from playable songs.- Single Shot uses previous latents only as its starting anchor, fresh noise for the middle and a generated ending anchor, avoiding repeated source imagery.- Dependent scenes can queue behind active sources; cancelling any linked generation cancels the whole pending group.diff --git a/src/components/ProjectWorkspace.tsx b/src/components/ProjectWorkspace.tsxindex 093bf68..7ff2656 100644--- a/src/components/ProjectWorkspace.tsx+++ b/src/components/ProjectWorkspace.tsx@@ -262,7 +262,7 @@ export function ProjectWorkspace({ project, initialView, runtime = null, onBack,<TitleBarclassName="project-titlebar"- leading={<button type="button" className="icon-button" onClick={goBack} aria-label={backNavigation?.label ?? "Back to project library"} data-tooltip={backNavigation?.label ?? "Back to projects"} data-tooltip-shortcut="Alt+Left" aria-keyshortcuts="Alt+ArrowLeft"><Back16 /></button>}+ leading={<button type="button" className="icon-button" data-app-back onClick={goBack} aria-label={backNavigation?.label ?? "Back to project library"} data-tooltip={backNavigation?.label ?? "Back to projects"} data-tooltip-shortcut="Alt+Left" aria-keyshortcuts="Alt+ArrowLeft"><Back16 /></button>}title={<button type="button" className="project-title" aria-label={`Edit project settings for ${config.name}`} aria-haspopup="dialog" aria-expanded={editingProject} data-tooltip="Project settings" onClick={() => { session.dismissError(); setEditingProject(true); }}><span className="project-title__name">{config.name}</span><ChevronDown12 aria-hidden="true" /></button>}/* Save, then Undo and Redo, right after the project's name: the commandsabout the document sit with the document's title. */diff --git a/src/components/SettingsView.tsx b/src/components/SettingsView.tsxindex 388b152..531a9f9 100644--- a/src/components/SettingsView.tsx+++ b/src/components/SettingsView.tsx@@ -694,7 +694,7 @@ export function SettingsView({ onClose, updates, initialTab = "engine", titleBarleaves a sub-page first, then Settings. */}<TitleBartitle="Settings"- leading={<button type="button" className="icon-button" onClick={back} aria-label="Back" data-tooltip="Back" data-tooltip-shortcut="Alt+Left" aria-keyshortcuts="Alt+ArrowLeft"><Back16 /></button>}+ leading={<button type="button" className="icon-button" data-app-back onClick={back} aria-label="Back" data-tooltip="Back" data-tooltip-shortcut="Alt+Left" aria-keyshortcuts="Alt+ArrowLeft"><Back16 /></button>}actions={<><button ref={agentToggle} type="button" className={`icon-button${agentOpen ? " icon-button--checked" : ""}${agentBusy ? " icon-button--busy" : ""}`}aria-label="Agent" aria-pressed={agentOpen} aria-busy={agentBusy} aria-controls="settings-agent"diff --git a/src/components/WorkspaceBackNavigation.integration.test.tsx b/src/components/WorkspaceBackNavigation.integration.test.tsxindex c49f19b..8674949 100644--- a/src/components/WorkspaceBackNavigation.integration.test.tsx+++ b/src/components/WorkspaceBackNavigation.integration.test.tsx@@ -6,14 +6,17 @@ import { ProjectWorkspace } from "./ProjectWorkspace";import { createProjectConfig } from "../lib/project";import { createEmptyImage } from "../lib/imageHistory";import { newVideo } from "../lib/videoLibrary";+import { installBrowserGuards } from "../lib/nativeShell";vi.mock("@tauri-apps/api/core", () => ({ invoke: vi.fn() }));vi.mock("@tauri-apps/api/event", () => ({ listen: vi.fn(async () => () => undefined) }));+let uninstallGuards: () => void;beforeEach(() => {localStorage.clear();+ uninstallGuards = installBrowserGuards();vi.spyOn(HTMLMediaElement.prototype, "load").mockImplementation(() => undefined);});-afterEach(() => { cleanup(); vi.restoreAllMocks(); });+afterEach(() => { uninstallGuards(); cleanup(); vi.restoreAllMocks(); });const project = () => createProjectConfig({ name: "Back navigation", prompt: "Walk", aspectRatio: "16:9", resolution: "416p", targetDurationSeconds: 30 });it("uses application Back and Alt+Left for scenes, clears the action on tab switches and preserves the project exit guard", () => {@@ -21,23 +24,26 @@ it("uses application Back and Alt+Left for scenes, clears the action on tab switconfig.videos = [{ ...newVideo(null), title: "Film", sceneIds: config.generationJobs.map((scene) => scene.id) }];const view = render(<ProjectWorkspace project={{ folderPath: "D:/Back", config }} initialView="generator" onBack={onBack} onSave={async () => {}} />);fireEvent.change(screen.getByRole("textbox", { name: "Video title" }), { target: { value: "Renamed film" } });- fireEvent.click(screen.getByRole("button", { name: "Open Renamed film" }));+ fireEvent.doubleClick(screen.getByRole("button", { name: "Select Renamed film" }));expect(within(view.container.querySelector(".video-scenes")!).queryByRole("button", { name: "Back to Video" })).not.toBeInTheDocument();fireEvent.click(screen.getByRole("button", { name: "Back to Video" }));- expect(screen.getByRole("button", { name: "Open Renamed film" })).toBeInTheDocument();+ expect(screen.getByRole("button", { name: "Select Renamed film" })).toBeInTheDocument();expect(screen.queryByRole("dialog")).not.toBeInTheDocument(); expect(onBack).not.toHaveBeenCalled();- fireEvent.click(screen.getByRole("button", { name: "Open Renamed film" }));+ fireEvent.doubleClick(screen.getByRole("button", { name: "Select Renamed film" }));fireEvent.click(screen.getByRole("tab", { name: "References" }));expect(screen.getByRole("button", { name: "Back to project library" })).toBeInTheDocument();fireEvent.click(screen.getByRole("tab", { name: "Video" }));expect(screen.getByRole("button", { name: "Back to Video" })).toBeInTheDocument();fireEvent.keyDown(document.body, { key: "ArrowLeft", code: "ArrowLeft", altKey: true });- expect(screen.getByRole("button", { name: "Open Renamed film" })).toBeInTheDocument();- fireEvent.click(screen.getByRole("button", { name: "Back to project library" }));+ expect(screen.getByRole("button", { name: "Select Renamed film" })).toBeInTheDocument();+ fireEvent.doubleClick(screen.getByRole("button", { name: "Select Renamed film" }));+ fireEvent.mouseUp(document.body, { button: 3 });+ expect(screen.getByRole("button", { name: "Select Renamed film" })).toBeInTheDocument();+ fireEvent.mouseUp(document.body, { button: 3 });expect(screen.getByRole("dialog")).toBeInTheDocument(); expect(onBack).not.toHaveBeenCalled();});-it.each(["local", "global"])("uses %s Back to show parent images, then restores the project back action", (action) => {+it.each(["local", "global", "mouse"])("uses %s Back to show parent images, then restores the project back action", (action) => {let config = createEmptyImage(project());const root = config.imageScene!.outputAssetId!;config = createEmptyImage(config, undefined, root);@@ -49,7 +55,8 @@ it.each(["local", "global"])("uses %s Back to show parent images, then restoresconst localBack = within(bar).getByRole("button", { name: "Back to all images" });const globalBack = screen.getAllByRole("button", { name: "Back to all images" }).find((button) => !bar.contains(button))!;expect(globalBack).toBeInTheDocument();- fireEvent.click(action === "local" ? localBack : globalBack);+ if (action === "mouse") fireEvent.mouseUp(document.body, { button: 3 });+ else fireEvent.click(action === "local" ? localBack : globalBack);expect(bar.querySelector(`[data-image-asset="${child}"]`)).not.toBeInTheDocument();expect(bar.querySelector(`[data-image-asset="${root}"]`)).toHaveAttribute("aria-pressed", "true");expect(onBack).not.toHaveBeenCalled();diff --git a/src/lib/nativeShell.test.ts b/src/lib/nativeShell.test.tsindex c2dac13..f0f401b 100644--- a/src/lib/nativeShell.test.ts+++ b/src/lib/nativeShell.test.ts@@ -312,6 +312,27 @@ describe("browser guards", () => {uninstall = installBrowserGuards();});+ it("routes mouse Back once to the visible global button, even over text, and respects dialogs", () => {+ document.body.innerHTML = '<div hidden><button data-app-back id="hidden-back"></button></div><button data-app-back id="back"></button><input id="field" />';+ const back = vi.fn(), hidden = vi.fn();+ document.getElementById("back")!.addEventListener("click", back);+ document.getElementById("hidden-back")!.addEventListener("click", hidden);+ const mouse = (type: string, button = 3) => {+ const event = new MouseEvent(type, { button, bubbles: true, cancelable: true });+ document.getElementById("field")!.dispatchEvent(event);+ return event;+ };+ for (const type of ["mousedown", "mouseup", "auxclick"]) expect(mouse(type).defaultPrevented).toBe(true);+ expect(back).toHaveBeenCalledTimes(1); expect(hidden).not.toHaveBeenCalled();+ for (const button of [0, 1, 2, 4]) expect(mouse("mouseup", button).defaultPrevented).toBe(false);+ expect(back).toHaveBeenCalledTimes(1);+ const modal = document.createElement("div"); modal.setAttribute("aria-modal", "true"); document.body.append(modal);+ expect(mouse("mouseup").defaultPrevented).toBe(true); expect(back).toHaveBeenCalledTimes(1);+ modal.remove();+ uninstall(); expect(mouse("mouseup").defaultPrevented).toBe(false); expect(back).toHaveBeenCalledTimes(1);+ uninstall = installBrowserGuards();+ });+it("refuses a drop nothing accepted, and leaves drop targets and dropzones alone", () => {const drag = (target: Element, accept = false) => {const event = new Event("dragover", { bubbles: true, cancelable: true });diff --git a/src/lib/nativeShell.ts b/src/lib/nativeShell.tsindex f55b388..3f38def 100644--- a/src/lib/nativeShell.ts+++ b/src/lib/nativeShell.ts@@ -498,11 +498,27 @@ export function installBrowserGuards(target: Window = window): () => void {.then(({ invoke }) => invoke("show_text_context_menu", { request: text })).catch(() => undefined);};+ // Mouse Back invokes the visible title-bar action, including Settings subpages.+ // Cancel every browser-history phase, but navigate only once, on release.+ const onMouseBack = (event: MouseEvent) => {+ if (event.button !== 3) return;+ event.preventDefault();+ event.stopPropagation();+ if (event.type !== "mouseup") return;+ const visible = (element: Element) => !element.closest('[hidden], [inert], [aria-hidden="true"]');+ const modal = [...doc.querySelectorAll('[aria-modal="true"]')].filter(visible).at(-1);+ const back = [...doc.querySelectorAll<HTMLButtonElement>('button[data-app-back]:not(:disabled)')]+ .find((button) => visible(button) && (!modal || modal.contains(button)));+ back?.click();+ };+ const mouseBackEvents = ["mousedown", "mouseup", "auxclick"] as const;+ for (const name of mouseBackEvents) target.addEventListener(name, onMouseBack, true);target.addEventListener("keydown", onKeyDownCapture, true);doc.addEventListener("dragover", onDragOver);doc.addEventListener("drop", onDrop);doc.addEventListener("contextmenu", onContextMenu);return () => {+ for (const name of mouseBackEvents) target.removeEventListener(name, onMouseBack, true);target.removeEventListener("keydown", onKeyDownCapture, true);unregisterFallback();doc.removeEventListener("dragover", onDragOver);