Skip to content

feat: add options to close many tabs - #302

Merged
vitonsky merged 7 commits into
masterfrom
300-add-options-to-close-many-tabs
May 18, 2026
Merged

feat: add options to close many tabs#302
vitonsky merged 7 commits into
masterfrom
300-add-options-to-close-many-tabs

Conversation

@vitonsky

@vitonsky vitonsky commented May 18, 2026

Copy link
Copy Markdown
Member

Closes #300

Summary by CodeRabbit

  • New Features

    • Expanded note tab context menu with new close options: close current note, close all, close other notes, close to the left/right.
  • Tests

    • Added test utilities for Redux-backed store setup and note mocking. Added tests covering active-note behavior and many close-notes scenarios (by range, exclusions, explicit lists, and all).
  • Localization

    • Added tab-related menu translations across many locales.

Review Change Stack

@vitonsky vitonsky linked an issue May 18, 2026 that may be closed by this pull request
@coderabbitai

coderabbitai Bot commented May 18, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Adds a Redux closeNotes action to close note tabs by flexible queries, wires tab-context-menu actions to dispatch those queries, provides test helpers and suites validating behavior, and adds i18n keys for tab close actions across locales.

Changes

Close Multiple Notes Tabs

Layer / File(s) Summary
Test utilities
packages/app/src/__tests__/utils/redux.ts
mockNoteObject and createTestStore exported to seed settings and vault/workspace state for tests.
Redux closeNotes Reducer
packages/app/src/state/redux/vaults/vaults.ts
Adds closeNotes action that filters openedNotes (all/noteIds/exclude/afterNoteId/beforeNoteId), updates activeNote via neighbor selection, and records recentlyClosedNotes.
UI: context menu close actions
packages/app/src/features/NotesContainer/NoteContextMenu/index.ts, packages/app/src/features/NotesContainer/NoteContextMenu/useNoteContextMenu.ts, packages/app/src/features/NotesContainer/OpenedNotesPanel.tsx
Adds close-related NoteActions members; refactors `useNoteContextMenu(context?: 'tabs'
Behavioral tests
packages/app/src/state/redux/vaults/__tests__/redux.vault.activeNote.test.ts, packages/app/src/state/redux/vaults/redux-workspace-utils.test.ts
New tests validate active-note consistency and transitions, closeNotes query behaviors (ranges, explicit IDs, exclusions, all), recently-closed ordering, and findNearNote cases.
i18n: menu locale additions
packages/app/src/locales/*/menu.json
Adds note.tab subtree with close, closeOthers, closeToTheLeft, closeToTheRight, and closeAll keys across many locales.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • DeepinkApp/deepink#195: Modifies useNoteContextMenu.ts and related context-menu dispatch patterns; related to UI action dispatch changes in this PR.

Poem

🐰 I nibble keys and test each case,

Tabs hop left and tabs hop right,
Redux trims the open space,
Active notes find morning light,
Hooray — close all with a single bite!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

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.
Linked Issues check ❓ Inconclusive No detailed requirements found in linked issue #300, making a full compliance assessment impossible to verify against specific coding objectives. Provide detailed requirements from issue #300 or confirm the PR objectives independently to validate completeness of implementation.
✅ 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 'feat: add options to close many tabs' accurately summarizes the main change: extending the note context menu with new close-related actions.
Out of Scope Changes check ✅ Passed All changes are within scope: Redux store testing utilities, context menu action types/handlers, tab close logic, and comprehensive translations for tab actions.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 300-add-options-to-close-many-tabs

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

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/app/src/state/redux/vaults/__tests__/redux.vault.activeNote.test.ts (1)

10-12: ⚡ Quick win

Use a fresh store per test to avoid state leakage.

Line 11 and Line 128 create one shared mutable store per describe, so state from prior tests can leak (especially recentlyClosedNotes). Prefer creating the store in beforeEach (or inside each test) for isolation.

Suggested refactor
 describe('Active note consistency', () => {
-  const { store, workspaceScope, selectors } = createTestStore();
+  let store: ReturnType<typeof createTestStore>['store'];
+  let workspaceScope: ReturnType<typeof createTestStore>['workspaceScope'];
+  let selectors: ReturnType<typeof createTestStore>['selectors'];

-  // Init state
-  beforeAll(() => {
+  beforeEach(() => {
+    ({ store, workspaceScope, selectors } = createTestStore());
     store.dispatch(
       workspacesApi.setOpenedNotes({
         ...workspaceScope,
         notes: [mockNoteObject('1'), mockNoteObject('2'), mockNoteObject('3')],
       }),
     );
   });
 describe('Close note tabs via queries', () => {
-  const { store, workspaceScope, selectors } = createTestStore();
+  let store: ReturnType<typeof createTestStore>['store'];
+  let workspaceScope: ReturnType<typeof createTestStore>['workspaceScope'];
+  let selectors: ReturnType<typeof createTestStore>['selectors'];

   beforeEach(() => {
+    ({ store, workspaceScope, selectors } = createTestStore());
     store.dispatch(
       workspacesApi.setOpenedNotes({
         ...workspaceScope,

Also applies to: 127-129

🤖 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/app/src/state/redux/vaults/__tests__/redux.vault.activeNote.test.ts`
around lines 10 - 12, The test suite 'Active note consistency' currently calls
createTestStore() once at describe scope producing shared store, workspaceScope,
and selectors which allows state leakage across tests (e.g.,
recentlyClosedNotes); change the setup to initialize these per test by moving
const { store, workspaceScope, selectors } = createTestStore() into a beforeEach
block (or into each individual it/ test) so each test gets a fresh store
instance; update any references to store/workspaceScope/selectors inside tests
to use the freshly created variables.
🤖 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.

