mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-24 16:04:21 +00:00
perf(settings): single-IPC local bootstrap snapshot and lazy page bodies (#4056)
The Settings window starts from one window_take_settings_init snapshot (launch, project, global settings, remote, updates) instead of several startup calls; on a remote session it paints with the client settings and reconciles with the host's projectCurrent() afterwards, rebasing without touching staged edits. Seven heavy pages (Color Scheme, Inspections, Scopes, Updates, Deployment, Run Targets, SSH) are split into a spec module (metadata and search labels, loaded with the registry) and a lazily loaded body; lazyComponent gains preload() so the target page is warmed before it is revealed. A launch that arrives between the snapshot and the event listener is still applied. Co-authored-by: dengliu <5108773+dengliu@users.noreply.github.com>
This commit is contained in:
@@ -214,6 +214,54 @@ pub fn window_take_launch(window: WebviewWindow, windows: State<'_, WindowsState
|
||||
windows.take_launch(window.label())
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Type)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct SettingsWindowInit {
|
||||
pub launch: Option<Launch>,
|
||||
pub remote: Option<crate::remote_dev::RemoteSession>,
|
||||
pub project: Option<ide_host::ops::project::ProjectInfo>,
|
||||
pub global_settings: ide_core::settings::Settings,
|
||||
pub updates: bool,
|
||||
}
|
||||
|
||||
/// Local bootstrap snapshot for a `settings-<parent>` window, avoiding a sequential
|
||||
/// startup IPC waterfall and any blocking SSH `project_current` round-trip before first paint.
|
||||
#[desktop_command(trust = always)]
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub fn window_take_settings_init(
|
||||
app: AppHandle,
|
||||
window: WebviewWindow,
|
||||
windows: State<'_, WindowsState>,
|
||||
state: State<'_, AppState>,
|
||||
) -> SettingsWindowInit {
|
||||
let owner = AppState::owner_window(window.label());
|
||||
let launch = windows.take_launch(window.label());
|
||||
let (remote, project) = if let Some(c) = state.remote_dev.get(owner) {
|
||||
let session = crate::remote_dev::RemoteSession {
|
||||
target: c.target.clone(),
|
||||
root: c.root.clone(),
|
||||
host: c.host.clone(),
|
||||
os: c.os.clone(),
|
||||
commands: c.commands.clone(),
|
||||
};
|
||||
// Leave `project` empty on remote sessions: the Settings page tree renders immediately
|
||||
// from local client settings, and `projectCurrent()` fills in project-scoped settings
|
||||
// right after first paint without keeping a shadow cache in sync.
|
||||
(Some(session), None)
|
||||
} else {
|
||||
let project = state.project(owner).ok().filter(|p| !p.light).map(|p| ide_host::ops::project::info(&p));
|
||||
(None, project)
|
||||
};
|
||||
SettingsWindowInit {
|
||||
launch,
|
||||
remote,
|
||||
project,
|
||||
global_settings: state.host.with_proxy_password(state.global_settings.effective()),
|
||||
updates: updates_configured(&app),
|
||||
}
|
||||
}
|
||||
|
||||
/// Release the opening window's reservation after navigation or cancellation.
|
||||
#[desktop_command(trust = always)]
|
||||
#[tauri::command]
|
||||
@@ -889,6 +937,7 @@ ide_command::desktop_domain!(
|
||||
window_set_smooth_scrolling,
|
||||
window_set_titlebar_height,
|
||||
window_take_launch,
|
||||
window_take_settings_init,
|
||||
window_toggle_fullscreen,
|
||||
window_toggle_zoom,
|
||||
);
|
||||
|
||||
@@ -730,6 +730,7 @@ window_set_smooth_scrolling always desktop bin
|
||||
window_set_titlebar_height always desktop bindings sync
|
||||
window_start_drag always desktop bindings sync
|
||||
window_take_launch always desktop bindings sync
|
||||
window_take_settings_init always desktop bindings sync
|
||||
window_toggle_fullscreen always desktop bindings sync
|
||||
window_toggle_zoom always desktop bindings sync
|
||||
workspace_attach always desktop bindings async
|
||||
|
||||
@@ -1963,6 +1963,11 @@ export const commands = {
|
||||
/** Deployment windows: the server and local selection to compare. */
|
||||
deployment: DeploymentLaunch | null,
|
||||
} | null>("window_take_launch"),
|
||||
/**
|
||||
* Local bootstrap snapshot for a `settings-<parent>` window, avoiding a sequential
|
||||
* startup IPC waterfall and any blocking SSH `project_current` round-trip before first paint.
|
||||
*/
|
||||
windowTakeSettingsInit: () => __TAURI_INVOKE<SettingsWindowInit_Serialize>("window_take_settings_init"),
|
||||
windowToggleFullscreen: () => typedError<boolean, IdeError>(__TAURI_INVOKE("window_toggle_fullscreen")),
|
||||
/** Fills the work area without the platform zoom animation. Returns whether it is filled now. */
|
||||
windowToggleZoom: () => typedError<boolean, IdeError>(__TAURI_INVOKE("window_toggle_zoom")),
|
||||
@@ -10702,6 +10707,24 @@ export type SettingsImport_Serialize = {
|
||||
|
||||
export type SettingsScope = "global" | "project";
|
||||
|
||||
export type SettingsWindowInit = SettingsWindowInit_Serialize | SettingsWindowInit_Deserialize;
|
||||
|
||||
export type SettingsWindowInit_Deserialize = {
|
||||
launch: Launch_Deserialize | null,
|
||||
remote: RemoteSession | null,
|
||||
project: ProjectInfo_Deserialize | null,
|
||||
globalSettings: Settings_Deserialize,
|
||||
updates: boolean,
|
||||
};
|
||||
|
||||
export type SettingsWindowInit_Serialize = {
|
||||
launch: Launch_Serialize | null,
|
||||
remote: RemoteSession | null,
|
||||
project: ProjectInfo_Serialize | null,
|
||||
globalSettings: Settings_Serialize,
|
||||
updates: boolean,
|
||||
};
|
||||
|
||||
export type Settings_Deserialize = {
|
||||
general?: GeneralSettings,
|
||||
appearance?: AppearanceSettings_Deserialize,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import { act, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { executeAction } from "@/platform/actions";
|
||||
import { CLEAR_COLOR, _setSchemeSource } from "@/platform/colorScheme";
|
||||
import { setLocale } from "@/platform/i18n";
|
||||
@@ -9,6 +9,7 @@ import { DEFAULT_SETTINGS } from "../model/schema";
|
||||
import { openSettings, stage, stagedValue, useSettingsDialog } from "../model/staging";
|
||||
import { PageContext } from "../components/context";
|
||||
import { COLOR_SCHEME_PAGES } from "../pages/editor/colorScheme";
|
||||
import { preloadBuiltinPage } from "../pages/lazyPage";
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
open: vi.fn(),
|
||||
@@ -40,6 +41,7 @@ const schemePage = (id: string) => {
|
||||
);
|
||||
};
|
||||
|
||||
beforeAll(() => preloadBuiltinPage("editor.colorScheme"));
|
||||
beforeEach(() => {
|
||||
vi.resetAllMocks();
|
||||
mocks.open.mockResolvedValue("/schemes/forest.icls");
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { DEFAULT_DEPLOYMENT_SERVER } from "@/platform/remoteSettings";
|
||||
import { useProject } from "@/platform/project";
|
||||
import { PageContext } from "../components/context";
|
||||
import { validateSettings } from "../model/schema";
|
||||
import { applySettings, openSettings, useSettingsDialog } from "../model/staging";
|
||||
import { DEPLOYMENT_PAGES } from "../pages/deployment";
|
||||
import { preloadBuiltinPage } from "../pages/lazyPage";
|
||||
|
||||
const mocks = vi.hoisted(() => ({ store: vi.fn(), saved: vi.fn(), test: vi.fn() }));
|
||||
vi.mock("@/platform/ipc", async (original) => {
|
||||
@@ -29,6 +30,7 @@ const savedDialog = useSettingsDialog.getState();
|
||||
const savedProject = useProject.getState();
|
||||
const PAGE = DEPLOYMENT_PAGES[0]!.id;
|
||||
|
||||
beforeAll(() => preloadBuiltinPage(PAGE));
|
||||
beforeEach(() => {
|
||||
vi.resetAllMocks();
|
||||
mocks.store.mockResolvedValue(undefined);
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
import { act, cleanup, fireEvent, render, screen } from "@testing-library/react";
|
||||
import type { ComponentType } from "react";
|
||||
import { afterEach, beforeEach, expect, it } from "vitest";
|
||||
import { afterEach, beforeAll, beforeEach, expect, it } from "vitest";
|
||||
import { DEFAULT_DEPLOYMENT_SERVER } from "@/platform/remoteSettings";
|
||||
import { useContextMenuStore } from "@/ui";
|
||||
import { PageContext } from "../components/context";
|
||||
import { DEFAULT_SETTINGS } from "../model/schema";
|
||||
import { stagedValue, useSettingsDialog } from "../model/staging";
|
||||
import { DEPLOYMENT_PAGES } from "../pages/deployment";
|
||||
import { preloadBuiltinPage } from "../pages/lazyPage";
|
||||
|
||||
const server = (id: string, name: string) => ({ ...DEFAULT_DEPLOYMENT_SERVER, id, name });
|
||||
|
||||
beforeAll(() => preloadBuiltinPage("build.deployment"));
|
||||
|
||||
beforeEach(() => {
|
||||
const base = structuredClone(DEFAULT_SETTINGS) as typeof DEFAULT_SETTINGS & { deployment: Record<string, unknown> };
|
||||
base.deployment = { ...base.deployment, servers: [server("a", "Alpha"), server("b", "Beta")], defaultServer: "a" };
|
||||
|
||||
@@ -1,6 +1,17 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
const logFrontend = vi.hoisted(() => vi.fn(() => Promise.resolve()));
|
||||
const defaultInit = () => ({
|
||||
launch: null,
|
||||
remote: null,
|
||||
project: null,
|
||||
globalSettings: {},
|
||||
updates: false,
|
||||
});
|
||||
const windowTakeSettingsInit = vi.hoisted(() => vi.fn<() => Promise<unknown>>(() => Promise.resolve(defaultInit())));
|
||||
const windowTakeLaunch = vi.hoisted(() => vi.fn<() => Promise<unknown>>(() => Promise.resolve(null)));
|
||||
const projectCurrent = vi.hoisted(() => vi.fn<() => Promise<unknown>>(() => Promise.resolve(null)));
|
||||
const settingsGetGlobal = vi.hoisted(() => vi.fn(() => Promise.resolve({})));
|
||||
vi.mock("@tauri-apps/api/webviewWindow", () => ({
|
||||
getCurrentWebviewWindow: () => ({
|
||||
label: "settings-main",
|
||||
@@ -11,32 +22,42 @@ vi.mock("@tauri-apps/api/webviewWindow", () => ({
|
||||
}));
|
||||
vi.mock("@/platform/ipc", async (importOriginal) => {
|
||||
const real = await importOriginal<typeof import("@/platform/ipc")>();
|
||||
const ok = (data: unknown) => Promise.resolve({ status: "ok", data });
|
||||
return {
|
||||
...real,
|
||||
isTauri: () => true,
|
||||
commands: {
|
||||
...real.commands,
|
||||
logFrontend,
|
||||
remoteCurrent: () => ok(null),
|
||||
projectCurrent: () => ok(null),
|
||||
settingsGetGlobal: () => ok({}),
|
||||
windowTakeLaunch: () => Promise.resolve(null),
|
||||
remoteCurrent: () => Promise.resolve(null),
|
||||
projectCurrent,
|
||||
settingsGet: () => Promise.resolve({}),
|
||||
settingsGetGlobal,
|
||||
windowTakeLaunch,
|
||||
windowTakeSettingsInit,
|
||||
},
|
||||
};
|
||||
});
|
||||
const loadBuiltinPages = vi.hoisted(() =>
|
||||
vi.fn<() => Promise<() => void>>(() => Promise.reject(new Error("page failed"))),
|
||||
);
|
||||
const preloadBuiltinRegistry = vi.hoisted(() => vi.fn(() => Promise.resolve()));
|
||||
vi.mock("../dialog/LazySettingsDialog", () => ({
|
||||
LazySettingsDialog: () => null,
|
||||
loadBuiltinPages: () => Promise.reject(new Error("page failed")),
|
||||
LazyProjectStructureDialog: () => null,
|
||||
loadBuiltinPages,
|
||||
preloadBuiltinRegistry,
|
||||
unloadBuiltinPages: () => {},
|
||||
}));
|
||||
|
||||
const { activateSettingsWindow } = await import("..");
|
||||
const { useSettingsDialog } = await import("../model/staging");
|
||||
const { disableRemote } = await import("@/platform/remote");
|
||||
const { useProject } = await import("@/platform/project");
|
||||
const { stage, useSettingsDialog } = await import("../model/staging");
|
||||
|
||||
describe("the native Settings window", () => {
|
||||
it("opens even when a page fails to register, and logs why", async () => {
|
||||
vi.spyOn(console, "error").mockImplementation(() => {});
|
||||
windowTakeSettingsInit.mockResolvedValueOnce(defaultInit());
|
||||
const dispose = activateSettingsWindow("main");
|
||||
expect(useSettingsDialog.getState().open).toBe(true);
|
||||
expect(useSettingsDialog.getState().pagesLoading).toBe(true);
|
||||
@@ -48,4 +69,74 @@ describe("the native Settings window", () => {
|
||||
);
|
||||
dispose();
|
||||
});
|
||||
|
||||
it("hydrates from windowTakeSettingsInit without blocking on SSH and rebases base while keeping staged edits", async () => {
|
||||
loadBuiltinPages.mockClear().mockResolvedValue(() => {});
|
||||
settingsGetGlobal.mockClear();
|
||||
windowTakeLaunch.mockClear().mockResolvedValueOnce(null);
|
||||
let resolveRemoteRefresh!: (v: unknown) => void;
|
||||
projectCurrent.mockReturnValueOnce(new Promise((r) => (resolveRemoteRefresh = r)));
|
||||
windowTakeSettingsInit.mockResolvedValueOnce({
|
||||
launch: { settingsPage: "keymap", newProjects: false },
|
||||
remote: {
|
||||
target: { type: "ssh", config: "devbox" },
|
||||
root: "/home/dev/repo",
|
||||
host: "devbox",
|
||||
os: "linux",
|
||||
commands: ["project_current"],
|
||||
},
|
||||
project: null,
|
||||
globalSettings: { appearance: { theme: "dark" }, editor: { tabSize: 4 } },
|
||||
updates: true,
|
||||
});
|
||||
|
||||
const dispose = activateSettingsWindow("main");
|
||||
// Unblocks pagesLoading immediately from local client settings while SSH projectCurrent is still pending.
|
||||
await vi.waitFor(() => expect(useSettingsDialog.getState().pagesLoading).toBe(false));
|
||||
await vi.waitFor(() => expect(windowTakeLaunch).toHaveBeenCalledTimes(1));
|
||||
expect(loadBuiltinPages).toHaveBeenCalledTimes(1);
|
||||
expect(loadBuiltinPages).toHaveBeenCalledWith({ pageId: "keymap", updates: true });
|
||||
expect(useSettingsDialog.getState().pageId).toBe("keymap");
|
||||
expect(useSettingsDialog.getState().base.appearance.theme).toBe("dark");
|
||||
expect(useSettingsDialog.getState().globalBase.editor.tabSize).toBe(4);
|
||||
expect(settingsGetGlobal).not.toHaveBeenCalled();
|
||||
|
||||
// Even if the user stages an edit before SSH returns, remote `base` updates while `staged` stays intact.
|
||||
stage("editor.codeStyle.other", "project", "editor.tabSize", 8);
|
||||
resolveRemoteRefresh({
|
||||
root: "/home/dev/repo",
|
||||
name: "repo",
|
||||
displayName: "repo",
|
||||
trusted: true,
|
||||
isGit: true,
|
||||
settings: { editor: { tabSize: 6 }, appearance: { theme: "dark" } },
|
||||
});
|
||||
await vi.waitFor(() => expect(useSettingsDialog.getState().base.editor.tabSize).toBe(6));
|
||||
expect(useProject.getState().project?.root).toBe("/home/dev/repo");
|
||||
expect(useSettingsDialog.getState().staged["project|editor.tabSize"]?.value).toBe(8);
|
||||
|
||||
disableRemote();
|
||||
useProject.setState({ project: null, settings: null });
|
||||
dispose();
|
||||
});
|
||||
|
||||
it("picks up a launch queued between windowTakeSettingsInit and listen()", async () => {
|
||||
loadBuiltinPages.mockResolvedValue(() => {});
|
||||
windowTakeLaunch.mockResolvedValueOnce({ settingsPage: "appearance", newProjects: true });
|
||||
windowTakeSettingsInit.mockResolvedValueOnce({
|
||||
launch: { settingsPage: "keymap", newProjects: false },
|
||||
remote: null,
|
||||
project: null,
|
||||
globalSettings: {},
|
||||
updates: false,
|
||||
});
|
||||
|
||||
const dispose = activateSettingsWindow("main");
|
||||
await vi.waitFor(() => expect(useSettingsDialog.getState().pagesLoading).toBe(false));
|
||||
await vi.waitFor(() => expect(useSettingsDialog.getState().newProjects).toBe(true));
|
||||
expect(useSettingsDialog.getState().pageId).toBe("appearance");
|
||||
|
||||
useProject.setState({ project: null, settings: null });
|
||||
dispose();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import { act, cleanup, fireEvent, render, screen } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { DEFAULT_SSH_CONFIG, type SshAuthValid } from "@/platform/remoteSettings";
|
||||
import { useProject } from "@/platform/project";
|
||||
import { PageContext } from "../components/context";
|
||||
import { validateSettings } from "../model/schema";
|
||||
import { applySettings, closeSettings, openSettings, resetPage, useSettingsDialog } from "../model/staging";
|
||||
import { SettingsFooter } from "../dialog/SettingsDialog";
|
||||
import { preloadBuiltinPage } from "../pages/lazyPage";
|
||||
import { SSH_PAGES } from "../pages/ssh";
|
||||
|
||||
const mocks = vi.hoisted(() => ({ store: vi.fn(), test: vi.fn(), needsSecret: vi.fn(), trust: vi.fn() }));
|
||||
@@ -32,6 +33,7 @@ const savedDialog = useSettingsDialog.getState();
|
||||
const savedProject = useProject.getState();
|
||||
let typed: string;
|
||||
|
||||
beforeAll(() => preloadBuiltinPage("tools.sshConfigurations"));
|
||||
beforeEach(() => {
|
||||
vi.resetAllMocks();
|
||||
typed = crypto.randomUUID();
|
||||
|
||||
@@ -4,7 +4,7 @@ import { nativeToAsciiAction } from "./nativeToAscii";
|
||||
/** Java's page first: JDK, Maven and the language server are what new projects most often need. */
|
||||
export const NEW_PROJECTS_PAGE = "languages.java";
|
||||
|
||||
export function settingsActions(open: (page?: string, newProjects?: boolean) => void): Action[] {
|
||||
export function settingsActions(open: (page?: string, newProjects?: boolean) => void | Promise<void>): Action[] {
|
||||
return [
|
||||
nativeToAsciiAction(),
|
||||
{
|
||||
|
||||
@@ -4,13 +4,24 @@
|
||||
* window rarely needs them.
|
||||
*/
|
||||
import { lazyComponent } from "@/ui";
|
||||
import { useSettingsDialog } from "../model/staging";
|
||||
import { DEFAULT_PAGE, splitPageTarget, useSettingsDialog } from "../model/staging";
|
||||
|
||||
let registry: Promise<typeof import("../pages/registry")> | null = null;
|
||||
let pages: Promise<() => void> | null = null;
|
||||
|
||||
/** Registers the built-in pages once; resolves with their disposer. */
|
||||
export function loadBuiltinPages(): Promise<() => void> {
|
||||
return (pages ??= import("../pages/registry").then((m) => m.registerBuiltinPages()));
|
||||
/** Pre-fetches the built-in page registry chunk without registering pages yet. */
|
||||
export function preloadBuiltinRegistry(): Promise<unknown> {
|
||||
return (registry ??= import("../pages/registry"));
|
||||
}
|
||||
|
||||
/** Registers the built-in pages once and preloads `pageId`'s body; resolves with their disposer. */
|
||||
export async function loadBuiltinPages(opts: { pageId?: string; updates?: boolean } = {}): Promise<() => void> {
|
||||
const mod = await (registry ??= import("../pages/registry"));
|
||||
const dispose = await (pages ??= Promise.resolve(mod.registerBuiltinPages({ updates: opts.updates })));
|
||||
const target = opts.pageId ? splitPageTarget(opts.pageId).pageId : DEFAULT_PAGE;
|
||||
const preload = mod.preloadBuiltinPage(target);
|
||||
if (preload) await preload;
|
||||
return dispose;
|
||||
}
|
||||
|
||||
/** Drops the pages registered by `loadBuiltinPages` (feature deactivation). */
|
||||
|
||||
@@ -18,7 +18,7 @@ import { lazyWhen } from "@/ui";
|
||||
import { useProject } from "@/platform/project";
|
||||
import { provideSettingsSearchIndex, registerOverlay } from "@/workbench/contributions";
|
||||
import { windowBackgroundHex } from "@/workbench/theme";
|
||||
import { settingsActions } from "./actions";
|
||||
import { NEW_PROJECTS_PAGE, settingsActions } from "./actions";
|
||||
import {
|
||||
LazyProjectStructureDialog,
|
||||
LazySettingsDialog,
|
||||
@@ -57,7 +57,8 @@ async function showSettings(page?: string, newProjects = false) {
|
||||
console.warn("settings window unavailable, using the dialog", e);
|
||||
}
|
||||
}
|
||||
await loadBuiltinPages();
|
||||
const targetPage = page ?? (newProjects ? NEW_PROJECTS_PAGE : useSettingsDialog.getState().pageId);
|
||||
await loadBuiltinPages({ pageId: targetPage });
|
||||
// Like a launch into the open window: go to the page, keep the edits not applied yet.
|
||||
if (useSettingsDialog.getState().open) relaunchSettings({ page, newProjects });
|
||||
else openSettings(page, { newProjects });
|
||||
@@ -87,7 +88,7 @@ export function activate(): () => void {
|
||||
...appearanceToggleActions(),
|
||||
presentationAssistantAction(),
|
||||
...navigationBarActions(),
|
||||
...settingsActions((page, newProjects) => void showSettings(page, newProjects)),
|
||||
...settingsActions((page, newProjects) => showSettings(page, newProjects)),
|
||||
{
|
||||
id: "file.projectStructure",
|
||||
title: "Project Structure…",
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
*/
|
||||
import { useMemo, useRef, useState, type MouseEvent } from "react";
|
||||
import clsx from "clsx";
|
||||
import { useActions, allActions, type Action } from "@/platform/actions";
|
||||
import { defaultPreset, formatBinding, type Keymap, PRESET_TITLES, PRESETS, useKeymap } from "@/platform/keymap";
|
||||
import { allActions, useActions, type Action } from "@/platform/actions";
|
||||
import { defaultPreset, formatBinding, type Keymap, PRESET_TITLES, PRESETS } from "@/platform/keymap";
|
||||
import { call, commands } from "@/platform/ipc";
|
||||
import { notifications } from "@/workbench/contributions";
|
||||
import { ask, confirm, showError } from "@/workbench/messages";
|
||||
@@ -40,6 +40,7 @@ import {
|
||||
isModified,
|
||||
isKeymapAction,
|
||||
keymapName,
|
||||
keymapSearchLabels,
|
||||
removeBinding,
|
||||
removeConflicts,
|
||||
renameKeymap,
|
||||
@@ -65,12 +66,7 @@ type KNode =
|
||||
|
||||
type GroupNode = Extract<KNode, { kind: "group" }>;
|
||||
|
||||
export function keymapSearchLabels(): string[] {
|
||||
const draft = useKeymap.getState();
|
||||
return allActions()
|
||||
.filter((a) => isKeymapAction(a, draft))
|
||||
.map((a) => a.title);
|
||||
}
|
||||
export { keymapSearchLabels };
|
||||
|
||||
const groupKey = (path: readonly string[]) => `grp:${path.join("/")}`;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* (plugins' default shortcuts count as the preset's), add / remove / reset,
|
||||
* conflict detection with `when` overlap, and shortcut search.
|
||||
*/
|
||||
import type { Action } from "@/platform/actions";
|
||||
import { allActions, type Action } from "@/platform/actions";
|
||||
import { evaluateWhen, type ContextKeys } from "@/platform/context";
|
||||
import {
|
||||
customKeymapId,
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
presetBindings,
|
||||
PRESET_TITLES,
|
||||
PRESETS,
|
||||
useKeymap,
|
||||
withBindings,
|
||||
type Keymap,
|
||||
type KeymapDraft,
|
||||
@@ -19,6 +20,13 @@ import {
|
||||
|
||||
export { presetBindings, withBindings, type KeymapDraft };
|
||||
|
||||
export function keymapSearchLabels(): string[] {
|
||||
const draft = useKeymap.getState();
|
||||
return allActions()
|
||||
.filter((a) => isKeymapAction(a, draft))
|
||||
.map((a) => a.title);
|
||||
}
|
||||
|
||||
export function resolveBindings(draft: KeymapDraft, id: string): string[] {
|
||||
return draft.overrides[id]?.map(normalizeBinding) ?? presetBindings(draft.preset, id);
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ export function splitPageTarget(target: string): { pageId: string; focus: string
|
||||
return i < 0 ? { pageId: target, focus: null } : { pageId: target.slice(0, i), focus: target.slice(i + 1) || null };
|
||||
}
|
||||
|
||||
export function openSettings(pageId?: string, opts: { newProjects?: boolean } = {}) {
|
||||
export function openSettings(pageId?: string, opts: { newProjects?: boolean; globalBase?: ValidSettings } = {}) {
|
||||
const s = useSettingsDialog.getState();
|
||||
const base = validateSettings(useProject.getState().settings);
|
||||
const target = pageId ? splitPageTarget(pageId) : { pageId: s.pageId, focus: null };
|
||||
@@ -120,7 +120,7 @@ export function openSettings(pageId?: string, opts: { newProjects?: boolean } =
|
||||
focus: target.focus,
|
||||
query: "",
|
||||
base,
|
||||
globalBase: base,
|
||||
globalBase: opts.globalBase ?? base,
|
||||
newProjects: opts.newProjects ?? false,
|
||||
staged: {},
|
||||
stagedSecrets: {},
|
||||
@@ -129,7 +129,7 @@ export function openSettings(pageId?: string, opts: { newProjects?: boolean } =
|
||||
saving: false,
|
||||
error: null,
|
||||
});
|
||||
void loadGlobalBase();
|
||||
if (!opts.globalBase) void loadGlobalBase();
|
||||
}
|
||||
|
||||
export function openProjectStructure(section?: string) {
|
||||
@@ -182,10 +182,10 @@ async function loadGlobalBase() {
|
||||
}
|
||||
}
|
||||
|
||||
export function rebaseSettings() {
|
||||
export function rebaseSettings(globalBase?: ValidSettings) {
|
||||
const base = validateSettings(useProject.getState().settings);
|
||||
useSettingsDialog.setState((s) => (s.open || s.projectStructureOpen ? { base, globalBase: base } : {}));
|
||||
void loadGlobalBase();
|
||||
useSettingsDialog.setState((s) => (s.open || s.projectStructureOpen ? { base, globalBase: globalBase ?? base } : {}));
|
||||
if (!globalBase) void loadGlobalBase();
|
||||
}
|
||||
|
||||
/** IDEA's File › New Projects Setup › Settings for New Projects. */
|
||||
|
||||
+2
-90
@@ -50,8 +50,6 @@ import {
|
||||
updateMapping,
|
||||
} from "./deploymentModel";
|
||||
import { choosePath } from "@/platform/choosePath";
|
||||
import { BUILD_GROUP } from "./execution";
|
||||
import type { PageSpec } from "./spec";
|
||||
import { parseSshPort, sshTestRemedy } from "./sshConnection";
|
||||
import { PageLink } from "./workflowControls";
|
||||
import workflow from "./Workflow.module.css";
|
||||
@@ -733,7 +731,7 @@ function GroupPanel({
|
||||
|
||||
type Selection = { kind: "server" | "group"; id: string } | null;
|
||||
|
||||
function DeploymentServersEditor() {
|
||||
export function DeploymentServersEditor() {
|
||||
const tx = useTx();
|
||||
const [servers, setServers] = useSetting<DeploymentServerValid[]>("deployment.servers");
|
||||
const [groups, setGroups] = useSetting<DeploymentGroupValid[]>("deployment.groups");
|
||||
@@ -955,7 +953,7 @@ function DeploymentServersEditor() {
|
||||
// ---------------------------------------------------------------------------
|
||||
// Options
|
||||
|
||||
function ExcludeNamesRow() {
|
||||
export function ExcludeNamesRow() {
|
||||
const [names, setNames] = useSetting<string[]>("deployment.exclude");
|
||||
const [draft, setDraft] = useState<string | null>(null);
|
||||
const id = useId();
|
||||
@@ -979,89 +977,3 @@ function ExcludeNamesRow() {
|
||||
</Row>
|
||||
);
|
||||
}
|
||||
|
||||
export const DEPLOYMENT_PAGES: PageSpec[] = [
|
||||
{
|
||||
id: "build.deployment",
|
||||
title: "Deployment",
|
||||
group: BUILD_GROUP,
|
||||
order: 365,
|
||||
projectScope: true,
|
||||
defaultScope: "project",
|
||||
keywords: [
|
||||
"local",
|
||||
"mounted",
|
||||
"sftp",
|
||||
"ftp",
|
||||
"ftps",
|
||||
"ssh",
|
||||
"server",
|
||||
"upload",
|
||||
"remote host",
|
||||
"mappings",
|
||||
"web server",
|
||||
"deploy",
|
||||
],
|
||||
sections: [
|
||||
{
|
||||
options: [
|
||||
{
|
||||
kind: "custom",
|
||||
label: "Deployment servers",
|
||||
keywords: [
|
||||
"Connection",
|
||||
"Mappings",
|
||||
"Excluded Paths",
|
||||
"Root path",
|
||||
"Web server URL",
|
||||
"SSH configuration",
|
||||
"FTP",
|
||||
"Passive mode",
|
||||
"Password",
|
||||
"Save password",
|
||||
"Test Connection",
|
||||
"Use as Default",
|
||||
"Server Group",
|
||||
"Local path",
|
||||
"Deployment path",
|
||||
"Web path",
|
||||
],
|
||||
component: DeploymentServersEditor,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "build.deployment.options",
|
||||
title: "Options",
|
||||
order: 0,
|
||||
projectScope: true,
|
||||
defaultScope: "project",
|
||||
keywords: ["deployment", "upload", "exclude", "timestamps", "automatic upload", "sftp"],
|
||||
sections: [
|
||||
{
|
||||
options: [
|
||||
{
|
||||
kind: "custom",
|
||||
label: "Exclude items by name",
|
||||
keywords: ["exclude"],
|
||||
component: ExcludeNamesRow,
|
||||
},
|
||||
{
|
||||
kind: "select",
|
||||
key: "deployment.autoUpload",
|
||||
label: "Upload changed files automatically to the default server",
|
||||
options: [
|
||||
{ value: "never", label: "Never" },
|
||||
{ value: "onExplicitSave", label: "On explicit save action" },
|
||||
{ value: "always", label: "Always" },
|
||||
],
|
||||
},
|
||||
{ kind: "toggle", key: "deployment.deleteRemote", label: "Delete remote files when local are deleted" },
|
||||
{ kind: "toggle", key: "deployment.preserveTimestamps", label: "Preserve files timestamps" },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
+2
-56
@@ -19,20 +19,10 @@ import { Button, Checkbox, Dialog, Icon, IconButton, Input, T, type SelectOption
|
||||
import { Row, Section, Select } from "../components/Form";
|
||||
import { useSetting } from "../components/context";
|
||||
import { SshConfigSelect, useSshConfigs } from "../components/SshConfigSelect";
|
||||
import { BUILD_GROUP } from "./execution";
|
||||
import type { PageSpec } from "./spec";
|
||||
import { parentPath, splitList } from "./runTargetsPaths";
|
||||
import styles from "./Workflow.module.css";
|
||||
import own from "./RunTargets.module.css";
|
||||
|
||||
/** Parent of a remote path (`~/a` → `~`, `/a` → `/`); null at the top. */
|
||||
export function parentPath(path: string): string | null {
|
||||
const p = path.length > 1 ? path.replace(/\/+$/, "") : path;
|
||||
if (p === "/" || p === "~" || p === "") return null;
|
||||
const i = p.lastIndexOf("/");
|
||||
if (i < 0) return null;
|
||||
return i === 0 ? "/" : p.slice(0, i);
|
||||
}
|
||||
|
||||
const UNKNOWN_HOST = /^Unknown SSH host key/;
|
||||
const NEEDS_SECRET = /^SSH (password|key passphrase) required|passphrase required|^cannot decrypt SSH key/;
|
||||
|
||||
@@ -259,13 +249,6 @@ function ProjectFolderField({ target, onChange }: { target: RunTargetValid; onCh
|
||||
);
|
||||
}
|
||||
|
||||
/** Settings typed as lists of words (`8000:8000 5678:5678`, `a.yaml; b.yaml`). */
|
||||
export const splitList = (text: string): string[] =>
|
||||
text
|
||||
.split(/[\s,;]+/)
|
||||
.map((s) => s.trim())
|
||||
.filter(Boolean);
|
||||
|
||||
function ListField({
|
||||
label,
|
||||
value,
|
||||
@@ -414,7 +397,7 @@ function ContainerFields({ target, update }: { target: RunTargetValid; update: (
|
||||
);
|
||||
}
|
||||
|
||||
function RunTargetsEditor() {
|
||||
export function RunTargetsEditor() {
|
||||
const plugins = usePluginRunTargets((s) => s.targets);
|
||||
const [defaultTarget, setDefaultTarget] = useSetting<string>("run.defaultTarget");
|
||||
const [raw, setTargets] = useSetting<RunTargetValid[] | undefined>("runTargets");
|
||||
@@ -593,40 +576,3 @@ function RunTargetsEditor() {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export const RUN_TARGET_PAGES: PageSpec[] = [
|
||||
{
|
||||
id: "build.runTargets",
|
||||
title: "Run Targets",
|
||||
group: BUILD_GROUP,
|
||||
order: 364,
|
||||
projectScope: true,
|
||||
keywords: ["ssh", "remote", "target", "run on", "interpreter", "upload", "sync", "docker", "compose", "container"],
|
||||
sections: [
|
||||
{
|
||||
options: [
|
||||
{
|
||||
kind: "custom",
|
||||
label: "Run Targets",
|
||||
keywords: [
|
||||
"SSH configuration",
|
||||
"Project folder on target",
|
||||
"Upload changed project files before each run",
|
||||
"Python interpreter",
|
||||
"Node.js interpreter",
|
||||
"Java executable",
|
||||
"Docker connection",
|
||||
"Image",
|
||||
"Compose files",
|
||||
"Service",
|
||||
"Container folder",
|
||||
"Published ports",
|
||||
"Run options",
|
||||
],
|
||||
component: RunTargetsEditor,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
+2
-49
@@ -10,8 +10,6 @@ import { BUILTIN_SCOPES, scopeError, validateScopes, type NamedScope } from "@/p
|
||||
import { IconButton, Input, T, type SelectOption } from "@/ui";
|
||||
import { ColorSwatches, Row, Section, Select } from "../components/Form";
|
||||
import { useSetting } from "../components/context";
|
||||
import { APPEARANCE_GROUP } from "./behavior";
|
||||
import type { PageSpec } from "./spec";
|
||||
import styles from "./Workflow.module.css";
|
||||
import own from "./Scopes.module.css";
|
||||
|
||||
@@ -73,7 +71,7 @@ function errorText(error: { message: string; at: number }): string {
|
||||
return tx`${message} at column ${column}`;
|
||||
}
|
||||
|
||||
function ScopesEditor() {
|
||||
export function ScopesEditor() {
|
||||
const [raw, setRaw] = useSetting<unknown>("scopes");
|
||||
const scopes = validateScopes(raw);
|
||||
const [selected, setSelected] = useState(0);
|
||||
@@ -182,7 +180,7 @@ const COLOR_LABELS: Record<string, string> = {
|
||||
|
||||
const colorLabel = (color: string) => COLOR_LABELS[color.toLowerCase()] ?? color;
|
||||
|
||||
function FileColorsEditor() {
|
||||
export function FileColorsEditor() {
|
||||
const [raw, setRaw] = useSetting<unknown>("fileColors");
|
||||
const [rawScopes] = useSetting<unknown>("scopes");
|
||||
const settings = validateFileColors(raw);
|
||||
@@ -266,48 +264,3 @@ function FileColorsEditor() {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export const SCOPE_PAGES: PageSpec[] = [
|
||||
{
|
||||
id: "fileColors",
|
||||
title: "File Colors",
|
||||
group: APPEARANCE_GROUP,
|
||||
order: 1.5,
|
||||
projectScope: true,
|
||||
defaultScope: "project",
|
||||
keywords: ["colour", "color", "tab", "background", "tests", "non-project"],
|
||||
sections: [
|
||||
{
|
||||
options: [
|
||||
{ kind: "toggle", key: "fileColors.enabled", label: "Enable file colors" },
|
||||
{ kind: "toggle", key: "fileColors.editorTabs", label: "Use in editor tabs" },
|
||||
{ kind: "toggle", key: "fileColors.projectView", label: "Use in project view" },
|
||||
],
|
||||
},
|
||||
{
|
||||
options: [
|
||||
{
|
||||
kind: "custom",
|
||||
label: "File Colors",
|
||||
keywords: ["Scope", "Color", "Custom", "Hex value"],
|
||||
component: FileColorsEditor,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "scopes",
|
||||
title: "Scopes",
|
||||
group: APPEARANCE_GROUP,
|
||||
order: 1.6,
|
||||
projectScope: true,
|
||||
defaultScope: "project",
|
||||
keywords: ["scope", "file set", "pattern"],
|
||||
sections: [
|
||||
{
|
||||
options: [{ kind: "custom", label: "Scopes", keywords: ["Name", "Pattern"], component: ScopesEditor }],
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -17,9 +17,7 @@ import { Button, Checkbox, IconButton, Input, type SelectOption, T } from "@/ui"
|
||||
import { Row, Section, Select } from "../components/Form";
|
||||
import { useSetting } from "../components/context";
|
||||
import { stageSshSecret, useSettingsDialog } from "../model/staging";
|
||||
import type { PageSpec } from "./spec";
|
||||
import { parseSshPort, sshTestRemedy, type SshTestRemedy } from "./sshConnection";
|
||||
import { TOOLS_GROUP } from "./tools";
|
||||
import styles from "./Workflow.module.css";
|
||||
|
||||
const AUTH: Array<SelectOption<SshAuthValid>> = [
|
||||
@@ -284,7 +282,7 @@ function SshConfigForm({
|
||||
);
|
||||
}
|
||||
|
||||
function SshConfigsEditor() {
|
||||
export function SshConfigsEditor() {
|
||||
const [stored, setConfigs] = useSetting<SshConfigValid[] | undefined>("ssh.configs", "global");
|
||||
const configs = stored ?? [];
|
||||
const [selected, setSelected] = useState<string | null>(configs[0]?.id ?? null);
|
||||
@@ -360,37 +358,3 @@ function SshConfigsEditor() {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export const SSH_PAGES: PageSpec[] = [
|
||||
{
|
||||
id: "tools.sshConfigurations",
|
||||
title: "SSH Configurations",
|
||||
group: TOOLS_GROUP,
|
||||
order: 603,
|
||||
keywords: ["ssh", "remote", "host", "server", "key pair", "private key", "password", "known_hosts", "agent"],
|
||||
sections: [
|
||||
{
|
||||
options: [
|
||||
{
|
||||
kind: "custom",
|
||||
label: "SSH Configurations",
|
||||
keywords: [
|
||||
"Host",
|
||||
"Port",
|
||||
"User name",
|
||||
"Authentication type",
|
||||
"Private key file",
|
||||
"Password",
|
||||
"Passphrase",
|
||||
"Save password",
|
||||
"Save passphrase",
|
||||
"Test Connection",
|
||||
"OpenSSH config and authentication agent",
|
||||
],
|
||||
component: SshConfigsEditor,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
+1
-44
@@ -5,9 +5,8 @@ import { call, commands, onIdeEvent, type UpdateStatus } from "@/platform/ipc";
|
||||
import { useTx } from "@/platform/i18n";
|
||||
import { Button, T } from "@/ui";
|
||||
import { Row } from "../components/Form";
|
||||
import type { PageSpec } from "./spec";
|
||||
|
||||
function UpdateStatusRows() {
|
||||
export function UpdateStatusRows() {
|
||||
const tx = useTx();
|
||||
const [version, setVersion] = useState<string | null>(null);
|
||||
const [status, setStatus] = useState<UpdateStatus | null>(null);
|
||||
@@ -49,45 +48,3 @@ function UpdateStatusRows() {
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export const UPDATES_PAGE: PageSpec = {
|
||||
id: "general.updates",
|
||||
title: "Updates",
|
||||
order: 3,
|
||||
keywords: ["update", "upgrade", "version", "automatic", "GitHub", "CNB"],
|
||||
sections: [
|
||||
{
|
||||
options: [
|
||||
{
|
||||
kind: "custom",
|
||||
label: "Current version",
|
||||
keywords: ["Last checked", "Check Now"],
|
||||
component: UpdateStatusRows,
|
||||
},
|
||||
{
|
||||
kind: "toggle",
|
||||
key: "general.autoCheckUpdates",
|
||||
label: "Check for updates automatically",
|
||||
hint: "At startup and every 4 hours while OpenIDEA runs. Each new version is announced once per session.",
|
||||
},
|
||||
{
|
||||
kind: "toggle",
|
||||
key: "general.showWhatsNewAfterUpdate",
|
||||
label: "Show What's New after an update",
|
||||
hint: "Opens a page with the release notes when a new version starts. Help › What's New opens it any time.",
|
||||
},
|
||||
{
|
||||
kind: "select",
|
||||
key: "general.updateSource",
|
||||
label: "Update source",
|
||||
hint: "Where updates are downloaded from. If it can't be reached, the other source is tried.",
|
||||
options: [
|
||||
{ value: "auto", label: "Automatic" },
|
||||
{ value: "github", label: "GitHub" },
|
||||
{ value: "cnb", label: "CNB (China mirror)" },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -1,11 +1,17 @@
|
||||
/** Built-in settings pages (IDEA layout: Appearance & Behavior, Keymap, Editor). */
|
||||
import { GlobListEditor, Row } from "../components/Form";
|
||||
import { useSetting } from "../components/context";
|
||||
import { KeymapPage, keymapSearchLabels } from "../keymap/KeymapPage";
|
||||
import { AssociatedApplicationsRow, RecognizedFileTypes } from "./FileTypes";
|
||||
import { keymapSearchLabels } from "../keymap/model";
|
||||
import { lazyPage } from "./lazyPage";
|
||||
import type { PageSpec } from "./spec";
|
||||
export const EDITOR_GROUP = "Editor";
|
||||
|
||||
const KeymapPage = lazyPage("keymap", () => import("../keymap/KeymapPage").then((m) => m.KeymapPage));
|
||||
const RecognizedFileTypes = lazyPage("editor.files", () => import("./FileTypes").then((m) => m.RecognizedFileTypes));
|
||||
const AssociatedApplicationsRow = lazyPage("editor.files", () =>
|
||||
import("./FileTypes").then((m) => m.AssociatedApplicationsRow),
|
||||
);
|
||||
|
||||
function ExcludeRow() {
|
||||
const [exclude, setExclude] = useSetting<string[]>("files.exclude");
|
||||
return (
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
import { BUILD_GROUP } from "./execution";
|
||||
import { lazyPage } from "./lazyPage";
|
||||
import type { PageSpec } from "./spec";
|
||||
|
||||
const DeploymentServersEditor = lazyPage("build.deployment", () =>
|
||||
import("./DeploymentBody").then((m) => m.DeploymentServersEditor),
|
||||
);
|
||||
const ExcludeNamesRow = lazyPage("build.deployment.options", () =>
|
||||
import("./DeploymentBody").then((m) => m.ExcludeNamesRow),
|
||||
);
|
||||
|
||||
export const DEPLOYMENT_PAGES: PageSpec[] = [
|
||||
{
|
||||
id: "build.deployment",
|
||||
title: "Deployment",
|
||||
group: BUILD_GROUP,
|
||||
order: 365,
|
||||
projectScope: true,
|
||||
defaultScope: "project",
|
||||
keywords: [
|
||||
"local",
|
||||
"mounted",
|
||||
"sftp",
|
||||
"ftp",
|
||||
"ftps",
|
||||
"ssh",
|
||||
"server",
|
||||
"upload",
|
||||
"remote host",
|
||||
"mappings",
|
||||
"web server",
|
||||
"deploy",
|
||||
],
|
||||
sections: [
|
||||
{
|
||||
options: [
|
||||
{
|
||||
kind: "custom",
|
||||
label: "Deployment servers",
|
||||
keywords: [
|
||||
"Connection",
|
||||
"Mappings",
|
||||
"Excluded Paths",
|
||||
"Root path",
|
||||
"Web server URL",
|
||||
"SSH configuration",
|
||||
"FTP",
|
||||
"Passive mode",
|
||||
"Password",
|
||||
"Save password",
|
||||
"Test Connection",
|
||||
"Use as Default",
|
||||
"Server Group",
|
||||
"Local path",
|
||||
"Deployment path",
|
||||
"Web path",
|
||||
],
|
||||
component: DeploymentServersEditor,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "build.deployment.options",
|
||||
title: "Options",
|
||||
order: 0,
|
||||
projectScope: true,
|
||||
defaultScope: "project",
|
||||
keywords: ["deployment", "upload", "exclude", "timestamps", "automatic upload", "sftp"],
|
||||
sections: [
|
||||
{
|
||||
options: [
|
||||
{
|
||||
kind: "custom",
|
||||
label: "Exclude items by name",
|
||||
keywords: ["exclude"],
|
||||
component: ExcludeNamesRow,
|
||||
},
|
||||
{
|
||||
kind: "select",
|
||||
key: "deployment.autoUpload",
|
||||
label: "Upload changed files automatically to the default server",
|
||||
options: [
|
||||
{ value: "never", label: "Never" },
|
||||
{ value: "onExplicitSave", label: "On explicit save action" },
|
||||
{ value: "always", label: "Always" },
|
||||
],
|
||||
},
|
||||
{ kind: "toggle", key: "deployment.deleteRemote", label: "Delete remote files when local are deleted" },
|
||||
{ kind: "toggle", key: "deployment.preserveTimestamps", label: "Preserve files timestamps" },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
File diff suppressed because it is too large
Load Diff
+6
-28
@@ -7,7 +7,6 @@
|
||||
*/
|
||||
import { useEffect, useId, useMemo, useRef, useState, type MouseEvent } from "react";
|
||||
import clsx from "clsx";
|
||||
import { commands, isTauri } from "@/platform/ipc";
|
||||
import {
|
||||
BUILTIN_INSPECTIONS,
|
||||
copyProfileName,
|
||||
@@ -44,10 +43,8 @@ import {
|
||||
import { useSetting } from "../../components/context";
|
||||
import { useSettingsDialog } from "../../model/staging";
|
||||
import { useProject } from "@/platform/project";
|
||||
import type { PageSpec } from "../spec";
|
||||
import {
|
||||
AS_REPORTED,
|
||||
INSPECTION_KEYWORDS,
|
||||
LEVEL_OPTIONS,
|
||||
buildInspectionTree,
|
||||
checkState,
|
||||
@@ -62,29 +59,20 @@ import {
|
||||
setLevel,
|
||||
withProfileOverrides,
|
||||
type InspectionNode,
|
||||
cachedInspectionLanguages,
|
||||
loadInspectionLanguages,
|
||||
type LanguageServers,
|
||||
} from "./inspectionsModel";
|
||||
import styles from "./Inspections.module.css";
|
||||
import { tx } from "@/platform/i18n";
|
||||
import { onLanguageListChanged, useLanguageListVersion } from "@/platform/languageList";
|
||||
|
||||
let languagesCache: LanguageServers[] | null = null;
|
||||
onLanguageListChanged(() => (languagesCache = null));
|
||||
|
||||
async function loadLanguages(): Promise<LanguageServers[]> {
|
||||
if (languagesCache) return languagesCache;
|
||||
if (!isTauri()) return [];
|
||||
const list = await commands.languages();
|
||||
languagesCache = list.map((l) => ({ name: l.name, servers: l.languageServers ?? [] }));
|
||||
return languagesCache;
|
||||
}
|
||||
import { useLanguageListVersion } from "@/platform/languageList";
|
||||
|
||||
function useLanguages(): LanguageServers[] {
|
||||
const [langs, setLangs] = useState<LanguageServers[]>(() => languagesCache ?? []);
|
||||
const [langs, setLangs] = useState<LanguageServers[]>(() => cachedInspectionLanguages());
|
||||
const version = useLanguageListVersion((s) => s.version);
|
||||
useEffect(() => {
|
||||
let alive = true;
|
||||
void loadLanguages().then(
|
||||
void loadInspectionLanguages().then(
|
||||
(l) => alive && setLangs(l),
|
||||
() => {},
|
||||
);
|
||||
@@ -103,7 +91,7 @@ function expandableKeys(nodes: readonly InspectionNode[], out = new Set<string>(
|
||||
return out;
|
||||
}
|
||||
|
||||
function InspectionsPage() {
|
||||
export function InspectionsPage() {
|
||||
const hasProject = useProject((s) => !!s.project);
|
||||
const newProjects = useSettingsDialog((s) => s.newProjects);
|
||||
const projectAvailable = hasProject && !newProjects;
|
||||
@@ -510,13 +498,3 @@ function InspectionOptions({
|
||||
</fieldset>
|
||||
);
|
||||
}
|
||||
|
||||
export const INSPECTIONS_PAGE: PageSpec = {
|
||||
id: "editor.inspections",
|
||||
title: "Inspections",
|
||||
group: "Editor",
|
||||
order: 25,
|
||||
keywords: INSPECTION_KEYWORDS,
|
||||
component: InspectionsPage,
|
||||
dynamicLabels: () => (languagesCache ?? []).flatMap((l) => [l.name, ...l.servers]),
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,19 @@
|
||||
import { ATTRIBUTES } from "@/platform/colorScheme";
|
||||
|
||||
export const LANGUAGES = [...new Set(ATTRIBUTES.map((a) => a.path[0]!))].filter(
|
||||
(s) => !["General", "Debugger", "Language Defaults", "Console Colors", "Git"].includes(s),
|
||||
);
|
||||
|
||||
/** A sub-page id: `C#` → `csharp`, `Console Colors` → `console-colors` (`#` would end a settings link). */
|
||||
export const languagePageId = (language: string) =>
|
||||
`editor.colorScheme.${language.toLowerCase().replace(/#/g, "sharp").replace(/\s+/g, "-")}`;
|
||||
|
||||
/** Sub-pages linked from the Color Scheme landing page, in sidebar order. */
|
||||
export const SCHEME_SUBPAGES = [
|
||||
{ id: "editor.colorScheme.general", title: "General" },
|
||||
{ id: "editor.colorScheme.language-defaults", title: "Language Defaults" },
|
||||
{ id: "editor.colorScheme.debugger", title: "Debugger" },
|
||||
{ id: "editor.colorScheme.console-colors", title: "Console Colors" },
|
||||
{ id: "editor.colorScheme.git", title: "Git" },
|
||||
...LANGUAGES.map((l) => ({ id: languagePageId(l), title: l })),
|
||||
];
|
||||
@@ -1,8 +1,8 @@
|
||||
/** Settings › Editor pages (General and sub-pages, Code Editing, Font, Color Scheme, Code Style, Inspections, Natural Languages › Spelling, File Encodings, Inlay Hints). */
|
||||
import type { PageSpec } from "../spec";
|
||||
import { COLOR_SCHEME_PAGES } from "./colorScheme";
|
||||
import { GENERAL_PAGES } from "./general";
|
||||
import { FONT_PAGE } from "./font";
|
||||
import { COLOR_SCHEME_PAGES } from "./colorScheme";
|
||||
import { CODE_STYLE_PAGES } from "./codeStyle";
|
||||
import { INSPECTIONS_PAGE } from "./inspections";
|
||||
import { NATURAL_LANGUAGES_PAGE, SPELLING_PAGE } from "./spelling";
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import { lazyPage } from "../lazyPage";
|
||||
import type { PageSpec } from "../spec";
|
||||
import { INSPECTION_KEYWORDS, cachedInspectionLanguages } from "./inspectionsModel";
|
||||
|
||||
const InspectionsPage = lazyPage("editor.inspections", () =>
|
||||
import("./InspectionsBody").then((m) => m.InspectionsPage),
|
||||
);
|
||||
|
||||
export const INSPECTIONS_PAGE: PageSpec = {
|
||||
id: "editor.inspections",
|
||||
title: "Inspections",
|
||||
group: "Editor",
|
||||
order: 25,
|
||||
keywords: INSPECTION_KEYWORDS,
|
||||
component: InspectionsPage,
|
||||
dynamicLabels: () => cachedInspectionLanguages().flatMap((l) => [l.name, ...l.servers]),
|
||||
};
|
||||
@@ -1,3 +1,5 @@
|
||||
import { commands, isTauri } from "@/platform/ipc";
|
||||
import { onLanguageListChanged } from "@/platform/languageList";
|
||||
/**
|
||||
* Editor › Inspections tree: language → language server → diagnostic codes
|
||||
* seen, plugins' problems under Plugins, plus the built-in checks; enabled /
|
||||
@@ -308,3 +310,18 @@ function codeDescription(server: string, { code, source, sample }: SeenCode): st
|
||||
: tx`${server} problems with code ${code}.`;
|
||||
return sample ? tx`${what}\n\nExample: ${sample}` : what;
|
||||
}
|
||||
|
||||
let languagesCache: LanguageServers[] | null = null;
|
||||
onLanguageListChanged(() => (languagesCache = null));
|
||||
|
||||
export function cachedInspectionLanguages(): LanguageServers[] {
|
||||
return languagesCache ?? [];
|
||||
}
|
||||
|
||||
export async function loadInspectionLanguages(): Promise<LanguageServers[]> {
|
||||
if (languagesCache) return languagesCache;
|
||||
if (!isTauri()) return [];
|
||||
const list = await commands.languages();
|
||||
languagesCache = list.map((l) => ({ name: l.name, servers: l.languageServers ?? [] }));
|
||||
return languagesCache;
|
||||
}
|
||||
|
||||
@@ -3,17 +3,20 @@
|
||||
* Stepping), Python Debugger and Run/Debug. Consumed by the run and debugger
|
||||
* features (and `ide-run` for encoding / termination timeout).
|
||||
*/
|
||||
import { CMakeProfiles } from "./cmake";
|
||||
import { WORKFLOW_LIMITS } from "@/platform/workflowSettings";
|
||||
import type { SelectOption } from "@/ui";
|
||||
import { ColorSwatches, FormGroup, GlobListEditor, NumberInput, Row, Toggle } from "../components/Form";
|
||||
import { GradlePage, MavenPage } from "../languages/LanguagePages";
|
||||
import { useSetting } from "../components/context";
|
||||
import { lazyPage } from "./lazyPage";
|
||||
import type { PageSpec } from "./spec";
|
||||
import { Indented, ToggleNumber } from "./workflowControls";
|
||||
import styles from "./Workflow.module.css";
|
||||
import { T } from "@/ui";
|
||||
|
||||
const CMakeProfiles = lazyPage("build.cmake", () => import("./cmake").then((m) => m.CMakeProfiles));
|
||||
const GradlePage = lazyPage("build.gradle", () => import("../languages/LanguagePages").then((m) => m.GradlePage));
|
||||
const MavenPage = lazyPage("build.maven", () => import("../languages/LanguagePages").then((m) => m.MavenPage));
|
||||
|
||||
export const BUILD_GROUP = "Build, Execution, Deployment";
|
||||
|
||||
const L = WORKFLOW_LIMITS;
|
||||
|
||||
@@ -3,25 +3,39 @@
|
||||
* Languages & Frameworks › Go / Java / Markdown / Node.js / PHP / Rust / TypeScript / Zig. Pages live in
|
||||
* `../languages/`; settings are `languages.*` / `projectStructure.*`.
|
||||
*/
|
||||
import {
|
||||
GoPage,
|
||||
JavaPage,
|
||||
NodePage,
|
||||
PhpPage,
|
||||
RubyPage,
|
||||
RustPage,
|
||||
TypeScriptPage,
|
||||
ZigPage,
|
||||
} from "../languages/LanguagePages";
|
||||
import { MarkdownPage } from "../languages/MarkdownPage";
|
||||
import { OxfmtPage, PrettierPage, RuffPage } from "../languages/FormatterPage";
|
||||
import { PythonInterpreterPage } from "../languages/PythonInterpreterPage";
|
||||
import { PythonInterpretersPage } from "../languages/PythonInterpretersPage";
|
||||
import { DocstringsPage } from "../languages/DocstringsPage";
|
||||
import { GoBuildTagsPage, GO_BUILD_TAG_SECTIONS } from "../languages/GoBuildTags";
|
||||
import { GoModulesPage, GO_MODULE_SECTIONS } from "../languages/GoModules";
|
||||
import { GO_BUILD_TAG_SECTIONS, GoBuildTagsPage } from "../languages/GoBuildTags";
|
||||
import { GO_MODULE_SECTIONS, GoModulesPage } from "../languages/GoModules";
|
||||
import { lazyPage } from "./lazyPage";
|
||||
import type { PageSpec } from "./spec";
|
||||
|
||||
const PythonInterpreterPage = lazyPage("python.interpreter", () =>
|
||||
import("../languages/PythonInterpreterPage").then((m) => m.PythonInterpreterPage),
|
||||
);
|
||||
const PythonInterpretersPage = lazyPage("python.interpreters", () =>
|
||||
import("../languages/PythonInterpretersPage").then((m) => m.PythonInterpretersPage),
|
||||
);
|
||||
const GoPage = lazyPage("languages.go", () => import("../languages/LanguagePages").then((m) => m.GoPage));
|
||||
const JavaPage = lazyPage("languages.java", () => import("../languages/LanguagePages").then((m) => m.JavaPage));
|
||||
const NodePage = lazyPage("languages.node", () => import("../languages/LanguagePages").then((m) => m.NodePage));
|
||||
const MarkdownPage = lazyPage("languages.markdown", () =>
|
||||
import("../languages/MarkdownPage").then((m) => m.MarkdownPage),
|
||||
);
|
||||
const PrettierPage = lazyPage("languages.prettier", () =>
|
||||
import("../languages/FormatterPage").then((m) => m.PrettierPage),
|
||||
);
|
||||
const OxfmtPage = lazyPage("languages.oxfmt", () => import("../languages/FormatterPage").then((m) => m.OxfmtPage));
|
||||
const DocstringsPage = lazyPage("python.docstrings", () =>
|
||||
import("../languages/DocstringsPage").then((m) => m.DocstringsPage),
|
||||
);
|
||||
const RuffPage = lazyPage("python.ruff", () => import("../languages/FormatterPage").then((m) => m.RuffPage));
|
||||
const PhpPage = lazyPage("languages.php", () => import("../languages/LanguagePages").then((m) => m.PhpPage));
|
||||
const RubyPage = lazyPage("languages.ruby", () => import("../languages/LanguagePages").then((m) => m.RubyPage));
|
||||
const RustPage = lazyPage("languages.rust", () => import("../languages/LanguagePages").then((m) => m.RustPage));
|
||||
const TypeScriptPage = lazyPage("languages.typescript", () =>
|
||||
import("../languages/LanguagePages").then((m) => m.TypeScriptPage),
|
||||
);
|
||||
const ZigPage = lazyPage("languages.zig", () => import("../languages/LanguagePages").then((m) => m.ZigPage));
|
||||
|
||||
export const LANGUAGES_GROUP = "Languages & Frameworks";
|
||||
|
||||
export const LANGUAGE_PAGES: PageSpec[] = [
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import type { ComponentType } from "react";
|
||||
import { lazyComponent, type LazyComponent } from "@/ui";
|
||||
|
||||
const preloaders = new Map<string, Array<() => Promise<unknown>>>();
|
||||
|
||||
/**
|
||||
* Registers a built-in page component via `lazyComponent` and indexes its
|
||||
* preloader under `pageIds` so `preloadBuiltinPage` can warm it ahead of mount.
|
||||
*/
|
||||
export function lazyPage<P extends object = Record<string, never>>(
|
||||
pageIds: string | readonly string[],
|
||||
load: () => Promise<ComponentType<P>>,
|
||||
): LazyComponent<P> {
|
||||
const Component = lazyComponent(load);
|
||||
const ids = typeof pageIds === "string" ? [pageIds] : pageIds;
|
||||
for (const id of ids) {
|
||||
const list = preloaders.get(id) ?? [];
|
||||
list.push(Component.preload);
|
||||
preloaders.set(id, list);
|
||||
}
|
||||
return Component;
|
||||
}
|
||||
|
||||
/** Preloads any lazy component registered for `pageId` before revealing it. */
|
||||
export function preloadBuiltinPage(pageId: string): Promise<void> | undefined {
|
||||
const list = preloaders.get(pageId);
|
||||
if (!list?.length) return undefined;
|
||||
return Promise.all(list.map((fn) => fn().catch(() => {}))).then(() => undefined);
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
/** Registers the built-in pages as ordinary settings-page contributions and indexes their labels. */
|
||||
import { commands } from "@/platform/ipc";
|
||||
import { UPDATES_PAGE } from "./updates";
|
||||
import { onLanguageListChanged } from "@/platform/languageList";
|
||||
import { registerSettingsPage, registerSettingsPages, type SettingsPageContribution } from "@/workbench/contributions";
|
||||
import { BEHAVIOR_PAGES } from "./behavior";
|
||||
@@ -9,14 +8,18 @@ import { DEPLOYMENT_PAGES } from "./deployment";
|
||||
import { EDITOR_PAGES, codeStyleLanguagePages } from "./editor";
|
||||
import { EXECUTION_PAGES } from "./execution";
|
||||
import { LANGUAGE_PAGES } from "./languages";
|
||||
import { preloadBuiltinPage } from "./lazyPage";
|
||||
import { OptionsPage } from "./OptionsPage";
|
||||
import { RUN_TARGET_PAGES } from "./runTargets";
|
||||
import { SCOPE_PAGES } from "./scopes";
|
||||
import { flattenOptions, specLabels, type PageSpec } from "./spec";
|
||||
import { SSH_PAGES } from "./ssh";
|
||||
import { TOOLS_PAGES } from "./tools";
|
||||
import { UPDATES_PAGE } from "./updates";
|
||||
import { VCS_PAGES } from "./vcs";
|
||||
|
||||
export { preloadBuiltinPage };
|
||||
|
||||
const BUILTIN_PAGES = [
|
||||
...BEHAVIOR_PAGES,
|
||||
...SCOPE_PAGES,
|
||||
@@ -59,19 +62,23 @@ function toContribution(spec: PageSpec): SettingsPageContribution {
|
||||
return { id: spec.id, title: spec.title, group: spec.group, order: spec.order, keywords: spec.keywords, component };
|
||||
}
|
||||
|
||||
export function registerBuiltinPages(): () => void {
|
||||
export function registerBuiltinPages(opts: { updates?: boolean } = {}): () => void {
|
||||
const disposeBuiltins = registerSettingsPages(
|
||||
BUILTIN_PAGES.filter((spec) => spec !== UPDATES_PAGE).map(toContribution),
|
||||
);
|
||||
// Code Style › <Language> pages come from the backend's language list, which plugins change.
|
||||
let live = true;
|
||||
let disposeUpdates = () => {};
|
||||
void commands
|
||||
.appBuildInfo()
|
||||
.then((info) => {
|
||||
if (live && info.updates) disposeUpdates = registerSettingsPage(toContribution(UPDATES_PAGE));
|
||||
})
|
||||
.catch(() => {});
|
||||
if (opts.updates !== undefined) {
|
||||
if (opts.updates) disposeUpdates = registerSettingsPage(toContribution(UPDATES_PAGE));
|
||||
} else {
|
||||
void commands
|
||||
.appBuildInfo()
|
||||
.then((info) => {
|
||||
if (live && info.updates) disposeUpdates = registerSettingsPage(toContribution(UPDATES_PAGE));
|
||||
})
|
||||
.catch(() => {});
|
||||
}
|
||||
let disposeLanguagePages = () => {};
|
||||
let generation = 0;
|
||||
const loadLanguagePages = () => {
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
import { BUILD_GROUP } from "./execution";
|
||||
import { lazyPage } from "./lazyPage";
|
||||
import type { PageSpec } from "./spec";
|
||||
|
||||
export { parentPath, splitList } from "./runTargetsPaths";
|
||||
|
||||
const RunTargetsEditor = lazyPage("build.runTargets", () => import("./RunTargetsBody").then((m) => m.RunTargetsEditor));
|
||||
|
||||
export const RUN_TARGET_PAGES: PageSpec[] = [
|
||||
{
|
||||
id: "build.runTargets",
|
||||
title: "Run Targets",
|
||||
group: BUILD_GROUP,
|
||||
order: 364,
|
||||
projectScope: true,
|
||||
keywords: ["ssh", "remote", "target", "run on", "interpreter", "upload", "sync", "docker", "compose", "container"],
|
||||
sections: [
|
||||
{
|
||||
options: [
|
||||
{
|
||||
kind: "custom",
|
||||
label: "Run Targets",
|
||||
keywords: [
|
||||
"SSH configuration",
|
||||
"Project folder on target",
|
||||
"Upload changed project files before each run",
|
||||
"Python interpreter",
|
||||
"Node.js interpreter",
|
||||
"Java executable",
|
||||
"Docker connection",
|
||||
"Image",
|
||||
"Compose files",
|
||||
"Service",
|
||||
"Container folder",
|
||||
"Published ports",
|
||||
"Run options",
|
||||
],
|
||||
component: RunTargetsEditor,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,15 @@
|
||||
/** Parent of a remote path (`~/a` → `~`, `/a` → `/`); null at the top. */
|
||||
export function parentPath(path: string): string | null {
|
||||
const p = path.length > 1 ? path.replace(/\/+$/, "") : path;
|
||||
if (p === "/" || p === "~" || p === "") return null;
|
||||
const i = p.lastIndexOf("/");
|
||||
if (i < 0) return null;
|
||||
return i === 0 ? "/" : p.slice(0, i);
|
||||
}
|
||||
|
||||
/** Settings typed as lists of words (`8000:8000 5678:5678`, `a.yaml; b.yaml`). */
|
||||
export const splitList = (text: string): string[] =>
|
||||
text
|
||||
.split(/[\s,;]+/)
|
||||
.map((s) => s.trim())
|
||||
.filter(Boolean);
|
||||
@@ -0,0 +1,51 @@
|
||||
import { APPEARANCE_GROUP } from "./behavior";
|
||||
import { lazyPage } from "./lazyPage";
|
||||
import type { PageSpec } from "./spec";
|
||||
|
||||
const FileColorsEditor = lazyPage("fileColors", () => import("./ScopesBody").then((m) => m.FileColorsEditor));
|
||||
const ScopesEditor = lazyPage("scopes", () => import("./ScopesBody").then((m) => m.ScopesEditor));
|
||||
|
||||
export const SCOPE_PAGES: PageSpec[] = [
|
||||
{
|
||||
id: "fileColors",
|
||||
title: "File Colors",
|
||||
group: APPEARANCE_GROUP,
|
||||
order: 1.5,
|
||||
projectScope: true,
|
||||
defaultScope: "project",
|
||||
keywords: ["colour", "color", "tab", "background", "tests", "non-project"],
|
||||
sections: [
|
||||
{
|
||||
options: [
|
||||
{ kind: "toggle", key: "fileColors.enabled", label: "Enable file colors" },
|
||||
{ kind: "toggle", key: "fileColors.editorTabs", label: "Use in editor tabs" },
|
||||
{ kind: "toggle", key: "fileColors.projectView", label: "Use in project view" },
|
||||
],
|
||||
},
|
||||
{
|
||||
options: [
|
||||
{
|
||||
kind: "custom",
|
||||
label: "File Colors",
|
||||
keywords: ["Scope", "Color", "Custom", "Hex value"],
|
||||
component: FileColorsEditor,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "scopes",
|
||||
title: "Scopes",
|
||||
group: APPEARANCE_GROUP,
|
||||
order: 1.6,
|
||||
projectScope: true,
|
||||
defaultScope: "project",
|
||||
keywords: ["scope", "file set", "pattern"],
|
||||
sections: [
|
||||
{
|
||||
options: [{ kind: "custom", label: "Scopes", keywords: ["Name", "Pattern"], component: ScopesEditor }],
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,39 @@
|
||||
import { lazyPage } from "./lazyPage";
|
||||
import type { PageSpec } from "./spec";
|
||||
import { TOOLS_GROUP } from "./tools";
|
||||
|
||||
const SshConfigsEditor = lazyPage("tools.sshConfigurations", () => import("./SshBody").then((m) => m.SshConfigsEditor));
|
||||
|
||||
export const SSH_PAGES: PageSpec[] = [
|
||||
{
|
||||
id: "tools.sshConfigurations",
|
||||
title: "SSH Configurations",
|
||||
group: TOOLS_GROUP,
|
||||
order: 603,
|
||||
keywords: ["ssh", "remote", "host", "server", "key pair", "private key", "password", "known_hosts", "agent"],
|
||||
sections: [
|
||||
{
|
||||
options: [
|
||||
{
|
||||
kind: "custom",
|
||||
label: "SSH Configurations",
|
||||
keywords: [
|
||||
"Host",
|
||||
"Port",
|
||||
"User name",
|
||||
"Authentication type",
|
||||
"Private key file",
|
||||
"Password",
|
||||
"Passphrase",
|
||||
"Save password",
|
||||
"Save passphrase",
|
||||
"Test Connection",
|
||||
"OpenSSH config and authentication agent",
|
||||
],
|
||||
component: SshConfigsEditor,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,46 @@
|
||||
import { lazyPage } from "./lazyPage";
|
||||
import type { PageSpec } from "./spec";
|
||||
|
||||
const UpdateStatusRows = lazyPage("general.updates", () => import("./UpdatesBody").then((m) => m.UpdateStatusRows));
|
||||
|
||||
export const UPDATES_PAGE: PageSpec = {
|
||||
id: "general.updates",
|
||||
title: "Updates",
|
||||
order: 3,
|
||||
keywords: ["update", "upgrade", "version", "automatic", "GitHub", "CNB"],
|
||||
sections: [
|
||||
{
|
||||
options: [
|
||||
{
|
||||
kind: "custom",
|
||||
label: "Current version",
|
||||
keywords: ["Last checked", "Check Now"],
|
||||
component: UpdateStatusRows,
|
||||
},
|
||||
{
|
||||
kind: "toggle",
|
||||
key: "general.autoCheckUpdates",
|
||||
label: "Check for updates automatically",
|
||||
hint: "At startup and every 4 hours while OpenIDEA runs. Each new version is announced once per session.",
|
||||
},
|
||||
{
|
||||
kind: "toggle",
|
||||
key: "general.showWhatsNewAfterUpdate",
|
||||
label: "Show What's New after an update",
|
||||
hint: "Opens a page with the release notes when a new version starts. Help › What's New opens it any time.",
|
||||
},
|
||||
{
|
||||
kind: "select",
|
||||
key: "general.updateSource",
|
||||
label: "Update source",
|
||||
hint: "Where updates are downloaded from. If it can't be reached, the other source is tried.",
|
||||
options: [
|
||||
{ value: "auto", label: "Automatic" },
|
||||
{ value: "github", label: "GitHub" },
|
||||
{ value: "cnb", label: "CNB (China mirror)" },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -8,12 +8,13 @@ import { registerActions } from "@/platform/actions";
|
||||
import { logError } from "@/platform/errorLog";
|
||||
import { isImeKey } from "@/platform/ime";
|
||||
import { commands } from "@/platform/ipc";
|
||||
import { loadSettings, useProject } from "@/platform/project";
|
||||
import { restoreRemote } from "@/platform/remote";
|
||||
import { useProject } from "@/platform/project";
|
||||
import { enableRemote } from "@/platform/remote";
|
||||
import { isPopupOpen } from "@/ui";
|
||||
import { settingsActions } from "./actions";
|
||||
import { loadBuiltinPages, unloadBuiltinPages } from "./dialog/LazySettingsDialog";
|
||||
import { NEW_PROJECTS_PAGE, settingsActions } from "./actions";
|
||||
import { loadBuiltinPages, preloadBuiltinRegistry, unloadBuiltinPages } from "./dialog/LazySettingsDialog";
|
||||
import { trackIconThemePages } from "./iconThemePages";
|
||||
import { validateSettings } from "./model/schema";
|
||||
import {
|
||||
closeSettings,
|
||||
openSettings,
|
||||
@@ -53,16 +54,18 @@ export function relaunchSettings(launch: SettingsLaunch | null) {
|
||||
navigate(launch.page);
|
||||
}
|
||||
|
||||
function listenLaunch(): () => void {
|
||||
function listenLaunch(afterInit: Promise<unknown>): () => void {
|
||||
let disposed = false;
|
||||
let off: (() => void) | undefined;
|
||||
void getCurrentWebviewWindow()
|
||||
.listen(LAUNCH_EVENT, () => void takeLaunch().then(relaunchSettings))
|
||||
.then((u) => {
|
||||
.then(async (u) => {
|
||||
if (disposed) return u();
|
||||
off = u;
|
||||
// A page requested before we listened: its event is gone, the launch is not.
|
||||
void takeLaunch().then(relaunchSettings);
|
||||
// A page requested after `window_take_settings_init` read the slot but before `listen`
|
||||
// attached: its event is gone, the launch is not. Apply it after the initial launch settles.
|
||||
await afterInit.catch(() => {});
|
||||
if (!disposed) void takeLaunch().then(relaunchSettings);
|
||||
});
|
||||
return () => {
|
||||
disposed = true;
|
||||
@@ -91,13 +94,53 @@ function installWindowKeys(): () => void {
|
||||
* the parent's project; Cancel / OK / Esc close the window.
|
||||
*/
|
||||
export function activateSettingsWindow(parent: string): () => void {
|
||||
const bootstrap = (async () => {
|
||||
useSettingsDialog.setState({ pagesLoading: true });
|
||||
openSettings(undefined, { globalBase: useSettingsDialog.getState().globalBase });
|
||||
try {
|
||||
const [init] = await Promise.all([commands.windowTakeSettingsInit(), preloadBuiltinRegistry().catch(() => null)]);
|
||||
if (init.remote) enableRemote(init.remote);
|
||||
const globalBase = validateSettings(init.globalSettings);
|
||||
if (init.project) {
|
||||
useProject.setState({ project: init.project, settings: init.project.settings });
|
||||
} else {
|
||||
useProject.setState({ project: null, settings: init.globalSettings });
|
||||
}
|
||||
const launch = init.launch && {
|
||||
page: init.launch.settingsPage ?? undefined,
|
||||
newProjects: init.launch.newProjects,
|
||||
};
|
||||
const targetPage =
|
||||
launch?.page ?? (launch?.newProjects ? NEW_PROJECTS_PAGE : useSettingsDialog.getState().pageId);
|
||||
await loadBuiltinPages({ pageId: targetPage, updates: init.updates }).catch((e) =>
|
||||
logError("cannot register settings pages", e),
|
||||
);
|
||||
relaunchSettings(launch);
|
||||
rebaseSettings(globalBase);
|
||||
if (init.remote) {
|
||||
// Reconcile remote-host settings asynchronously without blocking first paint on SSH.
|
||||
// `rebaseSettings` updates only `base` / `globalBase` and leaves any staged edits intact.
|
||||
void commands
|
||||
.projectCurrent()
|
||||
.then((fresh) => {
|
||||
if (!fresh || !useSettingsDialog.getState().open) return;
|
||||
useProject.setState({ project: fresh, settings: fresh.settings });
|
||||
rebaseSettings(globalBase);
|
||||
})
|
||||
.catch(() => {});
|
||||
}
|
||||
} finally {
|
||||
useSettingsDialog.setState({ pagesLoading: false });
|
||||
}
|
||||
})();
|
||||
bootstrap.catch((e) => logError("settings window startup failed", e));
|
||||
const disposers = [
|
||||
trackRuntimeSettings(),
|
||||
trackIconThemePages(),
|
||||
unloadBuiltinPages,
|
||||
registerActions(settingsActions((page, newProjects) => relaunchSettings({ page, newProjects: !!newProjects }))),
|
||||
installActionProxies(parent),
|
||||
listenLaunch(),
|
||||
listenLaunch(bootstrap),
|
||||
installWindowKeys(),
|
||||
useSettingsDialog.subscribe((s, prev) => {
|
||||
if (prev.open && !s.open) void getCurrentWebviewWindow().close();
|
||||
@@ -108,25 +151,5 @@ export function activateSettingsWindow(parent: string): () => void {
|
||||
}
|
||||
}),
|
||||
];
|
||||
void (async () => {
|
||||
useSettingsDialog.setState({ pagesLoading: true });
|
||||
openSettings();
|
||||
try {
|
||||
const launch = await takeLaunch();
|
||||
relaunchSettings(launch);
|
||||
await Promise.all([
|
||||
loadBuiltinPages().catch((e) => logError("cannot register settings pages", e)),
|
||||
(async () => {
|
||||
await restoreRemote();
|
||||
const project = await commands.projectCurrent().catch(() => null);
|
||||
if (project) useProject.setState({ project, settings: project.settings });
|
||||
else await loadSettings().catch((e) => console.warn("cannot load settings", e));
|
||||
rebaseSettings();
|
||||
})(),
|
||||
]);
|
||||
} finally {
|
||||
useSettingsDialog.setState({ pagesLoading: false });
|
||||
}
|
||||
})().catch((e) => logError("settings window startup failed", e));
|
||||
return () => disposers.reverse().forEach((d) => d());
|
||||
}
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ export { fuzzyMatch, wordMatch } from "./match";
|
||||
export { badgeKind } from "./symbolKind";
|
||||
export { acquirePopup, isPopupOpen } from "./popupState";
|
||||
export * from "./BarButton";
|
||||
export { lazyComponent, lazyWhen, prefetchLazyComponents } from "./lazy";
|
||||
export { lazyComponent, lazyWhen, prefetchLazyComponents, type LazyComponent } from "./lazy";
|
||||
export { Given, T } from "./T";
|
||||
export { selectableText, copyMenuFor, copyText } from "./selectableText";
|
||||
export { selectReadingPane, useSelectionBoundary } from "./useSelectionBoundary";
|
||||
|
||||
+6
-1
@@ -2,13 +2,17 @@ import { useEffect, useState, type ComponentType } from "react";
|
||||
|
||||
const loaders: Array<() => Promise<unknown>> = [];
|
||||
|
||||
export type LazyComponent<P extends object = Record<string, never>> = ComponentType<P> & {
|
||||
preload(): Promise<ComponentType<P>>;
|
||||
};
|
||||
|
||||
/**
|
||||
* A component whose code loads on first render (rendering nothing until then),
|
||||
* so contributions keep heavy views out of the start-up bundle. Deliberately
|
||||
* not `React.lazy`: a suspended boundary is revealed ~300 ms late (React's
|
||||
* fallback throttling), even when the chunk is already there.
|
||||
*/
|
||||
export function lazyComponent<P extends object>(load: () => Promise<ComponentType<P>>): ComponentType<P> {
|
||||
export function lazyComponent<P extends object>(load: () => Promise<ComponentType<P>>): LazyComponent<P> {
|
||||
let loaded: ComponentType<P> | null = null;
|
||||
let pending: Promise<ComponentType<P>> | null = null;
|
||||
const get = () =>
|
||||
@@ -36,6 +40,7 @@ export function lazyComponent<P extends object>(load: () => Promise<ComponentTyp
|
||||
}, [Component]);
|
||||
return Component ? <Component {...props} /> : null;
|
||||
}
|
||||
LazyComponent.preload = get;
|
||||
return LazyComponent;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user