Merge branch 'worktree-agent-ac8ee7a1fc97e24ae' into claude/practical-noether-1hb2s1

This commit is contained in:
Claude committed 2026-11-14 01:33:09 +00:00
commit 891649abc1
12 files changed
+169 -34

No files matched your search

+18
View File
@@ -5,6 +5,7 @@ import {
findConflict,
formatCombo,
isReservedCombo,
tabKeyAction,
matchesShortcut,
resolveCombo,
SHORTCUT_DEFS,
@@ -171,3 +172,20 @@ describe("formatCombo", () => {
// commandAliasOverrides.test.ts) — ohne dediziertes Unit-Test (window/
// localStorage im "node"-Vitest-Environment nicht vorhanden); beide sind
// bewusst defensiv (try/catch, No-op statt Absturz).
describe("[252] tabKeyAction", () => {
const ev = (o: Partial<KeyboardEvent>) => ({ key: "Tab", ctrlKey: false, metaKey: false, altKey: false, shiftKey: false, ...o });
it("Tab und Umschalt+Tab gehören der Befehlszeile", () => {
expect(tabKeyAction(ev({}))).toBe("commandLine");
expect(tabKeyAction(ev({ shiftKey: true }))).toBe("commandLine");
});
it("Ctrl+Tab vorwärts, Ctrl+Umschalt+Tab rückwärts", () => {
expect(tabKeyAction(ev({ ctrlKey: true }))).toBe("nextViewTab");
expect(tabKeyAction(ev({ ctrlKey: true, shiftKey: true }))).toBe("prevViewTab");
});
it("Cmd+Tab und Alt+Tab gehören dem System, andere Tasten nicht", () => {
expect(tabKeyAction(ev({ metaKey: true }))).toBeNull();
expect(tabKeyAction(ev({ altKey: true }))).toBeNull();
expect(tabKeyAction(ev({ key: "a", ctrlKey: true }))).toBeNull();
});
});
+12
View File
@@ -354,6 +354,18 @@ export function isReservedCombo(combo: string): boolean {
return RESERVED_BARE_COMBOS.has(combo);
}
/**
* [252] Fest verdrahtetes Tab-Verhalten (nicht umbelegbar): Tab gehört immer der Befehlszeile; Ctrl+Tab /
* Ctrl+Umschalt+Tab (auch auf dem Mac Ctrl, Cmd+Tab gehört dem System) springt durch die Ansichts-Reiter.
* `null` = keine Tab-Taste bzw. Cmd/Alt+Tab (System).
*/
export type TabKeyAction = "nextViewTab" | "prevViewTab" | "commandLine";
export function tabKeyAction(e: Pick<KeyboardEvent, "key" | "ctrlKey" | "metaKey" | "altKey" | "shiftKey">): TabKeyAction | null {
if (e.key !== "Tab" || e.metaKey || e.altKey) return null;
if (e.ctrlKey) return e.shiftKey ? "prevViewTab" : "nextViewTab";
return "commandLine";
}
function isMacPlatform(): boolean {
if (typeof navigator === "undefined") return false;
return /Mac|iPhone|iPad|iPod/.test(navigator.platform || navigator.userAgent || "");
+8 -2
View File
@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
import { buildShortcutOverview } from "./shortcutOverview";
import { buildShortcutOverview, FIXED_COMBO_ROWS } from "./shortcutOverview";
import { ALIASES, COMMANDS } from "../commands/registry";
import { SHORTCUT_DEFS } from "./keyboardShortcuts";
import { t } from "../i18n";
@@ -10,11 +10,17 @@ describe("[210] Kürzel-Übersicht", () => {
it("listet jede Tastenkombination der Registry genau einmal", () => {
const n = ov.combos.reduce((s, g) => s + g.rows.length, 0);
expect(n).toBe(SHORTCUT_DEFS.length);
expect(n).toBe(SHORTCUT_DEFS.length + FIXED_COMBO_ROWS.length);
const undo = ov.combos.flatMap((g) => g.rows).find((r) => r.labelKey === "shortcut.undo");
expect(undo?.combo).toBe("⌘Z");
});
it("[252] Ctrl+Tab / Ctrl+Umschalt+Tab stehen fest in der Übersicht (auf dem Mac Ctrl)", () => {
const rows = ov.combos.flatMap((g) => g.rows);
expect(rows.find((r) => r.labelKey === "shortcut.nextViewTab")?.combo).toBe("⌃Tab");
expect(buildShortcutOverview({}, {}, false).combos.flatMap((g) => g.rows).find((r) => r.labelKey === "shortcut.prevViewTab")?.combo).toBe("Strg+Umschalt+Tab");
});
it("zeigt Nutzer-Kombinationen statt der Vorgabe", () => {
const o = buildShortcutOverview({ undo: "mod+u" }, {}, false);
expect(o.combos.flatMap((g) => g.rows).find((r) => r.labelKey === "shortcut.undo")?.combo).toBe("Strg+U");
+14 -4
View File
@@ -40,17 +40,27 @@ export interface ShortcutOverview {
const CATEGORY_ORDER: ShortcutCategory[] = ["general", "selection", "edit", "boolean", "transform", "group", "tools", "navigation"];
/** [252] Fest verdrahtete Kürzel (nicht umbelegbar): Ctrl bleibt auch auf dem Mac Ctrl, Cmd+Tab gehört dem System. */
export const FIXED_COMBO_ROWS: { category: ShortcutCategory; labelKey: string; combo: (mac: boolean) => string }[] = [
{ category: "navigation", labelKey: "shortcut.nextViewTab", combo: (mac) => (mac ? "⌃Tab" : "Strg+Tab") },
{ category: "navigation", labelKey: "shortcut.prevViewTab", combo: (mac) => (mac ? "⌃⇧Tab" : "Strg+Umschalt+Tab") },
];
export function buildShortcutOverview(
comboOverrides: ShortcutOverrides = {},
aliasOverrides: Record<string, string> = {},
mac?: boolean,
): ShortcutOverview {
const isMac = mac ?? (typeof navigator !== "undefined" && /Mac|iPhone|iPad|iPod/.test(navigator.platform || navigator.userAgent || ""));
const combos: ComboGroup[] = CATEGORY_ORDER.map((category) => ({
category,
rows: SHORTCUT_DEFS.filter((d) => d.category === category).map((d) => ({
labelKey: d.labelKey,
combo: formatCombo(resolveCombo(d.id, comboOverrides), mac),
})),
rows: [
...SHORTCUT_DEFS.filter((d) => d.category === category).map((d) => ({
labelKey: d.labelKey,
combo: formatCombo(resolveCombo(d.id, comboOverrides), mac),
})),
...FIXED_COMBO_ROWS.filter((f) => f.category === category).map((f) => ({ labelKey: f.labelKey, combo: f.combo(isMac) })),
],
})).filter((g) => g.rows.length > 0);
// Nutzer-Kürzel überschreiben eingebaute mit gleichem Schlüssel (wie `resolveCommand`).
+11 -1
View File
@@ -6,7 +6,7 @@ import type { ViewType } from "../model/viewTypes";
import { sheetLevelOf } from "../model/layoutModel";
import { getState } from "./appStore";
import type { ViewSnapshotState } from "./viewSnapshots";
import { getViewStateBridge, getViewTabs, navigateToLevel, setViewTabs, stepFloor, switchViewKind, type TabNav } from "./viewTabs";
import { cycleTab, getViewStateBridge, getViewTabs, navigateToLevel, setViewTabs, stepFloor, switchViewKind, type TabNav } from "./viewTabs";
import { getView3dFilter, hideSelection3d, selectionIds3d, setView3dFilter, showSelection3d } from "./view3dFilter";
import { clearKinds } from "./selection";
@@ -43,6 +43,16 @@ export function openLayoutTab(layoutId: string): void {
if (sheet) openLevel(sheet.id);
}
/** [252] Ctrl+Tab (+1) / Ctrl+Umschalt+Tab (−1): durch die Ansichts-Reiter springen, zyklisch. */
export function cycleViewTab(dir: 1 | -1): void {
const bridge = getViewStateBridge();
if (!bridge) return;
const r = cycleTab(getViewTabs(), dir, bridge.live());
if (r.next === getViewTabs()) return;
setViewTabs(r.next);
if (r.apply) bridge.apply(r.apply);
}
/** [185] Cmd/Ctrl+5 (−1) bzw. Cmd/Ctrl+6 (+1): im Grundriss-/3D-Reiter ein Geschoss tiefer/höher (Zoom bleibt). */
export function stepActiveFloor(dir: 1 | -1): void {
run((live) => stepFloor(getViewTabs(), live, getState().project.drawingLevels, dir));
+12 -3
View File
@@ -32,12 +32,12 @@ import {
} from "../editors/elementClipboard";
import type { ElementClipboard, ElementSelectionIds, PastedIds } from "../editors/elementClipboard";
import { parseClipboardText, serializeClipboardText } from "../editors/elementClipboardSerialize";
import { matchesShortcut, type ShortcutId, type ShortcutOverrides } from "./keyboardShortcuts";
import { matchesShortcut, tabKeyAction, type ShortcutId, type ShortcutOverrides } from "./keyboardShortcuts";
import { isolateSelectionLayerCodes, showAllLayerCodes } from "./layerIsolate";
import { isInModalDialog } from "./modalScope";
import { toggleTraceAction } from "./traceActions";
import { joinCurrentSelection } from "./selectionJoin";
import { hideSelectionIn3d, showSelectionIn3d, stepActiveFloor } from "./tabNavigation";
import { cycleViewTab, hideSelectionIn3d, showSelectionIn3d, stepActiveFloor } from "./tabNavigation";
const isEditableTarget = (e: KeyboardEvent): boolean => {
const el = e.target as HTMLElement | null;
@@ -121,7 +121,16 @@ export function useCommandTabShortcut(
commandLineRef.current?.beginTyping(e.key);
return;
}
if (e.key !== "Tab") return;
const tabAction = tabKeyAction(e);
if (!tabAction) return;
// Overlay-Dialoge nutzen Tab für ihre eigenen Felder.
if ((e.target as HTMLElement | null)?.closest?.('[role="dialog"], [aria-modal="true"]')) return;
if (tabAction !== "commandLine") {
// [252] Ctrl+Tab / Ctrl+Umschalt+Tab: Ansichts-Reiter, zyklisch (auch aus Eingabefeldern).
e.preventDefault();
cycleViewTab(tabAction === "nextViewTab" ? 1 : -1);
return;
}
if (inInput) {
return;
}
+20
View File
@@ -17,6 +17,7 @@ import {
adjacentFloorId,
planFitKey,
stepFloor,
cycleTab,
isPlanKindActive,
openTab,
restoreViewTabs,
@@ -351,3 +352,22 @@ describe("Geschoss-Navigation wie Archicad [185]", () => {
expect(planFitKey({ id: "x", kind: "drawing" }, 1)).not.toBe(planFitKey({ id: "y", kind: "drawing" }, 1));
});
});
describe("[252] cycleTab — Ctrl+Tab durch die Reiter", () => {
const mk = (n: number, active: number) => {
const tabs = Array.from({ length: n }, (_, i) => ({ id: `t${i}`, state: st(`l${i}`) }));
return { tabs, activeId: `t${active}` };
};
it("vorwärts und rückwärts, zyklisch", () => {
expect(cycleTab(mk(3, 0), 1, st("l0")).next.activeId).toBe("t1");
expect(cycleTab(mk(3, 2), 1, st("l2")).next.activeId).toBe("t0");
expect(cycleTab(mk(3, 0), -1, st("l0")).next.activeId).toBe("t2");
expect(cycleTab(mk(3, 2), -1, st("l2")).apply?.activeLevelId).toBe("l1");
});
it("ein Reiter: nichts zu tun", () => {
const s = mk(1, 0);
const r = cycleTab(s, 1, st("l0"));
expect(r.next).toBe(s);
expect(r.apply).toBeNull();
});
});
+12
View File
@@ -88,6 +88,18 @@ export function activateTab(
return { next: { ...stored, activeId: id }, apply: target.state ?? null };
}
/** Ctrl+Tab / Ctrl+Umschalt+Tab: nächster bzw. vorheriger Reiter, zyklisch (ein Reiter: nichts zu tun). */
export function cycleTab(
s: ViewTabsState,
dir: 1 | -1,
live: ViewSnapshotState,
): { next: ViewTabsState; apply: ViewSnapshotState | null } {
const n = s.tabs.length;
if (n <= 1) return { next: s, apply: null };
const i = Math.max(0, s.tabs.findIndex((t) => t.id === s.activeId));
return activateTab(s, s.tabs[(i + dir + n) % n].id, live);
}
/** Schliesst einen Reiter (nie den letzten). War er aktiv, wird der rechte (sonst linke) Nachbar aktiv;
* dessen gemerkter Zustand ist anzuwenden. Ausschnitte bleiben unberührt. */
export function closeTab(