mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-24 09:01:00 -10:00
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
19207f1102 | ||
|
|
51766249f9 | ||
|
|
ff55bcdf9a | ||
|
|
fd6d1d5d0e | ||
|
|
9ad5bad82e |
No files matched your search
@@ -65,6 +65,8 @@ concurrency:
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
CARGO_INCREMENTAL: 0
|
||||
# Line tables keep test backtraces readable and the binaries the build job hands on small.
|
||||
CARGO_PROFILE_DEV_DEBUG: line-tables-only
|
||||
|
||||
jobs:
|
||||
# The languages a pull request can affect: a change to one language's fixture, definition or
|
||||
@@ -132,10 +134,40 @@ jobs:
|
||||
done < files.txt
|
||||
echo "languages=$(emit "$langs")" | tee -a "$GITHUB_OUTPUT"
|
||||
|
||||
smoke:
|
||||
name: Language smoke (${{ matrix.language }})
|
||||
# Builds the smoke test binaries and openidea-server once for every language below.
|
||||
build:
|
||||
name: Build
|
||||
needs: changes
|
||||
if: needs.changes.outputs.languages != '[]'
|
||||
# The tests find the fixtures through the checkout path compiled into them (CARGO_MANIFEST_DIR),
|
||||
# which is the same on every GitHub-hosted runner.
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
shared-key: language-smoke
|
||||
save-if: ${{ github.ref == 'refs/heads/main' }}
|
||||
- run: |
|
||||
set -euo pipefail
|
||||
mkdir -p smoke-bin
|
||||
cargo test --locked -p ide-host --test language_smoke --test project_smoke --no-run --message-format=json \
|
||||
| jq -r 'select(.reason == "compiler-artifact" and .executable != null and .target.kind == ["test"]) | "\(.target.name) \(.executable)"' \
|
||||
| while read -r name exe; do cp "$exe" "smoke-bin/$name"; done
|
||||
cargo build --locked -p ide-host --bin openidea-server
|
||||
cp target/debug/openidea-server smoke-bin/
|
||||
ls -l smoke-bin
|
||||
test -x smoke-bin/language_smoke && test -x smoke-bin/project_smoke
|
||||
# A tar keeps the executable bits, which artifacts drop.
|
||||
tar -cf smoke-bin.tar smoke-bin
|
||||
- uses: actions/upload-artifact@v6
|
||||
with: { name: smoke-bin, path: smoke-bin.tar, retention-days: 1 }
|
||||
|
||||
smoke:
|
||||
name: Language smoke (${{ matrix.language }})
|
||||
needs: [changes, build]
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
@@ -149,11 +181,11 @@ jobs:
|
||||
- run: grep -E '^[A-Z0-9_]+=' .github/tool-versions.env >> "$GITHUB_ENV"
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
with: { components: "rust-analyzer, rustfmt" }
|
||||
# One build cache for every language; main saves it.
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
shared-key: language-smoke
|
||||
save-if: ${{ github.ref == 'refs/heads/main' && matrix.language == 'rust' }}
|
||||
- uses: actions/download-artifact@v6
|
||||
with: { name: smoke-bin }
|
||||
- run: |
|
||||
tar -xf smoke-bin.tar && rm smoke-bin.tar
|
||||
mkdir -p target/debug && mv smoke-bin/openidea-server target/debug/
|
||||
|
||||
- uses: pnpm/action-setup@v4
|
||||
with: { version: 11 }
|
||||
@@ -209,17 +241,20 @@ jobs:
|
||||
- if: matrix.language == 'php'
|
||||
run: npm install --global "intelephense@$INTELEPHENSE"
|
||||
|
||||
- run: cargo test --locked -p ide-host --test language_smoke --no-run
|
||||
- run: cargo test --locked -p ide-host --test language_smoke -- --ignored --exact ${{ matrix.language }}
|
||||
# The binaries from the build job, run from the crate directory as `cargo test` does.
|
||||
- working-directory: crates/ide-host
|
||||
run: ../../smoke-bin/language_smoke --ignored --exact ${{ matrix.language }}
|
||||
- if: matrix.language == 'java'
|
||||
run: cargo test --locked -p ide-host --test project_smoke -- --ignored --exact maven_sync jdk maven_launch_classpath_uses_the_runner_jdk_classifier
|
||||
working-directory: crates/ide-host
|
||||
run: ../../smoke-bin/project_smoke --ignored --exact maven_sync jdk maven_launch_classpath_uses_the_runner_jdk_classifier
|
||||
- if: matrix.language == 'kotlin'
|
||||
run: cargo test --locked -p ide-host --test project_smoke -- --ignored --exact gradle_sync
|
||||
working-directory: crates/ide-host
|
||||
run: ../../smoke-bin/project_smoke --ignored --exact gradle_sync
|
||||
- if: matrix.language == 'python'
|
||||
run: cargo test --locked -p ide-host --test project_smoke -- --ignored --exact python_venv
|
||||
working-directory: crates/ide-host
|
||||
run: ../../smoke-bin/project_smoke --ignored --exact python_venv
|
||||
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- run: cargo build --locked -p ide-host --bin openidea-server
|
||||
- run: pnpm smoke smoke/run.test.ts -t "^${{ matrix.language }}$"
|
||||
- run: pnpm smoke smoke/debug.test.ts -t "^${{ matrix.language }}$"
|
||||
# The IDE installs the debugger from GitHub releases: authenticated, against rate limits.
|
||||
|
||||
@@ -430,6 +430,53 @@ test("Git Log puts affected changes on the changed-files toolbar and groups prev
|
||||
await expect(notes).toBeVisible();
|
||||
});
|
||||
|
||||
test("Git Log file selection stays in place and opens a diff on activation", async ({ workbench: page }) => {
|
||||
await page.clock.install();
|
||||
await page.evaluate(() => {
|
||||
window.__ipc.handlers.vcs_commit_files = () =>
|
||||
Array.from({ length: 30 }, (_, index) => ({
|
||||
path: `src/change-${String(index).padStart(2, "0")}.ts`,
|
||||
kind: "modified",
|
||||
oldPath: null,
|
||||
}));
|
||||
});
|
||||
await page.getByRole("listbox", { name: "Commits" }).getByRole("option").first().click();
|
||||
const tree = page.getByRole("tree", { name: "Changed files" });
|
||||
const first = tree.getByRole("treeitem", { name: "change-10.ts" });
|
||||
const second = tree.getByRole("treeitem", { name: "change-11.ts" });
|
||||
const firstDiff = page.getByRole("tab", { name: /^change-10\.ts/ });
|
||||
const secondDiff = page.getByRole("tab", { name: /^change-11\.ts/ });
|
||||
|
||||
await tree.evaluate((el) => (el.scrollTop = 24 * 11));
|
||||
await expect(first).toBeInViewport({ ratio: 1 });
|
||||
await expect(second).toBeInViewport({ ratio: 1 });
|
||||
const scrollTop = () => tree.evaluate((el) => el.scrollTop);
|
||||
const initialScroll = await scrollTop();
|
||||
await first.click();
|
||||
await page.clock.runFor(150);
|
||||
await expect(first).toHaveAttribute("aria-selected", "true");
|
||||
await expect(firstDiff).toHaveCount(0);
|
||||
expect(await scrollTop()).toBe(initialScroll);
|
||||
|
||||
await first.dblclick();
|
||||
await expect(firstDiff).toHaveAttribute("aria-selected", "true");
|
||||
expect(await scrollTop()).toBe(initialScroll);
|
||||
|
||||
await second.click();
|
||||
await expect(secondDiff).toHaveAttribute("aria-selected", "true");
|
||||
await expect(firstDiff).toHaveCount(0);
|
||||
await expect(second).toHaveAttribute("aria-selected", "true");
|
||||
expect(await scrollTop()).toBe(initialScroll);
|
||||
|
||||
await secondDiff.dblclick(); // Keep the preview tab open.
|
||||
await first.click();
|
||||
await page.clock.runFor(150);
|
||||
await expect(firstDiff).toHaveCount(0);
|
||||
await expect(secondDiff).toHaveAttribute("aria-selected", "true");
|
||||
await tree.press("Enter");
|
||||
await expect(firstDiff).toHaveAttribute("aria-selected", "true");
|
||||
});
|
||||
|
||||
test("Not Cherry-Picked Commits dims other rows while keeping unpicked commits readable", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
|
||||
@@ -679,3 +679,111 @@ test("Docker Compose dashboard shows per-service resource usage and named projec
|
||||
});
|
||||
await expect(detail).toContainText("27.40%", { timeout: 5000 });
|
||||
});
|
||||
|
||||
test("Docker Compose dashboard keeps its action row pinned when scrolling", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 1200, height: 640 });
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(async () => {
|
||||
const containers = Array.from({ length: 10 }, (_, idx) => {
|
||||
const n = idx + 1;
|
||||
return {
|
||||
id: `runner-${n}`,
|
||||
name: `selfhost-github-runner-${n}`,
|
||||
image: "myoung34/github-runner:latest",
|
||||
command: "./bin/Runner.Listener run",
|
||||
state: "running",
|
||||
status: "Up 24 hours",
|
||||
ports: "",
|
||||
createdAt: "2026-11-22T20:00:00Z",
|
||||
composeProject: "selfhost",
|
||||
composeService: `github-runner-${n}`,
|
||||
composeWorkingDir: "/work/selfhost",
|
||||
composeFiles: ["/work/selfhost/docker-compose.yml"],
|
||||
mounts: [],
|
||||
networks: ["selfhost_default"],
|
||||
};
|
||||
});
|
||||
const snapshot = {
|
||||
availability: { kind: "ready", clientVersion: "28.0.1", serverVersion: "28.0.1", context: "desktop-linux" },
|
||||
executable: "/usr/bin/docker",
|
||||
containers,
|
||||
images: [],
|
||||
volumes: [],
|
||||
networks: [],
|
||||
errors: [],
|
||||
};
|
||||
window.__ipc.handlers.docker_settings = () => ({
|
||||
connections: [{ id: "default", name: "Docker", endpoint: { kind: "default" } }],
|
||||
registries: [],
|
||||
});
|
||||
window.__ipc.handlers.docker_snapshot = () => snapshot;
|
||||
window.__ipc.handlers.docker_events = () => new Promise(() => {});
|
||||
window.__ipc.handlers.docker_inspect = () => "[]";
|
||||
window.__ipc.handlers.docker_container_stats = () => ({
|
||||
cpuPerc: "0.04%",
|
||||
memUsage: "99.85MiB / 114.3GiB",
|
||||
memPerc: "0.09%",
|
||||
netIo: "1.1MB / 3.75MB",
|
||||
blockIo: "0B / 213kB",
|
||||
pids: "15",
|
||||
});
|
||||
|
||||
const storeMod = "/src/features/services/store.ts";
|
||||
const treeMod = "/src/features/services/tree.ts";
|
||||
const { useServices } = await import(/* @vite-ignore */ storeMod);
|
||||
const { useServicesTree } = await import(/* @vite-ignore */ treeMod);
|
||||
useServices.setState({
|
||||
settings: { connections: [{ id: "default", name: "Docker", endpoint: { kind: "default" } }], registries: [] },
|
||||
conns: { default: { snapshot, loading: false, error: null } },
|
||||
});
|
||||
useServicesTree.setState({
|
||||
expanded: new Set(["docker:default"]),
|
||||
selectedKey: "docker:default:compose:selfhost",
|
||||
selectedKeys: new Set(["docker:default:compose:selfhost"]),
|
||||
});
|
||||
});
|
||||
|
||||
await page.keyboard.press("Meta+8");
|
||||
const services = page.getByRole("region", { name: "Services", exact: true });
|
||||
const detail = services.locator("[data-panel][id=services-detail]");
|
||||
const startBtn = detail.getByRole("button", { name: "Start", exact: true });
|
||||
const stopBtn = detail.getByRole("button", { name: "Stop", exact: true });
|
||||
const restartBtn = detail.getByRole("button", { name: "Restart", exact: true });
|
||||
const downBtn = detail.getByRole("button", { name: "Compose Down", exact: true });
|
||||
await expect(downBtn).toBeVisible();
|
||||
|
||||
const beforeStart = (await startBtn.boundingBox())!;
|
||||
const beforeDown = (await downBtn.boundingBox())!;
|
||||
const beforeBanner = (await detail.getByText("Compose project 'selfhost'").boundingBox())!;
|
||||
|
||||
const scrollState = await detail.evaluate((panel) => {
|
||||
const scrollers = Array.from(panel.querySelectorAll<HTMLElement>("*")).filter((el) => {
|
||||
const cs = getComputedStyle(el);
|
||||
return (cs.overflowY === "auto" || cs.overflowY === "scroll") && el.scrollHeight - el.clientHeight > 2;
|
||||
});
|
||||
scrollers[0]!.scrollTop = 160;
|
||||
return {
|
||||
scrollerCount: scrollers.length,
|
||||
scrollTop: scrollers[0]!.scrollTop,
|
||||
scrollerTop: scrollers[0]!.getBoundingClientRect().top,
|
||||
};
|
||||
});
|
||||
|
||||
expect(scrollState.scrollerCount).toBe(1);
|
||||
expect(scrollState.scrollTop).toBeGreaterThan(100);
|
||||
// The scroll container starts strictly below the pinned action row.
|
||||
expect(scrollState.scrollerTop).toBeGreaterThanOrEqual(beforeDown.y + beforeDown.height);
|
||||
|
||||
await expect(startBtn).toBeVisible();
|
||||
await expect(stopBtn).toBeVisible();
|
||||
await expect(restartBtn).toBeVisible();
|
||||
await expect(downBtn).toBeVisible();
|
||||
|
||||
const afterStart = (await startBtn.boundingBox())!;
|
||||
const afterDown = (await downBtn.boundingBox())!;
|
||||
const afterBanner = (await detail.getByText("Compose project 'selfhost'").boundingBox())!;
|
||||
|
||||
expect(afterStart.y).toBe(beforeStart.y);
|
||||
expect(afterDown.y).toBe(beforeDown.y);
|
||||
expect(afterBanner.y).toBeLessThan(beforeBanner.y - 100);
|
||||
});
|
||||
@@ -2171,8 +2171,10 @@ export class EditorController implements SlotHost {
|
||||
return this.removeGuarded((s) => closeKey(s, key));
|
||||
}
|
||||
|
||||
activeInput(): EditorInput | null {
|
||||
return this.activeTabOf()?.input ?? null;
|
||||
activeInput(options?: { previewOnly?: boolean }): EditorInput | null {
|
||||
const tab = this.activeTabOf();
|
||||
if (options?.previewOnly && (!tab?.preview || !editorPrefs().tabs.previewTab)) return null;
|
||||
return tab?.input ?? null;
|
||||
}
|
||||
|
||||
onActiveInputChange(fn: (input: EditorInput | null) => void): () => void {
|
||||
|
||||
@@ -58,7 +58,7 @@ export function activate(): void | (() => void) {
|
||||
onOpenTabsChange: (fn) => useTabs.subscribe(fn),
|
||||
openTabs: () => ctrl.openTabs(),
|
||||
tabInput: (paneId, tabId) => ctrl.tabInput(paneId, tabId),
|
||||
activeInput: () => ctrl.activeInput(),
|
||||
activeInput: (options) => ctrl.activeInput(options),
|
||||
onActiveInputChange: (fn) => ctrl.onActiveInputChange(fn),
|
||||
closePath: (path) => ctrl.closePath(path),
|
||||
closeInput: (key) => ctrl.closeInput(key),
|
||||
|
||||
@@ -408,6 +408,8 @@
|
||||
|
||||
.reply {
|
||||
position: relative;
|
||||
/* Keep WebKit's selection gap fill from extending across reply boundaries. */
|
||||
transform: translateX(0);
|
||||
}
|
||||
.replyFooter {
|
||||
position: absolute;
|
||||
|
||||
@@ -96,6 +96,7 @@
|
||||
}
|
||||
.detailPane {
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
@@ -235,6 +236,7 @@
|
||||
user-select: text;
|
||||
}
|
||||
.dashboardActions {
|
||||
flex: none;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
@@ -254,6 +256,10 @@
|
||||
border-top: 1px solid var(--border);
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
.dashboard > .sectionBanner:first-child,
|
||||
.dashboardActions + .sectionBanner {
|
||||
border-top: 0;
|
||||
}
|
||||
.propList {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
+138
-136
@@ -1888,7 +1888,7 @@ export function ComposeProjectDashboard({
|
||||
const { byId: activeStats, loading: statsLoading } = useLiveContainerStats(conn, runningIdsKey);
|
||||
|
||||
return (
|
||||
<div className={styles.dashboard} tabIndex={0} onKeyDown={copySelectionOnKeyDown}>
|
||||
<div className={styles.detailBody}>
|
||||
<div className={styles.dashboardActions}>
|
||||
<OpButton busy={busy === "start"} disabled={!canStart(target)} onClick={() => void start(target)}>
|
||||
Start
|
||||
@@ -1904,144 +1904,146 @@ export function ComposeProjectDashboard({
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<SectionBanner>{txTemplate(`Compose project '${project}'`)}</SectionBanner>
|
||||
<div className={styles.propList}>
|
||||
<PropRow label={<T>Project</T>}>
|
||||
<span className={styles.mono}>{project}</span>
|
||||
</PropRow>
|
||||
<PropRow label={<T>Status</T>}>
|
||||
<span>
|
||||
{runningCount}/{containers.length} running
|
||||
</span>
|
||||
</PropRow>
|
||||
<PropRow label={<T>Working directory</T>} hidden={!first?.composeWorkingDir}>
|
||||
<span className={styles.mono}>{first?.composeWorkingDir}</span>
|
||||
</PropRow>
|
||||
<PropRow label={<T>Compose files</T>} hidden={!first?.composeFiles.length}>
|
||||
<span className={styles.inlineRow}>
|
||||
{first?.composeFiles.map((file) => (
|
||||
<button
|
||||
key={file}
|
||||
type="button"
|
||||
className={styles.link}
|
||||
onClick={() => void openComposeFile(file, first.composeWorkingDir)}
|
||||
>
|
||||
<span className={styles.mono}>{file}</span>
|
||||
</button>
|
||||
))}
|
||||
</span>
|
||||
</PropRow>
|
||||
</div>
|
||||
<div className={styles.dashboard} tabIndex={0} onKeyDown={copySelectionOnKeyDown}>
|
||||
<SectionBanner>{txTemplate(`Compose project '${project}'`)}</SectionBanner>
|
||||
<div className={styles.propList}>
|
||||
<PropRow label={<T>Project</T>}>
|
||||
<span className={styles.mono}>{project}</span>
|
||||
</PropRow>
|
||||
<PropRow label={<T>Status</T>}>
|
||||
<span>
|
||||
{runningCount}/{containers.length} running
|
||||
</span>
|
||||
</PropRow>
|
||||
<PropRow label={<T>Working directory</T>} hidden={!first?.composeWorkingDir}>
|
||||
<span className={styles.mono}>{first?.composeWorkingDir}</span>
|
||||
</PropRow>
|
||||
<PropRow label={<T>Compose files</T>} hidden={!first?.composeFiles.length}>
|
||||
<span className={styles.inlineRow}>
|
||||
{first?.composeFiles.map((file) => (
|
||||
<button
|
||||
key={file}
|
||||
type="button"
|
||||
className={styles.link}
|
||||
onClick={() => void openComposeFile(file, first.composeWorkingDir)}
|
||||
>
|
||||
<span className={styles.mono}>{file}</span>
|
||||
</button>
|
||||
))}
|
||||
</span>
|
||||
</PropRow>
|
||||
</div>
|
||||
|
||||
<SectionBanner>
|
||||
<T>Services</T>
|
||||
</SectionBanner>
|
||||
<div className={styles.composeTableWrap}>
|
||||
<table className={clsx(styles.gridTable, styles.composeServicesTable)}>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<T>Service</T>
|
||||
</th>
|
||||
<th>
|
||||
<T>Status</T>
|
||||
</th>
|
||||
<th>
|
||||
<T>CPU</T>
|
||||
</th>
|
||||
<th>
|
||||
<T>Memory</T>
|
||||
</th>
|
||||
<th>
|
||||
<T>Network I/O</T>
|
||||
</th>
|
||||
<th>
|
||||
<T>Block I/O</T>
|
||||
</th>
|
||||
<th>
|
||||
<T>PIDs</T>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{containers.map((c) => {
|
||||
const running = isRunning(c);
|
||||
const stats = running ? activeStats[c.id] : undefined;
|
||||
const cpuPct = stats ? parsePercent(stats.cpuPerc) : 0;
|
||||
const memPair = stats ? parseUsagePair(stats.memUsage) : null;
|
||||
const memPct = memPair ? memPair.percent : stats ? parsePercent(stats.memPerc) : 0;
|
||||
return (
|
||||
<tr key={c.id}>
|
||||
<td className={styles.composeServiceCell}>
|
||||
<button type="button" className={styles.link} onClick={() => selectContainerInTree(conn, c)}>
|
||||
<span className={clsx(styles.statusDot, running ? styles.dotOk : styles.dotMuted)} />
|
||||
<span className={styles.mono}>{c.name}</span>
|
||||
</button>
|
||||
{c.composeService && !c.name.includes(c.composeService) && (
|
||||
<span className={styles.mutedMeta}>{c.composeService}</span>
|
||||
)}
|
||||
</td>
|
||||
<td className={styles.nowrapCell}>
|
||||
<StatusBadge state={c.state} text={c.status || c.state} />
|
||||
</td>
|
||||
<td className={styles.composeMetricCell}>
|
||||
{stats ? (
|
||||
<div className={styles.composeMetric}>
|
||||
<span className={styles.mono}>{stats.cpuPerc}</span>
|
||||
<LineProgress percent={cpuPct} />
|
||||
</div>
|
||||
) : running && statsLoading ? (
|
||||
<Spinner size={12} />
|
||||
) : (
|
||||
<span className={styles.mutedMeta}>—</span>
|
||||
)}
|
||||
</td>
|
||||
<td className={styles.composeMemoryCell}>
|
||||
{stats ? (
|
||||
<div className={styles.composeMetric}>
|
||||
<span className={styles.mono}>
|
||||
{stats.memUsage} ({stats.memPerc})
|
||||
<SectionBanner>
|
||||
<T>Services</T>
|
||||
</SectionBanner>
|
||||
<div className={styles.composeTableWrap}>
|
||||
<table className={clsx(styles.gridTable, styles.composeServicesTable)}>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<T>Service</T>
|
||||
</th>
|
||||
<th>
|
||||
<T>Status</T>
|
||||
</th>
|
||||
<th>
|
||||
<T>CPU</T>
|
||||
</th>
|
||||
<th>
|
||||
<T>Memory</T>
|
||||
</th>
|
||||
<th>
|
||||
<T>Network I/O</T>
|
||||
</th>
|
||||
<th>
|
||||
<T>Block I/O</T>
|
||||
</th>
|
||||
<th>
|
||||
<T>PIDs</T>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{containers.map((c) => {
|
||||
const running = isRunning(c);
|
||||
const stats = running ? activeStats[c.id] : undefined;
|
||||
const cpuPct = stats ? parsePercent(stats.cpuPerc) : 0;
|
||||
const memPair = stats ? parseUsagePair(stats.memUsage) : null;
|
||||
const memPct = memPair ? memPair.percent : stats ? parsePercent(stats.memPerc) : 0;
|
||||
return (
|
||||
<tr key={c.id}>
|
||||
<td className={styles.composeServiceCell}>
|
||||
<button type="button" className={styles.link} onClick={() => selectContainerInTree(conn, c)}>
|
||||
<span className={clsx(styles.statusDot, running ? styles.dotOk : styles.dotMuted)} />
|
||||
<span className={styles.mono}>{c.name}</span>
|
||||
</button>
|
||||
{c.composeService && !c.name.includes(c.composeService) && (
|
||||
<span className={styles.mutedMeta}>{c.composeService}</span>
|
||||
)}
|
||||
</td>
|
||||
<td className={styles.nowrapCell}>
|
||||
<StatusBadge state={c.state} text={c.status || c.state} />
|
||||
</td>
|
||||
<td className={styles.composeMetricCell}>
|
||||
{stats ? (
|
||||
<div className={styles.composeMetric}>
|
||||
<span className={styles.mono}>{stats.cpuPerc}</span>
|
||||
<LineProgress percent={cpuPct} />
|
||||
</div>
|
||||
) : running && statsLoading ? (
|
||||
<Spinner size={12} />
|
||||
) : (
|
||||
<span className={styles.mutedMeta}>—</span>
|
||||
)}
|
||||
</td>
|
||||
<td className={styles.composeMemoryCell}>
|
||||
{stats ? (
|
||||
<div className={styles.composeMetric}>
|
||||
<span className={styles.mono}>
|
||||
{stats.memUsage} ({stats.memPerc})
|
||||
</span>
|
||||
<LineProgress percent={memPct} />
|
||||
</div>
|
||||
) : running && statsLoading ? (
|
||||
<span className={styles.mutedMeta}>
|
||||
<T>Loading…</T>
|
||||
</span>
|
||||
<LineProgress percent={memPct} />
|
||||
</div>
|
||||
) : running && statsLoading ? (
|
||||
<span className={styles.mutedMeta}>
|
||||
<T>Loading…</T>
|
||||
</span>
|
||||
) : (
|
||||
<span className={styles.mutedMeta}>—</span>
|
||||
)}
|
||||
</td>
|
||||
<td className={clsx(styles.mono, styles.nowrapCell)}>
|
||||
{stats?.netIo || <span className={styles.mutedMeta}>—</span>}
|
||||
</td>
|
||||
<td className={clsx(styles.mono, styles.nowrapCell)}>
|
||||
{stats?.blockIo || <span className={styles.mutedMeta}>—</span>}
|
||||
</td>
|
||||
<td className={clsx(styles.mono, styles.nowrapCell)}>
|
||||
{stats?.pids || <span className={styles.mutedMeta}>—</span>}
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
) : (
|
||||
<span className={styles.mutedMeta}>—</span>
|
||||
)}
|
||||
</td>
|
||||
<td className={clsx(styles.mono, styles.nowrapCell)}>
|
||||
{stats?.netIo || <span className={styles.mutedMeta}>—</span>}
|
||||
</td>
|
||||
<td className={clsx(styles.mono, styles.nowrapCell)}>
|
||||
{stats?.blockIo || <span className={styles.mutedMeta}>—</span>}
|
||||
</td>
|
||||
<td className={clsx(styles.mono, styles.nowrapCell)}>
|
||||
{stats?.pids || <span className={styles.mutedMeta}>—</span>}
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<SectionBanner>
|
||||
<T>Volumes</T>
|
||||
</SectionBanner>
|
||||
{namedVolumes.length > 0 ? (
|
||||
<div className={styles.chipGroup}>
|
||||
{namedVolumes.map((v) => (
|
||||
<VolumeLinkChip key={v.name} conn={conn} volume={v} />
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<div className={styles.emptySection}>
|
||||
<T>No named volumes</T>
|
||||
</div>
|
||||
)}
|
||||
<SectionBanner>
|
||||
<T>Volumes</T>
|
||||
</SectionBanner>
|
||||
{namedVolumes.length > 0 ? (
|
||||
<div className={styles.chipGroup}>
|
||||
{namedVolumes.map((v) => (
|
||||
<VolumeLinkChip key={v.name} conn={conn} volume={v} />
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<div className={styles.emptySection}>
|
||||
<T>No named volumes</T>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -21,18 +21,20 @@ import {
|
||||
type TreeHandle,
|
||||
} from "@/ui";
|
||||
import { maybeEditorService, type EditorInput } from "@/workbench/contributions";
|
||||
import { useToolWindowLayout } from "@/workbench/toolwindows/store";
|
||||
import clsx from "clsx";
|
||||
import {
|
||||
useCallback,
|
||||
useContext,
|
||||
useEffect,
|
||||
useEffectEvent,
|
||||
useLayoutEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
type MouseEvent as ReactMouseEvent,
|
||||
} from "react";
|
||||
import { DIFF_KIND, diffInput, vcsDiffInFront } from "../diffInput";
|
||||
import { DIFF_KIND, diffInput } from "../diffInput";
|
||||
import { buildFileTree, dirKeys, type FileTreeNode } from "../fileTree";
|
||||
import styles from "../GitLog.module.css";
|
||||
import {
|
||||
@@ -213,29 +215,28 @@ export function CommitDetails({ commits, fileHistory = false }: { commits: Commi
|
||||
const ordered = useMemo(() => filesUnder(tree), [tree]);
|
||||
const chosenChanges = useMemo(() => filesUnder(tree, selectedKeys), [tree, selectedKeys]);
|
||||
|
||||
// Show Diff Preview: a single selected file follows into the editor's preview tab.
|
||||
// Selection updates an open preview. Double-click, Enter and Show Diff open it.
|
||||
const previewTimer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);
|
||||
useEffect(() => {
|
||||
if (!active) clearTimeout(previewTimer.current);
|
||||
return () => clearTimeout(previewTimer.current);
|
||||
}, [active]);
|
||||
useEffect(() => () => clearTimeout(previewTimer.current), [active, diffLocation, ordered, preview]);
|
||||
const previewSelection = (sel: ReadonlySet<string>) => {
|
||||
clearTimeout(previewTimer.current);
|
||||
if (syncingDiff.current || sel.size !== 1) return;
|
||||
// While the editor shows one of this pane's diffs, the selection walks it along (a click or
|
||||
// arrow key), as in the Commit window.
|
||||
const shown = maybeEditorService()?.activeInput?.();
|
||||
const following = shown?.kind === DIFF_KIND && ordered.some((c) => diffInput(c.diff).key === shown.key);
|
||||
if (!following && (!logOptions().diffPreview || logOptions().diffLocation !== "editor" || vcsDiffInFront())) return;
|
||||
if (!active || !preview || diffLocation !== "editor" || syncingDiff.current || sel.size !== 1) return;
|
||||
const editor = maybeEditorService();
|
||||
const shown = editor?.activeInput?.({ previewOnly: true });
|
||||
if (shown?.kind !== DIFF_KIND || !ordered.some((c) => diffInput(c.diff).key === shown.key)) return;
|
||||
const file = fileNodeAt(tree, [...sel][0]!)?.file;
|
||||
// A preview that cannot open (no editor yet, the file went away) is just skipped.
|
||||
if (file)
|
||||
previewTimer.current = setTimeout(() => void showChangesDiff([file], true).catch(() => undefined), PREVIEW_DELAY);
|
||||
if (!file || diffInput(file.diff).key === shown.key) return;
|
||||
previewTimer.current = setTimeout(() => {
|
||||
if (!useToolWindowLayout.getState().maximized && editor?.activeInput?.({ previewOnly: true })?.key === shown.key)
|
||||
void showChangesDiff([file], true, ordered).catch(() => undefined);
|
||||
}, PREVIEW_DELAY);
|
||||
};
|
||||
|
||||
// Follow only this pane's exact diff (path AND revisions); another commit or
|
||||
// Compare with Local must not move its selection. Never take focus from F7.
|
||||
const isOnlySelected = useEffectEvent((key: string) => selectedKeys.size === 1 && selectedKeys.has(key));
|
||||
useEffect(() => {
|
||||
if (!active) return;
|
||||
const editor = maybeEditorService();
|
||||
const followDiff = (input: EditorInput | null) => {
|
||||
if (input?.kind !== DIFF_KIND) return;
|
||||
@@ -243,16 +244,19 @@ export function CommitDetails({ commits, fileHistory = false }: { commits: Commi
|
||||
if (!change) return;
|
||||
clearTimeout(previewTimer.current);
|
||||
const rel = changeTreePath(change);
|
||||
const key = `f:${rel}`;
|
||||
// The tree already selected this row. Revealing it would scroll it to the center.
|
||||
if (isOnlySelected(key)) return;
|
||||
setExpanded((current) => {
|
||||
const next = new Set(current ?? allDirs);
|
||||
for (const key of allDirs) if (rel.startsWith(key.slice(2) + "/")) next.add(key);
|
||||
return next;
|
||||
});
|
||||
setDiffToReveal({ key: `f:${rel}` });
|
||||
setDiffToReveal({ key });
|
||||
};
|
||||
followDiff(editor?.activeInput?.() ?? null);
|
||||
return editor?.onActiveInputChange?.(followDiff);
|
||||
}, [ordered, allDirs, changeTreePath]);
|
||||
}, [active, ordered, allDirs, changeTreePath]);
|
||||
|
||||
// Tree.reveal needs the expanded rows to have rendered. Suppress the reverse
|
||||
// preview update so it cannot reopen the diff and lose its requested chunk.
|
||||
@@ -440,7 +444,10 @@ export function CommitDetails({ commits, fileHistory = false }: { commits: Commi
|
||||
previewSelection(sel);
|
||||
}}
|
||||
renderNode={(n) => <ChangedFileRow node={n} flat={!groupByDirectory} />}
|
||||
onActivate={(n) => n.file && void showChangesDiff([n.file])}
|
||||
onActivate={(n) => {
|
||||
clearTimeout(previewTimer.current);
|
||||
if (n.file) void showChangesDiff([n.file]);
|
||||
}}
|
||||
onJumpToSource={(n, sel) => {
|
||||
const files = sel.has(n.key) ? filesUnder(tree, sel) : filesUnder([n]);
|
||||
void executeAction("vcs.log.changes.jumpToSource", files);
|
||||
|
||||
@@ -34,7 +34,7 @@ export interface LogOptions {
|
||||
showBranches: boolean;
|
||||
/** Changed files grouped by directory (else a flat list). */
|
||||
groupByDirectory: boolean;
|
||||
/** Selecting a changed file shows its diff in the editor's preview tab. */
|
||||
/** Selecting a changed file updates the embedded preview or an open editor preview. */
|
||||
diffPreview: boolean;
|
||||
/** Changed files show how many lines the commit added and deleted. */
|
||||
showLineStats: boolean;
|
||||
|
||||
@@ -770,8 +770,8 @@ export interface EditorService {
|
||||
openTabs?(): OpenEditorTab[];
|
||||
/** Input of the tab `tabId` in pane `paneId` (dragging tabs between views), null if there is none. */
|
||||
tabInput?(paneId: string, tabId: string): EditorInput | null;
|
||||
/** Input of the active tab (any kind), if any. */
|
||||
activeInput?(): EditorInput | null;
|
||||
/** Input of the active tab, optionally restricted to the replaceable preview tab. */
|
||||
activeInput?(options?: { previewOnly?: boolean }): EditorInput | null;
|
||||
/** Calls `fn` whenever the active tab changes; returns the unsubscribe. */
|
||||
onActiveInputChange?(fn: (input: EditorInput | null) => void): () => void;
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user