feat(web): add request workspace tabs component#105
Conversation
Introduce tabbed request workspace UI with Params, Headers, and Body tabs for the HTTP editor.
Greptile SummaryThis PR introduces a scaffolded Key changes:
Confidence Score: 4/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[User opens .http file] --> B[EditorWithExecution mounts]
B --> C[createSignal: activeRequestTab = 'params']
B --> D[createMemo: selectedRequest]
B --> E[createMemo: requests]
E --> D
C --> F[RequestWorkspaceTabs rendered]
D --> F
F --> G{selectedRequest?}
G -- undefined --> H[Fallback: 'Select a request to view ...']
G -- present --> I{activeTab}
I -- params --> J[Params placeholder panel]
I -- headers --> K[Headers placeholder panel]
I -- body --> L[Body placeholder panel]
F --> M[User clicks tab button]
M --> N[onTabChange fires]
N --> O[setActiveRequestTab updates signal]
O --> F
P[User switches file path] --> Q[setActiveRequestTab reset to 'params']
Q --> F
Last reviewed commit: 9873427 |
packages/web/src/components/request-workspace/request-workspace-tabs.tsx
Show resolved
Hide resolved
| const selectedRequest = createMemo<WorkspaceRequest | undefined>(() => { | ||
| const allRequests = requests(); | ||
| if (allRequests.length === 0) { | ||
| return undefined; | ||
| } | ||
| return allRequests[selectedRequestIndex()]; | ||
| }); |
There was a problem hiding this comment.
selectedRequest memo missing out-of-bounds guard
The memo guards against an empty list but not against a stale index. If the requests() array shrinks (e.g., after a file save), there is a brief window before the index-clamping effect fires where selectedRequestIndex() can exceed allRequests.length - 1. In that window allRequests[selectedRequestIndex()] returns undefined from a non-empty array, which may cause a transient "Select a request" flash in the tab panel. An explicit bounds check makes the invariant clearer and avoids the timing dependency on the clamping effect.
| const selectedRequest = createMemo<WorkspaceRequest | undefined>(() => { | |
| const allRequests = requests(); | |
| if (allRequests.length === 0) { | |
| return undefined; | |
| } | |
| return allRequests[selectedRequestIndex()]; | |
| }); | |
| const selectedRequest = createMemo<WorkspaceRequest | undefined>(() => { | |
| const allRequests = requests(); | |
| const index = selectedRequestIndex(); | |
| if (index >= allRequests.length) { | |
| return undefined; | |
| } | |
| return allRequests[index]; | |
| }); |
Summary
Adds a tabbed request workspace interface to the web HTTP editor, allowing users to navigate between Params, Headers, and Body sections for each request.