This commit is contained in:
Classic298 2026-09-30 19:48:46 +04:00 • committed by GitHub
commit 41555cfdc6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 3 deletions

View file

@ -107,6 +107,8 @@ PROXY_METHODS = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS']
@router.api_route('/{server_id}/{path:path}', methods=PROXY_METHODS)
# Must stay the lower decorator so it registers before the catch-all, which would swallow chat paths.
@router.api_route('/{server_id}/chats/{chat_id}/{path:path}', methods=PROXY_METHODS)
async def proxy_terminal(
server_id: str,
path: str,
@ -151,7 +153,7 @@ async def proxy_terminal(
headers = {'X-User-Id': user.id}
# Forward per-session cwd tracking header
session_id = request.headers.get('x-session-id')
session_id = request.path_params.get('chat_id') or request.headers.get('x-session-id')
if session_id:
headers['X-Session-Id'] = session_id
if not terminal_context_available(connection, 'chat'):

View file

@ -355,6 +355,11 @@
let selectedTerminal: { url: string; key: string } | null = null;
let terminalChatContextPending = false;
let terminalChatContextHidden = false;
let scopedChatId: string | null = null;
$: portBaseUrl =
selectedTerminal && scopedChatId
? `${selectedTerminal.url}/chats/${encodeURIComponent(scopedChatId)}`
: (selectedTerminal?.url ?? '');
const chatContext = (terminal: any) => terminal?.contexts?.chat ?? {};
@ -364,6 +369,7 @@
: ($terminalServers?.[0] ?? null);
const chatConfig = chatContext(systemTerminal);
const chatScoped = !!systemTerminal && chatConfig?.context_id === 'chat_id';
scopedChatId = chatScoped ? chatId : null;
terminalChatContextHidden =
!!systemTerminal && (chatConfig === false || (chatScoped && isTemporaryChatId(chatId)));
terminalChatContextPending = chatScoped && !terminalChatContextHidden && !isSavedChatId(chatId);
@ -1824,7 +1830,7 @@
/>
{:else if previewPort !== null}
<PortPreview
baseUrl={selectedTerminal?.url ?? ''}
baseUrl={portBaseUrl}
port={previewPort}
overlay={overlay || isDraggingHandle}
onClose={() => {
@ -2099,7 +2105,7 @@
{#if selectedTerminal && !selectedFile && previewPort === null && !isSearching}
<div class="shrink-0 border-t border-gray-50 dark:border-gray-850/30">
<PortList
baseUrl={selectedTerminal.url}
baseUrl={portBaseUrl}
apiKey={selectedTerminal.key}
on:previewPort={(e) => {
selectedFile = null;