This commit is contained in:
Timothy Jaeryang Baek committed 2026-11-13 19:03:48 +09:00
1 parent 44d2dd3d52
commit bf0aa05a75
3 files changed
+23 -2

No files matched your search

+1 -1
View File
@@ -39,7 +39,7 @@ export function openTerminalSocket(
target: TerminalTarget,
path: string,
onOpen?: (socket: WebSocket) => void,
resume?: { resume: true; cursor: number; flow_control?: true }
resume?: { resume: true; cursor: number; flow_control?: true; process_info?: true }
) {
const url = new URL(`${target.baseUrl.replace(/\/$/, '')}${path}`, location.href);
url.protocol = url.protocol === 'https:' ? 'wss:' : 'ws:';
+6
View File
@@ -181,6 +181,7 @@
if (group?.activeId && tabs.activeGroupId !== id) tabs = activateTab(tabs, group.activeId);
};
let terminalViews: Record<string, XTerminal> = {};
let terminalTitles: Record<string, string> = {};
export const hasTerminals = () => tabs.tabs.some((tab) => tab.kind === 'terminal');
let browserViews: Record<string, Browser> = {};
let gitViews: Record<string, GitBar> = {};
@@ -282,6 +283,7 @@
viewReady = false;
tabs = emptyTabs();
viewError = '';
terminalTitles = {};
sideChatStreaming = {};
tabsChatId = id;
const owner = chatViewEntry($user.id, id, $temporaryChatEnabled);
@@ -1276,6 +1278,7 @@
: null;
// A side chat's artifacts tab names the chat it belongs to.
$: tabLabel = (tab: PanelTab) => {
if (tab.kind === 'terminal') return terminalTitles[tab.sessionId ?? ''] || tab.label;
const source =
tab.kind === 'artifacts' && tab.sourceTabId !== mainChatTabId
? tabs.tabs.find((item) => item.id === tab.sourceTabId)
@@ -2043,6 +2046,9 @@
sessionId={tab.sessionId}
active={panelVisible && visibleTabIds.has(tab.id)}
overlay={dragged}
onTitleChange={(title) => {
if (owner === viewEntry) terminalTitles[tab.sessionId!] = title.trim();
}}
onUnavailable={(message, status) => {
if (owner === viewEntry)
sessionFailures = { ...sessionFailures, [tab.id]: { message, status } };
+16 -1
View File
@@ -19,6 +19,7 @@
export let readOnly = false;
export let connected = false;
export let connecting = false;
export let onTitleChange: (title: string) => void = () => {};
let terminalEl: HTMLDivElement;
let term: Terminal | null = null;
@@ -42,6 +43,7 @@
let reconnectTimer: ReturnType<typeof setTimeout>;
let reconnectDelay = 1000;
let reconnecting = false;
let processName = '';
export async function bindChat(id: string) {
if (readOnly || destroyed || target.context.chatId === id) return;
@@ -134,7 +136,7 @@
if (ws?.readyState === WebSocket.OPEN) ws.send(JSON.stringify({ type: 'ping' }));
}, 25000);
},
{ resume: true, cursor, flow_control: true }
{ resume: true, cursor, flow_control: true, process_info: true }
);
const socket = ws;
let flowControlled = false;
@@ -145,6 +147,18 @@
try {
const message = JSON.parse(event.data);
if (message.type === 'chat') return;
if (message.type === 'process') {
if (typeof message.name === 'string') {
// Apply process changes between output batches so old titles cannot overtake them.
outputPending = outputBatch = outputPending.then(() => {
if (destroyed) return;
processName = message.name;
onTitleChange(processName);
});
outputBatchBytes = 0;
}
return;
}
if (message.type === 'flow_control') {
flowControlled = true;
return;
@@ -245,6 +259,7 @@
minimumContrastRatio: 4.5,
scrollback: 5000
});
term.onTitleChange((title) => onTitleChange(title.trim() || processName));
updateTheme();
themeObserver = new MutationObserver(updateTheme);
themeObserver.observe(document.documentElement, {