From 93f9b9e6c17aca47f9e5b6496ff2f06ea7dfd7a5 Mon Sep 17 00:00:00 2001 From: AviPeltz Date: Tue, 6 Jan 2026 14:21:44 -0800 Subject: [PATCH 1/3] rename terminal tabs --- .../TabsContent/GroupStrip/GroupItem.tsx | 61 ++++++++++++++++++- .../TabsContent/GroupStrip/GroupStrip.tsx | 5 ++ 2 files changed, 63 insertions(+), 3 deletions(-) diff --git a/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/GroupStrip/GroupItem.tsx b/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/GroupStrip/GroupItem.tsx index 5ba28f7871a..ae7ec8fd6e5 100644 --- a/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/GroupStrip/GroupItem.tsx +++ b/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/GroupStrip/GroupItem.tsx @@ -1,6 +1,7 @@ import { Button } from "@superset/ui/button"; import { Tooltip, TooltipContent, TooltipTrigger } from "@superset/ui/tooltip"; import { cn } from "@superset/ui/utils"; +import { useEffect, useRef, useState } from "react"; import { HiMiniXMark } from "react-icons/hi2"; import { StatusIndicator } from "renderer/screens/main/components/StatusIndicator"; import type { PaneStatus, Tab } from "renderer/stores/tabs/types"; @@ -12,6 +13,7 @@ interface GroupItemProps { status: PaneStatus | null; onSelect: () => void; onClose: () => void; + onRename: (newName: string) => void; } export function GroupItem({ @@ -20,8 +22,47 @@ export function GroupItem({ status, onSelect, onClose, + onRename, }: GroupItemProps) { const displayName = getTabDisplayName(tab); + const [isEditing, setIsEditing] = useState(false); + const [editValue, setEditValue] = useState(displayName); + const inputRef = useRef(null); + + useEffect(() => { + if (isEditing && inputRef.current) { + inputRef.current.focus(); + inputRef.current.select(); + } + }, [isEditing]); + + const handleDoubleClick = () => { + setEditValue(displayName); + setIsEditing(true); + }; + + const handleSave = () => { + const trimmedValue = editValue.trim(); + if (trimmedValue && trimmedValue !== displayName) { + onRename(trimmedValue); + } + setIsEditing(false); + }; + + const handleCancel = () => { + setEditValue(displayName); + setIsEditing(false); + }; + + const handleKeyDown = (e: React.KeyboardEvent) => { + if (e.key === "Enter") { + e.preventDefault(); + handleSave(); + } else if (e.key === "Escape") { + e.preventDefault(); + handleCancel(); + } + }; return (
@@ -30,6 +71,7 @@ export function GroupItem({ diff --git a/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/GroupStrip/GroupStrip.tsx b/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/GroupStrip/GroupStrip.tsx index a984cc9dfc6..97d3dc49d48 100644 --- a/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/GroupStrip/GroupStrip.tsx +++ b/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/GroupStrip/GroupStrip.tsx @@ -124,6 +124,10 @@ export function GroupStrip() { removeTab(tabId); }; + const handleRenameGroup = (tabId: string, newName: string) => { + renameTab(tabId, newName); + }; + return (
{tabs.length > 0 && ( @@ -143,6 +147,7 @@ export function GroupStrip() { status={tabStatusMap.get(tab.id) ?? null} onSelect={() => handleSelectGroup(tab.id)} onClose={() => handleCloseGroup(tab.id)} + onRename={(newName) => handleRenameGroup(tab.id, newName)} />
))} From 5ae84695aa4ecc029be49a41bb50ad2abce8ec64 Mon Sep 17 00:00:00 2001 From: AviPeltz Date: Tue, 6 Jan 2026 14:32:29 -0800 Subject: [PATCH 2/3] refactor --- .../TabsContent/GroupStrip/GroupItem.tsx | 64 ++++++++++--------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/GroupStrip/GroupItem.tsx b/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/GroupStrip/GroupItem.tsx index ae7ec8fd6e5..461c2c74d7a 100644 --- a/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/GroupStrip/GroupItem.tsx +++ b/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/GroupStrip/GroupItem.tsx @@ -26,7 +26,7 @@ export function GroupItem({ }: GroupItemProps) { const displayName = getTabDisplayName(tab); const [isEditing, setIsEditing] = useState(false); - const [editValue, setEditValue] = useState(displayName); + const [editValue, setEditValue] = useState(""); const inputRef = useRef(null); useEffect(() => { @@ -36,7 +36,7 @@ export function GroupItem({ } }, [isEditing]); - const handleDoubleClick = () => { + const startEditing = () => { setEditValue(displayName); setIsEditing(true); }; @@ -49,21 +49,41 @@ export function GroupItem({ setIsEditing(false); }; - const handleCancel = () => { - setEditValue(displayName); - setIsEditing(false); - }; - const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === "Enter") { e.preventDefault(); handleSave(); } else if (e.key === "Escape") { e.preventDefault(); - handleCancel(); + setIsEditing(false); } }; + const tabStyles = cn( + "flex items-center gap-2 transition-all w-full shrink-0 px-3 h-full", + isActive + ? "text-foreground bg-border/30" + : "text-muted-foreground/70 hover:text-muted-foreground hover:bg-tertiary/20", + ); + + if (isEditing) { + return ( +
+
+ setEditValue(e.target.value)} + onBlur={handleSave} + onKeyDown={handleKeyDown} + className="text-sm bg-transparent border-none outline-none flex-1 text-left min-w-0" + /> +
+
+ ); + } + return (
@@ -71,30 +91,12 @@ export function GroupItem({ From 277cebbdc584708ed32438717d23a67aef47c4eb Mon Sep 17 00:00:00 2001 From: AviPeltz Date: Tue, 6 Jan 2026 14:35:22 -0800 Subject: [PATCH 3/3] updated cleaner --- .../TabsContent/GroupStrip/GroupItem.tsx | 54 ++++++++++--------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/GroupStrip/GroupItem.tsx b/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/GroupStrip/GroupItem.tsx index 461c2c74d7a..a88ef454a3e 100644 --- a/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/GroupStrip/GroupItem.tsx +++ b/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/GroupStrip/GroupItem.tsx @@ -66,9 +66,9 @@ export function GroupItem({ : "text-muted-foreground/70 hover:text-muted-foreground hover:bg-tertiary/20", ); - if (isEditing) { - return ( -
+ return ( +
+ {isEditing ? (
setEditValue(e.target.value)} onBlur={handleSave} onKeyDown={handleKeyDown} + maxLength={64} className="text-sm bg-transparent border-none outline-none flex-1 text-left min-w-0" />
-
- ); - } - - return ( -
- - - + + + {displayName} + + Double-click to rename - {status && status !== "idle" && } - - - - {displayName} - - + + + )}