Repository navigation
fix(timeline): headers info in response timeline - #8766
shubh-bruno wants to merge 22 commits into
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughThe PR adds shared header-source resolution, captures transport and pre-request-script headers, orders timeline logs, updates Timeline and DevTools header rendering, adds cross-format Playwright coverage, and applies broad behavior-preserving ChangesHeader provenance and timeline rendering
Behavior-preserving cleanup
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant RequestRunner
participant AxiosInterceptor
participant Timeline
participant HeaderResolver
participant TimelineUI
RequestRunner->>RequestRunner: Execute pre-request script
RequestRunner->>AxiosInterceptor: Send request with scriptSetHeaders
AxiosInterceptor->>Timeline: Record and backfill sent headers
TimelineUI->>HeaderResolver: Resolve configured and timeline headers
HeaderResolver-->>TimelineUI: Return ordered header rows
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/bruno-electron/src/ipc/network/index.js (1)
1792-1799: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winRunner path's
requestSentis missingscriptSetHeaders.The standalone
runRequestpath includesscriptSetHeaders: request.scriptSetHeaders || []in itsrequestSentpayload (line 992), but this Runner-flowrequestSent(built from the samerunPreRequest-populatedrequest.scriptSetHeaders) omits it. Header-provenance attribution for pre-request-script-set headers will silently break for Collection Runner runs.🐛 Proposed fix
let requestSent = { url: request.url, method: request.method, headers: headersSent, + scriptSetHeaders: request.scriptSetHeaders || [], data: requestData, dataBuffer: requestDataBuffer, timestamp: Date.now() };🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/bruno-electron/src/ipc/network/index.js` around lines 1792 - 1799, Update the Runner-flow requestSent payload in the request execution path to include scriptSetHeaders from request, defaulting to an empty array as in the standalone runRequest payload. Preserve the existing requestSent fields and use the runPreRequest-populated request.scriptSetHeaders value.
🧹 Nitpick comments (1)
packages/bruno-common/src/utils/headers-source.js (1)
1-108: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueAdd the utility with the package TypeScript extension.
packages/bruno-commonalready has real TypeScript runtime source,tsconfig.json, and@rollup/plugin-typescript, so this new utility should beheaders-source.tswith appropriate typed inputs/outputs instead ofheaders-source.js.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/bruno-common/src/utils/headers-source.js` around lines 1 - 108, The new headers utility should use the TypeScript extension and typed interfaces throughout. Rename the implementation to headers-source.ts, add appropriate types for header entries, timeline entries, request data, collection/item inputs, and buildHeaderRows inputs/outputs, and ensure the existing behavior remains unchanged.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/bruno-electron/src/ipc/network/axios-instance.js`:
- Around line 234-273: Make redirect timelines hop-aware in backfillSentHeaders
at packages/bruno-electron/src/ipc/network/axios-instance.js:234-273 by
resetting the existing-header set and insertion boundary at the most recent
request marker, so only the current hop is scanned. Update sortRequestHeaderLogs
at
packages/bruno-app/src/components/ResponsePane/Timeline/TimelineItem/Network/index.js:11-40
to split slots at each request entry and sort/reassign request headers
independently within each hop segment.
- Around line 238-255: Update parseSentHeaders to stop reading the private
ClientRequest._header field. Use an API-supported source or mechanism that
preserves the sent wire-header names and ordering for timeline backfill, while
retaining the existing fallback behavior only if it provides equivalent
wire-header data; do not rely on getHeaders() as a casing/order substitute.
In `@packages/bruno-js/src/bruno-request.js`:
- Around line 140-153: Update setHeaders in the array-form merge path to filter
out prototype-pollution keys (__proto__, constructor, and prototype) from each
script-supplied entry before merging into this.req.headers. Preserve merging of
all other valid header keys and the existing object-form replacement behavior.
---
Outside diff comments:
In `@packages/bruno-electron/src/ipc/network/index.js`:
- Around line 1792-1799: Update the Runner-flow requestSent payload in the
request execution path to include scriptSetHeaders from request, defaulting to
an empty array as in the standalone runRequest payload. Preserve the existing
requestSent fields and use the runPreRequest-populated request.scriptSetHeaders
value.
---
Nitpick comments:
In `@packages/bruno-common/src/utils/headers-source.js`:
- Around line 1-108: The new headers utility should use the TypeScript extension
and typed interfaces throughout. Rename the implementation to headers-source.ts,
add appropriate types for header entries, timeline entries, request data,
collection/item inputs, and buildHeaderRows inputs/outputs, and ensure the
existing behavior remains unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: b516d0ab-9d59-43cc-9fda-77749788f80e
📒 Files selected for processing (11)
packages/bruno-app/src/components/Devtools/Console/RequestDetailsPanel/index.jspackages/bruno-app/src/components/ResponsePane/Timeline/TimelineItem/Common/Headers/index.jspackages/bruno-app/src/components/ResponsePane/Timeline/TimelineItem/Network/index.jspackages/bruno-app/src/components/ResponsePane/Timeline/TimelineItem/Request/index.jspackages/bruno-app/src/components/ResponsePane/Timeline/TimelineItem/StyledWrapper.jspackages/bruno-app/src/components/ResponsePane/Timeline/TimelineItem/index.jspackages/bruno-common/src/utils/headers-source.jspackages/bruno-common/src/utils/index.tspackages/bruno-electron/src/ipc/network/axios-instance.jspackages/bruno-electron/src/ipc/network/index.jspackages/bruno-js/src/bruno-request.js
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/response/timeline-headers/timeline-headers.spec.ts`:
- Around line 119-135: Add a centralized locator for the header-name elements
using data-testid="tl-header-name", then assert their text content matches the
expected ordered sequence: DEFAULT_HEADERS followed by collection, folder,
request, and script headers. Keep the existing count and value assertions in the
current test steps.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 1b5194f7-4249-447c-8bf3-efd65439d5ec
📒 Files selected for processing (14)
packages/bruno-app/src/components/ResponsePane/Timeline/TimelineItem/Common/Headers/index.jstests/response/timeline-headers/fixtures/collections/bru/bruno.jsontests/response/timeline-headers/fixtures/collections/bru/collection.brutests/response/timeline-headers/fixtures/collections/bru/folder-1/folder-2/folder.brutests/response/timeline-headers/fixtures/collections/bru/folder-1/folder-2/get-headers.brutests/response/timeline-headers/fixtures/collections/bru/folder-1/folder.brutests/response/timeline-headers/fixtures/collections/yml/folder-1/folder-2/folder.ymltests/response/timeline-headers/fixtures/collections/yml/folder-1/folder-2/get-headers.ymltests/response/timeline-headers/fixtures/collections/yml/folder-1/folder.ymltests/response/timeline-headers/fixtures/collections/yml/opencollection.ymltests/response/timeline-headers/timeline-headers.spec.tstests/utils/page/index.tstests/utils/page/locators.tstests/utils/page/timeline-headers.ts
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js (1)
410-429: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winDo not shadow the outer
savePromisesarray.The declaration at Line 410 creates a separate array, leaving the outer array from Line 401 empty.
saveMultipleCollectionscan therefore resolve before any collection-save IPC call finishes.Proposed fix
- const savePromises = []; + const collectionSavePromises = []; - savePromises.push(ipcRenderer.invoke('renderer:save-collection-root', collectionCopy.pathname, collectionRootToSave, collectionCopy.brunoConfig)); + collectionSavePromises.push(ipcRenderer.invoke('renderer:save-collection-root', collectionCopy.pathname, collectionRootToSave, collectionCopy.brunoConfig)); if (collectionCopy.draft?.brunoConfig) { - savePromises.push(ipcRenderer.invoke('renderer:update-bruno-config', collectionCopy.draft.brunoConfig, collectionCopy.pathname, collectionCopy.root)); + collectionSavePromises.push(ipcRenderer.invoke('renderer:update-bruno-config', collectionCopy.draft.brunoConfig, collectionCopy.pathname, collectionCopy.root)); } - Promise.all(savePromises) - .then(() => { - dispatch(saveCollectionDraft({ collectionUid: collectionDraft.collectionUid })); - }); + savePromises.push( + Promise.all(collectionSavePromises).then(() => { + dispatch(saveCollectionDraft({ collectionUid: collectionDraft.collectionUid })); + }) + );🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js` around lines 410 - 429, Remove the inner savePromises declaration in the collection-save branch and append IPC promises to the existing outer savePromises array used by saveMultipleCollections. Ensure the final Promise.all(savePromises) waits for every renderer:save-collection-root and renderer:update-bruno-config invocation before resolving.packages/bruno-app/src/utils/url/index.js (1)
4-12: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winInsert
versionbefore any URL fragment.For URLs such as
/docs/ai#setup, this currently produces/docs/ai#setup?version=...; the parameter is part of the fragment and is never sent to the server. Split/preserve the hash before appending the query, and add coverage for query-plus-fragment URLs.Proposed fix
export const getDocsUrlWithVersion = (url) => { - const separator = url.includes('?') ? '&' : '?'; - return `${url}${separator}version=${appVersion}`; + const hashIndex = url.indexOf('#'); + const baseUrl = hashIndex === -1 ? url : url.slice(0, hashIndex); + const hash = hashIndex === -1 ? '' : url.slice(hashIndex); + const separator = baseUrl.includes('?') ? '&' : '?'; + return `${baseUrl}${separator}version=${encodeURIComponent(appVersion)}${hash}`; };🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/bruno-app/src/utils/url/index.js` around lines 4 - 12, Update getDocsUrlWithVersion so it separates and preserves any URL hash before determining the query separator and appending the version parameter, then restores the fragment after the query. Add coverage for URLs containing both an existing query and fragment, ensuring version is sent before the hash.packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/CodeView/index.js (1)
36-49: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winClear stale generated code when regeneration starts.
When
language,item, orcollectionchanges,snippetstill contains the previous request until the async generation completes. Users can therefore view or copy code for the wrong request/language. Clear the state at effect start or render an explicit loading state.Proposed fix
const [snippet, setSnippet] = useState(''); useEffect(() => { let cancelled = false; + setSnippet(''); generateSnippet({🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/CodeView/index.js` around lines 36 - 49, Clear the existing snippet at the start of the useEffect that calls generateSnippet, before initiating the asynchronous request. Keep the current cancellation guard so only the latest generation updates snippet when language, item, collection, or interpolation preferences change.
🧹 Nitpick comments (3)
packages/bruno-app/src/utils/common/index.js (1)
558-567: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd focused tests for
formatProxyTimestamp.Cover the expected formatted output and invalid/edge timestamp inputs so locale-sensitive formatting does not regress. As per coding guidelines, meaningful behavior changes should include behavior-driven tests.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/bruno-app/src/utils/common/index.js` around lines 558 - 567, Add focused behavior-driven tests for formatProxyTimestamp covering the expected en-GB formatted output plus invalid and edge timestamp inputs. Use stable assertions that verify the configured date, time, and 12-hour formatting without making tests flaky across environments.Source: Coding guidelines
packages/bruno-app/src/components/MultiLineEditor/index.js (1)
186-188: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a regression test for live placeholder updates.
Verify that changing
placeholderupdates the rendered CodeMirror placeholder without recreating the editor. As per coding guidelines, meaningful behavior changes should include behavior-driven tests.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/bruno-app/src/components/MultiLineEditor/index.js` around lines 186 - 188, Add a regression test for the MultiLineEditor component covering a placeholder prop change after initial render. Assert that the rendered CodeMirror placeholder updates to the new value while the existing editor instance is preserved and not recreated.Source: Coding guidelines
packages/bruno-app/src/utils/collections/index.js (1)
1238-1247: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAdd regression coverage for secret-variable precedence.
The changed logic makes interpolation and
getVariableScopeprefer the secret when enabled plain and secret variables share a name. Add a test asserting both paths return the same secret value. As per coding guidelines, meaningful behavior changes should include behavior-driven tests.Also applies to: 1730-1734
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/bruno-app/src/utils/collections/index.js` around lines 1238 - 1247, Add regression coverage for the enabled duplicate-name variable case in the collection-variable test suite: configure one plain and one secret variable with the same name, then assert both interpolation and getVariableScope return the secret value. Keep the test focused on secret precedence and verify both access paths produce the same result.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/bruno-electron/src/utils/filesystem.js`:
- Line 408: Update the targetPath construction to use path.join with destination
and path.basename(source), removing the hardcoded slash while preserving the
existing filename behavior.
---
Outside diff comments:
In
`@packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/CodeView/index.js`:
- Around line 36-49: Clear the existing snippet at the start of the useEffect
that calls generateSnippet, before initiating the asynchronous request. Keep the
current cancellation guard so only the latest generation updates snippet when
language, item, collection, or interpolation preferences change.
In `@packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js`:
- Around line 410-429: Remove the inner savePromises declaration in the
collection-save branch and append IPC promises to the existing outer
savePromises array used by saveMultipleCollections. Ensure the final
Promise.all(savePromises) waits for every renderer:save-collection-root and
renderer:update-bruno-config invocation before resolving.
In `@packages/bruno-app/src/utils/url/index.js`:
- Around line 4-12: Update getDocsUrlWithVersion so it separates and preserves
any URL hash before determining the query separator and appending the version
parameter, then restores the fragment after the query. Add coverage for URLs
containing both an existing query and fragment, ensuring version is sent before
the hash.
---
Nitpick comments:
In `@packages/bruno-app/src/components/MultiLineEditor/index.js`:
- Around line 186-188: Add a regression test for the MultiLineEditor component
covering a placeholder prop change after initial render. Assert that the
rendered CodeMirror placeholder updates to the new value while the existing
editor instance is preserved and not recreated.
In `@packages/bruno-app/src/utils/collections/index.js`:
- Around line 1238-1247: Add regression coverage for the enabled duplicate-name
variable case in the collection-variable test suite: configure one plain and one
secret variable with the same name, then assert both interpolation and
getVariableScope return the secret value. Keep the test focused on secret
precedence and verify both access paths produce the same result.
In `@packages/bruno-app/src/utils/common/index.js`:
- Around line 558-567: Add focused behavior-driven tests for
formatProxyTimestamp covering the expected en-GB formatted output plus invalid
and edge timestamp inputs. Use stable assertions that verify the configured
date, time, and 12-hour formatting without making tests flaky across
environments.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: be40c29e-d1e1-4527-9a12-4d72893f01f8
📒 Files selected for processing (22)
packages/bruno-app/src/components/CodeEditor/index.jspackages/bruno-app/src/components/MultiLineEditor/index.jspackages/bruno-app/src/components/RequestTabPanel/index.jspackages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/CodeView/index.jspackages/bruno-app/src/providers/ReduxStore/slices/collections/actions.jspackages/bruno-app/src/utils/collections/index.jspackages/bruno-app/src/utils/common/index.jspackages/bruno-app/src/utils/url/index.jspackages/bruno-cli/src/runner/run-single-request.jspackages/bruno-common/src/generate-code/har/index.tspackages/bruno-common/src/utils/index.tspackages/bruno-converters/src/postman/bruno-to-postman.jspackages/bruno-converters/src/postman/postman-to-bruno.jspackages/bruno-electron/src/app/collection-watcher.jspackages/bruno-electron/src/ipc/collection.jspackages/bruno-electron/src/ipc/network/index.jspackages/bruno-electron/src/utils/collection.jspackages/bruno-electron/src/utils/filesystem.jstests/utils/page/actions.tstests/utils/page/index.tstests/utils/page/locators.tstests/websockets/subproto.spec.ts
🚧 Files skipped from review as they are similar to previous changes (5)
- tests/utils/page/index.ts
- packages/bruno-common/src/utils/index.ts
- tests/utils/page/locators.ts
- tests/utils/page/actions.ts
- packages/bruno-electron/src/ipc/network/index.js
| // Content-Length) after the request interceptor logged config.headers, so they're missing from the | ||
| // timeline. Read the real serialized header block off the ClientRequest and backfill the ones we | ||
| // didn't already log, inserted right after the existing request-header block so ordering holds. | ||
| const parseSentHeaders = (req) => { |
There was a problem hiding this comment.
Please export parseSentHeaders and backfillSentHeaders and write unit tests for them.
Also, could you check with @sid-bruno whether backfillSentHeaders should be wrapped in a try...catch? Since this runs as part of the core request execution path, we probably don't want a bug in backfillSentHeaders to break the app
|
overall looks goods but suspecting one bug here not sure about it in case of re-directes. |
sachin-thakur-bruno
left a comment
There was a problem hiding this comment.
Looks good and working fine locally.
|
LGTM, will wait on tests and merge |
|
@bijin-bruno @sid-bruno Please hold off on merging this PR. I wanted to discuss a few items |
|
Closing this pr will be creating new pr |
Description
BRU-3731
Fixes - #645
Problem
Bruno adds default headers when sending a request (Accept, User-Agent, request-start-time, Accept-Encoding, Host, Connection), but the app does not show them fully, also it doesn't shows headers from respective entity table and scripts.
Solution
Result: all six auto headers appear in Request > Headers and the Network log across all three surfaces, both views match, and they match a netcat/tcpdump capture.
Contribution Checklist:
Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.
Publishing to New Package Managers
Please see here for more information.
Summary by CodeRabbit