Inline comments:
In `@packages/app/src/state/redux/vaults/vaults.ts`:
- Around line 433-442: Detect and disallow the simultaneous use of
query.afterNoteId and query.beforeNoteId to avoid the conflicting early-return
behavior: add a runtime guard at the start of the vaults filtering routine in
vaults.ts that checks if both query.afterNoteId and query.beforeNoteId are set
and then either throw/log and return (or normalize by clearing one) so the later
per-id logic (the blocks referencing edgesReached.after, edgesReached.before and
excludes.has(id)) never runs with both boundaries active; this keeps the
afterNoteId early-return from bypassing the beforeNoteId logic and prevents
accidental over-closing.

---

Nitpick comments:
In
`@packages/app/src/state/redux/vaults/__tests__/redux.vault.activeNote.test.ts`:
- Around line 10-12: The test suite 'Active note consistency' currently calls
createTestStore() once at describe scope producing shared store, workspaceScope,
and selectors which allows state leakage across tests (e.g.,
recentlyClosedNotes); change the setup to initialize these per test by moving
const { store, workspaceScope, selectors } = createTestStore() into a beforeEach
block (or into each individual it/ test) so each test gets a fresh store
instance; update any references to store/workspaceScope/selectors inside tests
to use the freshly created variables.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c69c63d5-a744-4667-8b21-4d36b1a7de77

📥 Commits

Reviewing files that changed from the base of the PR and between ca7c8e4 and 78344cf.

📒 Files selected for processing (7)
  • packages/app/src/__tests__/utils/redux.ts
  • packages/app/src/features/NotesContainer/NoteContextMenu/index.ts
  • packages/app/src/features/NotesContainer/NoteContextMenu/useNoteContextMenu.ts
  • packages/app/src/features/NotesContainer/OpenedNotesPanel.tsx
  • packages/app/src/state/redux/vaults/__tests__/redux.vault.activeNote.test.ts
  • packages/app/src/state/redux/vaults/redux-workspace-utils.test.ts
  • packages/app/src/state/redux/vaults/vaults.ts

Comment thread packages/app/src/state/redux/vaults/vaults.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

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

