Skip to content

fix: update action bar value after users click import from url #8643

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 28, 2025

Conversation

ZxBing0066
Copy link
Member

@ZxBing0066 ZxBing0066 commented Apr 24, 2025

Background

After verifying #2937, query params could update immediately, but the value in the URL bar does not reflect the change.

Root Cause

One line editor is an uncontrolled component. As a result, when the URL is updated, it can't automatically update its value.

Changes

  • Add setValue to the one line editor
  • Add setUrl to the request pane and websocket-request-pane
  • Add smoke tests for Import from URL

Before

Kapture.2025-04-25.at.10.34.12.mp4

After

Kapture.2025-04-25.at.10.26.12.mp4

@ZxBing0066 ZxBing0066 requested review from a team and Copilot April 24, 2025 09:55
@ZxBing0066 ZxBing0066 self-assigned this Apr 24, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an issue where the URL bar value is not updated after the user clicks "Import from URL." Key changes include adding a setValue method to the one-line editor, exposing an updateUrl handle in both the action bar and request URL bar, and adding corresponding smoke tests for HTTP and WebSocket requests.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/insomnia/src/ui/components/websockets/websocket-request-pane.tsx Added a ref to the RequestUrlBar and invoked updateUrl after patching the request
packages/insomnia/src/ui/components/websockets/action-bar.tsx Introduced forwardRef and exposed an updateUrl method using useImperativeHandle
packages/insomnia/src/ui/components/request-url-bar.tsx Extended ref capabilities to support updateUrl
packages/insomnia/src/ui/components/panes/request-pane.tsx Integrated the RequestUrlBar ref to invoke updateUrl after updating the URL
packages/insomnia/src/ui/components/codemirror/one-line-editor.tsx Added and implemented setValue to update the one-line editor content
packages/insomnia/src/common/database.ts Minor comment update for consistency in terminology
packages/insomnia-smoke-test/tests/smoke/import-from-url.test.ts Added smoke tests for both HTTP and WebSocket requests to verify the fix
packages/insomnia-smoke-test/fixtures/import-from-url.yaml Provided updated fixture data for the import tests

@ZxBing0066 ZxBing0066 requested a review from Copilot April 24, 2025 10:05
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes the issue where the URL bar does not update after a user imports a URL by adding explicit setValue/setUrl methods to the one-line editors in both the request pane and websocket request pane. Key changes include:

  • Adding a ref and setUrl invocation to update the URL in the WebSocketActionBar.
  • Introducing the setUrl API in RequestUrlBar for consistent updates.
  • Implementing the setValue method in OneLineEditor to preserve the cursor location during updates, along with smoke tests for "Import from URL" flows.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/insomnia/src/ui/components/websockets/websocket-request-pane.tsx Added a ref to WebSocketActionBar and called setUrl on URL change.
packages/insomnia/src/ui/components/websockets/action-bar.tsx Updated to use forwardRef with a new setUrl method.
packages/insomnia/src/ui/components/request-url-bar.tsx Introduced setUrl in the imperative handle for URL bar updates.
packages/insomnia/src/ui/components/panes/request-pane.tsx Integrated the URL bar ref and setUrl on URL changes.
packages/insomnia/src/ui/components/codemirror/one-line-editor.tsx Added setValue to update the editor value while preserving the cursor.
packages/insomnia-smoke-test/tests/smoke/import-from-url.test.ts Added smoke tests to verify URL import functionality.

@ZxBing0066 ZxBing0066 marked this pull request as ready for review April 25, 2025 00:51
@ZxBing0066 ZxBing0066 requested a review from ihexxa April 25, 2025 02:39
@ZxBing0066 ZxBing0066 enabled auto-merge (squash) April 25, 2025 09:47
@ZxBing0066 ZxBing0066 merged commit 3fe4e54 into develop Apr 28, 2025
10 checks passed
@ZxBing0066 ZxBing0066 deleted the fix/action-bar-not-refreshed branch April 28, 2025 07:50
Copy link

sentry-io bot commented Apr 29, 2025

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ TypeError: Cannot destructure property 'activeRequest' of 'useRouteLoaderData(...)' as it is undefined. /index.html View Issue

Did you find this useful? React with a 👍 or 👎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants