Skip to content

fix(ws): persist message name rename on cmd+s/ctrl+s while editing#8447

Open
pooja-bruno wants to merge 1 commit into
usebruno:mainfrom
pooja-bruno:fix/ws-message-rename-save-shortcut
Open

fix(ws): persist message name rename on cmd+s/ctrl+s while editing#8447
pooja-bruno wants to merge 1 commit into
usebruno:mainfrom
pooja-bruno:fix/ws-message-rename-save-shortcut

Conversation

@pooja-bruno

@pooja-bruno pooja-bruno commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Description

Previously, if you rename message title and then pressed cmd+s / ctrl+s while the name input was still focused, nothing was saved.

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

  • New Features

    • You can now save a message rename with Ctrl/Cmd+S while editing, without leaving the input field.
    • The updated name is immediately kept in sync and persisted after saving.
  • Tests

    • Added coverage for keyboard-based rename saving in both message formats to confirm the name updates in the UI and on disk.
@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Adds a Ctrl/⌘+S keyboard shortcut in the WebSocket message name editor to prevent default browser save, commit the edited name, and dispatch a save action. Corresponding Playwright tests verify rename persistence for both .bru and .yml collection formats.

Changes

WS Message Rename Shortcut

Layer / File(s) Summary
Ctrl/⌘+S save handler
packages/bruno-app/src/components/RequestPane/WsBody/SingleWSMessage/index.js
Adds a keydown handler for Ctrl/⌘+S in the message name input that prevents default save behavior, saves the edited name, and dispatches saveRequest(item.uid, collection.uid).
Rename persistence tests
tests/websockets/multi-message-bru/multi-message.spec.ts, tests/websockets/multi-message-yml/multi-message.spec.ts
Adds Playwright tests that rename a message via double-click, type a new name, trigger the OS-specific save shortcut without blurring, and confirm the new name is committed in the UI and persisted to the .bru/.yml fixture files.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant SingleWSMessage
  participant Redux
  participant Filesystem
  User->>SingleWSMessage: Double-click label, edit name
  User->>SingleWSMessage: Press Ctrl/Cmd+S
  SingleWSMessage->>SingleWSMessage: preventDefault()
  SingleWSMessage->>SingleWSMessage: saveName(editValue)
  SingleWSMessage->>Redux: dispatch saveRequest(item.uid, collection.uid)
  Redux->>Filesystem: Persist renamed message to .bru/.yml
Loading

Possibly related PRs

  • usebruno/bruno#7141: Standardizes the platform-correct Ctrl/⌘+S keypress used in Playwright tests, similar to the shortcut added here.
  • usebruno/bruno#7719: Refactored the same SingleWSMessage component to support inline name editing with Enter/Escape/blur save/cancel behavior, which this PR extends.

Suggested reviewers: helloanoop, bijin-bruno, lohit-bruno, naman-bruno, sid-bruno

Poem

A rabbit taps Ctrl, then S with delight,
The message's new name locks in tight.
No Enter, no blur, just keys held down,
Saved to disk without a frown.
Bru and yml both agree —
renamed and persisted, happily! 🐰💾

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: saving websocket message renames with Cmd/Ctrl+S while editing.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/bruno-app/src/components/RequestPane/WsBody/SingleWSMessage/index.js (1)

82-93: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Stop the bubbled Ctrl/⌘+S here

RequestTabs/RequestTab also binds the save shortcut for the active tab, so this input can trigger both saveName(editValue) and the tab-level dispatch(saveRequest(...)). Add e.stopPropagation() after preventDefault() to avoid a duplicate save/toast.

