Skip to content

refactor(cleanup): reduce defensive duplication and dead code - #167

Merged
BerryUIKI merged 3 commits into
devfrom
refactor/review-cleanup
Nov 6, 2026
Merged

BerryUIKI merged 3 commits into
devfrom
refactor/review-cleanup

Conversation

@BerryUIKI

@BerryUIKI BerryUIKI commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner

📝 Description

Full-codebase review for over-defensive and duplicated logic.

This PR removes dead code and duplicated state, consolidates the two frontend error channels, shares Rust document response building, simplifies workspace search, and drops guards for states that cannot occur in the Tauri/SPA + jsdom test environment. It also fixes the duplicate Ctrl+Shift+X binding and stale hard-coded version fallbacks.

Net: 49 files changed, roughly 590 lines removed.

Changes

  • Dead code: unused AppState.active_document / get_active_document, greet, highlight_code, MobileHeader, TitleBar, singleFlight, plugin runtime leftovers, unused props and imports.
  • Frontend: one file-error banner (the store channel), shared export action, and no more alert + banner double reporting in FileTree.
  • Backend: open_file and save_file share one response builder; workspace search canonicalizes only symlinks and checks its bounds once per entry; redundant .exists() calls removed.
  • Guards: removed typeof window / localStorage / document / navigator checks that always hold here; kept matchMedia and visualViewport capability checks because jsdom/webviews can lack them.
  • Fixes: Ctrl+Shift+X now only toggles strikethrough; the version comes from package.json + getVersion(); .mdx files are recognized in the file tree; Save As queues behind an in-flight save; the watcher is not started twice; small MarkdownView / SearchModal / FindReplace defenses removed.
  • Kept deliberately: the TabBar rapid-double-click throttle and the window-API → Rust fallback both have regression tests.

🎯 Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • 🧹 Code refactor / cleanup

🧪 Testing Performed

  • cargo test --manifest-path src-tauri/Cargo.toml passed
  • pnpm tsc --noEmit passed
  • pnpm build passed
  • Manual verification in development/production build

📸 Screenshots / Demos (if applicable)

N/A — no visual changes.

🔗 Related Issues

Closes #162
Closes #163
Closes #164
Closes #165
Closes #166

- remove unused active-document cache, IPC commands, components, and utility
- unify frontend file-error reporting and share the export flow
- share open/save response building and simplify workspace search
- drop redundant environment/fs existence guards and silent fallbacks
- fix duplicate Ctrl+Shift+X binding, stale version fallback, and small UI guards

Closes #162
Closes #163
Closes #164
Closes #165
Closes #166
@BerryUIKI BerryUIKI added the enhancement New feature or request label Nov 6, 2026
Local integrity tests require a save with no competing request to begin before the key event returns. TabBar also has a regression test for two rapid double-clicks creating one tab.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant