Skip to content

Commit 7f3abbf

Browse files
authored
fix: request name reverts after renaming an open request panel (#24)
## Description ### Problem If a request panel is open and you rename that request from the sidebar, sending (or saving) the request afterward silently restores the old name. ### Root cause `SidebarProvider.renameRequest` persists the new name to storage and updates the panel title via `RequestEditorProvider.updatePanelTitle`, but never notifies the already-open webview. The webview's React state keeps the stale name in its `config` object. Both "Send Request" and "Save" post that full `config` back to the extension host, which writes it straight to storage and the sidebar tree — so the stale name overwrites the rename. ### Fix `updatePanelTitle` now also posts a `requestRenamed` message to the webview. `RequestContext.tsx` handles it by updating `config.name` in state, keeping the webview in sync so subsequent saves carry the correct name. ### Files changed - `src/providers/RequestEditorProvider.ts` - `src/webview/request/RequestContext.tsx` ## Test plan - [x] `npx tsc --noEmit` passes - [ ] Manual: open a request, rename it via the sidebar context menu, then click Send — confirm the name stays renamed in both the sidebar and the panel title - [ ] Manual: rename, then click Save — confirm the name persists after reopening the panel
1 parent 60b1c73 commit 7f3abbf

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

src/providers/RequestEditorProvider.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ export class RequestEditorProvider {
4949
const panel = RequestEditorProvider.openPanels.get(requestId);
5050
if (panel) {
5151
panel.title = newTitle;
52+
// Sync the webview's in-memory config so a subsequent save (e.g. from
53+
// Send Request) doesn't post back the stale name and undo the rename.
54+
panel.webview.postMessage({ type: "requestRenamed", name: newTitle });
5255
}
5356
}
5457

src/webview/request/RequestContext.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,9 @@ export const RequestContextProvider: React.FC<RequestContextProviderProps> = ({
340340
case "historyUpdated":
341341
setHistoryEntries(message.entries || []);
342342
break;
343+
case "requestRenamed":
344+
setConfig((prev) => ({ ...prev, name: message.name }));
345+
break;
343346
case "historyRestored":
344347
setConfig((prev) => ({
345348
...prev,

0 commit comments

Comments
 (0)