Skip to content

refactor: remove dead main process exports (Phase 01D)#812

Merged
reachrazamair merged 3 commits intoRunMaestro:rcfrom
jSydorowicz21:dedup/phase-01d-dead-main-process
Apr 16, 2026
Merged

refactor: remove dead main process exports (Phase 01D)#812
reachrazamair merged 3 commits intoRunMaestro:rcfrom
jSydorowicz21:dedup/phase-01d-dead-main-process

Conversation

@jSydorowicz21
Copy link
Copy Markdown
Contributor

@jSydorowicz21 jSydorowicz21 commented Apr 12, 2026

Summary

Removes 28 dead exports from main process modules. Conservatively excludes exports whose only references are in test files with extensive setup logic, and excludes src/main/cue/ entirely per risk boundaries (active development).

Net: -710 lines across 32 files

Fully deleted (15): getAutoRunWatcherCount, getDocumentGraphWatcherCount, registerAllHandlers + HandlerDependencies + helpers, getGhPath, clearGhCache, getSshPath, clearSshCache, stopMemoryMonitoring, getWslWarningMessage, startSessionCleanup + STALE_SESSION_THRESHOLD_MS, getPendingParticipants, findSshRemoteById, ensureParsersInitialized, findSshConfigHost, debugLogLazy.

Demoted to private (13): DEBUG_GROUP_CHAT, sanitizeText, getCustomShellPath, setGroupChatReadOnlyState, getGroupChatsDir, sanitizeDisplayName, isValidToolType, getMigrations, needsWindowsShell, shellEscapeArgs, getStatsCachePath, getGlobalStatsCachePath, isWindowsMountPath.

The playbook originally targeted ~75 symbols; the remaining 47 were kept exported to preserve complex test setups without rewriting test isolation logic. Follow-up work can revisit.

Test plan

  • npm run lint passes clean (all 3 tsconfigs)
  • Main process tests pass (baseline flakes only)
  • Agent detection completes on startup
  • Group chat moderator works
  • Shell escape for special chars in terminal
  • Stats/usage data loads in Usage Dashboard

Risk

Low - conservative removal, nothing in src/main/cue/ touched.

Summary by CodeRabbit

  • Refactor

    • Reduced public API surface: many helpers and small diagnostic/query functions were made internal or removed across debug, group chat, parsers, and utility areas.
    • Removed some exported convenience APIs for CLI detection, stats cache paths, WSL warning text, session cleanup start/stop, and watcher counts.
    • Simplified parser initialization by removing the conditional lazy-init API.
  • Tests

    • Removed corresponding unit tests that covered the now-private or deleted helpers.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 12, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1cc167ec-726a-4936-a640-c4e9169136b4

📥 Commits

Reviewing files that changed from the base of the PR and between 2461de0 and ae1e425.

📒 Files selected for processing (6)
  • src/__tests__/main/ipc/handlers/director-notes.test.ts
  • src/__tests__/main/stores/utils.test.ts
  • src/main/parsers/index.ts
  • src/main/utils/cliDetection.ts
  • src/main/utils/sentry.ts
  • src/main/utils/wslDetector.ts
💤 Files with no reviewable changes (3)
  • src/main/parsers/index.ts
  • src/main/utils/sentry.ts
  • src/main/utils/cliDetection.ts
✅ Files skipped from review due to trivial changes (1)
  • src/tests/main/stores/utils.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/tests/main/ipc/handlers/director-notes.test.ts

📝 Walkthrough

Walkthrough

This PR reduces the public API surface by converting many previously exported helpers/constants/functions into module-local (non-exported) entities and removes the associated tests that covered those APIs.

Changes

Cohort / File(s) Summary
Constants & Debugging
src/main/constants.ts, src/main/debug-package/collectors/sanitize.ts
DEBUG_GROUP_CHAT and sanitizeText changed from exported to module-local; exported debugLogLazy removed.
Group Chat
src/main/group-chat/group-chat-config.ts, src/main/group-chat/group-chat-moderator.ts, src/main/group-chat/group-chat-router.ts, src/main/group-chat/group-chat-storage.ts
Removed/privatized exports: getCustomShellPath, startSessionCleanup, setGroupChatReadOnlyState (export removed), getPendingParticipants, and getGroupChatsDir.
IPC Handlers
src/main/ipc/handlers/autorun.ts, src/main/ipc/handlers/director-notes.ts, src/main/ipc/handlers/documentGraph.ts, src/main/ipc/handlers/index.ts
Removed watcher-count accessors and made sanitizeDisplayName internal; removed some unused imports in handler index.
Parsers
src/main/parsers/agent-output-parser.ts, src/main/parsers/index.ts
isValidToolType made file-local; removed _initialized and exported ensureParsersInitialized.
Utilities — CLI / Exec / Shell / WSL / Stats
src/main/utils/cliDetection.ts, src/main/utils/execFile.ts, src/main/utils/shell-escape.ts, src/main/utils/wslDetector.ts, src/main/utils/statsCache.ts
Privatized or removed exports: getGhPath/getSshPath/clear cache APIs, needsWindowsShell, shellEscapeArgs, isWindowsMountPath (now internal), removed getWslWarningMessage, and cache-path helpers.
Utilities — Sentry / SSH / Stores / Migrations
src/main/utils/sentry.ts, src/main/utils/ssh-config-parser.ts, src/main/stores/utils.ts, src/main/stats/migrations.ts
Removed exported stopMemoryMonitoring, findSshConfigHost, findSshRemoteById; made getMigrations internal.
Tests
src/__tests__/main/... (multiple test files)
Deleted or reduced test suites that covered the removed/privatized APIs (imports and describe/it blocks removed across many test files).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