🤖 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/RequestPane/WsBody/SingleWSMessage/index.js`
around lines 82 - 93, The Ctrl/⌘+S handler in handleNameKeyDown currently lets
the shortcut bubble up to RequestTabs/RequestTab, causing a duplicate save.
Update the existing keydown logic to stop propagation in the same branch where
preventDefault is called, so the SingleWSMessage name editor handles the
shortcut without triggering the tab-level save dispatch.
🧹 Nitpick comments (2)
tests/websockets/multi-message-bru/multi-message.spec.ts (1)

257-282: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Wrap the test body in test.step for readable reports.

The rest of the coding standards for this test directory recommend promoting test.step usage. This new test has no step breakdown (rename, save, verify UI, verify persistence), unlike what's implied by the surrounding test suite conventions.

As per path instructions, "Promote the use of test.step as much as possible so the generated reports are easier to read."

♻️ Suggested structure
   test('rename a message and save with the keyboard shortcut while editing', async ({ pageWithUserData: page }) => {
     const saveShortcut = process.platform === 'darwin' ? 'Meta+s' : 'Control+s';

-    await openRequest(page, COLLECTION_NAME, SINGLE_MSG_REQ);
-
-    const messageLabel = page.getByTestId('ws-message-label-0');
-    await messageLabel.dblclick();
-
-    const nameInput = page.getByTestId('ws-message-name-input-0');
-    await expect(nameInput).toBeVisible();
-
-    await nameInput.selectText();
-    await page.keyboard.type('renamed via shortcut');
-
-    // Press cmd/ctrl+s while the name input still has focus, without pressing
-    // Enter or blurring first. This must commit the pending name and persist it.
-    await nameInput.press(saveShortcut);
-
-    // The editing input closes and the new name is committed to the UI.
-    await expect(page.getByTestId('ws-message-label-0').filter({ hasText: 'renamed via shortcut' })).toBeVisible();
-
-    // The rename must be written to disk by the shortcut-triggered save.
-    await expect
-      .poll(async () => await readFile(SINGLE_MSG_BRU_PATH, 'utf8'))
-      .toContain('name: renamed via shortcut');
+    await openRequest(page, COLLECTION_NAME, SINGLE_MSG_REQ);
+
+    const messageLabel = page.getByTestId('ws-message-label-0');
+    const nameInput = page.getByTestId('ws-message-name-input-0');
+
+    await test.step('Rename message and trigger save shortcut while editing', async () => {
+      await messageLabel.dblclick();
+      await expect(nameInput).toBeVisible();
+      await nameInput.selectText();
+      await page.keyboard.type('renamed via shortcut');
+      await nameInput.press(saveShortcut);
+    });
+
+    await test.step('Verify name is committed in the UI', async () => {
+      await expect(messageLabel.filter({ hasText: 'renamed via shortcut' })).toBeVisible();
+    });
+
+    await test.step('Verify name is persisted to disk', async () => {
+      await expect
+        .poll(async () => await readFile(SINGLE_MSG_BRU_PATH, 'utf8'))
+        .toContain('name: renamed via shortcut');
+    });
   });
🤖 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 `@tests/websockets/multi-message-bru/multi-message.spec.ts` around lines 257 -
282, The new test "rename a message and save with the keyboard shortcut while
editing" should be broken into `test.step` blocks for readability in reports.
Refactor the test body to group the existing phases—opening the request,
editing/renaming, triggering the save shortcut, verifying the UI update, and
verifying persistence—using `test.step` inside the same test function so the
scenario remains the same but the report shows clear sub-steps.

Source: Path instructions

tests/websockets/multi-message-yml/multi-message.spec.ts (1)

316-319: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Persistence assertion is weaker than the .bru counterpart.

The .bru test asserts toContain('name: renamed via shortcut') (verifying the actual name field), but this checks only toContain('renamed via shortcut'). A bug that wrote the value into the wrong field would still pass this assertion.

🔧 Suggested tightening
     await expect
       .poll(async () => await readFile(SINGLE_MSG_YML_PATH, 'utf8'))
-      .toContain('renamed via shortcut');
+      .toContain('name: renamed via shortcut');

Please confirm the exact YAML key/format used for message names before applying (e.g. quoting style may differ).

🤖 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 `@tests/websockets/multi-message-yml/multi-message.spec.ts` around lines 316 -
319, Tighten the persistence check in the multi-message websocket spec so it
verifies the YAML name field rather than just any occurrence of the renamed
text. Update the assertion in the shortcut-triggered save flow within the
multi-message test to match the actual YAML key/format used for message names in
this fixture, using the same style as the existing .bru test’s field-level
check.
🤖 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.

Outside diff comments:
In
`@packages/bruno-app/src/components/RequestPane/WsBody/SingleWSMessage/index.js`:
- Around line 82-93: The Ctrl/⌘+S handler in handleNameKeyDown currently lets
the shortcut bubble up to RequestTabs/RequestTab, causing a duplicate save.
Update the existing keydown logic to stop propagation in the same branch where
preventDefault is called, so the SingleWSMessage name editor handles the
shortcut without triggering the tab-level save dispatch.

---

Nitpick comments:
In `@tests/websockets/multi-message-bru/multi-message.spec.ts`:
- Around line 257-282: The new test "rename a message and save with the keyboard
shortcut while editing" should be broken into `test.step` blocks for readability
in reports. Refactor the test body to group the existing phases—opening the
request, editing/renaming, triggering the save shortcut, verifying the UI
update, and verifying persistence—using `test.step` inside the same test
function so the scenario remains the same but the report shows clear sub-steps.

In `@tests/websockets/multi-message-yml/multi-message.spec.ts`:
- Around line 316-319: Tighten the persistence check in the multi-message
websocket spec so it verifies the YAML name field rather than just any
occurrence of the renamed text. Update the assertion in the shortcut-triggered
save flow within the multi-message test to match the actual YAML key/format used
for message names in this fixture, using the same style as the existing .bru
test’s field-level check.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9d663151-d391-472f-b0f7-8e3d6dc1690b

📥 Commits

Reviewing files that changed from the base of the PR and between 4f31e9b and db4bb8f.

📒 Files selected for processing (3)
  • packages/bruno-app/src/components/RequestPane/WsBody/SingleWSMessage/index.js
  • tests/websockets/multi-message-bru/multi-message.spec.ts
  • tests/websockets/multi-message-yml/multi-message.spec.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1 participant