fix: terminal tab title uses workspace + tool type + session name
Instead of relying on display_name (which for old instances is just the
workspace name), fetch the full session info and build the title from
individual fields:
- Base: '{workspace_name} {tool_type_name}'
- With multiple terminal sessions: '{workspace_name} {tool_type_name} {session_name}'
- Fallback: 'Instance {id}' if session lookup fails
This gives meaningful titles like 'MyWorkspace code-server Session 1'
instead of just 'MyWorkspace — Terminal'.
Quality gates: tsc --noEmit pass, npm run build pass, 82/82 tests pass
This commit is contained in:
@@ -45,9 +45,11 @@ export const useTerminalPage = () => {
|
|||||||
const { isOpen: isKeyboardOpen, height: keyboardHeight } =
|
const { isOpen: isKeyboardOpen, height: keyboardHeight } =
|
||||||
useVirtualKeyboard();
|
useVirtualKeyboard();
|
||||||
|
|
||||||
const [instanceDisplayName, setInstanceDisplayName] = useState<string | null>(
|
const [instanceInfo, setInstanceInfo] = useState<{
|
||||||
null,
|
display_name: string;
|
||||||
);
|
workspace_name?: string | null;
|
||||||
|
tool_type_name: string;
|
||||||
|
} | null>(null);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
sessions,
|
sessions,
|
||||||
@@ -66,13 +68,15 @@ export const useTerminalPage = () => {
|
|||||||
if (!instanceId) return;
|
if (!instanceId) return;
|
||||||
const load = async () => {
|
const load = async () => {
|
||||||
try {
|
try {
|
||||||
// Try to find instance in user sessions first
|
|
||||||
const { getUserSessions } = await import("../api/sessions");
|
const { getUserSessions } = await import("../api/sessions");
|
||||||
const allSessions = await getUserSessions();
|
const allSessions = await getUserSessions();
|
||||||
const match = allSessions.find((s) => s.id === instanceId);
|
const match = allSessions.find((s) => s.id === instanceId);
|
||||||
if (match) {
|
if (match) {
|
||||||
setInstanceDisplayName(match.display_name);
|
setInstanceInfo({
|
||||||
return;
|
display_name: match.display_name,
|
||||||
|
workspace_name: match.workspace_name,
|
||||||
|
tool_type_name: match.tool_type_name,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
// ignore
|
// ignore
|
||||||
@@ -95,20 +99,19 @@ export const useTerminalPage = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const active = sessions.find((s) => s.id === activeSessionId);
|
const active = sessions.find((s) => s.id === activeSessionId);
|
||||||
const baseName =
|
const baseName = instanceInfo
|
||||||
instanceDisplayName ?? `Instance ${instanceId.slice(0, 8)}`;
|
? `${instanceInfo.workspace_name ?? instanceInfo.display_name} ${instanceInfo.tool_type_name}`
|
||||||
// Single session: just show "{name} — Terminal"
|
: `Instance ${instanceId.slice(0, 8)}`;
|
||||||
// Multiple sessions: "{name} · {session_name} — Terminal"
|
|
||||||
if (sessions.length <= 1) {
|
if (sessions.length <= 1) {
|
||||||
document.title = `${baseName} — Terminal`;
|
document.title = baseName;
|
||||||
} else {
|
} else {
|
||||||
const sessionName = active?.name ?? "Session";
|
const sessionName = active?.name ?? "Session";
|
||||||
document.title = `${baseName} · ${sessionName} — Terminal`;
|
document.title = `${baseName} ${sessionName}`;
|
||||||
}
|
}
|
||||||
return () => {
|
return () => {
|
||||||
document.title = "Headquarter";
|
document.title = "Headquarter";
|
||||||
};
|
};
|
||||||
}, [instanceId, activeSessionId, sessions, instanceDisplayName]);
|
}, [instanceId, activeSessionId, sessions, instanceInfo]);
|
||||||
|
|
||||||
// Sync refs with sessions
|
// Sync refs with sessions
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user