Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions view/app/terminal/terminal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ export const Terminal: React.FC<TerminalProps> = ({
}) => {
const { t } = useTranslation();
const [dimensions, setDimensions] = useState({ width: 0, height: 0 });
const [sessions, setSessions] = useState([{ id: uuidv4(), label: 'Session 1' }]);
const [sessions, setSessions] = useState(() => {
const id = uuidv4();
return [{ id, label: `Session ${id.slice(0, 3)}` }];
});
const [activeSessionId, setActiveSessionId] = useState(sessions[0].id);
const containerRef = useRef<HTMLDivElement>(null);
const resizeTimeoutRef = useRef<NodeJS.Timeout | undefined>(undefined);
Expand Down Expand Up @@ -156,9 +159,10 @@ export const Terminal: React.FC<TerminalProps> = ({
if (sessions.length >= SESSION_LIMIT) {
return;
}
const id = uuidv4();
const newSession = {
id: uuidv4(),
label: `Session ${sessions.length + 1}`
id,
label: `Session ${id.slice(0, 3)}`
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if label is not made use here, then why do we need to have a label key in the state?

};
setSessions((prev) => [...prev, newSession]);
setActiveSessionId(newSession.id);
Expand Down Expand Up @@ -206,6 +210,7 @@ export const Terminal: React.FC<TerminalProps> = ({
{sessions.map((session) => (
<div
key={session.id}
title={`Terminal ID: ${session.id}`}
className={`flex items-center px-2 py-1 rounded-t-md cursor-pointer ${
session.id === activeSessionId
? 'bg-[#232323] border border-[#333]'
Expand Down