Skip to content

fix: path-param variable edit popup - #6955

Merged
sid-bruno merged 1 commit into
usebruno:mainfrom
shubh-bruno:fix/path-param-var-edit
Jan 28, 2026
Merged

sid-bruno merged 1 commit into
usebruno:mainfrom
shubh-bruno:fix/path-param-var-edit

Conversation

@shubh-bruno

@shubh-bruno shubh-bruno commented Jan 28, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Fixes : #6933

Jira

Contribution Checklist:

  • I've used AI significantly to create this pull request
  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

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

Release Notes

  • New Features
    • Added path parameter support with tooltip information display for path parameters (e.g., /:param)
    • Path parameter values can now be updated and managed alongside other variables in your projects

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Jan 28, 2026 •

Copy link
Copy Markdown
Contributor

Walkthrough

Added path parameter variable support to Bruno's variable system. Changes include: a new pathParam case in updateVariableInScope to handle path parameter updates via the updatePathParam action, and extended variable info rendering to detect and display path parameter tokens (/:param) in editor hover tooltips with fallback detection logic.

Changes

Cohort / File(s) Summary
Collections action handling
packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js
Added pathParam case to updateVariableInScope to find and update matching path parameters, dispatching updatePathParam action. Exported updatePathParam for public API use.
Variable detection and rendering
packages/bruno-app/src/utils/codemirror/brunoVarInfo.js
Enhanced variable info to detect path parameter tokens (/:param) in hover tooltips alongside existing brace-based variable detection. Implements fallback flow: attempt {{ ... }} resolution first, then detect /:param segments. Added "Path Param" scope label for display.

Sequence Diagram(s)

sequenceDiagram
    participant User as User
    participant Editor as Editor / Hover
    participant VarDetect as Variable Detector
    participant Redux as Redux Store
    participant Request as Request Handler

    User->>Editor: Hover over /:param in path
    Editor->>VarDetect: Check token for variable
    VarDetect->>VarDetect: Detect /:param pattern
    VarDetect->>Editor: Render path param tooltip
    
    User->>Editor: Update path parameter value
    Editor->>Redux: Dispatch updateVariableInScope<br/>(type: 'pathParam')
    Redux->>Redux: Locate matching path param<br/>in draft/request
    Redux->>Redux: Create updated param<br/>with new value
    Redux->>Redux: Dispatch updatePathParam
    Redux->>Request: Save related request
    Request-->>User: Changes persisted
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • #6691: Modifies the same brunoVarInfo.js hover and variable-detection logic for path parameter handling.
  • #6835: Updates both updateVariableInScope in collections actions and variable-detection logic in brunoVarInfo.js.

Suggested reviewers

  • helloanoop
  • lohit-bruno
  • naman-bruno
  • bijin-bruno

Poem

🛤️ Along the path, a param waits,
With hovering hints at REST's front gates,
Variables dance in :colons bright,
Redux updates them left and right,
Requests flow—saved with delight! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: path-param variable edit popup' directly describes the main change—enabling path parameter variable editing in the popup UI.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js`:
- Around line 2011-2026: The pathParam branch silently no-ops when
params.find(...) returns undefined, causing the UI to show a value that isn’t
persisted; fix by creating and persisting a new path param when not found:
inside the case 'pathParam' branch, if pathParam is falsy create a newParam = {
name: variableName, type: 'path', value: newValue, /* other defaults from
existing param shape */ } and dispatch an action to add/upsert it (use an
existing addRequestParam/addPathParam if available, otherwise dispatch
updatePathParam as an upsert), then continue to call saveRequest(item.uid,
collection.uid, true). Ensure you still return the promise chain (return
dispatch(saveRequest(...)).then(resolve).catch(reject)) so callers get the
correct success/failure outcome.

