diff --git a/packages/bruno-app/src/components/SaveTransientRequest/index.js b/packages/bruno-app/src/components/SaveTransientRequest/index.js index 772876dbe..9bad4c86d 100644 --- a/packages/bruno-app/src/components/SaveTransientRequest/index.js +++ b/packages/bruno-app/src/components/SaveTransientRequest/index.js @@ -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({ diff --git a/packages/bruno-app/src/providers/ReduxStore/middlewares/tasks/middleware.js b/packages/bruno-app/src/providers/ReduxStore/middlewares/tasks/middleware.js index fb0e43470..3d0730e42 100644 --- a/packages/bruno-app/src/providers/ReduxStore/middlewares/tasks/middleware.js +++ b/packages/bruno-app/src/providers/ReduxStore/middlewares/tasks/middleware.js @@ -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 }) ); } diff --git a/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js b/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js index b2d33e966..a1f1ce16a 100644 --- a/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js +++ b/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js @@ -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();