Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion windows/tauri/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
traceWindowOpen,
traceWindowOpenAfterFrame,
} from "@/features/window/utils/window-open-diagnostics";
import { LocaleProvider } from "./i18n/locale-provider";

const WorkbenchApp = lazy(() => import("./workbench-app"));

Expand Down Expand Up @@ -92,7 +93,9 @@ function App() {

return (
<Suspense fallback={<InitialWindowShell />}>
<WorkbenchApp />
<LocaleProvider>
<WorkbenchApp />
</LocaleProvider>
</Suspense>
);
}
Expand Down
19 changes: 19 additions & 0 deletions windows/tauri/src/config/backend-capabilities.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { describe, expect, test } from "bun:test";
import { BACKEND_UNAVAILABLE_TOOLTIP, backendCapabilities } from "./backend-capabilities";
import { defaultSettings } from "@/features/settings/config/default-settings";

describe("default Windows workbench capability policy", () => {
test("does not enable unavailable feature families by default", () => {
expect(BACKEND_UNAVAILABLE_TOOLTIP).toBe("待开发");

for (const capability of ["github", "remote", "docker", "agent", "collaboration"] as const) {
expect(backendCapabilities[capability]).toBe(false);
}

expect(defaultSettings.coreFeatures.github).toBe(false);
expect(defaultSettings.coreFeatures.remote).toBe(false);
expect(defaultSettings.coreFeatures.docker).toBe(false);
expect(defaultSettings.coreFeatures.aiChat).toBe(false);
expect(defaultSettings.coreFeatures.teamCollaboration).toBe(false);
});
});
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { appDataDir } from "@tauri-apps/api/path";
import { ClockCounterClockwiseIcon as History, PuzzlePieceIcon as Puzzle } from "@/ui/icons";
import { ClockCounterClockwiseIcon as History } from "@/ui/icons";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { useUIExtensionStore } from "@/extensions/ui/stores/ui-extension-store";
import { IconThemeSelectorContent } from "@/features/command-palette/components/icon-theme-selector";
import { ThemeSelectorContent } from "@/features/command-palette/components/theme-selector";
import { useEditorSettingsStore } from "@/features/editor/stores/settings.store";
import { DatabaseCommandContent } from "@/features/database/components/database-sidebar";
import { useLspStore } from "@/features/editor/lsp/stores/lsp.store";
import { useBufferStore } from "@/features/editor/stores/buffer.store";
import { isMarkdownFile } from "@/features/editor/utils/lines";
Expand All @@ -20,7 +18,6 @@ import {
unstageAllFiles,
} from "@/features/git/api/git-status-api";
import { useRepositoryStore } from "@/features/git/stores/git-repository.store";
import { useGitHubStore } from "@/features/github/stores/github.store";
import { useToast } from "@/features/layout/contexts/toast-context";
import { useOnboardingStore } from "@/features/onboarding/stores/onboarding.store";
import { useSettingsStore } from "@/features/settings/stores/settings.store";
Expand All @@ -42,11 +39,9 @@ import Command, {
import Keybinding from "@/features/keymaps/components/keybinding";
import { matchesSearchQuery } from "@/utils/search-match";
import { createAdvancedActions } from "../constants/advanced-actions";
import { createDatabaseActions } from "../constants/database-actions";
import { createFileActions } from "../constants/file-actions";
import { createGenerateActions } from "../constants/generate-actions";
import { createGitActions } from "../constants/git-actions";
import { createGitHubActions } from "../constants/github-actions";
import { createMarkdownActions } from "../constants/markdown-actions";
import { createNavigationActions } from "../constants/navigation-actions";
import { createPaneActions } from "../constants/pane-actions";
Expand Down Expand Up @@ -154,8 +149,6 @@ const CommandPaletteContent = ({ commandPaletteInitialView }: CommandPaletteCont
const lspStatus = useLspStore.use.lspStatus();
const rootFolderPath = useFileSystemStore((state) => state.rootFolderPath);
const activeRepoPath = useRepositoryStore.use.activeRepoPath();
const { checkAuth: checkGitHubAuth } = useGitHubStore.use.actions();
const extensionCommands = useUIExtensionStore.use.commands();
const extensionViews = useCommandPaletteViews();
const { showToast } = useToast();
const openWhatsNew = useWhatsNewStore((state) => state.actions.open);
Expand All @@ -170,7 +163,6 @@ const CommandPaletteContent = ({ commandPaletteInitialView }: CommandPaletteCont
switchToPreviousBuffer,
reopenClosedTab,
openWebViewerBuffer,
openGitHubFormBuffer,
openContent,
} = useBufferStore.use.actions();
const { zoomIn, zoomOut, resetZoom } = useZoomStore.use.actions();
Expand Down Expand Up @@ -289,8 +281,6 @@ const CommandPaletteContent = ({ commandPaletteInitialView }: CommandPaletteCont
...createNavigationActions({
setIsSidebarVisible,
setActiveView,
setIsBottomPaneVisible,
setBottomPaneActiveTab,
setIsQuickOpenVisible,
openCommandPaletteView,
openSettingsDialog,
Expand All @@ -314,26 +304,6 @@ const CommandPaletteContent = ({ commandPaletteInitialView }: CommandPaletteCont
...createGenerateActions({
onClose,
}),
...Array.from(extensionCommands.values()).map(
(command): Action => ({
id: `extension-command:${command.id}`,
label: command.title,
description: command.category
? `${command.category} extension command`
: "Installed extension command",
icon: <Puzzle />,
category: command.category ?? "Extensions",
action: () => {
onClose();
void Promise.resolve(command.execute()).catch((error) => {
showToast({
message: error instanceof Error ? error.message : "Extension command failed",
type: "error",
});
});
},
}),
),
...createWindowActions({
onClose,
}),
Expand All @@ -354,27 +324,6 @@ const CommandPaletteContent = ({ commandPaletteInitialView }: CommandPaletteCont
},
onClose,
}),
...createGitHubActions({
repoPath: activeRepoPath ?? rootFolderPath ?? null,
setIsSidebarVisible,
setActiveView,
settings: {
showGitHubPullRequests: commandSettings.showGitHubPullRequests,
showGitHubIssues: commandSettings.showGitHubIssues,
showGitHubActions: commandSettings.showGitHubActions,
},
updateSetting: useSettingsStore.getState().actions.updateSetting as (
key: string,
value: any,
) => void | Promise<void>,
checkAuth: checkGitHubAuth,
showToast,
openGitHubFormBuffer,
onClose,
}),
...createDatabaseActions({
openDatabaseCommand: () => pushView("databases"),
}),
...createAdvancedActions({
lspStatus,
vimMode: commandSettings.vimMode,
Expand Down Expand Up @@ -481,12 +430,6 @@ const CommandPaletteContent = ({ commandPaletteInitialView }: CommandPaletteCont
onBack={popView}
onClose={onClose}
/>
) : currentView === "databases" ? (
<DatabaseCommandContent
isActive={currentView === "databases"}
onBack={popView}
onClose={onClose}
/>
) : extensionView ? (
extensionView.render({
isActive: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
stopAllLanguageServers,
} from "@/features/keymaps/commands/lsp-command-actions";
import { openLitheLogBuffer } from "@/features/settings/services/lithe-log-service";
import { useUIState } from "@/features/window/stores/ui-state.store";
import { showAlertDialog } from "@/ui/dialog";
import type { Action } from "../types/action.types";

Expand All @@ -36,18 +35,6 @@ export const createAdvancedActions = (params: AdvancedActionsParams): Action[] =
const { lspStatus, vimMode, vimCommands, setMode, openQuickEdit, showToast, onClose } = params;

const baseActions: Action[] = [
{
id: "ai-new-agent",
label: "AI: New Agent",
description: "Open the unified agent launcher",
icon: <Sparkles />,
category: "AI",
commandId: "workbench.agentLauncher",
action: () => {
useUIState.getState().setIsAgentLauncherVisible(true);
onClose();
},
},
{
id: "ai-quick-edit",
label: "AI: Quick Edit Selection",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,19 @@
import {
FileTextIcon as FileText,
FolderOpenIcon as FolderOpen,
BugBeetleIcon as BugBeetle,
GitBranchIcon as GitBranch,
GitPullRequestIcon as GitPullRequest,
HashIcon as Hash,
ListBulletsIcon as ListBullets,
PackageIcon as Package,
MagnifyingGlassIcon as Search,
} from "@/ui/icons";
import { useBufferStore } from "@/features/editor/stores/buffer.store";
import type { SidebarView } from "@/features/layout/utils/sidebar-pane-utils";
import type {
BottomPaneTab,
SettingsTab,
} from "@/features/window/stores/ui-state/types/ui-state.types";
import type { SettingsTab } from "@/features/window/stores/ui-state/types/ui-state.types";
import type { Action } from "../types/action.types";

interface NavigationActionsParams {
setIsSidebarVisible: (v: boolean) => void;
setActiveView: (view: SidebarView) => void;
setIsBottomPaneVisible: (v: boolean) => void;
setBottomPaneActiveTab: (tab: BottomPaneTab) => void;
setIsQuickOpenVisible: (v: boolean) => void;
openCommandPaletteView?: (view: "outline") => void;
openSettingsDialog: (tab?: SettingsTab) => void;
Expand All @@ -33,8 +25,6 @@ export const createNavigationActions = (params: NavigationActionsParams): Action
const {
setIsSidebarVisible,
setActiveView,
setIsBottomPaneVisible,
setBottomPaneActiveTab,
setIsQuickOpenVisible,
openCommandPaletteView,
coreFeatures,
Expand Down Expand Up @@ -68,32 +58,6 @@ export const createNavigationActions = (params: NavigationActionsParams): Action
onClose();
},
},
{
id: "view-show-github-prs",
label: "View: Show Pull Requests",
description: "Switch to GitHub Pull Requests view",
icon: <GitPullRequest />,
category: "Navigation",
commandId: "workbench.showGitHub",
action: () => {
setIsSidebarVisible(true);
setActiveView("github-prs");
onClose();
},
},
{
id: "view-show-debugger",
label: "View: Show Run and Debug",
description: "Switch to debugger view",
icon: <BugBeetle />,
category: "Navigation",
commandId: "workbench.showDebugger",
action: () => {
setBottomPaneActiveTab("debugger");
setIsBottomPaneVisible(true);
onClose();
},
},
...(coreFeatures.outline
? [
{
Expand Down Expand Up @@ -123,17 +87,6 @@ export const createNavigationActions = (params: NavigationActionsParams): Action
useBufferStore.getState().actions.openGlobalSearchBuffer();
},
},
{
id: "view-show-extensions",
label: "View: Show Extensions",
description: "Open the extensions tab",
icon: <Package />,
category: "Navigation",
action: () => {
onClose();
useBufferStore.getState().actions.openExtensionsBuffer();
},
},
{
id: "go-to-line",
label: "Go: Go to Line",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,19 @@ const settingsTabLabels: Record<SettingsTab, string> = {

const settingsTabCommands = (Object.entries(settingsTabLabels) as Array<[SettingsTab, string]>)
.map(([tab, label]) => ({ tab, label }))
.filter(({ tab }) => tab !== "language");
.filter(
({ tab }) =>
!["account", "ai", "collaboration", "enterprise", "language"].includes(tab),
);

function getMatchingSettingsRecords(query: string) {
const trimmedQuery = query.trim();
if (trimmedQuery.length < 2) return [];

return settingsSearchIndex
.filter(
(record) => !["account", "ai", "collaboration", "enterprise"].includes(record.tab),
)
.filter((record) => record.id !== "editor-vim-mode")
.map((record) => {
const score = scoreSearchQuery(trimmedQuery, [
Expand Down
33 changes: 33 additions & 0 deletions windows/tauri/src/features/keymaps/utils/matcher.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { describe, expect, test } from "bun:test";
import { matchKeybinding } from "./matcher";

function keyboardEvent(overrides: Partial<KeyboardEvent>): KeyboardEvent {
return {
altKey: false,
code: "",
ctrlKey: false,
key: "",
metaKey: false,
shiftKey: false,
...overrides,
} as KeyboardEvent;
}

describe("keymap matcher", () => {
test("matches Ctrl+Shift+F by physical key while an IME changes event.key", () => {
const event = keyboardEvent({
code: "KeyF",
ctrlKey: true,
key: "ㄈ",
shiftKey: true,
});

expect(matchKeybinding(event, "cmd+shift+f").matched).toBe(true);
});

test("does not treat a modifier-only key as global search", () => {
const event = keyboardEvent({ code: "ShiftLeft", key: "Shift", shiftKey: true });

expect(matchKeybinding(event, "cmd+shift+f").matched).toBe(false);
});
});
4 changes: 3 additions & 1 deletion windows/tauri/src/features/keymaps/utils/matcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ export function eventToKey(event: KeyboardEvent): ParsedKey {
// where the character at that physical position differs from the US layout.
let key = event.key;
const hasModifier = event.metaKey || event.ctrlKey || event.altKey;
if (key === "Dead" || key === "Unidentified" || (hasModifier && CODE_TO_KEY[event.code])) {
if (hasModifier && /^Key[A-Z]$/.test(event.code)) {
key = event.code.slice(3).toLowerCase();
} else if (key === "Dead" || key === "Unidentified" || (hasModifier && CODE_TO_KEY[event.code])) {
key = CODE_TO_KEY[event.code] || event.code;
}

Expand Down
Loading
Loading