Inline comments:
In `@packages/app/src/locales/sl/menu.json`:
- Line 26: The translation string for the move-to-bin action is incorrect for
key "deleteToBin" in the locales file; replace the current value "Prevedi v
smetnjak" with the proper user-facing Slovenian phrase such as "Premakni v koš"
(or "Premakni v smetnjak" if you prefer that wording) in the "deleteToBin" entry
so the UI shows "move to bin/trash" instead of "translate to trash". Ensure only
the string value for "deleteToBin" is changed and keep the JSON formatting
intact.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4a5c8522-00cd-477e-8c06-d482587885ec

📥 Commits

Reviewing files that changed from the base of the PR and between 78344cf and 02e3cda.

📒 Files selected for processing (37)
  • packages/app/src/features/NotesContainer/NoteContextMenu/useNoteContextMenu.ts
  • packages/app/src/locales/ar/menu.json
  • packages/app/src/locales/bg/menu.json
  • packages/app/src/locales/ca/menu.json
  • packages/app/src/locales/cs/menu.json
  • packages/app/src/locales/da/menu.json
  • packages/app/src/locales/de/menu.json
  • packages/app/src/locales/el/menu.json
  • packages/app/src/locales/en/menu.json
  • packages/app/src/locales/es/menu.json
  • packages/app/src/locales/fa/menu.json
  • packages/app/src/locales/fi/menu.json
  • packages/app/src/locales/fr/menu.json
  • packages/app/src/locales/he/menu.json
  • packages/app/src/locales/hi/menu.json
  • packages/app/src/locales/hu/menu.json
  • packages/app/src/locales/id/menu.json
  • packages/app/src/locales/it/menu.json
  • packages/app/src/locales/ja/menu.json
  • packages/app/src/locales/ka/menu.json
  • packages/app/src/locales/ko/menu.json
  • packages/app/src/locales/nb/menu.json
  • packages/app/src/locales/nl/menu.json
  • packages/app/src/locales/pl/menu.json
  • packages/app/src/locales/pt-BR/menu.json
  • packages/app/src/locales/pt-PT/menu.json
  • packages/app/src/locales/ro/menu.json
  • packages/app/src/locales/ru/menu.json
  • packages/app/src/locales/sl/menu.json
  • packages/app/src/locales/sr/menu.json
  • packages/app/src/locales/sv/menu.json
  • packages/app/src/locales/th/menu.json
  • packages/app/src/locales/tr/menu.json
  • packages/app/src/locales/uk/menu.json
  • packages/app/src/locales/vi/menu.json
  • packages/app/src/locales/zh-CN/menu.json
  • packages/app/src/locales/zh-TW/menu.json
✅ Files skipped from review due to trivial changes (20)
  • packages/app/src/locales/ar/menu.json
  • packages/app/src/locales/it/menu.json
  • packages/app/src/locales/es/menu.json
  • packages/app/src/locales/de/menu.json
  • packages/app/src/locales/ru/menu.json
  • packages/app/src/locales/ka/menu.json
  • packages/app/src/locales/zh-CN/menu.json
  • packages/app/src/locales/ca/menu.json
  • packages/app/src/locales/pl/menu.json
  • packages/app/src/locales/hu/menu.json
  • packages/app/src/locales/hi/menu.json
  • packages/app/src/locales/nb/menu.json
  • packages/app/src/locales/fi/menu.json
  • packages/app/src/locales/he/menu.json
  • packages/app/src/locales/uk/menu.json
  • packages/app/src/locales/nl/menu.json
  • packages/app/src/locales/da/menu.json
  • packages/app/src/locales/zh-TW/menu.json
  • packages/app/src/locales/pt-PT/menu.json
  • packages/app/src/locales/ro/menu.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/app/src/features/NotesContainer/NoteContextMenu/useNoteContextMenu.ts

Comment thread packages/app/src/locales/sl/menu.json
@vitonsky
vitonsky merged commit c53db8a into master May 18, 2026
6 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request May 20, 2026
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.

Add options to close many tabs

1 participant