approved

Poem

🐰 Exports tucked in, shy and neat,
Silent helpers hum, discreet,
Tests trimmed back, the surface small,
Modules keep their secrets all,
Hoppity code — compact and sweet. 🥕

🚥 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 concisely summarizes the main change: removing dead exports from the main process as part of a phased refactoring effort.
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 self-assigned this Apr 14, 2026
@jSydorowicz21 jSydorowicz21 marked this pull request as ready for review April 14, 2026 04:35
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 14, 2026

Greptile Summary

This PR conservatively removes 28 dead exports from main process modules across 32 files, either deleting them outright (15 symbols) or demoting them to module-private (13 symbols). All removals were verified against the live codebase — no remaining references exist for the deleted symbols, and all demoted functions are still called only within their own modules. Test files were updated in lockstep to import only the remaining public API.

Confidence Score: 5/5

  • Safe to merge — all deletions verified dead by grep, all demotions remain internally consistent, tests updated in lockstep.
  • The only finding is a P2 style note: stopSessionCleanup is exported but permanently a no-op after startSessionCleanup was deleted. All other changes are straightforward visibility reductions with no behavioral impact. No logic, data, or security concerns introduced.
  • src/main/group-chat/group-chat-moderator.ts — stopSessionCleanup/cleanupIntervalId bookkeeping is now dead code.

Important Files Changed

Filename Overview
src/main/group-chat/group-chat-moderator.ts startSessionCleanup and STALE_SESSION_THRESHOLD_MS fully deleted; stopSessionCleanup exported and called from index.ts/quit-handler.ts but is now always a no-op since cleanupIntervalId is never set. Minor dead code remains.
src/main/utils/statsCache.ts getStatsCachePath and getGlobalStatsCachePath demoted to private (function declarations without export). All cache load/save functions and interfaces remain exported.
src/main/utils/execFile.ts needsWindowsShell demoted to private; execFileNoThrow, ExecOptions, ExecResult remain exported. The corresponding needsWindowsShell.test.ts was deleted.
src/main/ipc/handlers/index.ts registerAllHandlers aggregator function and HandlerDependencies union type removed; all individual registerXxx handlers remain re-exported for selective use. This is the correct usage pattern.
src/main/parsers/index.ts ensureParsersInitialized removed; initializeOutputParsers, registerOutputParser, getOutputParser, and all parser classes remain exported. Tests verify the public API.
src/main/utils/cliDetection.ts getGhPath and clearGhCache deleted; getSshPath and clearSshCache deleted. Confirmed by grep: no remaining references in the codebase. resolveGhPath, resolveSshPath, isGhInstalled, detectSshPath remain exported.
src/main/utils/sentry.ts stopMemoryMonitoring deleted; startMemoryMonitoring, captureException, captureMessage, addBreadcrumb remain exported. Verified no remaining references to stopMemoryMonitoring.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[startSessionCleanup\nDELETED] -->|set| B[cleanupIntervalId\nNow always null]
    B -->|clear| C[stopSessionCleanup\nStill exported - no-op]
    C --> D[index.ts shutdown\nline 658]
    C --> E[quit-handler.ts\nline 216]

    subgraph "Deleted Exports (15)"
        F[getAutoRunWatcherCount]
        G[getDocumentGraphWatcherCount]
        H[registerAllHandlers + HandlerDependencies]
        I[getGhPath / clearGhCache]
        J[getSshPath / clearSshCache]
        K[stopMemoryMonitoring]
        L[startSessionCleanup + STALE_SESSION_THRESHOLD_MS]
        M[getPendingParticipants]
        N[findSshRemoteById]
        O[ensureParsersInitialized / findSshConfigHost / debugLogLazy]
    end

    subgraph "Demoted to Private (13)"
        P[DEBUG_GROUP_CHAT]
        Q[sanitizeText / sanitizeDisplayName]
        R[getCustomShellPath / getGroupChatsDir]
        S[setGroupChatReadOnlyState]
        T[isValidToolType / getMigrations]
        U[needsWindowsShell / shellEscapeArgs]
        V[getStatsCachePath / getGlobalStatsCachePath]
        W[isWindowsMountPath]
    end
Loading

Comments Outside Diff (1)

  1. src/main/group-chat/group-chat-moderator.ts, line 66-76 (link)

    P2 stopSessionCleanup is now always a no-op

    cleanupIntervalId is declared here but startSessionCleanup was deleted by this PR, so cleanupIntervalId can never be set to a non-null value. stopSessionCleanup is still called from index.ts (line 658) and quit-handler.ts (line 216) on application shutdown — both calls are harmless but effectless.

    If session cleanup was intentionally disabled as part of this refactor, consider removing the cleanupIntervalId declaration and the stopSessionCleanup export (and updating its call sites) to avoid leaving dead bookkeeping state. If cleanup should still run, startSessionCleanup needs to be re-introduced or the interval wired up elsewhere.

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

