Files
Netcatty/components/terminalTopTabsTheme.ts
T
陈大猫andCursor ae209d37c1 feat(terminal): remote command history side panel (#1385)
* feat(terminal): add remote command history side panel

Read remote shell history over SSH/ET/Mosh exec channels, browse it in a virtualized side panel with search, paste, and save-as-snippet actions. Closes #1381.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(history): expand command detail inline below selected row

Move the detail strip from a fixed slot above the list into the row
immediately below the clicked entry so expansion reads top-to-bottom.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(history): filter Netcatty AI PTY commands from remote history

Drop shell history lines containing the __NCMCP_ marker so AI exec noise
does not clutter the command history panel.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(history): tighten detail strip and add run action

Size the expanded row to its content, add a run-in-terminal button, and
use clearer snippet icon/tooltip for save-as-snippet.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(history): address review findings before merge

Key cache by host+session, retry Mosh pending reads, and clamp virtual
list scroll position when filtered items shrink.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-10 23:19:31 +08:00

61 lines
1.6 KiB
TypeScript

import { collectSessionIds } from "../domain/workspace";
import type { Workspace } from "../types";
export type TopTabsSidePanelTab = "sftp" | "scripts" | "history" | "theme" | "ai" | null;
type ScopedTopTabsThemeInput = {
activeSidePanelTab: TopTabsSidePanelTab;
activeThemePreviewId: string | null;
activeWorkspace: Workspace | null | undefined;
followAppTerminalTheme: boolean;
isVisible: boolean;
previewTargetSessionId: string | null;
previewedOrVisibleThemeId: string;
resolveSessionThemeId: (sessionId: string) => string | null;
};
export function getScopedTopTabsThemeId({
activeSidePanelTab,
activeThemePreviewId,
activeWorkspace,
followAppTerminalTheme,
isVisible,
previewTargetSessionId,
previewedOrVisibleThemeId,
resolveSessionThemeId,
}: ScopedTopTabsThemeInput): string | null {
if (activeSidePanelTab === "theme" && previewTargetSessionId && activeThemePreviewId) {
return activeThemePreviewId;
}
if (!isVisible || followAppTerminalTheme) {
return null;
}
if (!activeWorkspace) {
return previewedOrVisibleThemeId;
}
if (activeWorkspace.viewMode === "focus") {
return null;
}
const sessionIds = collectSessionIds(activeWorkspace.root);
if (sessionIds.length < 2) return null;
let firstThemeId: string | null = null;
for (const sessionId of sessionIds) {
const themeId = resolveSessionThemeId(sessionId);
if (!themeId) continue;
if (firstThemeId == null) {
firstThemeId = themeId;
continue;
}
if (themeId !== firstThemeId) {
return previewedOrVisibleThemeId;
}
}
return null;
}