diff --git a/e2e/remoteResources.spec.ts b/e2e/remoteResources.spec.ts
index 87a898419..ca8fc7a17 100644
--- a/e2e/remoteResources.spec.ts
+++ b/e2e/remoteResources.spec.ts
@@ -109,6 +109,18 @@ test("shows compact remote CPU+RAM pill beside SSH status and opens detailed das
await expect(pill).toBeVisible();
await expect(pill).toContainText("22% · 5.8G");
+ // Hovering the pill (even on a narrow window) renders a single clean horizontal tooltip, never a vertical char stack.
+ await page.setViewportSize({ width: 480, height: 700 });
+ await pill.hover();
+ const tooltip = page.getByRole("tooltip");
+ await expect(tooltip).toBeVisible();
+ await expect(tooltip).toContainText("CPU 22% · Memory 5.8 GB / 16 GB");
+ await expect(tooltip).not.toContainText("22% · 5.8GCPU");
+ const tipBox = (await tooltip.boundingBox())!;
+ expect(tipBox.height).toBeLessThan(80);
+ expect(tipBox.x + tipBox.width).toBeLessThanOrEqual(480);
+ await page.setViewportSize({ width: 1280, height: 720 });
+
// Sits immediately to the right of the Remote Host status bar item.
const leftOrder = await statusBar
.locator(":scope > [data-status-item]")
diff --git a/src/features/remote-dev/RemoteDev.module.css b/src/features/remote-dev/RemoteDev.module.css
index 7a07349ad..1b738f603 100644
--- a/src/features/remote-dev/RemoteDev.module.css
+++ b/src/features/remote-dev/RemoteDev.module.css
@@ -88,5 +88,11 @@
display: inline-flex;
align-items: center;
gap: var(--space-1);
+ min-width: 0;
color: var(--warning);
}
+.statusLabel {
+ min-width: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
diff --git a/src/features/remote-dev/RemoteResources.module.css b/src/features/remote-dev/RemoteResources.module.css
index 44af8d89b..6f60d80a0 100644
--- a/src/features/remote-dev/RemoteResources.module.css
+++ b/src/features/remote-dev/RemoteResources.module.css
@@ -48,6 +48,9 @@
}
.pillText {
+ min-width: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
font-size: var(--fs-small);
}
diff --git a/src/features/remote-dev/RemoteResources.tsx b/src/features/remote-dev/RemoteResources.tsx
index 9cf3b11d6..445a8c41b 100644
--- a/src/features/remote-dev/RemoteResources.tsx
+++ b/src/features/remote-dev/RemoteResources.tsx
@@ -120,6 +120,7 @@ export function RemoteResources() {
pressure.level === "warn" && styles.levelWarn,
pressure.level === "danger" && styles.levelDanger,
)}
+ data-no-tooltip=""
aria-haspopup="dialog"
aria-expanded={open}
aria-label={tx`Remote host resources: ${tooltip}`}
diff --git a/src/features/remote-dev/RemoteStatus.tsx b/src/features/remote-dev/RemoteStatus.tsx
index 2915dbaf5..d04caaf24 100644
--- a/src/features/remote-dev/RemoteStatus.tsx
+++ b/src/features/remote-dev/RemoteStatus.tsx
@@ -27,6 +27,7 @@ export function RemoteStatus() {
if (lost)
return (
{reconnecting ? : }
- {label}
+ {label}
);
return (
void executeAction("remote.connect")}
@@ -62,7 +64,7 @@ export function RemoteStatus() {
}}
>
- {label}
+ {label}
);
}
diff --git a/src/ui/Tooltip.module.css b/src/ui/Tooltip.module.css
index 033f45e8c..40c60c8e2 100644
--- a/src/ui/Tooltip.module.css
+++ b/src/ui/Tooltip.module.css
@@ -22,10 +22,20 @@
transition: opacity var(--dur-fast) var(--ease);
}
/* Long paths wrap inside the bubble; the shortcut stays on one line. */
+.withNote {
+ flex-wrap: wrap;
+ align-items: baseline;
+ row-gap: var(--space-0-5);
+}
.text {
min-width: 0;
overflow-wrap: anywhere;
}
+.note {
+ min-width: 0;
+ color: color-mix(in srgb, var(--fg-tooltip) 68%, transparent);
+ overflow-wrap: anywhere;
+}
.shortcut {
font-family: var(--font-keys);
font-size: var(--fs-ui);
@@ -43,6 +53,7 @@
box-shadow: var(--shadow-stripe-tooltip, var(--shadow-tooltip));
line-height: 18px;
}
+.stripe .note,
.stripe .shortcut {
color: color-mix(in srgb, var(--fg-stripe-tooltip, var(--fg-tooltip)) 80%, transparent);
}
diff --git a/src/ui/Tooltip.test.tsx b/src/ui/Tooltip.test.tsx
index bf11767a3..8da10c396 100644
--- a/src/ui/Tooltip.test.tsx
+++ b/src/ui/Tooltip.test.tsx
@@ -180,7 +180,41 @@ it("shows a tab's cut-off title whole, with the tab's own tooltip beside it", ()
act(() => {
vi.advanceTimersByTime(TOOLTIP_DELAY);
});
- expect(screen.getByRole("tooltip").textContent).toBe("历史记录: PscPrinted.js/repo/src/history/PscPrinted.js");
+ const tip = screen.getByRole("tooltip");
+ expect(tip.textContent).toBe("历史记录: PscPrinted.js/repo/src/history/PscPrinted.js");
+ expect(tip).toHaveClass(styles.withNote!);
+ expect(tip.querySelector(`.${styles.note!}`)?.textContent).toBe("/repo/src/history/PscPrinted.js");
+ expect(tip.querySelector(`.${styles.shortcut!}`)).toBeNull();
+ cleanup();
+ vi.useRealTimers();
+});
+
+it("respects data-no-tooltip on a tooltip owner so truncated children show only the owner's own tooltip", () => {
+ vi.useFakeTimers();
+ render(
+ <>
+
+
+ >,
+ );
+ const pillText = screen.getByTestId("pill-text");
+ Object.defineProperty(pillText, "scrollWidth", { configurable: true, value: 120 });
+ Object.defineProperty(pillText, "clientWidth", { configurable: true, value: 60 });
+ fireEvent.pointerOver(pillText);
+ act(() => {
+ vi.advanceTimersByTime(TOOLTIP_DELAY);
+ });
+ const tip = screen.getByRole("tooltip");
+ expect(tip.textContent).toBe("CPU 1.8% · Memory 2.4 GB / 56 GB · RTT 128 ms");
+ expect(tip.querySelector(`.${styles.note!}`)).toBeNull();
cleanup();
vi.useRealTimers();
});
diff --git a/src/ui/Tooltip.tsx b/src/ui/Tooltip.tsx
index e6c477cbb..1d9c28a90 100644
--- a/src/ui/Tooltip.tsx
+++ b/src/ui/Tooltip.tsx
@@ -30,31 +30,41 @@ const TRUNCATED_DEPTH = 4;
/** The element whose text is cut off with an ellipsis around `node`, up to `stop`, if any. */
function truncatedText(node: Element | null, stop: Element | null): HTMLElement | null {
+ if (stop?.hasAttribute("data-no-tooltip")) return null;
+ let found: HTMLElement | null = null;
for (let el = node, depth = 0; el instanceof HTMLElement && depth < TRUNCATED_DEPTH; el = el.parentElement, depth++) {
// A native tooltip shows instead, or the element opts out of auto-ellipsis tooltips.
if (el.hasAttribute("title") || el.hasAttribute("data-no-tooltip")) return null;
- if (isTruncated(el)) return el;
+ if (!found && isTruncated(el)) found = el;
if (el === stop) break;
}
- return null;
+ return found;
}
const isTruncated = (el: HTMLElement) =>
el.scrollWidth > el.clientWidth && getComputedStyle(el).textOverflow === "ellipsis" && !!el.textContent?.trim();
+interface TooltipContent {
+ text: string;
+ note?: string;
+ shortcut?: string;
+}
+
/**
* What the tooltip of `el` shows: its own text, and the whole of `cut`'s text while that is
* cut off (with its own text beside it, when that says something else).
*/
-function tooltipText(el: HTMLElement, cut: HTMLElement | null): { text: string; note?: string } | undefined {
+function tooltipText(el: HTMLElement, cut: HTMLElement | null): TooltipContent | undefined {
const own = el.dataset.tooltipVerbatim === undefined ? tx(el.dataset.tooltip) : el.dataset.tooltip;
+ const shortcut = el.dataset.tooltipShortcut;
const whole = cut?.isConnected && isTruncated(cut) ? cut.textContent!.trim().replace(/\s+/g, " ") : undefined;
- if (!whole) return own ? { text: own, note: el.dataset.tooltipShortcut } : undefined;
- return { text: whole, note: own && !own.includes(whole) ? own : undefined };
+ if (!whole) return own ? { text: own, shortcut } : undefined;
+ return { text: whole, note: own && !own.includes(whole) ? own : undefined, shortcut };
}
interface Shown {
text: string;
+ note?: string;
shortcut?: string;
x: number;
y: number;
@@ -88,7 +98,8 @@ export function TooltipHost() {
const stripe = el.dataset.tooltipStripe;
setShown({
text: shows.text,
- shortcut: shows.note,
+ note: shows.note,
+ shortcut: shows.shortcut,
x: -9999,
y: -9999,
placed: false,
@@ -168,11 +179,12 @@ export function TooltipHost() {
{shown.text}
+ {shown.note && {shown.note}}
{shown.shortcut && {shown.shortcut}}
,
document.body,
diff --git a/src/workbench/StatusBar.module.css b/src/workbench/StatusBar.module.css
index 57536c07a..4bbfc0d00 100644
--- a/src/workbench/StatusBar.module.css
+++ b/src/workbench/StatusBar.module.css
@@ -34,6 +34,7 @@
overflow: hidden;
}
.shrink[data-status-item="editor.breadcrumbs"]:not(:empty) {
+ flex-shrink: 1000;
min-width: min(152px, 28vw);
}
.shrink > * {