bugfix: auto open saved transient request (#7058)

This commit is contained in:
Chirag Chandrashekhar
2026-02-06 17:57:54 +05:30
committed by GitHub
parent f07c93d613
commit 1c5e1c5fcf
3 changed files with 22 additions and 5 deletions

View File

@@ -9,12 +9,15 @@ import toast from 'react-hot-toast';
import StyledWrapper from './StyledWrapper';
import useCollectionFolderTree from 'hooks/useCollectionFolderTree';
import { removeSaveTransientRequestModal, deleteRequestDraft } from 'providers/ReduxStore/slices/collections';
import { insertTaskIntoQueue } from 'providers/ReduxStore/slices/app';
import { newFolder, closeTabs } from 'providers/ReduxStore/slices/collections/actions';
import { sanitizeName, validateName, validateNameError } from 'utils/common/regex';
import { resolveRequestFilename } from 'utils/common/platform';
import path from 'utils/common/path';
import { transformRequestToSaveToFilesystem, findCollectionByUid, findItemInCollection } from 'utils/collections';
import { DEFAULT_COLLECTION_FORMAT } from 'utils/common/constants';
import { itemSchema } from '@usebruno/schema';
import { uuid } from 'utils/common';
import { formatIpcError } from 'utils/common/error';
const SaveTransientRequest = ({ item: itemProp, collection: collectionProp, isOpen = false, onClose }) => {
@@ -118,6 +121,7 @@ const SaveTransientRequest = ({ item: itemProp, collection: collectionProp, isOp
const format = collection.format || DEFAULT_COLLECTION_FORMAT;
const targetFilename = resolveRequestFilename(sanitizedFilename, format);
const targetPathname = path.join(targetDirname, targetFilename);
await ipcRenderer.invoke('renderer:save-transient-request', {
sourcePathname: item.pathname,
@@ -127,6 +131,17 @@ const SaveTransientRequest = ({ item: itemProp, collection: collectionProp, isOp
format
});
// Add task to open the newly saved request when file watcher detects it
dispatch(
insertTaskIntoQueue({
uid: uuid(),
type: 'OPEN_REQUEST',
collectionUid: collection.uid,
itemPathname: targetPathname,
preview: false
})
);
dispatch(closeTabs({ tabUids: [item.uid] }));
dispatch({

View File

@@ -29,14 +29,13 @@ taskMiddleware.startListening({
const collection = findCollectionByUid(state.collections.collections, collectionUid);
if (collection && collection.mountStatus === 'mounted' && !collection.isLoading) {
const item = findItemInCollectionByPathname(collection, task.itemPathname);
const isTransient = item?.isTransient ?? false;
if (item) {
listenerApi.dispatch(
addTab({
uid: item.uid,
collectionUid: collection.uid,
requestPaneTab: getDefaultRequestPaneTab(item),
preview: !isTransient
preview: task?.preview ?? true
})
);
}

View File

@@ -1338,7 +1338,8 @@ export const newHttpRequest = (params) => (dispatch, getState) => {
uid: uuid(),
type: 'OPEN_REQUEST',
collectionUid,
itemPathname: fullName
itemPathname: fullName,
preview: false
})
);
resolve();
@@ -1494,7 +1495,8 @@ export const newGrpcRequest = (params) => (dispatch, getState) => {
uid: uuid(),
type: 'OPEN_REQUEST',
collectionUid,
itemPathname: fullName
itemPathname: fullName,
preview: false
})
);
resolve();
@@ -1621,7 +1623,8 @@ export const newWsRequest = (params) => (dispatch, getState) => {
uid: uuid(),
type: 'OPEN_REQUEST',
collectionUid,
itemPathname: fullName
itemPathname: fullName,
preview: false
})
);
resolve();