Remove 28 dead main-process exports across src/main/, reducing 710
lines net. Per Phase 01D methodology: grep-verified zero external
production references (tests not considered prod). Kept exports used
internally with many test refs to avoid cascading test rewrites.

Fully deleted (no internal use, no/trivial test refs):
- src/main/ipc/handlers/autorun.ts: getAutoRunWatcherCount
- src/main/ipc/handlers/documentGraph.ts: getDocumentGraphWatcherCount
- src/main/ipc/handlers/index.ts: registerAllHandlers, HandlerDependencies
  interface, AgentConfigsData, ClaudeSessionOriginsData, 6 unused imports
- src/main/utils/cliDetection.ts: getGhPath, clearGhCache, getSshPath,
  clearSshCache
- src/main/utils/sentry.ts: stopMemoryMonitoring
- src/main/utils/wslDetector.ts: getWslWarningMessage
- src/main/group-chat/group-chat-moderator.ts: startSessionCleanup,
  STALE_SESSION_THRESHOLD_MS const (stopSessionCleanup kept, production used)
- src/main/group-chat/group-chat-router.ts: getPendingParticipants
- src/main/stores/utils.ts: findSshRemoteById + unused SshRemoteConfig
  import
- src/main/parsers/index.ts: ensureParsersInitialized + _initialized
- src/main/utils/ssh-config-parser.ts: findSshConfigHost
- src/main/constants.ts: debugLogLazy

Exports dropped to private (still used internally, test blocks removed):
- src/main/constants.ts: DEBUG_GROUP_CHAT
- src/main/debug-package/collectors/sanitize.ts: sanitizeText
- src/main/group-chat/group-chat-config.ts: getCustomShellPath
- src/main/group-chat/group-chat-router.ts: setGroupChatReadOnlyState
- src/main/group-chat/group-chat-storage.ts: getGroupChatsDir
- src/main/ipc/handlers/director-notes.ts: sanitizeDisplayName
- src/main/parsers/agent-output-parser.ts: isValidToolType
- src/main/stats/migrations.ts: getMigrations
- src/main/utils/execFile.ts: needsWindowsShell
- src/main/utils/shell-escape.ts: shellEscapeArgs
- src/main/utils/statsCache.ts: getStatsCachePath, getGlobalStatsCachePath
- src/main/utils/wslDetector.ts: isWindowsMountPath

Test files updated (import cleanup + dead test block removal):
- src/__tests__/main/constants.test.ts
- src/__tests__/main/debug-package/collectors.test.ts
- src/__tests__/main/group-chat/group-chat-config.test.ts
- src/__tests__/main/group-chat/group-chat-storage.test.ts
- src/__tests__/main/ipc/handlers/director-notes.test.ts
- src/__tests__/main/parsers/agent-output-parser.test.ts
- src/__tests__/main/parsers/index.test.ts
- src/__tests__/main/stores/utils.test.ts
- src/__tests__/main/utils/shell-escape.test.ts
- src/__tests__/main/utils/ssh-config-parser.test.ts
- src/__tests__/main/utils/needsWindowsShell.test.ts (deleted; file
  exclusively tested a now-private function)

Skipped (removal would cascade into heavy test rewrites or has test
infrastructure dependencies): clearCloudflaredCache and 5 notifications.ts
test helpers, 4 ipcHandler.ts factory helpers, extractMentions,
extractAllMentions, extractTextGeneric, extractTextFromAgentOutput,
getShellCommand, isCommandEcho, extractCommand, escapeContent,
unescapeContent, detectLanguageFromPath, WRITE_TOOL_NAMES,
detectSessionNotFoundError, buildRemoteCommand, parseConfigContent,
parseNotificationCommand, and 5 group-chat-agent participant helpers.
Also did not touch src/main/cue/ per playbook risk boundary.

Kept as production-used (playbook flagged but verified active):
stopSessionCleanup, setupProcessListeners, initializeSessionStorages,
initializeOutputParsers.
@jSydorowicz21 jSydorowicz21 force-pushed the dedup/phase-01d-dead-main-process branch from 9353f50 to 2461de0 Compare April 15, 2026 04:22
@jSydorowicz21 jSydorowicz21 added refactor Clean-up needs ready to merge This PR is ready to merge labels Apr 15, 2026
@reachrazamair reachrazamair merged commit eedf2a6 into RunMaestro:rc Apr 16, 2026
3 checks passed
jSydorowicz21 added a commit to jSydorowicz21/Maestro that referenced this pull request Apr 16, 2026
Auto-resolver merged both old standalone managers (now removed in rc) with
new shared spec-command-manager wrapper, creating duplicate types and
undefined references. Take rc's clean version.

Also remove startSessionCleanup from group-chat-moderator - it was
removed in PR RunMaestro#812 as dead code (never called in production).
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