diff --git a/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/TabPane.tsx b/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/TabPane.tsx
index 8e82a2d5289..3710403f134 100644
--- a/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/TabPane.tsx
+++ b/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/TabPane.tsx
@@ -123,7 +123,7 @@ export function TabPane({
onMoveToNewTab={onMoveToNewTab}
>
-
+
diff --git a/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/Terminal.tsx b/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/Terminal.tsx
index cdc27f69ad1..ff62fe478d5 100644
--- a/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/Terminal.tsx
+++ b/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/Terminal.tsx
@@ -46,13 +46,11 @@ import { TerminalSearch } from "./TerminalSearch";
import type { TerminalProps, TerminalStreamEvent } from "./types";
import { scrollToBottom, shellEscapePaths } from "./utils";
-export const Terminal = ({ tabId, workspaceId }: TerminalProps) => {
- const paneId = tabId;
+export const Terminal = ({ paneId, tabId, workspaceId }: TerminalProps) => {
const pane = useTabsStore((s) => s.panes[paneId]);
const paneInitialCommands = pane?.initialCommands;
const paneInitialCwd = pane?.initialCwd;
const clearPaneInitialData = useTabsStore((s) => s.clearPaneInitialData);
- const parentTabId = pane?.tabId;
const terminalRef = useRef(null);
const xtermRef = useRef(null);
const fitAddonRef = useRef(null);
@@ -69,9 +67,7 @@ export const Terminal = ({ tabId, workspaceId }: TerminalProps) => {
const [xtermInstance, setXtermInstance] = useState(null);
const setFocusedPane = useTabsStore((s) => s.setFocusedPane);
const setTabAutoTitle = useTabsStore((s) => s.setTabAutoTitle);
- const focusedPaneId = useTabsStore(
- (s) => s.focusedPaneIds[pane?.tabId ?? ""],
- );
+ const focusedPaneId = useTabsStore((s) => s.focusedPaneIds[tabId]);
const terminalTheme = useTerminalTheme();
const restartTerminalRef = useRef<() => void>(() => {});
@@ -142,9 +138,6 @@ export const Terminal = ({ tabId, workspaceId }: TerminalProps) => {
) => void
>(() => {});
- const parentTabIdRef = useRef(parentTabId);
- parentTabIdRef.current = parentTabId;
-
const setTabAutoTitleRef = useRef(setTabAutoTitle);
setTabAutoTitleRef.current = setTabAutoTitle;
@@ -200,8 +193,8 @@ export const Terminal = ({ tabId, workspaceId }: TerminalProps) => {
handleStartShell,
} = useTerminalColdRestore({
paneId,
+ tabId,
workspaceId,
- parentTabIdRef,
xtermRef,
fitAddonRef,
isStreamReadyRef,
@@ -253,9 +246,7 @@ export const Terminal = ({ tabId, workspaceId }: TerminalProps) => {
// Focus handler ref
const handleTerminalFocusRef = useRef(() => {});
handleTerminalFocusRef.current = () => {
- if (pane?.tabId) {
- setFocusedPane(pane.tabId, paneId);
- }
+ setFocusedPane(tabId, paneId);
};
useEffect(() => {
@@ -378,7 +369,7 @@ export const Terminal = ({ tabId, workspaceId }: TerminalProps) => {
createOrAttachRef.current(
{
paneId,
- tabId: parentTabIdRef.current || paneId,
+ tabId,
workspaceId,
cols: xterm.cols,
rows: xterm.rows,
@@ -419,8 +410,8 @@ export const Terminal = ({ tabId, workspaceId }: TerminalProps) => {
if (domEvent.key === "Enter") {
if (!isAlternateScreenRef.current) {
const title = sanitizeForTitle(commandBufferRef.current);
- if (title && parentTabIdRef.current) {
- debouncedSetTabAutoTitleRef.current(parentTabIdRef.current, title);
+ if (title) {
+ debouncedSetTabAutoTitleRef.current(tabId, title);
}
}
commandBufferRef.current = "";
@@ -473,7 +464,7 @@ export const Terminal = ({ tabId, workspaceId }: TerminalProps) => {
createOrAttachRef.current(
{
paneId,
- tabId: parentTabIdRef.current || paneId,
+ tabId,
workspaceId,
cols: xterm.cols,
rows: xterm.rows,
@@ -546,8 +537,8 @@ export const Terminal = ({ tabId, workspaceId }: TerminalProps) => {
const inputDisposable = xterm.onData(handleTerminalInput);
const keyDisposable = xterm.onKey(handleKeyPress);
const titleDisposable = xterm.onTitleChange((title) => {
- if (title && parentTabIdRef.current) {
- debouncedSetTabAutoTitleRef.current(parentTabIdRef.current, title);
+ if (title) {
+ debouncedSetTabAutoTitleRef.current(tabId, title);
}
});
diff --git a/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/hooks/useTerminalColdRestore.ts b/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/hooks/useTerminalColdRestore.ts
index 0c61d87e2f5..ca2ca7e91f8 100644
--- a/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/hooks/useTerminalColdRestore.ts
+++ b/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/hooks/useTerminalColdRestore.ts
@@ -13,8 +13,8 @@ import { scrollToBottom } from "../utils";
export interface UseTerminalColdRestoreOptions {
paneId: string;
+ tabId: string;
workspaceId: string;
- parentTabIdRef: React.MutableRefObject;
xtermRef: React.MutableRefObject;
fitAddonRef: React.MutableRefObject;
isStreamReadyRef: React.MutableRefObject;
@@ -51,8 +51,8 @@ export interface UseTerminalColdRestoreReturn {
*/
export function useTerminalColdRestore({
paneId,
+ tabId,
workspaceId,
- parentTabIdRef,
xtermRef,
fitAddonRef,
isStreamReadyRef,
@@ -90,7 +90,7 @@ export function useTerminalColdRestore({
createOrAttachRef.current(
{
paneId,
- tabId: parentTabIdRef.current || paneId,
+ tabId,
workspaceId,
cols: xterm.cols,
rows: xterm.rows,
@@ -151,8 +151,8 @@ export function useTerminalColdRestore({
);
}, [
paneId,
+ tabId,
workspaceId,
- parentTabIdRef,
xtermRef,
isStreamReadyRef,
isExitedRef,
@@ -199,7 +199,7 @@ export function useTerminalColdRestore({
createOrAttachRef.current(
{
paneId,
- tabId: parentTabIdRef.current || paneId,
+ tabId,
workspaceId,
cols: xterm.cols,
rows: xterm.rows,
@@ -234,8 +234,8 @@ export function useTerminalColdRestore({
);
}, [
paneId,
+ tabId,
workspaceId,
- parentTabIdRef,
xtermRef,
fitAddonRef,
isStreamReadyRef,
diff --git a/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/types.ts b/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/types.ts
index f9d11d85ec0..c654c6df96f 100644
--- a/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/types.ts
+++ b/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/types.ts
@@ -1,4 +1,5 @@
export interface TerminalProps {
+ paneId: string;
tabId: string;
workspaceId: string;
}