mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-17 04:50:52 +00:00
* fix(#2725): automated Cursor CLI fix * fix(ui): keep Quick Switcher open for host context menu clicks Portaled ContextMenuContent lives outside containerRef, so outside mousedown was closing the switcher before Connect/Edit host could run. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: netcatty-bot <308658023+netcatty-bot@users.noreply.github.com> Co-authored-by: bincxz <16399091+binaricat@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com>
81 lines
2.6 KiB
TypeScript
81 lines
2.6 KiB
TypeScript
import React from 'react';
|
|
|
|
import type { useI18n } from '../../application/i18n/I18nProvider';
|
|
import type { Host, TerminalSession } from '../../types';
|
|
import { ContextMenuContent, ContextMenuItem } from '../ui/context-menu';
|
|
|
|
type TranslateFn = ReturnType<typeof useI18n>['t'];
|
|
|
|
interface SessionTabContextMenuContentProps {
|
|
sessionId: string;
|
|
onCloseSession: (sessionId: string) => void;
|
|
onCopySession?: (sessionId: string) => void;
|
|
onCopySessionToNewWindow?: (sessionId: string) => void;
|
|
onDetachSession?: (sessionId: string) => void;
|
|
onReconnectSession: (sessionId: string) => void;
|
|
sessionStatus: TerminalSession['status'];
|
|
onRenameSession: (sessionId: string) => void;
|
|
/** Vault host for this session; omit edit when missing (e.g. local shell). */
|
|
editHost?: Host;
|
|
onEditHost?: (host: Host) => void;
|
|
renderBulkCloseItems?: (anchorId: string) => React.ReactNode;
|
|
t: TranslateFn;
|
|
}
|
|
|
|
export function SessionTabContextMenuContent({
|
|
sessionId,
|
|
onCloseSession,
|
|
onCopySession,
|
|
onCopySessionToNewWindow,
|
|
onDetachSession,
|
|
onReconnectSession,
|
|
sessionStatus,
|
|
onRenameSession,
|
|
editHost,
|
|
onEditHost,
|
|
renderBulkCloseItems,
|
|
t,
|
|
}: SessionTabContextMenuContentProps) {
|
|
return (
|
|
<ContextMenuContent>
|
|
<ContextMenuItem
|
|
disabled={isSessionReconnectDisabled(sessionStatus)}
|
|
onClick={() => onReconnectSession(sessionId)}
|
|
>
|
|
{t('terminal.menu.reconnect')}
|
|
</ContextMenuItem>
|
|
<ContextMenuItem onClick={() => onRenameSession(sessionId)}>
|
|
{t('common.rename')}
|
|
</ContextMenuItem>
|
|
{editHost && onEditHost && (
|
|
<ContextMenuItem onClick={() => onEditHost(editHost)}>
|
|
{t('terminal.layer.hostTree.editHost')}
|
|
</ContextMenuItem>
|
|
)}
|
|
{onCopySession && (
|
|
<ContextMenuItem onClick={() => onCopySession(sessionId)}>
|
|
{t('tabs.copyTab')}
|
|
</ContextMenuItem>
|
|
)}
|
|
{onCopySessionToNewWindow && (
|
|
<ContextMenuItem onClick={() => onCopySessionToNewWindow(sessionId)}>
|
|
{t('tabs.copyTabToNewWindow')}
|
|
</ContextMenuItem>
|
|
)}
|
|
{onDetachSession && (
|
|
<ContextMenuItem onClick={() => onDetachSession(sessionId)}>
|
|
{t('terminal.menu.detach')}
|
|
</ContextMenuItem>
|
|
)}
|
|
<ContextMenuItem className="text-destructive" onClick={() => onCloseSession(sessionId)}>
|
|
{t('common.close')}
|
|
</ContextMenuItem>
|
|
{renderBulkCloseItems?.(sessionId)}
|
|
</ContextMenuContent>
|
|
);
|
|
}
|
|
|
|
export const isSessionReconnectDisabled = (status: TerminalSession['status']): boolean => (
|
|
status === 'connecting'
|
|
);
|