From e5cc1ed712035990034623bb0774ad8ebb276fd8 Mon Sep 17 00:00:00 2001 From: l0ng-ai <24760907+l0ng-ai@users.noreply.github.com> Date: Thu, 12 Nov 2026 20:40:59 +0800 Subject: [PATCH] fix(http-client): show the request in the tool window while it is sent (#2966) The HTTP Client tool window opened only once a response arrived, so slow requests looked unanswered. It now opens as the request is sent, and the response pane shows the request line, a progress indicator and Stop Request until the response replaces it. Fixes #2937 --- .../http-client/HttpClient.module.css | 21 +++++++++++++++++++ src/features/http-client/HttpClientView.tsx | 19 ++++++++++++++++- src/features/http-client/store.ts | 14 ++++++++++++- 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/src/features/http-client/HttpClient.module.css b/src/features/http-client/HttpClient.module.css index b0400947f..62ab7b0ee 100644 --- a/src/features/http-client/HttpClient.module.css +++ b/src/features/http-client/HttpClient.module.css @@ -186,3 +186,24 @@ align-items: center; justify-content: center; } + +/* The request being sent, in place of a response. */ +.pending { + display: flex; + flex-direction: column; + gap: 10px; + padding: 12px; +} +.pendingLine { + display: flex; + align-items: center; + gap: 8px; + color: var(--fg-secondary); +} +.pendingRequest { + font-family: var(--font-mono); + overflow-wrap: anywhere; +} +.pendingMethod { + font-weight: 600; +} diff --git a/src/features/http-client/HttpClientView.tsx b/src/features/http-client/HttpClientView.tsx index 0acbd69b3..d3d4263e6 100644 --- a/src/features/http-client/HttpClientView.tsx +++ b/src/features/http-client/HttpClientView.tsx @@ -7,6 +7,7 @@ import { useEffect, useMemo, useRef, useState } from "react"; import clsx from "clsx"; import type { HttpExchange, HttpHistoryEntry } from "@/platform/ipc"; import { + Button, EmptyState, IconButton, SplitGroup, @@ -173,7 +174,23 @@ export function HttpClientView() { - {exchange ? ( + {running ? ( +
+
+ {tx`Sending request #${running.index + 1}…`} +
+ {running.method && ( +
+ {running.method} {running.url} +
+ )} +
+ +
+
+ ) : exchange ? ( ) : selected ? (
diff --git a/src/features/http-client/store.ts b/src/features/http-client/store.ts index 83c5ab9ea..5a67ad075 100644 --- a/src/features/http-client/store.ts +++ b/src/features/http-client/store.ts @@ -29,6 +29,9 @@ interface Running { path: string | null; index: number; request: RequestId; + /** The request line as written, once parsed. */ + method?: string; + url?: string; } interface HttpClientState { @@ -135,6 +138,16 @@ export async function runRequest(path: string | null, text: string, index: numbe if (busy) void commands.cancelRequest(busy.request); const request = nextRequestId(); useHttpClient.setState({ running: { path, index, request } }); + // The tool window shows the request as it is sent, not only once it has answered. + showServiceView(SERVICE_VIEW, false); + void parseRequests(text) + .then((blocks) => { + const block = blocks.find((b) => b.index === index); + const running = useHttpClient.getState().running; + if (block && running?.request === request) + useHttpClient.setState({ running: { ...running, method: block.method, url: block.url } }); + }) + .catch(() => {}); try { if (path && !useHttpClient.getState().environments[path]) await loadEnvironments(path); const ex = await call(commands.httpExecute(request, path, text, index, effectiveEnvironment(path))); @@ -143,7 +156,6 @@ export async function runRequest(path: string | null, text: string, index: numbe exchanges: { ...s.exchanges, [ex.entry.id]: ex }, selected: ex.entry.id, })); - showServiceView(SERVICE_VIEW, false); return true; } catch (e) { if (!isCancelled(e))