Skip to content

fix(web): close settings with Escape#916

Closed
anduimagui wants to merge 3 commits intopingdotgg:mainfrom
anduimagui:fix/web-settings-escape
Closed

fix(web): close settings with Escape#916
anduimagui wants to merge 3 commits intopingdotgg:mainfrom
anduimagui:fix/web-settings-escape

Conversation

@anduimagui
Copy link
Copy Markdown

@anduimagui anduimagui commented Mar 11, 2026

What Changed

  • add an Escape handler to the settings route so the existing settings view can be dismissed from the keyboard
  • reuse the current back-navigation flow when settings was opened from inside the app, with a safe fallback to / for direct-entry cases
  • cover the Escape match and history fallback logic with focused unit tests

Why

  • CmdOrCtrl+, already opens settings in desktop builds, but there was no matching keyboard path to leave that view
  • using the same back behavior as the sidebar keeps settings exit behavior predictable whether the view came from the menu or in-app navigation

UI Changes

  • No visual UI changes; this is a keyboard-only interaction update, so screenshots/video are not applicable.

Validation

  • bun fmt
  • bun lint
  • bun typecheck
  • bun run test src/lib/settingsNavigation.test.ts

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Note

Close settings view on Escape key press

Adds a keydown listener in _chat.settings.tsx that closes the settings view when an unmodified, unprevented Escape key is pressed. If in-app back navigation is available (detected via TanStack Router's __TSR_index in window.history.state), it calls window.history.back(); otherwise it navigates to / with replace: true. Two utility functions, shouldCloseSettingsOnEscape and canNavigateBackInApp, are extracted to settingsNavigation.ts with corresponding Vitest tests.

Macroscope summarized 1c79239.


Note

Low Risk
Adds a global Escape key handler to the settings route that manipulates browser history/navigation; limited scope but could affect keyboard shortcut propagation and routing behavior.

Overview
Enables dismissing the settings view via an unmodified Escape keypress.

_chat.settings.tsx now installs a window keydown listener that prevents/stops the event, navigates back() when TanStack Router history indicates an in-app previous entry, and otherwise replaces the route with /.

Adds settingsNavigation.ts with small helpers (shouldCloseSettingsOnEscape, canNavigateBackInApp) plus Vitest coverage for Escape matching and history-state detection.

Written by Cursor Bugbot for commit 1c79239. This will update automatically on new commits. Configure here.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 11, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 0ccb78d1-3ccc-439a-9c54-6921e1a2c81e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ 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 and usage tips.

@github-actions github-actions bot added the vouch:unvouched PR author is not yet trusted in the VOUCHED list. label Mar 11, 2026
@anduimagui anduimagui marked this pull request as ready for review March 15, 2026 08:43
@github-actions github-actions bot added the size:M 30-99 changed lines (additions + deletions). label Mar 15, 2026
Comment on lines +321 to +342
useEffect(() => {
const onWindowKeyDown = (event: KeyboardEvent) => {
if (!shouldCloseSettingsOnEscape(event)) {
return;
}

event.preventDefault();
event.stopPropagation();

if (canNavigateBackInApp(window.history.state)) {
window.history.back();
return;
}

void navigate({ to: "/", replace: true });
};

window.addEventListener("keydown", onWindowKeyDown);
return () => {
window.removeEventListener("keydown", onWindowKeyDown);
};
}, [navigate]);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this will conflict with the global keybinding system pretty sure

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

no longer the case with new sidebar layout.

fixed in #1503

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

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants