дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-03 16:51:16 +02:00
A truncated element with a long data-tooltip put that text in the tooltip's shortcut slot (nowrap, keys font), which overflowed the bubble and crushed the main text to one character per line, as on the Remote Host Resources status item. The tooltip now shows such text as a wrapping note separate from the shortcut and honours data-no-tooltip up to the tooltip owner. The remote status items opt out of the redundant ellipsis tooltip and ellipsize their labels, and the breadcrumbs yield space first in the status bar. Co-authored-by: dengliu <[email protected]>
71 рядки
2.5 KiB
TypeScript
71 рядки
2.5 KiB
TypeScript
import { executeAction } from "@/platform/actions";
|
|
import { tx } from "@/platform/i18n";
|
|
import type { RemoteSession } from "@/platform/ipc";
|
|
import { useRemote } from "@/platform/remote";
|
|
import { BarButton, Icon, showContextMenu, Spinner } from "@/ui";
|
|
import { canMonitorRemoteHost } from "./resources";
|
|
import styles from "./RemoteDev.module.css";
|
|
|
|
const BADGE: Record<RemoteSession["target"]["kind"], string> = {
|
|
ssh: "SSH",
|
|
wsl: "WSL",
|
|
devContainer: "Dev Container",
|
|
};
|
|
|
|
/** Status bar label of a remote window: where its project runs. */
|
|
export function remoteBadge(session: Pick<RemoteSession, "target" | "host">): string {
|
|
return `${BADGE[session.target.kind]}: ${session.host}`;
|
|
}
|
|
|
|
export function RemoteStatus() {
|
|
const session = useRemote((s) => s.session);
|
|
const lost = useRemote((s) => s.lost !== null);
|
|
const takenOver = useRemote((s) => s.takenOver);
|
|
const reconnecting = useRemote((s) => s.reconnecting);
|
|
if (!session) return null;
|
|
const label = remoteBadge(session);
|
|
if (lost)
|
|
return (
|
|
<BarButton
|
|
data-no-tooltip=""
|
|
tooltip={
|
|
reconnecting
|
|
? tx`Reconnecting to ${session.host}…`
|
|
: takenOver
|
|
? tx("Another window took over this remote session")
|
|
: tx`Lost the connection to ${session.host}. Click to reconnect.`
|
|
}
|
|
aria-label={tx`${label} (disconnected)`}
|
|
disabled={reconnecting}
|
|
onClick={() => void executeAction("remote.reconnect")}
|
|
>
|
|
<span className={styles.lost}>
|
|
{reconnecting ? <Spinner size={10} /> : <Icon name="warning" size={13} />}
|
|
<span className={styles.statusLabel}>{label}</span>
|
|
</span>
|
|
</BarButton>
|
|
);
|
|
return (
|
|
<BarButton
|
|
data-no-tooltip=""
|
|
tooltip={tx`Project runs on ${label}`}
|
|
aria-label={label}
|
|
onClick={() => void executeAction("remote.connect")}
|
|
onContextMenu={(e) => {
|
|
e.preventDefault();
|
|
showContextMenu(e, [
|
|
{ kind: "action", action: "remote.connect" },
|
|
...(canMonitorRemoteHost(session) ? [{ kind: "action" as const, action: "remote.showResources" }] : []),
|
|
{ kind: "action", action: "remote.reloadEnvironment" },
|
|
{ kind: "separator" },
|
|
{ kind: "action", action: "remote.disconnect" },
|
|
{ kind: "action", action: "remote.stopBackend" },
|
|
]);
|
|
}}
|
|
>
|
|
<Icon name="remote" size={13} />
|
|
<span className={styles.statusLabel}>{label}</span>
|
|
</BarButton>
|
|
);
|
|
}
|