mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-21 16:03:46 +00:00
perf(startup): load DiffEditor, the Run console and the file-revision chooser on demand (#3544)
DiffWindow, the Services detail pane and Compare with Revision imported these statically, which kept their chunks in the startup set despite lazy imports elsewhere. They now load on demand; initial JS drops by about 34 KB gzip. Co-authored-by: Mr0Bread <55754540+Mr0Bread@users.noreply.github.com>
This commit is contained in:
@@ -13,7 +13,7 @@ import type { RunConfig } from "@/platform/ipc";
|
||||
import { useProject } from "@/platform/project";
|
||||
import { projectLocation, useRemote } from "@/platform/remote";
|
||||
import { tx, useT, useTxTemplate } from "@/platform/i18n";
|
||||
import { Button, EmptyState, T, showContextMenu } from "@/ui";
|
||||
import { Button, EmptyState, T, lazyComponent, showContextMenu } from "@/ui";
|
||||
import type { MenuItem } from "@/ui";
|
||||
import {
|
||||
toolWindowService,
|
||||
@@ -29,7 +29,6 @@ import {
|
||||
import { pickServices } from "./serviceImport";
|
||||
import { CATEGORY_ORDER, categoryOf, commandLine, configIcon, KIND_OPTIONS, kindLabel } from "./configs";
|
||||
import { openUrl } from "./navigate";
|
||||
import { SessionPanel } from "./RunView";
|
||||
import { showApplicationUpdate } from "./applicationUpdate";
|
||||
import { isUpdatable } from "./updatePolicies";
|
||||
import {
|
||||
@@ -64,6 +63,8 @@ import {
|
||||
} from "./serviceOrder";
|
||||
import styles from "./RunServices.module.css";
|
||||
|
||||
const SessionPanel = lazyComponent(() => import("./RunView").then((m) => m.SessionPanel));
|
||||
|
||||
export const RUN_PROVIDER = "runConfigurations";
|
||||
const TYPE_PREFIX = "run:type:";
|
||||
const CONFIG_PREFIX = "run:config:";
|
||||
|
||||
@@ -231,7 +231,7 @@ it("shows the owning Run output for attached debugging and routes the controls t
|
||||
useDebugRunSessions.setState({ serviceSessions: [d] });
|
||||
render(<ServicesTreeView />);
|
||||
select();
|
||||
expect(screen.getByRole("log")).toHaveTextContent("Maven application log");
|
||||
expect(await screen.findByRole("log")).toHaveTextContent("Maven application log");
|
||||
// The console strip keeps only console controls: the window toolbar owns Run / Debug / Stop.
|
||||
const strip = within(screen.getByRole("toolbar", { name: "Run actions" }));
|
||||
expect(strip.queryByRole("button", { name: "Rerun" })).toBeNull();
|
||||
|
||||
@@ -18,18 +18,19 @@ import { projectFolder, useProject } from "@/platform/project";
|
||||
import { installDiffWindowSave } from "./diffWindowSave";
|
||||
import { restoreRemote } from "@/platform/remote";
|
||||
import { usePlatform } from "@/platform/platformInfo";
|
||||
import { Spinner, T, isPopupOpen } from "@/ui";
|
||||
import { Spinner, T, isPopupOpen, lazyComponent } from "@/ui";
|
||||
import { ask, showError } from "@/workbench/messages";
|
||||
import { editorService, notifications, provideEditorService, type OpenOptions } from "@/workbench/contributions";
|
||||
import { OverlayHost } from "@/workbench/OverlayHost";
|
||||
import { TitleBar } from "@/workbench/TitleBar";
|
||||
import { WindowResizeHandles } from "@/workbench/WindowResizeHandles";
|
||||
import { useApplyTheme, windowBackgroundHex } from "@/workbench/theme";
|
||||
import { DiffEditor } from "./DiffEditor";
|
||||
import { DIFF_KIND, diffInput, diffTitle, openDiff, type DiffData, type DiffSide } from "./diffInput";
|
||||
import { refreshNow, useVcs } from "./store";
|
||||
import styles from "./common.module.css";
|
||||
|
||||
const DiffEditor = lazyComponent(() => import("./DiffEditor").then((m) => m.DiffEditor));
|
||||
|
||||
/** Opens `path` in the project window's editor (DiffEditor's "Jump to Source"). */
|
||||
const OPEN_SOURCE = "openidea://diff/open-source";
|
||||
/** Opens a diff in an editor tab of the project window (IDEA's "Show Diff in Editor Tab"). */
|
||||
|
||||
@@ -65,7 +65,6 @@ import { tx } from "@/platform/i18n";
|
||||
|
||||
import { addToIgnore } from "./ignore";
|
||||
import { hasFileHistory, showCurrentRevision, trackFileHistory } from "./fileRevisions";
|
||||
import { compareWithFileRevision } from "./FileRevisionChooser";
|
||||
|
||||
const VCS = "vcsAvailable";
|
||||
const IN_COMMIT_WINDOW = "vcsAvailable && activeToolWindow == commit";
|
||||
@@ -496,7 +495,10 @@ export function registerVcsActions(): () => void {
|
||||
icon: "diff",
|
||||
when: VCS,
|
||||
enabled: ({ arg }) => hasFileHistory(argPath(arg) ?? maybeEditorService()?.activePath()),
|
||||
run: ({ arg }) => compareWithFileRevision(argPath(arg) ?? maybeEditorService()?.activePath()),
|
||||
run: ({ arg }) => {
|
||||
const path = argPath(arg) ?? maybeEditorService()?.activePath();
|
||||
void import("./FileRevisionChooser").then((m) => m.compareWithFileRevision(path));
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "vcs.nextChange",
|
||||
|
||||
Reference in New Issue
Block a user