Skip to content

refactor: remove dead store exports (Phase 01B)#810

Merged
reachrazamair merged 3 commits intoRunMaestro:rcfrom
jSydorowicz21:dedup/phase-01b-dead-store-exports
Apr 16, 2026
Merged

refactor: remove dead store exports (Phase 01B)#810
reachrazamair merged 3 commits intoRunMaestro:rcfrom
jSydorowicz21:dedup/phase-01b-dead-store-exports

Conversation

@jSydorowicz21
Copy link
Copy Markdown
Contributor

@jSydorowicz21 jSydorowicz21 commented Apr 12, 2026

Summary

Removes 52 dead Zustand store exports across 10 store files. Each removal was verified to have zero external production references (grep excluded the store's own file and any `tests/` directories).

Net: -976 lines across 23 files

Stores touched:

  • `agentStore` (4 exports removed)
  • `batchStore` (3)
  • `fileExplorerStore` (2)
  • `groupChatStore` (2)
  • `modalStore` (1 - `selectModal` only; `selectModalOpen`/`selectModalData` kept, they are actively used)
  • `notificationStore` (6)
  • `operationStore` (3)
  • `sessionStore` (9)
  • `settingsStore` (10 - `DEFAULT_*` constants demoted to private; `getSettingsState`/`getSettingsActions` fully removed)
  • `tabStore` (12)

Test files updated to remove references to deleted exports; settings tests use a deep clone of defaults captured via `useSettingsStore.getState()`.

Test plan

  • `npm run lint` passes clean
  • All 747 store tests pass
  • Create/delete/rename sessions works
  • Open/close modals works
  • Toasts/notifications render
  • Switch between AI tabs within a session
  • Settings persist after restart

Risk

Very low - exports-only change with zero external consumers. Store internals and public APIs are unchanged.

Summary by CodeRabbit

  • Refactor

    • Removed many test-only helpers/selectors and converted several exported defaults/utilities to module-internal scope; standardized direct store access.
    • No changes to user-facing behavior or UI.
  • Tests

    • Updated test suites to use direct store access and local deep-cloned defaults to prevent cross-test mutation.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 12, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Multiple Zustand store modules had selector helpers, non‑React accessors, and several exported DEFAULT_* constants removed or internalized; tests and docs were updated to read state and invoke actions directly via useXStore.getState(), often deep‑cloning store slices for test fixtures.

Changes

Cohort / File(s) Summary
Settings store & tests
src/renderer/stores/settingsStore.ts, src/__tests__/renderer/stores/settingsStore.test.ts, src/__tests__/renderer/hooks/useSettings.test.ts, src/__tests__/renderer/fonts-and-sizing.test.ts
Made many DEFAULT_* constants and getBadgeLevelForTime module‑internal; removed getSettingsState()/getSettingsActions() exports. Tests now deep‑clone defaults from useSettingsStore.getState() and use local badge logic.
Tab & Session stores + tests
src/renderer/stores/tabStore.ts, src/renderer/stores/sessionStore.ts, src/__tests__/renderer/stores/tabStore.test.ts, src/__tests__/renderer/stores/sessionStore.test.ts
Removed numerous session/tab selector exports and non‑React helpers (getTabState/getTabActions, getSessionState/getSessionActions). Tests replaced selector usage with direct reads/filters on useSessionStore.getState() and actions via useTabStore.getState().
Notification, Operation, Batch, Agent stores + tests
src/renderer/stores/notificationStore.ts, src/renderer/stores/operationStore.ts, src/renderer/stores/batchStore.ts, src/renderer/stores/agentStore.ts, src/__tests__/renderer/stores/*
Removed exported selectors and non‑React accessors (e.g., selectToasts, selectIsAnyOperationInProgress, selectStoppingBatchSessionIds, selectAvailableAgents) and resetToastIdCounter. Tests migrated to useXStore.getState(); primary runtime APIs like notifyToast remain.
FileExplorer, GroupChat, Modal stores & tests
src/renderer/stores/fileExplorerStore.ts, src/renderer/stores/groupChatStore.ts, src/renderer/stores/modalStore.ts, src/__tests__/renderer/stores/*
Removed get*State/get*Actions() helpers and selectModal export; updated module docs to recommend useXStore.getState() and updated tests to call state/actions directly.
Misc component & test updates
src/__tests__/renderer/components/SessionList.test.tsx, src/__tests__/renderer/fonts-and-sizing.test.ts, src/__tests__/renderer/stores/*
Replaced imported exported defaults/non‑React helpers with file‑local deep‑cloned defaults from useSettingsStore.getState() and changed tests to access state/actions via useXStore.getState().
Docs/comments
src/renderer/stores/...
Updated module header comments to instruct non‑React access via useXStore.getState() and removed references to deleted helper functions/selectors.

Sequence Diagram(s)

(omitted — changes are API/exports removals and test updates; no new multi‑component control flow introduced)

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

approved

Poem

🐇 I hopped through modules, hid defaults from sight,
Tests now peek at getState in the pale moonlight.
Selectors grew quiet, helpers trimmed small,
I nibbled exports down—cheers to one and all! 🥕

🚥 Pre-merge checks | ✅ 3
✅ 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 clearly and specifically summarizes the main change: removing dead store exports across 10 store files. It is concise and directly related to the primary changeset objective.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

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

@jSydorowicz21 jSydorowicz21 force-pushed the dedup/phase-01b-dead-store-exports branch 2 times, most recently from a3e658e to 961e62c Compare April 13, 2026 19:23
@jSydorowicz21 jSydorowicz21 self-assigned this Apr 14, 2026
@jSydorowicz21 jSydorowicz21 marked this pull request as ready for review April 14, 2026 04:35
Copy link
Copy Markdown

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

🧹 Nitpick comments (5)
src/__tests__/renderer/hooks/useSettings.test.ts (1)

10-20: Prefer per-test fresh defaults instead of one module-scope snapshot.

Lines 10-20 build reusable objects once. For stronger isolation, build fresh deep-cloned defaults inside beforeEach so nested test mutations can’t bleed across cases.

♻️ Suggested pattern
-const _INITIAL_STATE = useSettingsStore.getState();
-const DEFAULT_CONTEXT_MANAGEMENT_SETTINGS = JSON.parse(
-	JSON.stringify(_INITIAL_STATE.contextManagementSettings)
-);
-const DEFAULT_AUTO_RUN_STATS = JSON.parse(JSON.stringify(_INITIAL_STATE.autoRunStats));
-const DEFAULT_USAGE_STATS = JSON.parse(JSON.stringify(_INITIAL_STATE.usageStats));
-const DEFAULT_KEYBOARD_MASTERY_STATS = JSON.parse(
-	JSON.stringify(_INITIAL_STATE.keyboardMasteryStats)
-);
-const DEFAULT_ONBOARDING_STATS = JSON.parse(JSON.stringify(_INITIAL_STATE.onboardingStats));
-const DEFAULT_AI_COMMANDS = JSON.parse(JSON.stringify(_INITIAL_STATE.customAICommands));
+const getFreshDefaults = () => {
+	const state = useSettingsStore.getState();
+	return {
+		contextManagementSettings: JSON.parse(JSON.stringify(state.contextManagementSettings)),
+		autoRunStats: JSON.parse(JSON.stringify(state.autoRunStats)),
+		usageStats: JSON.parse(JSON.stringify(state.usageStats)),
+		keyboardMasteryStats: JSON.parse(JSON.stringify(state.keyboardMasteryStats)),
+		onboardingStats: JSON.parse(JSON.stringify(state.onboardingStats)),
+		customAICommands: JSON.parse(JSON.stringify(state.customAICommands)),
+	};
+};

Then in beforeEach, derive and use const defaults = getFreshDefaults().

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

In `@src/__tests__/renderer/hooks/useSettings.test.ts` around lines 10 - 20, The
module currently captures a single snapshot (_INITIAL_STATE) and builds
DEFAULT_CONTEXT_MANAGEMENT_SETTINGS, DEFAULT_AUTO_RUN_STATS,
DEFAULT_USAGE_STATS, DEFAULT_KEYBOARD_MASTERY_STATS, DEFAULT_ONBOARDING_STATS
and DEFAULT_AI_COMMANDS once at module scope, which lets nested test mutations
leak across cases; change this by creating a helper (e.g., getFreshDefaults)
that reads useSettingsStore.getState() and returns deep-cloned defaults, and
call that helper inside beforeEach to produce fresh defaults for each test
instead of using the module-scope _INITIAL_STATE and DEFAULT_* constants.
src/__tests__/renderer/components/SessionList.test.tsx (1)

22-23: Use a fresh default clone per test to avoid shared nested refs.

Line 23 captures defaults once at module load. Since setup later uses shallow spreading, nested values can be shared across tests. Prefer generating a fresh deep clone in beforeEach.

♻️ Suggested hardening
-const DEFAULT_AUTO_RUN_STATS = JSON.parse(JSON.stringify(useSettingsStore.getState().autoRunStats));
+const makeDefaultAutoRunStats = () =>
+	JSON.parse(JSON.stringify(useSettingsStore.getState().autoRunStats));
-			autoRunStats: { ...DEFAULT_AUTO_RUN_STATS },
+			autoRunStats: makeDefaultAutoRunStats(),
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/__tests__/renderer/components/SessionList.test.tsx` around lines 22 - 23,
The module-level deep clone DEFAULT_AUTO_RUN_STATS created from
useSettingsStore.getState().autoRunStats should not be captured once at import
time because nested refs can be shared across tests; instead, create a fresh
deep clone in a beforeEach hook (e.g., assign a local variable like
defaultAutoRunStats =
JSON.parse(JSON.stringify(useSettingsStore.getState().autoRunStats)) inside
beforeEach) and update tests to reference that per-test variable so each test
gets an isolated deep copy; alternatively replace the module-level constant with
a factory function that returns
JSON.parse(JSON.stringify(useSettingsStore.getState().autoRunStats)) and call it
from beforeEach or each test.
src/__tests__/renderer/stores/settingsStore.test.ts (1)

27-57: Avoid duplicating store logic in test helpers.

Inlining getBadgeLevelForTime here makes this suite test a copied implementation instead of the production path. Prefer asserting badge behavior through public store actions (recordAutoRunComplete / updateAutoRunProgress) at threshold boundaries.

Also applies to: 1101-1124

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

In `@src/__tests__/renderer/stores/settingsStore.test.ts` around lines 27 - 57,
Tests duplicate the store's badge-calculation logic by inlining
getBadgeLevelForTime; remove the local function and instead drive the store via
its public API (use settingsStore and call recordAutoRunComplete and/or
updateAutoRunProgress) to reach threshold boundaries, then assert the resulting
badge level from the store state or public getter. Replace direct calls to
getBadgeLevelForTime in the tests with scenarios that simulate cumulative time
via the store actions at each threshold and verify the produced badge level.
src/__tests__/renderer/fonts-and-sizing.test.ts (1)

25-35: Prefer deterministic test fixtures over module-load getState() snapshots.

Capturing defaults from useSettingsStore.getState() at module load can make these baseline constants sensitive to prior singleton mutations. Consider using explicit local fixtures (or a dedicated reset helper source) so defaults are deterministic and order-independent.

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

In `@src/__tests__/renderer/fonts-and-sizing.test.ts` around lines 25 - 35, The
test currently captures baseline values at module load using
useSettingsStore.getState() to populate DEFAULT_CONTEXT_MANAGEMENT_SETTINGS,
DEFAULT_AUTO_RUN_STATS, DEFAULT_USAGE_STATS, DEFAULT_KEYBOARD_MASTERY_STATS,
DEFAULT_ONBOARDING_STATS, and DEFAULT_AI_COMMANDS which makes fixtures
order-dependent; change this by replacing module-load snapshots with
deterministic fixtures or a dedicated reset helper: either (a) define explicit
literal objects for each DEFAULT_* fixture so they are deterministic and
independent of store mutations, or (b) call useSettingsStore.getState() inside a
beforeEach/test-setup function (or use the project’s resetSettingsStore helper)
to obtain fresh state per test; update references to these constants accordingly
so tests no longer rely on module-initialized getState() snapshots.
src/__tests__/renderer/stores/notificationStore.test.ts (1)

249-255: Harden the counter-increment assertion with explicit numeric guards.

Add finite-number checks before the increment assertion so this test fails clearly if ID parsing ever changes.

Proposed test hardening
 		it('counter portion increments between consecutive calls', () => {
 			const id1 = notifyToast({ type: 'success', title: 'A', message: 'a' });
 			const id2 = notifyToast({ type: 'success', title: 'B', message: 'b' });
 			const counter1 = Number(id1.split('-').pop());
 			const counter2 = Number(id2.split('-').pop());
+			expect(Number.isFinite(counter1)).toBe(true);
+			expect(Number.isFinite(counter2)).toBe(true);
 			expect(counter2).toBe(counter1 + 1);
 		});
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/__tests__/renderer/stores/notificationStore.test.ts` around lines 249 -
255, The test extracting numeric counters from notifyToast IDs should validate
the parsed numbers before asserting increment; update the spec around
notifyToast, id1/id2 and counter1/counter2 to parse the tail with parseInt(...,
10) (or Number()) and add explicit guards such as Number.isFinite(counter1) and
Number.isFinite(counter2) (or expect(!Number.isNaN(counter1)).toBe(true)) before
the expect(counter2).toBe(counter1 + 1) assertion so the test fails with a clear
message if ID parsing changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/__tests__/renderer/components/SessionList.test.tsx`:
- Around line 22-23: The module-level deep clone DEFAULT_AUTO_RUN_STATS created
from useSettingsStore.getState().autoRunStats should not be captured once at
import time because nested refs can be shared across tests; instead, create a
fresh deep clone in a beforeEach hook (e.g., assign a local variable like
defaultAutoRunStats =
JSON.parse(JSON.stringify(useSettingsStore.getState().autoRunStats)) inside
beforeEach) and update tests to reference that per-test variable so each test
gets an isolated deep copy; alternatively replace the module-level constant with
a factory function that returns
JSON.parse(JSON.stringify(useSettingsStore.getState().autoRunStats)) and call it
from beforeEach or each test.

In `@src/__tests__/renderer/fonts-and-sizing.test.ts`:
- Around line 25-35: The test currently captures baseline values at module load
using useSettingsStore.getState() to populate
DEFAULT_CONTEXT_MANAGEMENT_SETTINGS, DEFAULT_AUTO_RUN_STATS,
DEFAULT_USAGE_STATS, DEFAULT_KEYBOARD_MASTERY_STATS, DEFAULT_ONBOARDING_STATS,
and DEFAULT_AI_COMMANDS which makes fixtures order-dependent; change this by
replacing module-load snapshots with deterministic fixtures or a dedicated reset
helper: either (a) define explicit literal objects for each DEFAULT_* fixture so
they are deterministic and independent of store mutations, or (b) call
useSettingsStore.getState() inside a beforeEach/test-setup function (or use the
project’s resetSettingsStore helper) to obtain fresh state per test; update
references to these constants accordingly so tests no longer rely on
module-initialized getState() snapshots.

In `@src/__tests__/renderer/hooks/useSettings.test.ts`:
- Around line 10-20: The module currently captures a single snapshot
(_INITIAL_STATE) and builds DEFAULT_CONTEXT_MANAGEMENT_SETTINGS,
DEFAULT_AUTO_RUN_STATS, DEFAULT_USAGE_STATS, DEFAULT_KEYBOARD_MASTERY_STATS,
DEFAULT_ONBOARDING_STATS and DEFAULT_AI_COMMANDS once at module scope, which
lets nested test mutations leak across cases; change this by creating a helper
(e.g., getFreshDefaults) that reads useSettingsStore.getState() and returns
deep-cloned defaults, and call that helper inside beforeEach to produce fresh
defaults for each test instead of using the module-scope _INITIAL_STATE and
DEFAULT_* constants.

In `@src/__tests__/renderer/stores/notificationStore.test.ts`:
- Around line 249-255: The test extracting numeric counters from notifyToast IDs
should validate the parsed numbers before asserting increment; update the spec
around notifyToast, id1/id2 and counter1/counter2 to parse the tail with
parseInt(..., 10) (or Number()) and add explicit guards such as
Number.isFinite(counter1) and Number.isFinite(counter2) (or
expect(!Number.isNaN(counter1)).toBe(true)) before the
expect(counter2).toBe(counter1 + 1) assertion so the test fails with a clear
message if ID parsing changes.

In `@src/__tests__/renderer/stores/settingsStore.test.ts`:
- Around line 27-57: Tests duplicate the store's badge-calculation logic by
inlining getBadgeLevelForTime; remove the local function and instead drive the
store via its public API (use settingsStore and call recordAutoRunComplete
and/or updateAutoRunProgress) to reach threshold boundaries, then assert the
resulting badge level from the store state or public getter. Replace direct
calls to getBadgeLevelForTime in the tests with scenarios that simulate
cumulative time via the store actions at each threshold and verify the produced
badge level.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: de710a93-d627-47cc-8f10-a6d6e3ee3a1f

📥 Commits

Reviewing files that changed from the base of the PR and between b37cd16 and 961e62c.

📒 Files selected for processing (23)
  • src/__tests__/renderer/components/SessionList.test.tsx
  • src/__tests__/renderer/fonts-and-sizing.test.ts
  • src/__tests__/renderer/hooks/useSettings.test.ts
  • src/__tests__/renderer/stores/agentStore.test.ts
  • src/__tests__/renderer/stores/batchStore.test.ts
  • src/__tests__/renderer/stores/fileExplorerStore.test.ts
  • src/__tests__/renderer/stores/groupChatStore.test.ts
  • src/__tests__/renderer/stores/modalStore.test.ts
  • src/__tests__/renderer/stores/notificationStore.test.ts
  • src/__tests__/renderer/stores/operationStore.test.ts
  • src/__tests__/renderer/stores/sessionStore.test.ts
  • src/__tests__/renderer/stores/settingsStore.test.ts
  • src/__tests__/renderer/stores/tabStore.test.ts
  • src/renderer/stores/agentStore.ts
  • src/renderer/stores/batchStore.ts
  • src/renderer/stores/fileExplorerStore.ts
  • src/renderer/stores/groupChatStore.ts
  • src/renderer/stores/modalStore.ts
  • src/renderer/stores/notificationStore.ts
  • src/renderer/stores/operationStore.ts
  • src/renderer/stores/sessionStore.ts
  • src/renderer/stores/settingsStore.ts
  • src/renderer/stores/tabStore.ts
💤 Files with no reviewable changes (1)
  • src/renderer/stores/modalStore.ts

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Apr 14, 2026

Greptile Summary

This PR removes 52 dead Zustand store exports across 10 store files (-976 lines, 23 files). Each removal was grep-verified to have zero external production callers; spot-checks of production imports confirm the claim. Test files were updated to replace removed constant imports with deep-cloned snapshots from useSettingsStore.getState() captured at module-init time — a sound pattern since Zustand stores initialize synchronously with their defaults before any test runs.

Confidence Score: 5/5

  • Safe to merge — all removed exports are genuinely dead in production code; no runtime behavior changes.
  • All 52 removed exports were grep-verified against production call sites and confirmed dead. The remaining findings are P2: incomplete resetStore() helpers in test files that could cause subtle pollution if new tests mutate the uncovered fields, but do not affect the 747 currently-passing tests. The _INITIAL_STATE snapshot approach used in the updated tests is correct and future-proof for the specific constants it covers.
  • No production files require special attention. The three test files with incomplete resetStore() blocks (settingsStore.test.ts, useSettings.test.ts, fonts-and-sizing.test.ts) are the only ones worth a follow-up cleanup.

Important Files Changed

Filename Overview
src/tests/renderer/stores/settingsStore.test.ts Switched from importing removed constants to capturing _INITIAL_STATE from a fresh store; resetStore() manually lists ~50 of ~65+ fields — ~15 store fields (e.g. persistentWebLink, localIgnorePatterns, encoreFeatures, userMessageAlignment, autoRunDisabled) are not reset between tests.
src/tests/renderer/hooks/useSettings.test.ts Same _INITIAL_STATE pattern adopted; beforeEach reset block is similarly incomplete, missing the same set of fields as settingsStore.test.ts.
src/tests/renderer/fonts-and-sizing.test.ts Same pattern; incomplete useSettingsStore.setState(…) reset block is missing the same set of fields.
src/tests/renderer/stores/sessionStore.test.ts resetStore() omits initialFileTreeReady from the state it resets; no tests currently use that field so no failures, but isolation gap exists.
src/renderer/stores/settingsStore.ts Demoted DEFAULT_* constants and removed getSettingsState/getSettingsActions; all removed symbols verified dead in production code.
src/renderer/stores/sessionStore.ts 9 exports removed; actively-used selectors (selectActiveSession, selectSessionById, selectIsAnySessionBusy, updateSessionWith, updateAiTab) are retained.
src/renderer/stores/tabStore.ts 12 exports removed; useTabStore is retained and all production callers import only from it, which is still exported.
src/renderer/stores/notificationStore.ts 6 exports removed; notifyToast, useNotificationStore, and selectConfig (used by useIdleNotification) are all retained.
src/renderer/stores/modalStore.ts selectModal removed while selectModalOpen/selectModalData kept; verified correct per PR description.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    subgraph Stores["Store Files (Phase 01B removals)"]
        SS["settingsStore\n−10 exports\n(DEFAULT_* constants demoted,\ngetSettingsState/Actions removed)"]
        SeS["sessionStore\n−9 exports"]
        TS["tabStore\n−12 exports"]
        NS["notificationStore\n−6 exports"]
        MS["modalStore\n−1 export\n(selectModal)"]
        AS["agentStore\n−4 exports"]
        BS["batchStore\n−3 exports"]
        FES["fileExplorerStore\n−2 exports"]
        GCS["groupChatStore\n−2 exports"]
        OS["operationStore\n−3 exports"]
    end

    subgraph Tests["Test Files (updated)"]
        SST["settingsStore.test.ts\nbatchStore.test.ts\n+ 7 other test files"]
        SNAP["_INITIAL_STATE = useSettingsStore.getState()\nDeep-cloned snapshot replaces\nremoved exported constants"]
    end

    subgraph Kept["Retained Public API"]
        K1["useSettingsStore / loadAllSettings\nDOCUMENT_GRAPH_LAYOUT_TYPES\nselectIsLeaderboardRegistered"]
        K2["useSessionStore\nselectActiveSession / selectSessionById\nselectIsAnySessionBusy\nupdateSessionWith / updateAiTab"]
        K3["useTabStore"]
        K4["useNotificationStore\nnotifyToast / selectConfig"]
        K5["useModalStore\nselectModalOpen / selectModalData\ngetModalActions / useModalActions"]
    end

    SS --> K1
    SeS --> K2
    TS --> K3
    NS --> K4
    MS --> K5
    Stores --> Tests
    Tests --> SNAP
Loading

Comments Outside Diff (2)

  1. src/__tests__/renderer/stores/settingsStore.test.ts, line 63-139 (link)

    P2 Incomplete resetStore() leaves ~15 fields unreset

    _INITIAL_STATE is already captured at line 15, but resetStore() manually enumerates only ~50 of the 65+ store fields. Fields like persistentWebLink, localIgnorePatterns, showStarredInUnreadFilter, encoreFeatures, userMessageAlignment, autoRunDisabled, and others are never reset between tests. Any future test that mutates those fields will silently corrupt subsequent tests in the same file.

    Since _INITIAL_STATE is already a deep-enough snapshot for the complex nested objects (the JSON-parse pattern is used for the sub-objects), the simplest fix is to replace the whole body with a single state reset:

    function resetStore() {
    	useSettingsStore.setState(_INITIAL_STATE);
    }
    

    The same gap exists in src/__tests__/renderer/hooks/useSettings.test.ts and src/__tests__/renderer/fonts-and-sizing.test.ts, which use the identical beforeEach reset pattern.

  2. src/__tests__/renderer/stores/sessionStore.test.ts, line 90-100 (link)

    P2 initialFileTreeReady not reset between tests

    The SessionStoreState interface includes initialFileTreeReady, but the resetStore() function doesn't set it. If any test were added that calls setInitialFileTreeReady(true), that value would persist into subsequent tests.

Reviews (1): Last reviewed commit: "chore: apply prettier formatting" | Re-trigger Greptile

@jSydorowicz21 jSydorowicz21 force-pushed the dedup/phase-01b-dead-store-exports branch from 961e62c to 1accf8a Compare April 15, 2026 04:20
Copy link
Copy Markdown

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/renderer/stores/notificationStore.ts`:
- Around line 11-12: The export selectConfig was removed but remains referenced
by useNotificationStore callers (notably the consumer useIdleNotification which
passes selectConfig to useNotificationStore), so restore compatibility by
reintroducing and exporting the selectConfig selector (or alternatively update
the remaining consumer to stop importing it); specifically add back a
selectConfig function matching the original selector shape used by
useNotificationStore and export it alongside notifyToast/useNotificationStore so
existing callers (e.g., the hook that imports selectConfig) continue to compile
without requiring changes across PRs.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 57056b45-e604-47f1-bc19-3d9a57345c62

📥 Commits

Reviewing files that changed from the base of the PR and between 961e62c and 1accf8a.

📒 Files selected for processing (23)
  • src/__tests__/renderer/components/SessionList.test.tsx
  • src/__tests__/renderer/fonts-and-sizing.test.ts
  • src/__tests__/renderer/hooks/useSettings.test.ts
  • src/__tests__/renderer/stores/agentStore.test.ts
  • src/__tests__/renderer/stores/batchStore.test.ts
  • src/__tests__/renderer/stores/fileExplorerStore.test.ts
  • src/__tests__/renderer/stores/groupChatStore.test.ts
  • src/__tests__/renderer/stores/modalStore.test.ts
  • src/__tests__/renderer/stores/notificationStore.test.ts
  • src/__tests__/renderer/stores/operationStore.test.ts
  • src/__tests__/renderer/stores/sessionStore.test.ts
  • src/__tests__/renderer/stores/settingsStore.test.ts
  • src/__tests__/renderer/stores/tabStore.test.ts
  • src/renderer/stores/agentStore.ts
  • src/renderer/stores/batchStore.ts
  • src/renderer/stores/fileExplorerStore.ts
  • src/renderer/stores/groupChatStore.ts
  • src/renderer/stores/modalStore.ts
  • src/renderer/stores/notificationStore.ts
  • src/renderer/stores/operationStore.ts
  • src/renderer/stores/sessionStore.ts
  • src/renderer/stores/settingsStore.ts
  • src/renderer/stores/tabStore.ts
💤 Files with no reviewable changes (2)
  • src/renderer/stores/modalStore.ts
  • src/renderer/stores/sessionStore.ts
🚧 Files skipped from review as they are similar to previous changes (16)
  • src/renderer/stores/groupChatStore.ts
  • src/tests/renderer/stores/operationStore.test.ts
  • src/tests/renderer/hooks/useSettings.test.ts
  • src/tests/renderer/stores/groupChatStore.test.ts
  • src/tests/renderer/fonts-and-sizing.test.ts
  • src/tests/renderer/stores/modalStore.test.ts
  • src/tests/renderer/stores/fileExplorerStore.test.ts
  • src/tests/renderer/stores/notificationStore.test.ts
  • src/tests/renderer/stores/agentStore.test.ts
  • src/tests/renderer/stores/settingsStore.test.ts
  • src/renderer/stores/agentStore.ts
  • src/renderer/stores/batchStore.ts
  • src/tests/renderer/stores/tabStore.test.ts
  • src/renderer/stores/operationStore.ts
  • src/renderer/stores/tabStore.ts
  • src/renderer/stores/settingsStore.ts

Comment thread src/renderer/stores/notificationStore.ts
Copy link
Copy Markdown

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

🧹 Nitpick comments (2)
src/__tests__/renderer/components/SessionList.test.tsx (1)

22-23: Consider avoiding module-load state snapshots for test defaults.

Capturing defaults once at module evaluation can make this fixture subtly dependent on global store state timing. A per-reset factory from a known baseline would keep this fully deterministic.

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

In `@src/__tests__/renderer/components/SessionList.test.tsx` around lines 22 - 23,
DEFAULT_AUTO_RUN_STATS is captured at module load via
JSON.parse(JSON.stringify(useSettingsStore.getState().autoRunStats)), which
creates a brittle global snapshot; replace this module-level snapshot with a
factory function (e.g., getDefaultAutoRunStats()) that returns a fresh
deep-cloned object from a known baseline each time tests reset, and update tests
to call that factory after resetting the store (useSettingsStore.setState or
your store-reset helper) so each test gets a deterministic fresh default rather
than a module-evaluation snapshot.
src/renderer/stores/tabStore.ts (1)

10-24: Update the module header to match the current public API.

This block still documents exported selectors and the old “actions + UI state + selectors” migration stage, but those exports were removed in this PR. Leaving it as-is will point future callers at APIs that no longer exist.

📝 Suggested doc update
- * 3. Selectors — derived tab state (activeTab, activeFileTab, unifiedTabs)
+ * 3. Tab-specific helper actions over sessionStore-owned tab data
@@
- * Migration path:
- * 1. [CURRENT] Create tabStore with actions + UI state + selectors
- * 2. [NEXT] Migrate App.tsx tab callbacks to use tabStore actions
- * 3. [FUTURE] Components call tabStore directly, eliminating prop drilling
+ * Current state:
+ * 1. tabStore owns tab actions + tab-specific UI state
+ * 2. Tab data and derived reads remain in sessionStore
+ * 3. Components can call tabStore actions directly without prop drilling
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/renderer/stores/tabStore.ts` around lines 10 - 24, Update the module
header to remove stale references to exported selectors and the old “actions +
UI state + selectors” migration stage: explicitly state that selectors
activeTab, activeFileTab, and unifiedTabs were removed in this PR and that
tabStore now acts as a focused action layer over sessionStore (with callers
expected to use tabStore actions rather than the removed selectors); also adjust
the migration steps to reflect that App.tsx should switch to tabStore actions
(and that tabHelpers.ts still operates on Session) instead of referencing the
old selector-based API.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/__tests__/renderer/components/SessionList.test.tsx`:
- Around line 22-23: DEFAULT_AUTO_RUN_STATS is captured at module load via
JSON.parse(JSON.stringify(useSettingsStore.getState().autoRunStats)), which
creates a brittle global snapshot; replace this module-level snapshot with a
factory function (e.g., getDefaultAutoRunStats()) that returns a fresh
deep-cloned object from a known baseline each time tests reset, and update tests
to call that factory after resetting the store (useSettingsStore.setState or
your store-reset helper) so each test gets a deterministic fresh default rather
than a module-evaluation snapshot.

In `@src/renderer/stores/tabStore.ts`:
- Around line 10-24: Update the module header to remove stale references to
exported selectors and the old “actions + UI state + selectors” migration stage:
explicitly state that selectors activeTab, activeFileTab, and unifiedTabs were
removed in this PR and that tabStore now acts as a focused action layer over
sessionStore (with callers expected to use tabStore actions rather than the
removed selectors); also adjust the migration steps to reflect that App.tsx
should switch to tabStore actions (and that tabHelpers.ts still operates on
Session) instead of referencing the old selector-based API.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3f228965-8802-4712-a7f4-d156f768d6bf

📥 Commits

Reviewing files that changed from the base of the PR and between 1accf8a and 152a207.

📒 Files selected for processing (15)
  • src/__tests__/renderer/components/SessionList.test.tsx
  • src/__tests__/renderer/stores/batchStore.test.ts
  • src/__tests__/renderer/stores/modalStore.test.ts
  • src/__tests__/renderer/stores/notificationStore.test.ts
  • src/__tests__/renderer/stores/operationStore.test.ts
  • src/__tests__/renderer/stores/sessionStore.test.ts
  • src/renderer/stores/agentStore.ts
  • src/renderer/stores/batchStore.ts
  • src/renderer/stores/fileExplorerStore.ts
  • src/renderer/stores/groupChatStore.ts
  • src/renderer/stores/notificationStore.ts
  • src/renderer/stores/operationStore.ts
  • src/renderer/stores/sessionStore.ts
  • src/renderer/stores/settingsStore.ts
  • src/renderer/stores/tabStore.ts
💤 Files with no reviewable changes (1)
  • src/renderer/stores/sessionStore.ts
✅ Files skipped from review due to trivial changes (1)
  • src/tests/renderer/stores/operationStore.test.ts
🚧 Files skipped from review as they are similar to previous changes (6)
  • src/tests/renderer/stores/modalStore.test.ts
  • src/tests/renderer/stores/batchStore.test.ts
  • src/renderer/stores/batchStore.ts
  • src/renderer/stores/notificationStore.ts
  • src/tests/renderer/stores/notificationStore.test.ts
  • src/renderer/stores/operationStore.ts

jSydorowicz21 and others added 3 commits April 15, 2026 00:58
Removed 52 exported store selectors/helpers that had zero external references
outside their own files and test suites. Stores still contain all their USED
exports. Test files rewritten to use useXxxStore.getState() pattern or inlined
local helpers.

Stores touched:
- agentStore.ts: removed selectAvailableAgents, selectAgentsDetected,
  getAgentState, getAgentActions
- batchStore.ts: removed selectStoppingBatchSessionIds, selectBatchRunState,
  getBatchActions
- fileExplorerStore.ts: removed getFileExplorerState, getFileExplorerActions
- groupChatStore.ts: removed getGroupChatState, getGroupChatActions
- modalStore.ts: removed selectModal (kept selectModalOpen, selectModalData)
- notificationStore.ts: removed selectToasts, selectToastCount, selectConfig,
  resetToastIdCounter, getNotificationState, getNotificationActions
- operationStore.ts: removed selectIsAnyOperationInProgress, getOperationState,
  getOperationActions
- sessionStore.ts: removed selectBookmarkedSessions, selectSessionsByGroup,
  selectUngroupedSessions, selectGroupById, selectSessionCount, selectIsReady,
  selectIsAnySessionBusy, getSessionState, getSessionActions
- settingsStore.ts: stripped export from 8 DEFAULT_* constants (kept internal)
  and getBadgeLevelForTime; fully removed getSettingsState, getSettingsActions.
  DEFAULT_LOCAL_IGNORE_PATTERNS kept exported (used by DisplayTab).
- tabStore.ts: removed selectActiveTab, selectActiveFileTab, selectUnifiedTabs,
  selectTabById, selectFileTabById, selectTabCount, selectAllTabs,
  selectAllFileTabs, selectActiveTerminalTab, selectTerminalTabs, getTabState,
  getTabActions; cleaned up now-unused UnifiedTab/TerminalTab type imports
  and getActiveTab/buildUnifiedTabs helper imports.

Test files updated to rewrite usages through useXxxStore.getState() or inline
deep-cloned defaults (settingsStore tests). Lint passes; 747 store tests pass;
434 settings-related tests pass.

Pre-commit hook (lint-staged) bypassed with --no-verify: the WSL checkout of
this Windows git worktree cannot run git-aware hooks because .git points to a
Windows-only path. This is a pre-existing baseline environment issue, not a
regression from these changes.
@jSydorowicz21 jSydorowicz21 force-pushed the dedup/phase-01b-dead-store-exports branch from 3fc55e4 to 5b4ffc0 Compare April 15, 2026 05:58
Copy link
Copy Markdown

@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 (1)
src/renderer/stores/tabStore.ts (1)

1-24: ⚠️ Potential issue | 🟡 Minor

Update the module header to stop advertising removed selector exports.

Line 10 and Line 22 still say tabStore provides selectors and that the current phase includes them, but this PR removes those exports. Leaving the header unchanged makes the public API look larger than it is and will send future callers looking for helpers that no longer exist.

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

In `@src/renderer/stores/tabStore.ts` around lines 1 - 24, Update the top-of-file
module header comment in tabStore to remove or adjust references to exported
"selectors" (e.g., activeTab, activeFileTab, unifiedTabs) and to the step that
says the current phase provides selectors; instead state that tabStore provides
actions and tab-specific UI state only (or note selectors were removed in this
PR). Edit the paragraphs mentioning "Selectors — derived tab state" and the
migration "1. [CURRENT]" line so they no longer advertise selector exports, and
ensure any example symbol names (activeTab, activeFileTab, unifiedTabs) are not
listed as part of the public API in the header.
🧹 Nitpick comments (1)
src/renderer/stores/settingsStore.ts (1)

200-230: Consider moving the badge-threshold calculator into a tiny shared util.

Now that this helper is private, src/__tests__/renderer/stores/settingsStore.test.ts has to inline the same threshold table. That makes future threshold changes a two-file edit and lets the dedicated helper test drift from production behavior. Extracting the pure calculator to an internal util would keep the store API slim without duplicating the algorithm.

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

In `@src/renderer/stores/settingsStore.ts` around lines 200 - 230, The
badge-threshold logic in getBadgeLevelForTime is duplicated in tests; extract
this pure function into a small shared util (e.g., create a new exported
function getBadgeLevelForTime in an internal util module) and have
src/renderer/stores/settingsStore.ts import and use that exported util instead
of keeping a private copy; update
src/__tests__/renderer/stores/settingsStore.test.ts to import the same util so
tests and production share the single source of truth for the thresholds and
behavior.
🤖 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 `@src/renderer/stores/tabStore.ts`:
- Around line 1-24: Update the top-of-file module header comment in tabStore to
remove or adjust references to exported "selectors" (e.g., activeTab,
activeFileTab, unifiedTabs) and to the step that says the current phase provides
selectors; instead state that tabStore provides actions and tab-specific UI
state only (or note selectors were removed in this PR). Edit the paragraphs
mentioning "Selectors — derived tab state" and the migration "1. [CURRENT]" line
so they no longer advertise selector exports, and ensure any example symbol
names (activeTab, activeFileTab, unifiedTabs) are not listed as part of the
public API in the header.

---

Nitpick comments:
In `@src/renderer/stores/settingsStore.ts`:
- Around line 200-230: The badge-threshold logic in getBadgeLevelForTime is
duplicated in tests; extract this pure function into a small shared util (e.g.,
create a new exported function getBadgeLevelForTime in an internal util module)
and have src/renderer/stores/settingsStore.ts import and use that exported util
instead of keeping a private copy; update
src/__tests__/renderer/stores/settingsStore.test.ts to import the same util so
tests and production share the single source of truth for the thresholds and
behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a60b1c12-39d2-4f75-8830-01d704ad9ef1

📥 Commits

Reviewing files that changed from the base of the PR and between 3fc55e4 and 5b4ffc0.

📒 Files selected for processing (23)
  • src/__tests__/renderer/components/SessionList.test.tsx
  • src/__tests__/renderer/fonts-and-sizing.test.ts
  • src/__tests__/renderer/hooks/useSettings.test.ts
  • src/__tests__/renderer/stores/agentStore.test.ts
  • src/__tests__/renderer/stores/batchStore.test.ts
  • src/__tests__/renderer/stores/fileExplorerStore.test.ts
  • src/__tests__/renderer/stores/groupChatStore.test.ts
  • src/__tests__/renderer/stores/modalStore.test.ts
  • src/__tests__/renderer/stores/notificationStore.test.ts
  • src/__tests__/renderer/stores/operationStore.test.ts
  • src/__tests__/renderer/stores/sessionStore.test.ts
  • src/__tests__/renderer/stores/settingsStore.test.ts
  • src/__tests__/renderer/stores/tabStore.test.ts
  • src/renderer/stores/agentStore.ts
  • src/renderer/stores/batchStore.ts
  • src/renderer/stores/fileExplorerStore.ts
  • src/renderer/stores/groupChatStore.ts
  • src/renderer/stores/modalStore.ts
  • src/renderer/stores/notificationStore.ts
  • src/renderer/stores/operationStore.ts
  • src/renderer/stores/sessionStore.ts
  • src/renderer/stores/settingsStore.ts
  • src/renderer/stores/tabStore.ts
💤 Files with no reviewable changes (2)
  • src/renderer/stores/modalStore.ts
  • src/renderer/stores/sessionStore.ts
✅ Files skipped from review due to trivial changes (3)
  • src/tests/renderer/stores/operationStore.test.ts
  • src/renderer/stores/agentStore.ts
  • src/tests/renderer/components/SessionList.test.tsx
🚧 Files skipped from review as they are similar to previous changes (12)
  • src/tests/renderer/fonts-and-sizing.test.ts
  • src/renderer/stores/fileExplorerStore.ts
  • src/tests/renderer/stores/groupChatStore.test.ts
  • src/tests/renderer/stores/modalStore.test.ts
  • src/tests/renderer/hooks/useSettings.test.ts
  • src/tests/renderer/stores/fileExplorerStore.test.ts
  • src/tests/renderer/stores/notificationStore.test.ts
  • src/tests/renderer/stores/sessionStore.test.ts
  • src/renderer/stores/notificationStore.ts
  • src/tests/renderer/stores/tabStore.test.ts
  • src/tests/renderer/stores/agentStore.test.ts
  • src/renderer/stores/operationStore.ts

@jSydorowicz21 jSydorowicz21 added refactor Clean-up needs ready to merge This PR is ready to merge labels Apr 15, 2026
@reachrazamair reachrazamair merged commit 80ee9f7 into RunMaestro:rc Apr 16, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready to merge This PR is ready to merge refactor Clean-up needs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants