Skip to content

Comments

fix: make mouse back/forward navigation configurable#1708

Open
kingdomseed wants to merge 2 commits intosuperset-sh:mainfrom
kingdomseed:fix-mouse-navigation-setting
Open

fix: make mouse back/forward navigation configurable#1708
kingdomseed wants to merge 2 commits intosuperset-sh:mainfrom
kingdomseed:fix-mouse-navigation-setting

Conversation

@kingdomseed
Copy link

@kingdomseed kingdomseed commented Feb 23, 2026

Description

Make mouse back/forward navigation configurable in the desktop app. The default is disabled to respect system shortcuts while keeping the behavior opt‑in.

Related Issues

Closes #1701

Type of Change

  • Bug fix
  • New feature
  • Documentation
  • Refactor
  • Other (please describe):

Testing

  • bun run lint (pass)
  • bun run format (pass)
  • bun run typecheck (pass)
  • bun run test (pass)

Screenshots (if applicable)

N/A

Additional Notes

Adds a new settings toggle under Settings → Behavior and persists it to the local DB. Includes a new local‑db migration.

Summary by CodeRabbit

  • New Features
    • Added mouse navigation support: use mouse buttons 3 and 4 to navigate backward and forward between workspace tabs
    • New toggle in behavior settings to enable/disable mouse navigation feature

Copilot AI review requested due to automatic review settings February 23, 2026 17:26
Copy link

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

Adds an opt-in setting to enable mouse back/forward button navigation between workspace tabs in the desktop app (defaulting to disabled to avoid conflicting with OS/system mouse shortcuts), persisted via local-db.

Changes:

  • Add mouseNavigationEnabled setting to the local DB schema + Drizzle migration/snapshot metadata.
  • Expose getMouseNavigationEnabled / setMouseNavigationEnabled via the settings tRPC router and wire it into the Behavior settings UI.
  • Gate the NavigationControls mouse button listener behind the new setting.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/local-db/src/schema/schema.ts Adds mouseNavigationEnabled boolean setting column to the Drizzle schema.
packages/local-db/drizzle/meta/_journal.json Registers migration 0032 in Drizzle’s migration journal.
packages/local-db/drizzle/meta/0032_snapshot.json New Drizzle snapshot reflecting the updated schema.
packages/local-db/drizzle/0032_normal_cardiac.sql Migration adding mouse_navigation_enabled column to settings.
apps/desktop/src/shared/constants.ts Introduces default value DEFAULT_MOUSE_NAVIGATION_ENABLED = false.
apps/desktop/src/renderer/routes/_authenticated/settings/utils/settings-search/settings-search.ts Adds a searchable settings entry for the new Behavior toggle.
apps/desktop/src/renderer/routes/_authenticated/settings/behavior/components/BehaviorSettings/BehaviorSettings.tsx Adds UI toggle + optimistic mutation for mouse navigation setting.
apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/TopBar/components/NavigationControls/NavigationControls.tsx Conditionally installs mouseup handler only when setting is enabled.
apps/desktop/src/lib/trpc/routers/settings/index.ts Adds tRPC procedures to get/set the new persisted setting.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@kingdomseed kingdomseed changed the title Make mouse back/forward navigation configurable fix: make mouse back/forward navigation configurable Feb 24, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 24, 2026

📝 Walkthrough

Walkthrough

The changes introduce a configurable mouse navigation feature, allowing users to enable or disable mouse button 3/4 navigation between workspace tabs. New database schema, TRPC procedures, and UI settings components enable fetching and persisting this user preference.

Changes

Cohort / File(s) Summary
Database Schema & Migrations
packages/local-db/drizzle/0032_normal_cardiac.sql, packages/local-db/drizzle/meta/0032_snapshot.json, packages/local-db/drizzle/meta/_journal.json, packages/local-db/src/schema/schema.ts
Added mouseNavigationEnabled integer column to settings table with corresponding schema field and migration metadata.
Shared Constants
apps/desktop/src/shared/constants.ts
Introduced DEFAULT_MOUSE_NAVIGATION_ENABLED constant set to false as the default preference value.
Settings API Router
apps/desktop/src/lib/trpc/routers/settings/index.ts
Added two TRPC procedures: getMouseNavigationEnabled (query that reads setting with fallback to default) and setMouseNavigationEnabled (mutation that upserts setting value and returns success).
Navigation Component
apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/TopBar/components/NavigationControls/NavigationControls.tsx
Integrated mouse navigation query, conditionally enabled mouseup event handler for buttons 3 and 4 based on fetched setting, and updated effect dependencies.
Settings UI & Search
apps/desktop/src/renderer/routes/_authenticated/settings/behavior/components/BehaviorSettings/BehaviorSettings.tsx, apps/desktop/src/renderer/routes/_authenticated/settings/utils/settings-search/settings-search.ts
Added UI toggle for mouse navigation setting with query/mutation integration, optimistic updates, and error handling; registered setting in searchable settings items with metadata.

Sequence Diagram

sequenceDiagram
    participant User
    participant UI as BehaviorSettings UI
    participant Query as getMouseNavigationEnabled Query
    participant Mutation as setMouseNavigationEnabled Mutation
    participant TRPC as TRPC Router
    participant DB as Settings Table

    User->>UI: Opens settings page
    UI->>Query: Fetch mouse navigation enabled
    Query->>TRPC: Call getMouseNavigationEnabled()
    TRPC->>DB: Read mouseNavigationEnabled
    DB-->>TRPC: Return value or null
    TRPC-->>Query: Return (value ?? DEFAULT_FALSE)
    Query-->>UI: Display current setting

    User->>UI: Toggle mouse navigation switch
    UI->>UI: Optimistic update local state
    UI->>Mutation: Call setMouseNavigationEnabled({enabled})
    Mutation->>TRPC: Call setMouseNavigationEnabled()
    TRPC->>DB: Upsert mouseNavigationEnabled
    DB-->>TRPC: Confirm success
    TRPC-->>Mutation: Return {success: true}
    Mutation-->>UI: Invalidate query, sync state

    Note over UI,DB: NavigationControls component now<br/>conditionally listens to mouse<br/>buttons 3/4 based on setting
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Whiskers twitch with delight!
Mouse buttons dance at the user's command,
No more forced navigation—now choice rules the land!
A toggle, a query, a setting so sweet,
The woodland apps bow to control, neat and complete! 🖱️✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title 'fix: make mouse back/forward navigation configurable' accurately and concisely describes the main change—making mouse navigation a user-configurable feature instead of always-on behavior.
Description check ✅ Passed The PR description follows the required template with all essential sections completed: clear description, linked issue reference, type of change marked, testing steps listed, and relevant additional context provided about the new settings toggle and DB migration.
Linked Issues check ✅ Passed The PR fully implements the 'make configurable' solution from issue #1701: adds a settings toggle under Behavior, defaults to disabled to respect system shortcuts, persists via DB migration, and guards mouse button navigation behind the setting toggle.
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing the configurable mouse navigation feature: settings router procedures, UI toggle, database schema migration, constants, and search index—no unrelated modifications detected.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

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 (2)
packages/local-db/drizzle/meta/0032_snapshot.json (1)

138-182: ⚠️ Potential issue | 🔴 Critical

JSON syntax error: missing commas before duplicate key sections.

The organization_members_organization_id_organizations_id_fk and organization_members_user_id_users_id_fk foreign key definitions contain syntax errors that make the file unparseable. Line 150 ends without a comma before the duplicate keys begin at line 151; the same issue occurs at lines 171–172. This is a merge or generation artifact that resulted in malformed JSON.

Regenerate the snapshot with drizzle-kit generate to produce valid output.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/local-db/drizzle/meta/0032_snapshot.json` around lines 138 - 182,
The JSON in the snapshot contains duplicated/merged sections and missing commas
in the foreign key objects for
organization_members_organization_id_organizations_id_fk and
organization_members_user_id_users_id_fk which makes the file invalid; fix by
removing the duplicated blocks and restoring proper JSON structure (ensure each
object has a single set of keys: name, tableFrom, tableTo, columnsFrom,
columnsTo, onDelete, onUpdate, with commas between entries) for the two foreign
keys, or simply regenerate the snapshot using drizzle-kit generate to recreate a
valid packages/local-db/drizzle/meta/0032_snapshot.json containing correct
definitions for organization_members_organization_id_organizations_id_fk and
organization_members_user_id_users_id_fk.
packages/local-db/drizzle/meta/_journal.json (1)

229-237: ⚠️ Potential issue | 🔴 Critical

Critical: Duplicate when/tag keys in journal entry idx 32 — migration will be silently lost.

Entry idx 32 in _journal.json contains two "when" and two "tag" keys within the same JSON object (lines 232–235). When parsed as standard JSON, only the last occurrence of each key is retained, meaning "0032_normal_cardiac" is silently overwritten by "0032_migrate_workspace_ids_to_uuid_v4". As a result, the migration from 0032_normal_cardiac.sql will never be applied to existing databases.

This is a merge conflict where both migrations received idx 32. Renumber the new migration to idx 33 (or the next available index) and rename all corresponding files (0033_normal_cardiac.sql, 0033_snapshot.json, etc.) to match. Alternatively, regenerate via drizzle-kit generate after rebasing on main.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/local-db/drizzle/meta/_journal.json` around lines 229 - 237, The
journal entry at idx 32 contains duplicate "when" and "tag" keys
("0032_normal_cardiac" and "0032_migrate_workspace_ids_to_uuid_v4") so the first
migration is being overwritten; fix by renumbering the conflicting migration to
the next available index (e.g., change "0032_normal_cardiac" ->
"0033_normal_cardiac"), update the corresponding filenames
(0032_normal_cardiac.sql, 0032_snapshot.json, etc.) to match the new index, and
update the _journal.json entry so idx 32 refers only to the intended migration
and the new idx (33) has the renamed migration and correct "when"/"tag" values;
alternatively re-generate the journal with drizzle-kit generate after rebasing
main to ensure consistent indices.
🧹 Nitpick comments (1)
apps/desktop/src/renderer/routes/_authenticated/settings/behavior/components/BehaviorSettings/BehaviorSettings.tsx (1)

