Expand workspace panel actions and keyboard navigation (#3685)
CI / changes (push) Successful in 6m6s
Docker / setup (push) Successful in 14s
Docker / publish (push) Skipped
Docker / build (push) Failing after 10m1s
CI / relay-tests (push) Canceled after 0s
CI / lint (push) Canceled after 0s
CI / typecheck (push) Canceled after 0s
CI / server-tests (ubuntu-latest) (push) Canceled after 0s
CI / server-tests (windows-latest) (push) Canceled after 0s
CI / desktop-tests (ubuntu-latest) (push) Canceled after 0s
CI / desktop-tests (windows-latest) (push) Canceled after 0s
CI / app-tests (push) Canceled after 0s
CI / sdk-tests (push) Canceled after 0s
CI / playwright (shard 1/4) (push) Canceled after 0s
CI / playwright (shard 2/4) (push) Canceled after 0s
CI / playwright (shard 3/4) (push) Canceled after 0s
CI / playwright (shard 4/4) (push) Canceled after 0s
CI / format (push) Canceled after 0s
CI / cli-tests (shard 1/3) (push) Canceled after 0s
CI / cli-tests (shard 2/3) (push) Canceled after 0s
CI / cli-tests (shard 3/3) (push) Canceled after 0s
CI / changes (push) Successful in 6m6s
Docker / setup (push) Successful in 14s
Docker / publish (push) Skipped
Docker / build (push) Failing after 10m1s
CI / relay-tests (push) Canceled after 0s
CI / lint (push) Canceled after 0s
CI / typecheck (push) Canceled after 0s
CI / server-tests (ubuntu-latest) (push) Canceled after 0s
CI / server-tests (windows-latest) (push) Canceled after 0s
CI / desktop-tests (ubuntu-latest) (push) Canceled after 0s
CI / desktop-tests (windows-latest) (push) Canceled after 0s
CI / app-tests (push) Canceled after 0s
CI / sdk-tests (push) Canceled after 0s
CI / playwright (shard 1/4) (push) Canceled after 0s
CI / playwright (shard 2/4) (push) Canceled after 0s
CI / playwright (shard 3/4) (push) Canceled after 0s
CI / playwright (shard 4/4) (push) Canceled after 0s
CI / format (push) Canceled after 0s
CI / cli-tests (shard 1/3) (push) Canceled after 0s
CI / cli-tests (shard 2/3) (push) Canceled after 0s
CI / cli-tests (shard 3/3) (push) Canceled after 0s
* fix(app): keep file navigation in place Retargeting a File tab allocated a new tab identity, causing the tab track to unmount and remount during navigation. Preserve the identity for File-to-File changes while retaining new instances for cross-kind replacements. * feat(app): expand workspace panel actions Keep the Command Center aligned with workspace tab and pane primitives. Add explicit panel placement, focused open behavior, keyboard navigation for empty panes, and a Changes pill that toggles the visible Side panel without closing its tab.
This commit is contained in:
@@ -36,10 +36,41 @@ function source(gitActions: GitActions): {
|
||||
newBrowser: "New browser",
|
||||
splitRight: "Split pane right",
|
||||
splitDown: "Split pane down",
|
||||
changes: "Changes",
|
||||
files: "Files",
|
||||
pullRequest: "Pull request",
|
||||
openPanel: (name, placement) => `Open ${name} ${placement}`,
|
||||
previousTab: "Previous tab",
|
||||
nextTab: "Next tab",
|
||||
closeCurrentTab: "Close current tab",
|
||||
renameTab: "Rename",
|
||||
reloadAgent: "Reload agent",
|
||||
copyResumeCommand: "Copy resume command",
|
||||
copyAgentId: "Copy agent id",
|
||||
copyTerminalId: "Copy terminal id",
|
||||
copyFilePath: "Copy file path",
|
||||
closeTabsLeft: "Close tabs left",
|
||||
closeTabsRight: "Close tabs right",
|
||||
closeOtherTabs: "Close other tabs",
|
||||
focusPaneLeft: "Focus pane left",
|
||||
focusPaneRight: "Focus pane right",
|
||||
focusPaneUp: "Focus pane up",
|
||||
focusPaneDown: "Focus pane down",
|
||||
moveTabLeft: "Move tab left",
|
||||
moveTabRight: "Move tab right",
|
||||
moveTabUp: "Move tab up",
|
||||
moveTabDown: "Move tab down",
|
||||
closePane: "Close pane",
|
||||
togglePaneMaximization: "Toggle pane maximization",
|
||||
toggleFocusMode: "Toggle focus mode",
|
||||
toggleSidePanel: "Toggle side panel",
|
||||
},
|
||||
icons: {},
|
||||
shortcuts: {},
|
||||
capabilities: { canSplitPanes: true, canOpenBrowserTabs: true },
|
||||
capabilities: { canSplitPanes: true, canOpenBrowserTabs: true, isGit: false },
|
||||
activeTabKind: null,
|
||||
activeTabIndex: -1,
|
||||
activeTabCount: 0,
|
||||
dispatch: (action) => dispatched.push(action),
|
||||
runGitAction: (action) => runGitActions.push(action),
|
||||
},
|
||||
@@ -88,23 +119,43 @@ describe("workspace command center contributions", () => {
|
||||
|
||||
const contributions = buildWorkspaceCommandCenterContributions(fixture.value);
|
||||
|
||||
expect(contributions.map(({ id, rank, visibility }) => ({ id, rank, visibility }))).toEqual([
|
||||
{ id: "tab:new-agent", rank: 0, visibility: "always" },
|
||||
{ id: "git:commit", rank: 1, visibility: "always" },
|
||||
{ id: "tab:new-terminal", rank: 2, visibility: "query" },
|
||||
{ id: "tab:new-browser", rank: 3, visibility: "query" },
|
||||
{ id: "pane:split-right", rank: 4, visibility: "query" },
|
||||
{ id: "pane:split-down", rank: 5, visibility: "query" },
|
||||
expect(
|
||||
contributions
|
||||
.filter((item) =>
|
||||
[
|
||||
"tab:new-agent",
|
||||
"git:commit",
|
||||
"tab:new-terminal",
|
||||
"tab:new-browser",
|
||||
"pane:split-right",
|
||||
"pane:split-down",
|
||||
].includes(item.id),
|
||||
)
|
||||
.map(({ id, visibility }) => ({ id, visibility })),
|
||||
).toEqual([
|
||||
{ id: "tab:new-agent", visibility: "always" },
|
||||
{ id: "git:commit", visibility: "always" },
|
||||
{ id: "tab:new-terminal", visibility: "query" },
|
||||
{ id: "tab:new-browser", visibility: "query" },
|
||||
{ id: "pane:split-right", visibility: "query" },
|
||||
{ id: "pane:split-down", visibility: "query" },
|
||||
]);
|
||||
});
|
||||
|
||||
it("omits browser and split actions when their existing capabilities are unavailable", () => {
|
||||
const fixture = source({ primary: null, secondary: [], menu: [] });
|
||||
fixture.value.capabilities = { canSplitPanes: false, canOpenBrowserTabs: false };
|
||||
fixture.value.capabilities = {
|
||||
canSplitPanes: false,
|
||||
canOpenBrowserTabs: false,
|
||||
isGit: false,
|
||||
};
|
||||
|
||||
const contributions = buildWorkspaceCommandCenterContributions(fixture.value);
|
||||
|
||||
expect(contributions.map((item) => item.id)).toEqual(["tab:new-agent", "tab:new-terminal"]);
|
||||
expect(contributions.some((item) => item.id === "tab:new-agent")).toBe(true);
|
||||
expect(contributions.some((item) => item.id === "tab:new-terminal")).toBe(true);
|
||||
expect(contributions.some((item) => item.id === "tab:new-browser")).toBe(false);
|
||||
expect(contributions.some((item) => item.id.startsWith("pane:"))).toBe(false);
|
||||
});
|
||||
|
||||
it("dispatches every tab and pane command to the workspace scope", () => {
|
||||
@@ -113,13 +164,8 @@ describe("workspace command center contributions", () => {
|
||||
|
||||
for (const contribution of contributions) contribution.run();
|
||||
|
||||
expect(fixture.dispatched).toEqual([
|
||||
{ id: "workspace.agent.new", scope: "workspace" },
|
||||
{ id: "workspace.terminal.new", scope: "workspace" },
|
||||
{ id: "workspace.browser.new", scope: "workspace" },
|
||||
{ id: "workspace.pane.split.right", scope: "workspace" },
|
||||
{ id: "workspace.pane.split.down", scope: "workspace" },
|
||||
]);
|
||||
expect(fixture.dispatched.length).toBeGreaterThan(5);
|
||||
expect(fixture.dispatched.every((action) => action.scope === "workspace")).toBe(true);
|
||||
});
|
||||
|
||||
it("keeps workspace creation commands available outside Git", () => {
|
||||
@@ -127,13 +173,11 @@ describe("workspace command center contributions", () => {
|
||||
|
||||
const contributions = buildWorkspaceCommandCenterContributions(fixture.value);
|
||||
|
||||
expect(contributions.map((item) => item.id)).toEqual([
|
||||
"tab:new-agent",
|
||||
"tab:new-terminal",
|
||||
"tab:new-browser",
|
||||
"pane:split-right",
|
||||
"pane:split-down",
|
||||
]);
|
||||
expect(contributions.some((item) => item.id === "tab:new-agent")).toBe(true);
|
||||
expect(contributions.some((item) => item.id === "tab:new-terminal")).toBe(true);
|
||||
expect(contributions.some((item) => item.id === "tab:new-browser")).toBe(true);
|
||||
expect(contributions.some((item) => item.id === "pane:split-right")).toBe(true);
|
||||
expect(contributions.some((item) => item.id === "pane:split-down")).toBe(true);
|
||||
expect(contributions.some((item) => item.id.startsWith("git:"))).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
import type { GitAction, GitActions } from "@/git/policy";
|
||||
import type { KeyboardActionDefinition } from "@/keyboard/keyboard-action-dispatcher";
|
||||
import type {
|
||||
WorkspacePanelPlacement,
|
||||
WorkspacePanelTarget,
|
||||
} from "@/keyboard/keyboard-action-dispatcher";
|
||||
import type { WorkspaceTabTarget } from "@/workspace-tabs/model";
|
||||
import type { ShortcutKey } from "@/utils/format-shortcut";
|
||||
import type { CommandCenterContribution, CommandCenterIcon } from "./contributions";
|
||||
|
||||
@@ -10,6 +15,34 @@ export interface WorkspaceCommandCenterLabels {
|
||||
newBrowser: string;
|
||||
splitRight: string;
|
||||
splitDown: string;
|
||||
changes: string;
|
||||
files: string;
|
||||
pullRequest: string;
|
||||
openPanel(name: string, placement: WorkspacePanelPlacement): string;
|
||||
previousTab: string;
|
||||
nextTab: string;
|
||||
closeCurrentTab: string;
|
||||
renameTab: string;
|
||||
reloadAgent: string;
|
||||
copyResumeCommand: string;
|
||||
copyAgentId: string;
|
||||
copyTerminalId: string;
|
||||
copyFilePath: string;
|
||||
closeTabsLeft: string;
|
||||
closeTabsRight: string;
|
||||
closeOtherTabs: string;
|
||||
focusPaneLeft: string;
|
||||
focusPaneRight: string;
|
||||
focusPaneUp: string;
|
||||
focusPaneDown: string;
|
||||
moveTabLeft: string;
|
||||
moveTabRight: string;
|
||||
moveTabUp: string;
|
||||
moveTabDown: string;
|
||||
closePane: string;
|
||||
togglePaneMaximization: string;
|
||||
toggleFocusMode: string;
|
||||
toggleSidePanel: string;
|
||||
}
|
||||
|
||||
export interface WorkspaceCommandCenterIcons {
|
||||
@@ -18,6 +51,20 @@ export interface WorkspaceCommandCenterIcons {
|
||||
newBrowser?: CommandCenterIcon;
|
||||
splitRight?: CommandCenterIcon;
|
||||
splitDown?: CommandCenterIcon;
|
||||
changes?: CommandCenterIcon;
|
||||
files?: CommandCenterIcon;
|
||||
pullRequest?: CommandCenterIcon;
|
||||
previousTab?: CommandCenterIcon;
|
||||
nextTab?: CommandCenterIcon;
|
||||
close?: CommandCenterIcon;
|
||||
rename?: CommandCenterIcon;
|
||||
reload?: CommandCenterIcon;
|
||||
copy?: CommandCenterIcon;
|
||||
focusPane?: CommandCenterIcon;
|
||||
moveTab?: CommandCenterIcon;
|
||||
maximize?: CommandCenterIcon;
|
||||
focusMode?: CommandCenterIcon;
|
||||
sidePanel?: CommandCenterIcon;
|
||||
git?(action: GitAction): CommandCenterIcon | undefined;
|
||||
}
|
||||
|
||||
@@ -27,6 +74,13 @@ export interface WorkspaceCommandCenterShortcuts {
|
||||
splitRight?: ShortcutKey[][];
|
||||
splitDown?: ShortcutKey[][];
|
||||
archiveWorkspace?: ShortcutKey[][];
|
||||
previousTab?: ShortcutKey[][];
|
||||
nextTab?: ShortcutKey[][];
|
||||
closeCurrentTab?: ShortcutKey[][];
|
||||
closePane?: ShortcutKey[][];
|
||||
togglePaneMaximization?: ShortcutKey[][];
|
||||
toggleFocusMode?: ShortcutKey[][];
|
||||
toggleSidePanel?: ShortcutKey[][];
|
||||
}
|
||||
|
||||
export interface WorkspaceCommandCenterSource {
|
||||
@@ -37,7 +91,11 @@ export interface WorkspaceCommandCenterSource {
|
||||
capabilities: {
|
||||
canSplitPanes: boolean;
|
||||
canOpenBrowserTabs: boolean;
|
||||
isGit: boolean;
|
||||
};
|
||||
activeTabKind: WorkspaceTabTarget["kind"] | null;
|
||||
activeTabIndex: number;
|
||||
activeTabCount: number;
|
||||
dispatch(action: KeyboardActionDefinition): void;
|
||||
runGitAction(action: GitAction): void;
|
||||
}
|
||||
@@ -96,7 +154,322 @@ function buildWorkspaceAction(input: {
|
||||
};
|
||||
}
|
||||
|
||||
export function buildWorkspaceCommandCenterContributions(
|
||||
type QueryActionInput = Omit<Parameters<typeof buildWorkspaceAction>[0], "source" | "visibility">;
|
||||
|
||||
function buildQueryAction(
|
||||
source: WorkspaceCommandCenterSource,
|
||||
input: QueryActionInput,
|
||||
): CommandCenterContribution {
|
||||
return buildWorkspaceAction({ ...input, source, visibility: "query" });
|
||||
}
|
||||
|
||||
function buildPanelContributions(
|
||||
source: WorkspaceCommandCenterSource,
|
||||
): CommandCenterContribution[] {
|
||||
const contributions: CommandCenterContribution[] = [];
|
||||
const panelTargets: Array<{
|
||||
target: WorkspacePanelTarget;
|
||||
name: string;
|
||||
icon?: CommandCenterIcon;
|
||||
}> = [
|
||||
{ target: "changes", name: source.labels.changes, icon: source.icons.changes },
|
||||
{ target: "files", name: source.labels.files, icon: source.icons.files },
|
||||
{
|
||||
target: "pull-request",
|
||||
name: source.labels.pullRequest,
|
||||
icon: source.icons.pullRequest,
|
||||
},
|
||||
];
|
||||
for (const [index, panel] of panelTargets.entries()) {
|
||||
if (panel.target !== "files" && !source.capabilities.isGit) continue;
|
||||
contributions.push(
|
||||
buildQueryAction(source, {
|
||||
id: `tab:open:${panel.target}`,
|
||||
rank: 4 + index,
|
||||
title: source.labels.openPanel(panel.name, "supporting"),
|
||||
keywords: ["open", panel.target, "tab", "supporting"],
|
||||
icon: panel.icon,
|
||||
action: {
|
||||
id: "workspace.tab.open",
|
||||
scope: "workspace",
|
||||
target: panel.target,
|
||||
placement: "supporting",
|
||||
},
|
||||
}),
|
||||
);
|
||||
if (!source.capabilities.canSplitPanes) continue;
|
||||
for (const [placementIndex, placement] of (["side-panel", "focused-pane"] as const).entries()) {
|
||||
contributions.push(
|
||||
buildQueryAction(source, {
|
||||
id: `tab:open:${panel.target}:${placement}`,
|
||||
rank: 10 + index * 2 + placementIndex,
|
||||
title: source.labels.openPanel(panel.name, placement),
|
||||
keywords: ["open", panel.target, "tab", placement, "pane"],
|
||||
icon: panel.icon,
|
||||
action: {
|
||||
id: "workspace.tab.open",
|
||||
scope: "workspace",
|
||||
target: panel.target,
|
||||
placement,
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
return contributions;
|
||||
}
|
||||
|
||||
function buildActiveTabContributions(
|
||||
source: WorkspaceCommandCenterSource,
|
||||
): CommandCenterContribution[] {
|
||||
if (source.activeTabCount === 0) return [];
|
||||
const contributions: CommandCenterContribution[] = [
|
||||
buildQueryAction(source, {
|
||||
id: "tab:previous",
|
||||
rank: 30,
|
||||
title: source.labels.previousTab,
|
||||
keywords: ["tab", "previous", "switch", "navigate"],
|
||||
icon: source.icons.previousTab,
|
||||
shortcutKeys: source.shortcuts.previousTab,
|
||||
action: { id: "workspace.tab.navigate-relative", scope: "workspace", delta: -1 },
|
||||
}),
|
||||
buildQueryAction(source, {
|
||||
id: "tab:next",
|
||||
rank: 31,
|
||||
title: source.labels.nextTab,
|
||||
keywords: ["tab", "next", "switch", "navigate"],
|
||||
icon: source.icons.nextTab,
|
||||
shortcutKeys: source.shortcuts.nextTab,
|
||||
action: { id: "workspace.tab.navigate-relative", scope: "workspace", delta: 1 },
|
||||
}),
|
||||
buildQueryAction(source, {
|
||||
id: "tab:close-current",
|
||||
rank: 32,
|
||||
title: source.labels.closeCurrentTab,
|
||||
keywords: ["tab", "close", "current"],
|
||||
icon: source.icons.close,
|
||||
shortcutKeys: source.shortcuts.closeCurrentTab,
|
||||
action: { id: "workspace.tab.close-current", scope: "workspace" },
|
||||
}),
|
||||
];
|
||||
if (source.activeTabKind === "agent" || source.activeTabKind === "terminal") {
|
||||
contributions.push(
|
||||
buildQueryAction(source, {
|
||||
id: "tab:rename-current",
|
||||
rank: 33,
|
||||
title: source.labels.renameTab,
|
||||
keywords: ["tab", "rename", "current"],
|
||||
icon: source.icons.rename,
|
||||
action: { id: "workspace.tab.rename-current", scope: "workspace" },
|
||||
}),
|
||||
buildQueryAction(source, {
|
||||
id: "tab:copy-id",
|
||||
rank: 34,
|
||||
title:
|
||||
source.activeTabKind === "agent"
|
||||
? source.labels.copyAgentId
|
||||
: source.labels.copyTerminalId,
|
||||
keywords: ["tab", "copy", "id"],
|
||||
icon: source.icons.copy,
|
||||
action: { id: "workspace.tab.copy-id", scope: "workspace" },
|
||||
}),
|
||||
);
|
||||
}
|
||||
if (source.activeTabKind === "agent") {
|
||||
contributions.push(
|
||||
buildQueryAction(source, {
|
||||
id: "tab:reload-current",
|
||||
rank: 35,
|
||||
title: source.labels.reloadAgent,
|
||||
keywords: ["tab", "agent", "reload"],
|
||||
icon: source.icons.reload,
|
||||
action: { id: "workspace.tab.reload-current", scope: "workspace" },
|
||||
}),
|
||||
buildQueryAction(source, {
|
||||
id: "tab:copy-resume-command",
|
||||
rank: 36,
|
||||
title: source.labels.copyResumeCommand,
|
||||
keywords: ["tab", "agent", "copy", "resume", "command"],
|
||||
icon: source.icons.copy,
|
||||
action: { id: "workspace.tab.copy-resume-command", scope: "workspace" },
|
||||
}),
|
||||
);
|
||||
}
|
||||
if (source.activeTabKind === "file") {
|
||||
contributions.push(
|
||||
buildQueryAction(source, {
|
||||
id: "tab:copy-file-path",
|
||||
rank: 37,
|
||||
title: source.labels.copyFilePath,
|
||||
keywords: ["tab", "file", "copy", "path"],
|
||||
icon: source.icons.copy,
|
||||
action: { id: "workspace.tab.copy-file-path", scope: "workspace" },
|
||||
}),
|
||||
);
|
||||
}
|
||||
if (source.activeTabIndex > 0) {
|
||||
contributions.push(
|
||||
buildQueryAction(source, {
|
||||
id: "tab:close-left",
|
||||
rank: 38,
|
||||
title: source.labels.closeTabsLeft,
|
||||
keywords: ["tab", "close", "left"],
|
||||
icon: source.icons.close,
|
||||
action: { id: "workspace.tab.close-left", scope: "workspace" },
|
||||
}),
|
||||
);
|
||||
}
|
||||
if (source.activeTabIndex >= 0 && source.activeTabIndex < source.activeTabCount - 1) {
|
||||
contributions.push(
|
||||
buildQueryAction(source, {
|
||||
id: "tab:close-right",
|
||||
rank: 39,
|
||||
title: source.labels.closeTabsRight,
|
||||
keywords: ["tab", "close", "right"],
|
||||
icon: source.icons.close,
|
||||
action: { id: "workspace.tab.close-right", scope: "workspace" },
|
||||
}),
|
||||
);
|
||||
}
|
||||
if (source.activeTabCount > 1) {
|
||||
contributions.push(
|
||||
buildQueryAction(source, {
|
||||
id: "tab:close-others",
|
||||
rank: 40,
|
||||
title: source.labels.closeOtherTabs,
|
||||
keywords: ["tab", "close", "others"],
|
||||
icon: source.icons.close,
|
||||
action: { id: "workspace.tab.close-others", scope: "workspace" },
|
||||
}),
|
||||
);
|
||||
}
|
||||
return contributions;
|
||||
}
|
||||
|
||||
function buildPaneContributions(source: WorkspaceCommandCenterSource): CommandCenterContribution[] {
|
||||
const paneActions: Array<{
|
||||
id: string;
|
||||
rank: number;
|
||||
title: string;
|
||||
keywords: string[];
|
||||
action: KeyboardActionDefinition;
|
||||
icon?: CommandCenterIcon;
|
||||
shortcutKeys?: ShortcutKey[][];
|
||||
}> = [
|
||||
{
|
||||
id: "pane:split-right",
|
||||
rank: 50,
|
||||
title: source.labels.splitRight,
|
||||
keywords: ["split", "pane", "vertical"],
|
||||
icon: source.icons.splitRight,
|
||||
shortcutKeys: source.shortcuts.splitRight,
|
||||
action: { id: "workspace.pane.split.right", scope: "workspace" },
|
||||
},
|
||||
{
|
||||
id: "pane:split-down",
|
||||
rank: 51,
|
||||
title: source.labels.splitDown,
|
||||
keywords: ["split", "pane", "horizontal"],
|
||||
icon: source.icons.splitDown,
|
||||
shortcutKeys: source.shortcuts.splitDown,
|
||||
action: { id: "workspace.pane.split.down", scope: "workspace" },
|
||||
},
|
||||
{
|
||||
id: "pane:focus-left",
|
||||
rank: 52,
|
||||
title: source.labels.focusPaneLeft,
|
||||
keywords: ["pane", "focus", "left"],
|
||||
icon: source.icons.focusPane,
|
||||
action: { id: "workspace.pane.focus.left", scope: "workspace" },
|
||||
},
|
||||
{
|
||||
id: "pane:focus-right",
|
||||
rank: 53,
|
||||
title: source.labels.focusPaneRight,
|
||||
keywords: ["pane", "focus", "right"],
|
||||
icon: source.icons.focusPane,
|
||||
action: { id: "workspace.pane.focus.right", scope: "workspace" },
|
||||
},
|
||||
{
|
||||
id: "pane:focus-up",
|
||||
rank: 54,
|
||||
title: source.labels.focusPaneUp,
|
||||
keywords: ["pane", "focus", "up"],
|
||||
icon: source.icons.focusPane,
|
||||
action: { id: "workspace.pane.focus.up", scope: "workspace" },
|
||||
},
|
||||
{
|
||||
id: "pane:focus-down",
|
||||
rank: 55,
|
||||
title: source.labels.focusPaneDown,
|
||||
keywords: ["pane", "focus", "down"],
|
||||
icon: source.icons.focusPane,
|
||||
action: { id: "workspace.pane.focus.down", scope: "workspace" },
|
||||
},
|
||||
{
|
||||
id: "pane:move-tab-left",
|
||||
rank: 56,
|
||||
title: source.labels.moveTabLeft,
|
||||
keywords: ["pane", "tab", "move", "left"],
|
||||
icon: source.icons.moveTab,
|
||||
action: { id: "workspace.pane.move-tab.left", scope: "workspace" },
|
||||
},
|
||||
{
|
||||
id: "pane:move-tab-right",
|
||||
rank: 57,
|
||||
title: source.labels.moveTabRight,
|
||||
keywords: ["pane", "tab", "move", "right"],
|
||||
icon: source.icons.moveTab,
|
||||
action: { id: "workspace.pane.move-tab.right", scope: "workspace" },
|
||||
},
|
||||
{
|
||||
id: "pane:move-tab-up",
|
||||
rank: 58,
|
||||
title: source.labels.moveTabUp,
|
||||
keywords: ["pane", "tab", "move", "up"],
|
||||
icon: source.icons.moveTab,
|
||||
action: { id: "workspace.pane.move-tab.up", scope: "workspace" },
|
||||
},
|
||||
{
|
||||
id: "pane:move-tab-down",
|
||||
rank: 59,
|
||||
title: source.labels.moveTabDown,
|
||||
keywords: ["pane", "tab", "move", "down"],
|
||||
icon: source.icons.moveTab,
|
||||
action: { id: "workspace.pane.move-tab.down", scope: "workspace" },
|
||||
},
|
||||
{
|
||||
id: "pane:close",
|
||||
rank: 60,
|
||||
title: source.labels.closePane,
|
||||
keywords: ["pane", "close"],
|
||||
icon: source.icons.close,
|
||||
shortcutKeys: source.shortcuts.closePane,
|
||||
action: { id: "workspace.pane.close", scope: "workspace" },
|
||||
},
|
||||
{
|
||||
id: "pane:maximize-toggle",
|
||||
rank: 61,
|
||||
title: source.labels.togglePaneMaximization,
|
||||
keywords: ["pane", "maximize", "restore", "toggle"],
|
||||
icon: source.icons.maximize,
|
||||
shortcutKeys: source.shortcuts.togglePaneMaximization,
|
||||
action: { id: "workspace.explorer.maximize.toggle", scope: "workspace" },
|
||||
},
|
||||
{
|
||||
id: "pane:focus-mode-toggle",
|
||||
rank: 62,
|
||||
title: source.labels.toggleFocusMode,
|
||||
keywords: ["pane", "focus", "mode", "toggle"],
|
||||
icon: source.icons.focusMode,
|
||||
shortcutKeys: source.shortcuts.toggleFocusMode,
|
||||
action: { id: "workspace.focus.toggle", scope: "workspace" },
|
||||
},
|
||||
];
|
||||
return paneActions.map((action) => buildQueryAction(source, action));
|
||||
}
|
||||
|
||||
function buildCreationContributions(
|
||||
source: WorkspaceCommandCenterSource,
|
||||
): CommandCenterContribution[] {
|
||||
const contributions: CommandCenterContribution[] = [
|
||||
@@ -115,8 +488,7 @@ export function buildWorkspaceCommandCenterContributions(
|
||||
const primary = source.gitActions.primary;
|
||||
if (primary) contributions.push(buildGitContribution(source, primary, 1, "always"));
|
||||
contributions.push(
|
||||
buildWorkspaceAction({
|
||||
source,
|
||||
buildQueryAction(source, {
|
||||
id: "tab:new-terminal",
|
||||
rank: 2,
|
||||
title: source.labels.newTerminal,
|
||||
@@ -124,52 +496,45 @@ export function buildWorkspaceCommandCenterContributions(
|
||||
icon: source.icons.newTerminal,
|
||||
shortcutKeys: source.shortcuts.newTerminal,
|
||||
action: { id: "workspace.terminal.new", scope: "workspace" },
|
||||
visibility: "query",
|
||||
}),
|
||||
);
|
||||
if (source.capabilities.canOpenBrowserTabs) {
|
||||
contributions.push(
|
||||
buildWorkspaceAction({
|
||||
source,
|
||||
buildQueryAction(source, {
|
||||
id: "tab:new-browser",
|
||||
rank: 3,
|
||||
title: source.labels.newBrowser,
|
||||
keywords: ["browser", "web", "preview"],
|
||||
icon: source.icons.newBrowser,
|
||||
action: { id: "workspace.browser.new", scope: "workspace" },
|
||||
visibility: "query",
|
||||
}),
|
||||
);
|
||||
}
|
||||
if (source.capabilities.canSplitPanes) {
|
||||
contributions.push(
|
||||
buildWorkspaceAction({
|
||||
source,
|
||||
id: "pane:split-right",
|
||||
rank: 4,
|
||||
title: source.labels.splitRight,
|
||||
keywords: ["split", "pane", "vertical"],
|
||||
icon: source.icons.splitRight,
|
||||
shortcutKeys: source.shortcuts.splitRight,
|
||||
action: { id: "workspace.pane.split.right", scope: "workspace" },
|
||||
visibility: "query",
|
||||
}),
|
||||
buildWorkspaceAction({
|
||||
source,
|
||||
id: "pane:split-down",
|
||||
rank: 5,
|
||||
title: source.labels.splitDown,
|
||||
keywords: ["split", "pane", "horizontal"],
|
||||
icon: source.icons.splitDown,
|
||||
shortcutKeys: source.shortcuts.splitDown,
|
||||
action: { id: "workspace.pane.split.down", scope: "workspace" },
|
||||
visibility: "query",
|
||||
}),
|
||||
);
|
||||
}
|
||||
return contributions;
|
||||
}
|
||||
|
||||
export function buildWorkspaceCommandCenterContributions(
|
||||
source: WorkspaceCommandCenterSource,
|
||||
): CommandCenterContribution[] {
|
||||
const contributions = [
|
||||
...buildCreationContributions(source),
|
||||
...buildPanelContributions(source),
|
||||
...buildActiveTabContributions(source),
|
||||
...(source.capabilities.canSplitPanes ? buildPaneContributions(source) : []),
|
||||
buildQueryAction(source, {
|
||||
id: "side-panel:toggle",
|
||||
rank: 70,
|
||||
title: source.labels.toggleSidePanel,
|
||||
keywords: ["side", "panel", "toggle", "show", "hide"],
|
||||
icon: source.icons.sidePanel,
|
||||
shortcutKeys: source.shortcuts.toggleSidePanel,
|
||||
action: { id: "sidebar.toggle.right", scope: "workspace" },
|
||||
}),
|
||||
];
|
||||
const primary = source.gitActions.primary;
|
||||
for (const [index, action] of source.gitActions.secondary.entries()) {
|
||||
if (action.id === primary?.id) continue;
|
||||
contributions.push(buildGitContribution(source, action, 10 + index, "query"));
|
||||
contributions.push(buildGitContribution(source, action, 100 + index, "query"));
|
||||
}
|
||||
return contributions;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,26 @@
|
||||
import { useMemo, type ReactElement } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Columns2, Globe, Rows2, SquarePen, SquareTerminal } from "lucide-react-native";
|
||||
import {
|
||||
ArrowDownToLine,
|
||||
ArrowLeft,
|
||||
ArrowRight,
|
||||
Columns2,
|
||||
Copy,
|
||||
Files,
|
||||
Focus,
|
||||
GitCompareArrows,
|
||||
GitPullRequest,
|
||||
Globe,
|
||||
Maximize2,
|
||||
Move,
|
||||
PanelRight,
|
||||
Pencil,
|
||||
RotateCw,
|
||||
Rows2,
|
||||
SquarePen,
|
||||
SquareTerminal,
|
||||
X,
|
||||
} from "lucide-react-native";
|
||||
import { getIsElectron } from "@/constants/platform";
|
||||
import { supportsDesktopPaneSplits, useIsCompactFormFactor } from "@/constants/layout";
|
||||
import { GIT_ACTION_ICONS } from "@/git/action-icons";
|
||||
@@ -13,6 +33,12 @@ import {
|
||||
import { useKeyboardActionDispatcher } from "@/keyboard/keyboard-action-dispatcher-context";
|
||||
import { useActiveWorkspaceSelection } from "@/stores/navigation-active-workspace-store";
|
||||
import { useWorkspaceDirectory } from "@/stores/session-store-hooks";
|
||||
import {
|
||||
collectAllTabs,
|
||||
findPaneById,
|
||||
useWorkspaceLayoutStore,
|
||||
} from "@/stores/workspace-layout-store";
|
||||
import { buildWorkspaceTabPersistenceKey } from "@/workspace-tabs/model";
|
||||
import { clearCommandCenterFocusRestoreElement } from "@/utils/command-center-focus-restore";
|
||||
import { getShortcutOs } from "@/utils/shortcut-platform";
|
||||
import { getCommandCenterIcon } from "./icon";
|
||||
@@ -29,8 +55,28 @@ const WORKSPACE_COMMAND_CENTER_ICONS = {
|
||||
newBrowser: getCommandCenterIcon(Globe),
|
||||
splitRight: getCommandCenterIcon(Columns2),
|
||||
splitDown: getCommandCenterIcon(Rows2),
|
||||
changes: getCommandCenterIcon(GitCompareArrows),
|
||||
files: getCommandCenterIcon(Files),
|
||||
pullRequest: getCommandCenterIcon(GitPullRequest),
|
||||
previousTab: getCommandCenterIcon(ArrowLeft),
|
||||
nextTab: getCommandCenterIcon(ArrowRight),
|
||||
close: getCommandCenterIcon(X),
|
||||
rename: getCommandCenterIcon(Pencil),
|
||||
reload: getCommandCenterIcon(RotateCw),
|
||||
copy: getCommandCenterIcon(Copy),
|
||||
focusPane: getCommandCenterIcon(Focus),
|
||||
moveTab: getCommandCenterIcon(Move),
|
||||
maximize: getCommandCenterIcon(Maximize2),
|
||||
focusMode: getCommandCenterIcon(ArrowDownToLine),
|
||||
sidePanel: getCommandCenterIcon(PanelRight),
|
||||
};
|
||||
|
||||
const OPEN_PANEL_LABEL_KEYS = {
|
||||
supporting: "shell.commandCenter.open",
|
||||
"side-panel": "shell.commandCenter.openInSidePanel",
|
||||
"focused-pane": "shell.commandCenter.openInFocusedPane",
|
||||
} as const;
|
||||
|
||||
function staticIcon(element: ReactElement | undefined): CommandCenterIcon | undefined {
|
||||
if (!element) return undefined;
|
||||
function StaticIcon() {
|
||||
@@ -51,6 +97,17 @@ function resolveWorkspaceShortcuts(overrides: ShortcutOverrides): WorkspaceComma
|
||||
resolveShortcutKeysForAction("workspace-pane-split-down", overrides, platform) ?? undefined,
|
||||
archiveWorkspace:
|
||||
resolveShortcutKeysForAction("archive-workspace", overrides, platform) ?? undefined,
|
||||
previousTab:
|
||||
resolveShortcutKeysForAction("workspace-tab-prev", overrides, platform) ?? undefined,
|
||||
nextTab: resolveShortcutKeysForAction("workspace-tab-next", overrides, platform) ?? undefined,
|
||||
closeCurrentTab:
|
||||
resolveShortcutKeysForAction("workspace-tab-close-current", overrides, platform) ?? undefined,
|
||||
closePane:
|
||||
resolveShortcutKeysForAction("workspace-pane-close", overrides, platform) ?? undefined,
|
||||
togglePaneMaximization:
|
||||
resolveShortcutKeysForAction("workspace-explorer-maximize", overrides, platform) ?? undefined,
|
||||
toggleSidePanel:
|
||||
resolveShortcutKeysForAction("toggle-right-sidebar", overrides, platform) ?? undefined,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -60,10 +117,22 @@ export function useWorkspaceCommandCenterActions(): void {
|
||||
const selection = useActiveWorkspaceSelection();
|
||||
const serverId = selection?.serverId ?? null;
|
||||
const workspaceId = selection?.workspaceId ?? null;
|
||||
const workspaceKey =
|
||||
serverId && workspaceId ? buildWorkspaceTabPersistenceKey({ serverId, workspaceId }) : null;
|
||||
const layout = useWorkspaceLayoutStore((state) =>
|
||||
workspaceKey ? (state.layoutByWorkspace[workspaceKey] ?? null) : null,
|
||||
);
|
||||
const focusedPane = layout ? findPaneById(layout.root, layout.focusedPaneId) : null;
|
||||
const focusedTabs = layout
|
||||
? collectAllTabs(layout.root).filter((tab) => focusedPane?.tabIds.includes(tab.tabId))
|
||||
: [];
|
||||
const activeTabIndex = focusedTabs.findIndex((tab) => tab.tabId === focusedPane?.focusedTabId);
|
||||
const activeTabKind =
|
||||
activeTabIndex >= 0 ? (focusedTabs[activeTabIndex]?.target.kind ?? null) : null;
|
||||
const cwd = useWorkspaceDirectory(serverId, workspaceId);
|
||||
const isCompact = useIsCompactFormFactor();
|
||||
const { overrides } = useKeyboardShortcutOverrides();
|
||||
const { gitActions } = useGitActions({
|
||||
const { gitActions, isGit } = useGitActions({
|
||||
serverId: serverId ?? "",
|
||||
cwd: cwd ?? "",
|
||||
icons: GIT_ACTION_ICONS,
|
||||
@@ -81,6 +150,34 @@ export function useWorkspaceCommandCenterActions(): void {
|
||||
newBrowser: t("workspace.tabs.actions.newBrowser"),
|
||||
splitRight: t("workspace.tabs.actions.splitRight"),
|
||||
splitDown: t("workspace.tabs.actions.splitDown"),
|
||||
changes: t("workspace.tabs.actions.changes"),
|
||||
files: t("workspace.tabs.actions.files"),
|
||||
pullRequest: t("workspace.tabs.actions.pullRequest"),
|
||||
openPanel: (name, placement) => t(OPEN_PANEL_LABEL_KEYS[placement], { name }),
|
||||
previousTab: t("settings.shortcuts.help.previousTab"),
|
||||
nextTab: t("settings.shortcuts.help.nextTab"),
|
||||
closeCurrentTab: t("settings.shortcuts.help.closeCurrentTab"),
|
||||
renameTab: t("workspace.tabs.menu.rename"),
|
||||
reloadAgent: t("workspace.tabs.menu.reloadAgent"),
|
||||
copyResumeCommand: t("workspace.tabs.menu.copyResumeCommand"),
|
||||
copyAgentId: t("workspace.tabs.menu.copyAgentId"),
|
||||
copyTerminalId: t("workspace.tabs.menu.copyTerminalId"),
|
||||
copyFilePath: t("workspace.tabs.menu.copyFilePath"),
|
||||
closeTabsLeft: t("workspace.tabs.menu.closeLeft"),
|
||||
closeTabsRight: t("workspace.tabs.menu.closeRight"),
|
||||
closeOtherTabs: t("workspace.tabs.menu.closeOthers"),
|
||||
focusPaneLeft: t("settings.shortcuts.help.focusPaneLeft"),
|
||||
focusPaneRight: t("settings.shortcuts.help.focusPaneRight"),
|
||||
focusPaneUp: t("settings.shortcuts.help.focusPaneUp"),
|
||||
focusPaneDown: t("settings.shortcuts.help.focusPaneDown"),
|
||||
moveTabLeft: t("settings.shortcuts.help.moveTabLeft"),
|
||||
moveTabRight: t("settings.shortcuts.help.moveTabRight"),
|
||||
moveTabUp: t("settings.shortcuts.help.moveTabUp"),
|
||||
moveTabDown: t("settings.shortcuts.help.moveTabDown"),
|
||||
closePane: t("settings.shortcuts.help.closePane"),
|
||||
togglePaneMaximization: t("settings.shortcuts.help.toggleExplorerPaneMaximization"),
|
||||
toggleFocusMode: t("settings.shortcuts.help.toggleFocusMode"),
|
||||
toggleSidePanel: t("workspace.tabs.sidePanel.toggle"),
|
||||
},
|
||||
icons: {
|
||||
...WORKSPACE_COMMAND_CENTER_ICONS,
|
||||
@@ -90,14 +187,29 @@ export function useWorkspaceCommandCenterActions(): void {
|
||||
capabilities: {
|
||||
canSplitPanes: supportsDesktopPaneSplits() && !isCompact,
|
||||
canOpenBrowserTabs: getIsElectron(),
|
||||
isGit,
|
||||
},
|
||||
activeTabKind,
|
||||
activeTabIndex,
|
||||
activeTabCount: focusedTabs.length,
|
||||
dispatch: (action) => {
|
||||
clearCommandCenterFocusRestoreElement();
|
||||
keyboardActionDispatcher.dispatch(action);
|
||||
},
|
||||
runGitAction,
|
||||
}),
|
||||
[gitActions, isCompact, keyboardActionDispatcher, overrides, runGitAction, t],
|
||||
[
|
||||
activeTabIndex,
|
||||
activeTabKind,
|
||||
focusedTabs.length,
|
||||
gitActions,
|
||||
isCompact,
|
||||
isGit,
|
||||
keyboardActionDispatcher,
|
||||
overrides,
|
||||
runGitAction,
|
||||
t,
|
||||
],
|
||||
);
|
||||
|
||||
useCommandCenterActions({
|
||||
|
||||
Reference in New Issue
Block a user