feat(remote-dev): distinguish remote windows and project switcher entries

Add a corner server badge on remote project avatars and a tinted SSH / WSL / Dev Container host chip in ProjectPopup, RecentList and Welcome Projects while keeping row fill reserved for selection. Show the server icon on the connected Remote Host status bar label and colour the disconnected label in --warning without a filled background.
Цей коміт міститься в:
Deng Liu committed 2026-11-27 10:20:10 -08:00
1 джерело d31a22b5dd
коміт f08b6ef044
10 files changed
+187 -19

No files matched your search

+3
Переглянути файл
@@ -50,6 +50,9 @@ test("project switcher keeps names and metadata on separate lines and highlights
);
const remote = popup.getByRole("option", { name: /Payment Ledger/ });
await expect(remote.locator("[data-remote-badge]")).toHaveCount(1);
await expect(remote.locator('[data-remote-kind="ssh"]')).toBeVisible();
await expect(local.locator("[data-remote-badge]")).toHaveCount(0);
await expectBelow(remote, "Payment Ledger", HOST);
await expectBelow(remote, HOST, REMOTE_PATH);
+1
Переглянути файл
@@ -88,4 +88,5 @@
display: inline-flex;
align-items: center;
gap: var(--space-1);
color: var(--warning);
}
+1
Переглянути файл
@@ -61,6 +61,7 @@ export function RemoteStatus() {
]);
}}
>
<Icon name="remote" size={13} />
{label}
</BarButton>
);
+14
Переглянути файл
@@ -5,6 +5,7 @@ import type { HostMetrics, RemoteSession } from "@/platform/ipc";
import { useProject } from "@/platform/project";
import { disableRemote, enableRemote, useRemote } from "@/platform/remote";
import { RemoteResources, RemoteResourcesDashboard } from "./RemoteResources";
import { RemoteStatus } from "./RemoteStatus";
import {
compactResourceText,
diskUsedBytes,
@@ -235,4 +236,17 @@ describe("remote resources widget and dashboard", () => {
await act(async () => inflight);
expect(useRemoteResources.getState().metrics).toBeNull();
});
it("renders a server icon on the Remote Host status bar label and highlights disconnected text in warning tone", () => {
act(() => enableRemote(sshSession("deng@thinkpad")));
const { rerender } = render(<RemoteStatus />);
const connected = screen.getByRole("button", { name: "SSH: deng@thinkpad" });
expect(connected.querySelector("svg")).not.toBeNull();
expect(connected.querySelector('[class*="lost"]')).toBeNull();
act(() => useRemote.setState({ lost: "deng@thinkpad" }));
rerender(<RemoteStatus />);
const disconnected = screen.getByRole("button", { name: "SSH: deng@thinkpad (disconnected)" });
expect(disconnected.querySelector('[class*="lost"]')).not.toBeNull();
});
});
+26
Переглянути файл
@@ -73,6 +73,32 @@ describe("ProjectPopup", () => {
expect(text.indexOf("datahub-front")).toBeLessThan(text.indexOf("Recent Projects"));
expect(text.indexOf("Recent Projects")).toBeLessThan(text.indexOf("other"));
expect(within(list).getAllByText("FastAPIProject")).toHaveLength(1);
const remoteRow = within(list).getByText("FastAPIProject").closest('[role="option"]')!;
expect(remoteRow.querySelector("[data-remote-badge]")).not.toBeNull();
expect(remoteRow.querySelector('[data-remote-kind="wsl"]')?.textContent).toContain("WSL");
});
it("leaves local project avatars and rows free of remote badges", async () => {
open = [
{ name: "same-name", root: "/home/me/same-name", current: false, remote: { kind: "ssh", config: "devbox" } },
{ name: "same-name", root: "/Users/me/same-name", current: true, remote: null },
];
groups = [];
recent = [];
const anchor = createRef<HTMLButtonElement>();
render(
<>
<button ref={anchor} />
<ProjectPopup anchor={anchor} onClose={() => {}} />
</>,
);
await screen.findByText("Open Projects");
const rows = screen.getAllByRole("option").filter((r) => r.textContent?.includes("same-name"));
expect(rows).toHaveLength(2);
expect(rows[0]!.querySelector("[data-remote-badge]")).not.toBeNull();
expect(rows[0]!.querySelector('[data-remote-kind="ssh"]')?.textContent).toContain("SSH");
expect(rows[1]!.querySelector("[data-remote-badge]")).toBeNull();
expect(rows[1]!.querySelector("[data-remote-kind]")).toBeNull();
});
it("lists recent projects under the Welcome screen's groups, collapsed or not, then the ungrouped ones", async () => {
+12 -13
Переглянути файл
@@ -4,7 +4,15 @@ import { executeAction, useActions } from "@/platform/actions";
import { call, commands, isTauri, type OpenProject, type RecentProject } from "@/platform/ipc";
import { HighlightedText, Icon, Popup, showContextMenu, type IconName, T } from "@/ui";
import type { ProjectPopupProps } from "@/workbench/contributions";
import { askRemoveRecent, ProjectBadge, projectAppearanceMenu, recentMenu, unavailableTitle } from "./RecentList";
import {
askRemoveRecent,
ProjectBadge,
projectAppearanceMenu,
recentMenu,
RemoteHostPill,
splitRemoteMatch,
unavailableTitle,
} from "./RecentList";
import { filterRecent, loadRecent, openRecent, recentRows, useRecent, type RecentMatch } from "./recent";
import styles from "./ProjectPopup.module.css";
import { tx } from "@/platform/i18n";
@@ -231,11 +239,7 @@ function GroupBoundary({
}
function ProjectRow({ m, active }: { m: RecentMatch; active: boolean }) {
const { remote, pathMatch } = m;
const pathStart = remote ? remote.host.length + 1 : 0;
const hostMatch = remote && pathMatch ? pathMatch.filter((i) => i < remote.host.length) : null;
const locationMatch =
remote && pathMatch ? pathMatch.filter((i) => i >= pathStart).map((i) => i - pathStart) : pathMatch;
const { hostMatch, locationMatch, locationText } = splitRemoteMatch(m);
return (
<>
@@ -252,13 +256,8 @@ function ProjectRow({ m, active }: { m: RecentMatch; active: boolean }) {
indices={m.nameMatch}
tone={active ? "accent" : "strong"}
/>
{remote && (
<span className={styles.metadata}>
<Icon name="terminal" size={12} />
<HighlightedText className={styles.ellipsis} text={remote.host} indices={hostMatch} />
</span>
)}
<HighlightedText className={styles.path} text={remote?.path ?? m.displayPath} indices={locationMatch} />
{m.remote && <RemoteHostPill remote={m.remote} hostMatch={hostMatch} />}
<HighlightedText className={styles.path} text={locationText} indices={locationMatch} />
{m.project.branch && (
<span className={styles.metadata}>
<Icon name="branch" size={12} />
+14 -2
Переглянути файл
@@ -21,7 +21,15 @@ import {
showContextMenu,
T,
} from "@/ui";
import { askRemoveRecent, groupMenu, ProjectBadge, recentMenu, unavailableTitle } from "./RecentList";
import {
askRemoveRecent,
groupMenu,
ProjectBadge,
recentMenu,
RemoteHostPill,
splitRemoteMatch,
unavailableTitle,
} from "./RecentList";
import { openRecent, recentRows, setGroupExpanded, useRecent, type RecentMatch, type RecentRow } from "./recent";
import { projectWindowOverride } from "@/workbench/projectWindow";
import type { RecentProjectGroup } from "@/platform/ipc";
@@ -263,6 +271,7 @@ function ProjectRow({
const stage = progress
? tx(stageLabel(progress.stage)) + (progress.fraction == null ? "" : ` ${Math.round(progress.fraction * 100)}%`)
: null;
const { hostMatch, locationMatch, locationText } = splitRemoteMatch(m);
const ref = useRef<HTMLDivElement>(null);
useEffect(() => {
if (selected) ref.current?.scrollIntoView?.({ block: "nearest" });
@@ -304,7 +313,10 @@ function ProjectRow({
{stage}
</span>
) : (
<HighlightedText className={styles.projectPath} text={m.displayPath} indices={m.pathMatch} />
<>
{m.remote && <RemoteHostPill remote={m.remote} hostMatch={hostMatch} />}
<HighlightedText className={styles.projectPath} text={locationText} indices={locationMatch} />
</>
)}
{m.project.branch && (
<span className={styles.projectBranch}>
+43 -2
Переглянути файл
@@ -68,13 +68,52 @@ export function ProjectBadge({
missing?: boolean;
}) {
useSyncExternalStore(subscribeTabColors, tabColorsVersion);
const remote = Boolean(parseRemoteLocation(path));
return (
<span
className={clsx(styles.tile, missing && styles.tileMissing, className)}
className={clsx(styles.tile, remote && styles.tileRemote, missing && styles.tileMissing, className)}
style={tabColorVars(name, tabColorOverride(path))}
data-remote-badge={remote ? "" : undefined}
aria-hidden
>
<ProjectAvatar name={name} root={path} />
{remote && (
<i className={styles.remoteCorner} aria-hidden="true">
<Icon name="remote" size={8} />
</i>
)}
</span>
);
}
/** Splits `pathMatch` of a remote `host:path` display string into host and path highlight indices. */
export function splitRemoteMatch(m: Pick<RecentMatch, "remote" | "pathMatch" | "displayPath">) {
const { remote, pathMatch } = m;
if (!remote) return { hostMatch: null, locationMatch: pathMatch, locationText: m.displayPath };
const pathStart = remote.host.length + 1;
return {
hostMatch: pathMatch ? pathMatch.filter((i) => i < remote.host.length) : null,
locationMatch: pathMatch ? pathMatch.filter((i) => i >= pathStart).map((i) => i - pathStart) : null,
locationText: remote.path,
};
}
/** Tinted SSH / WSL / Dev Container host pill shown on remote project rows. */
export function RemoteHostPill({
remote,
hostMatch,
}: {
remote: NonNullable<RecentMatch["remote"]>;
hostMatch: number[] | null;
}) {
return (
<span className={styles.remoteHostPill} data-remote-kind={remote.kind}>
<Icon name="remote" size={11} />
<strong className={styles.remoteKind}>{remote.kindLabel}</strong>
<span className={styles.remoteDot} aria-hidden="true">
·
</span>
<HighlightedText className={styles.remoteHostText} text={remote.host} indices={hostMatch} />
</span>
);
}
@@ -245,6 +284,7 @@ function RecentRow({
}) {
const opening = useRecent((s) => s.opening === m.project.path);
const when = relativeTime(m.project.openedAtMs);
const { hostMatch, locationMatch, locationText } = splitRemoteMatch(m);
return (
<div className={styles.recent} title={unavailableTitle(m.project)}>
<ProjectBadge name={m.project.name} path={m.project.path} missing={!!m.project.missing} />
@@ -263,7 +303,8 @@ function RecentRow({
</span>
)}
</span>
<HighlightedText className={styles.recentPath} text={m.displayPath} indices={m.pathMatch} />
{m.remote && <RemoteHostPill remote={m.remote} hostMatch={hostMatch} />}
<HighlightedText className={styles.recentPath} text={locationText} indices={locationMatch} />
</span>
{opening ? (
<Spinner size={14} />
+63
Переглянути файл
@@ -215,6 +215,69 @@
height: 32px;
margin-top: var(--space-0-5);
font-size: var(--fs-ui);
--remote-badge-ring: var(--bg-island);
}
.tileRemote {
position: relative;
overflow: visible;
}
.remoteCorner {
position: absolute;
right: -3px;
bottom: -3px;
width: 12px;
height: 12px;
border-radius: 3.5px;
background: var(--accent);
color: var(--fg-on-accent);
--icon-color: currentColor;
border: 1.5px solid var(--remote-badge-ring, var(--bg-popup));
display: inline-flex;
align-items: center;
justify-content: center;
font-style: normal;
pointer-events: none;
}
.projectBadge .remoteCorner {
width: 14px;
height: 14px;
border-radius: 4px;
}
.remoteHostPill {
display: inline-flex;
align-items: center;
align-self: flex-start;
gap: var(--space-1);
max-width: 100%;
min-width: 0;
padding: 1px 6px;
border-radius: var(--radius-toolbar-button);
background: color-mix(in srgb, var(--accent) 14%, transparent);
box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 28%, transparent);
color: var(--link);
--icon-color: currentColor;
font-size: var(--fs-tiny);
line-height: 15px;
}
:global(:root[data-theme="light"]) .remoteHostPill {
background: color-mix(in srgb, var(--accent) 11%, transparent);
box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 25%, transparent);
color: var(--accent);
}
.remoteKind {
flex: none;
font-weight: 600;
letter-spacing: 0.02em;
}
.remoteDot {
flex: none;
opacity: 0.65;
}
.remoteHostText {
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
/* A project group: one line, folds its projects. */
.group {
+10 -2
Переглянути файл
@@ -92,12 +92,20 @@ function withRemotes(local: RecentProject[]): RecentProject[] {
return [...local, ...remote].sort((a, b) => (b.openedAtMs ?? 0) - (a.openedAtMs ?? 0));
}
function remoteDetails(location: string): { host: string; path: string } | null {
const REMOTE_KIND_LABEL: Record<RemoteTarget["kind"], string> = {
ssh: "SSH",
wsl: "WSL",
devContainer: "Dev Container",
};
function remoteDetails(
location: string,
): { kind: RemoteTarget["kind"]; kindLabel: string; host: string; path: string } | null {
const r = parseRemoteLocation(location);
if (!r) return null;
const host =
recentRemotes().find((x) => sameTarget(x.target, r.target) && x.path === r.path)?.host || targetName(r.target);
return { host, path: r.path };
return { kind: r.target.kind, kindLabel: REMOTE_KIND_LABEL[r.target.kind], host, path: r.path };
}
export async function removeRecent(path: string) {