462-483: LGTM — UI block is well-formed; consider adding a test for the new toggle.

The htmlFor/id pairing is correct, the ?? false default aligns with the opt-in intent, and the disabled logic mirrors all other switches. However, no test file is provided for the new toggle path. As per coding guidelines, tests should be co-located using BehaviorSettings.test.tsx.

#!/bin/bash
# Check whether a test file already exists for BehaviorSettings
fd -t f "BehaviorSettings.test.tsx" --full-path
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@apps/desktop/src/renderer/routes/_authenticated/settings/behavior/components/BehaviorSettings/BehaviorSettings.tsx`
around lines 462 - 483, Add a co-located test file BehaviorSettings.test.tsx
that covers the new mouse navigation toggle in the BehaviorSettings component:
mount/render BehaviorSettings with showMouseNavigation=true and assert the
Switch with id "mouse-navigation" / Label exists, verify it defaults to
unchecked when mouseNavigationEnabled is undefined (the component uses
"mouseNavigationEnabled ?? false"), verify the Switch is disabled when
isMouseNavigationLoading or setMouseNavigationEnabled.isPending are true, and
simulate toggling to assert setMouseNavigationEnabled.mutate is called;
reference the component and props: BehaviorSettings, showMouseNavigation,
mouseNavigationEnabled, setMouseNavigationEnabled, and isMouseNavigationLoading
when writing tests.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@packages/local-db/drizzle/meta/_journal.json`:
- Around line 229-237: The journal entry at idx 32 contains duplicate "when" and
"tag" keys ("0032_normal_cardiac" and "0032_migrate_workspace_ids_to_uuid_v4")
so the first migration is being overwritten; fix by renumbering the conflicting
migration to the next available index (e.g., change "0032_normal_cardiac" ->
"0033_normal_cardiac"), update the corresponding filenames
(0032_normal_cardiac.sql, 0032_snapshot.json, etc.) to match the new index, and
update the _journal.json entry so idx 32 refers only to the intended migration
and the new idx (33) has the renamed migration and correct "when"/"tag" values;
alternatively re-generate the journal with drizzle-kit generate after rebasing
main to ensure consistent indices.

In `@packages/local-db/drizzle/meta/0032_snapshot.json`:
- Around line 138-182: The JSON in the snapshot contains duplicated/merged
sections and missing commas in the foreign key objects for
organization_members_organization_id_organizations_id_fk and
organization_members_user_id_users_id_fk which makes the file invalid; fix by
removing the duplicated blocks and restoring proper JSON structure (ensure each
object has a single set of keys: name, tableFrom, tableTo, columnsFrom,
columnsTo, onDelete, onUpdate, with commas between entries) for the two foreign
keys, or simply regenerate the snapshot using drizzle-kit generate to recreate a
valid packages/local-db/drizzle/meta/0032_snapshot.json containing correct
definitions for organization_members_organization_id_organizations_id_fk and
organization_members_user_id_users_id_fk.

---

Nitpick comments:
In
`@apps/desktop/src/renderer/routes/_authenticated/settings/behavior/components/BehaviorSettings/BehaviorSettings.tsx`:
- Around line 462-483: Add a co-located test file BehaviorSettings.test.tsx that
covers the new mouse navigation toggle in the BehaviorSettings component:
mount/render BehaviorSettings with showMouseNavigation=true and assert the
Switch with id "mouse-navigation" / Label exists, verify it defaults to
unchecked when mouseNavigationEnabled is undefined (the component uses
"mouseNavigationEnabled ?? false"), verify the Switch is disabled when
isMouseNavigationLoading or setMouseNavigationEnabled.isPending are true, and
simulate toggling to assert setMouseNavigationEnabled.mutate is called;
reference the component and props: BehaviorSettings, showMouseNavigation,
mouseNavigationEnabled, setMouseNavigationEnabled, and isMouseNavigationLoading
when writing tests.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1207434 and eac7bbd.

📒 Files selected for processing (9)
  • apps/desktop/src/lib/trpc/routers/settings/index.ts
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/TopBar/components/NavigationControls/NavigationControls.tsx
  • apps/desktop/src/renderer/routes/_authenticated/settings/behavior/components/BehaviorSettings/BehaviorSettings.tsx
  • apps/desktop/src/renderer/routes/_authenticated/settings/utils/settings-search/settings-search.ts
  • apps/desktop/src/shared/constants.ts
  • packages/local-db/drizzle/0032_normal_cardiac.sql
  • packages/local-db/drizzle/meta/0032_snapshot.json
  • packages/local-db/drizzle/meta/_journal.json
  • packages/local-db/src/schema/schema.ts

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.

Disable or make configurable mouse forward/back buttons for workspace navigation

1 participant