feat(vscode): update layout thresholds and improve server readiness timeout
This commit is contained in:
@@ -12,7 +12,7 @@ import { RiAddLine, RiArrowLeftLine, RiRobot2Line, RiSettings3Line } from '@remi
|
|||||||
// Width threshold for mobile vs desktop layout in settings
|
// Width threshold for mobile vs desktop layout in settings
|
||||||
const MOBILE_WIDTH_THRESHOLD = 550;
|
const MOBILE_WIDTH_THRESHOLD = 550;
|
||||||
// Width threshold for expanded layout (sidebar + chat side by side)
|
// Width threshold for expanded layout (sidebar + chat side by side)
|
||||||
const EXPANDED_LAYOUT_THRESHOLD = 700;
|
const EXPANDED_LAYOUT_THRESHOLD = 1400;
|
||||||
// Sessions sidebar width in expanded layout
|
// Sessions sidebar width in expanded layout
|
||||||
const SESSIONS_SIDEBAR_WIDTH = 280;
|
const SESSIONS_SIDEBAR_WIDTH = 280;
|
||||||
|
|
||||||
@@ -299,7 +299,7 @@ export const VSCodeLayout: React.FC = () => {
|
|||||||
// Expanded layout: sessions sidebar + chat side by side
|
// Expanded layout: sessions sidebar + chat side by side
|
||||||
<div className="flex h-full">
|
<div className="flex h-full">
|
||||||
{/* Sessions sidebar */}
|
{/* Sessions sidebar */}
|
||||||
<div
|
<div
|
||||||
className="h-full border-r border-border overflow-hidden flex-shrink-0"
|
className="h-full border-r border-border overflow-hidden flex-shrink-0"
|
||||||
style={{ width: SESSIONS_SIDEBAR_WIDTH }}
|
style={{ width: SESSIONS_SIDEBAR_WIDTH }}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -72,12 +72,12 @@ function getCandidateBaseUrls(serverUrl: string): string[] {
|
|||||||
if (!candidates.includes(v)) candidates.push(v);
|
if (!candidates.includes(v)) candidates.push(v);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Prefer SDK-provided url first.
|
const normalizedPath = parsed.pathname.replace(/\/+$/, '');
|
||||||
add(normalized);
|
// Prefer plain origin. Only keep SDK url when already root.
|
||||||
// Newer OpenCode servers may mount HTTP API under /api.
|
|
||||||
add(`${origin}/api`);
|
|
||||||
// Fallback to plain origin (in case SDK url includes path not accepted).
|
|
||||||
add(origin);
|
add(origin);
|
||||||
|
if (normalizedPath === '' || normalizedPath === '/') {
|
||||||
|
add(normalized);
|
||||||
|
}
|
||||||
|
|
||||||
return candidates;
|
return candidates;
|
||||||
} catch {
|
} catch {
|
||||||
@@ -85,7 +85,7 @@ function getCandidateBaseUrls(serverUrl: string): string[] {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function waitForReady(serverUrl: string, timeoutMs = 5000, workingDirectory = ''): Promise<ReadyResult> {
|
async function waitForReady(serverUrl: string, timeoutMs = 15000, workingDirectory = ''): Promise<ReadyResult> {
|
||||||
const start = Date.now();
|
const start = Date.now();
|
||||||
const candidates = getCandidateBaseUrls(serverUrl);
|
const candidates = getCandidateBaseUrls(serverUrl);
|
||||||
let attempts = 0;
|
let attempts = 0;
|
||||||
@@ -95,13 +95,10 @@ async function waitForReady(serverUrl: string, timeoutMs = 5000, workingDirector
|
|||||||
attempts += 1;
|
attempts += 1;
|
||||||
try {
|
try {
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
const timeout = setTimeout(() => controller.abort(), 1500);
|
const timeout = setTimeout(() => controller.abort(), 3000);
|
||||||
|
|
||||||
// Keep using /config since the UI proxies to it (via /api -> strip prefix).
|
// Keep using /config since the UI proxies to it (via /api -> strip prefix).
|
||||||
const url = new URL(`${baseUrl}/config`);
|
const url = new URL(`${baseUrl}/config`);
|
||||||
if (workingDirectory) {
|
|
||||||
url.searchParams.set('directory', workingDirectory);
|
|
||||||
}
|
|
||||||
const res = await fetch(url.toString(), {
|
const res = await fetch(url.toString(), {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: { Accept: 'application/json' },
|
headers: { Accept: 'application/json' },
|
||||||
|
|||||||
Reference in New Issue
Block a user