In `@packages/bruno-app/src/utils/codemirror/brunoVarInfo.js`:
- Around line 700-786: The path-param tokenizer can include trailing quotes,
commas or spaces because separators only include ['/', '?', '&', '=']; update
the separator set used in the path-param logic (the separators array used when
advancing pathValueEnd) to also include double-quote ("), single-quote ('),
whitespace characters (space, tab), comma (,) and any other common delimiters
(e.g., closing paren) so that the while loop that advances pathValueEnd stops at
these characters; this change should be applied where pathParamStart,
pathValueEnd and separators are defined before creating the token passed to
renderVarInfo/showPopup.

Comment on lines +2011 to +2026
case 'pathParam': {
const { item } = data;
const params = item.draft ? get(item, 'draft.request.params', []) : get(item, 'request.params', []);
const pathParam = params.find((p) => p.type === 'path' && p.name === variableName);

if (pathParam) {
const updatedParam = { ...pathParam, value: newValue };
dispatch(updatePathParam({
pathParam: updatedParam,
itemUid: item.uid,
collectionUid: collection.uid
}));
}
return dispatch(saveRequest(item.uid, collection.uid, true))
.then(resolve)
.catch(reject);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Avoid silent no-op when a path param is missing.
If a URL includes a new /:param not yet in params, this branch skips updatePathParam but still saves, so the UI can reflect a value that wasn’t persisted. Consider rejecting or creating the param when it’s not found.

🛠️ Suggested fix
-          const pathParam = params.find((p) => p.type === 'path' && p.name === variableName);
-
-          if (pathParam) {
-            const updatedParam = { ...pathParam, value: newValue };
-            dispatch(updatePathParam({
-              pathParam: updatedParam,
-              itemUid: item.uid,
-              collectionUid: collection.uid
-            }));
-          }
+          const pathParam = params.find((p) => p.type === 'path' && p.name === variableName);
+
+          if (!pathParam) {
+            return reject(new Error(`Path param "${variableName}" not found`));
+          }
+
+          const updatedParam = { ...pathParam, value: newValue };
+          dispatch(updatePathParam({
+            pathParam: updatedParam,
+            itemUid: item.uid,
+            collectionUid: collection.uid
+          }));
🤖 Prompt for AI Agents
In `@packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js`
around lines 2011 - 2026, The pathParam branch silently no-ops when
params.find(...) returns undefined, causing the UI to show a value that isn’t
persisted; fix by creating and persisting a new path param when not found:
inside the case 'pathParam' branch, if pathParam is falsy create a newParam = {
name: variableName, type: 'path', value: newValue, /* other defaults from
existing param shape */ } and dispatch an action to add/upsert it (use an
existing addRequestParam/addPathParam if available, otherwise dispatch
updatePathParam as an upsert), then continue to call saveRequest(item.uid,
collection.uid, true). Ensure you still return the promise chain (return
dispatch(saveRequest(...)).then(resolve).catch(reject)) so callers get the
correct success/failure outcome.

Comment on lines +700 to 786
// ---------- 1) MODE: Double-Brace Variable {{ ... }} ----------
// We check this first as it's the most common variable type.
if (line.includes('{{') && line.includes('}}')) {
// Check if the cursor is roughly between a '{{' to the left and '}}' to the right
if (line.lastIndexOf('{{', pos.ch) !== -1 && line.indexOf('}}', pos.ch) !== -1) {
let start = pos.ch;
let end = pos.ch;

// Scan LEFT to find the nearest '{{'
while (start > 0) {
const leftTwo = line.substring(start - 2, start);
if (leftTwo === '{{') {
start -= 2;
break;
}
// If we hit a '}}' while looking for '{{', the cursor is outside a pair
if (leftTwo === '}}') break;
start--;
}

// If we find opening braces, stop
if (leftTwo === '{{') {
start -= 2;
break;
}
// Validate we actually found a '{{'
if (start >= 0 && line.substring(start, start + 2) === '{{') {
// Scan RIGHT to find the nearest '}}'
while (end < line.length) {
const rightTwo = line.substring(end, end + 2);
if (rightTwo === '}}') {
end += 2;
break;
}
// If we hit another '{{' before a closing '}}', the structure is invalid
if (rightTwo === '{{') {
end = line.length + 1;
break;
}
end++;
}

// If we cross a closing braces before finding '{{', we're not inside a variable
if (leftTwo === '}}') {
return;
// Validate the final string and show popup
if (end <= line.length && line.substring(end - 2, end) === '}}') {
const fullVariableString = line.substring(start, end);
const inner = fullVariableString.slice(2, -2).trim();

if (inner) {
const token = { string: fullVariableString, start, end };
const brunoVarInfo = renderVarInfo(token, options);
if (brunoVarInfo) {
showPopup(cm, box, brunoVarInfo);
return; // EXIT: We found a variable, don't look for path params
}
}
}
}
}

start--;
}

// If we reached the start of the line and didn't match '{{', return
if (start < 0 || line.substring(start, start + 2) !== '{{') {
return;
}

// ---------- Find closing '}}' to the RIGHT ----------
while (end < line.length) {
const rightTwo = line.substring(end, end + 2);
// ---------- 2) MODE: Path Parameter /:varName ----------
// If we didn't return from the brace logic, check if cursor is on a path param
const pathParamStart = line.substring(0, pos.ch + 1).lastIndexOf('/:');

// If we find closing braces, stop
if (rightTwo === '}}') {
end += 2;
break;
}
if (pathParamStart !== -1) {
let pathValueEnd = pathParamStart + 2;

// If we hit another '{{' before a '}}', then this isn't a valid enclosing pair
if (rightTwo === '{{') {
return;
// Path params end at the next URL separator (/, ?, &, =) or end of line
const separators = ['/', '?', '&', '='];
while (pathValueEnd < line.length && !separators.includes(line[pathValueEnd])) {
pathValueEnd++;
}

end++;
}
// If we reached end-of-line without finding '}}', return
if (end > line.length || line.substring(end - 2, end) !== '}}') {
return;
}

const fullVariableString = line.substring(start, end);
// Check if cursor is actually inside the detected /:param range
if (pos.ch >= pathParamStart && pos.ch < pathValueEnd) {
const fullVariableString = line.substring(pathParamStart, pathValueEnd);

// Basic validation to ensure it's a non-empty variable
if (!fullVariableString.startsWith('{{') || !fullVariableString.endsWith('}}')) {
return;
}

// Prevent tooltips for empty variables like {{ }}
const inner = fullVariableString.slice(2, -2).trim();
if (!inner) return;

// Build a token object compatible with renderVarInfo
const token = {
string: fullVariableString,
start: start,
end: end
};

const brunoVarInfo = renderVarInfo(token, options);
if (brunoVarInfo) {
showPopup(cm, box, brunoVarInfo);
// Ensure it's not just "/:" but has a name (e.g., "/:id")
if (fullVariableString.length > 2) {
const token = {
string: fullVariableString,
start: pathParamStart,
end: pathValueEnd
};
const brunoVarInfo = renderVarInfo(token, options);
if (brunoVarInfo) {
showPopup(cm, box, brunoVarInfo);
return; // EXIT: Popup shown
}
}
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Path-param tokenization should stop at quotes/whitespace.
In common URL strings (e.g., "/users/:id"), the current separators skip ", ', and whitespace, so the token can include trailing quotes/commas and fail validation. Add common delimiters to avoid invalid tokens.

🛠️ Suggested fix
-      const separators = ['/', '?', '&', '='];
+      const separators = ['/', '?', '&', '=', '#', '"', '\'', '`', ' ', '\t', ')', '}', ']', ','];
🤖 Prompt for AI Agents
In `@packages/bruno-app/src/utils/codemirror/brunoVarInfo.js` around lines 700 -
786, The path-param tokenizer can include trailing quotes, commas or spaces
because separators only include ['/', '?', '&', '=']; update the separator set
used in the path-param logic (the separators array used when advancing
pathValueEnd) to also include double-quote ("), single-quote ('), whitespace
characters (space, tab), comma (,) and any other common delimiters (e.g.,
closing paren) so that the while loop that advances pathValueEnd stops at these
characters; this change should be applied where pathParamStart, pathValueEnd and
separators are defined before creating the token passed to
renderVarInfo/showPopup.

@sid-bruno

Copy link
Copy Markdown
Collaborator

Both failing tests tests/request/headers/header-validation.spec.ts, tests/environments/multiline-variables/write-multiline-variable.spec.ts pass when run singularly and not in a parallel fashion.

Merging the fix in

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Variable input value changes on focus and not persist changes

2 participants