1
0
mirror of https://github.com/tw93/Mole.git synced 2026-03-22 17:55:08 +00:00
Commit Graph

507 Commits

Author SHA1 Message Date
tw93
7a6da7b419 fix(uninstall): auto-exit return-to-list prompt after configurable timeout
Replace blocking read with a timed read (default 3 s) so the prompt
exits automatically instead of waiting forever. Timeout is configurable
via MOLE_UNINSTALL_RETURN_PROMPT_TIMEOUT_SEC. Use a read_ok flag to
distinguish timeout (exit) from Enter (return to list).
2026-02-26 19:42:47 +08:00
tw93
837df390a5 fix(purge): rewrite spinner for /dev/tty reliability and fix cursor position
- Capture terminal width in parent before forking; avoids unreliable
  tput calls inside the background subshell
- Write spinner output directly to /dev/tty to prevent stdout state
  contention between parent and background processes
- Use \033[2K (erase entire line) instead of \033[K (erase to EOL)
- Add handle_interrupt() so Ctrl-C cleanly stops spinner, restores
  cursor, and exits 130
- cleanup_monitor now writes \r\033[2K\n so subsequent output starts
  on a clean line rather than on the cleared spinner line
2026-02-26 19:42:34 +08:00
tw93
3bd3e400b6 style: improve code consistency and formatting
- Rename _MOLE_HINTS_DIR to mole_hints_dir (naming convention)
- Split local variable declaration and assignment
- Add ICON_INFO constant to base.sh
- Remove redundant has_cached_sudo function (use has_sudo_session)
2026-02-26 11:47:41 +08:00
tw93
5241b59ea9 refactor: reuse sudo cache checks in clean dry-run tests 2026-02-25 10:32:12 +08:00
Luke Bullimore
ee1f2bd372 Fix --dry-run hiding system cleanup preview (#493)
The dry-run mode hardcoded SYSTEM_CLEAN=false, which meant
the entire system section was silently skipped during preview.
Users had no way to see what /Library/Caches, /private/var/log,
diagnostics, or other sudo-required paths would be cleaned.

Now dry-run checks for a cached sudo session (sudo -n) and
includes the system preview when available. When sudo isn't
cached, a hint tells the user how to get the full preview
without running the whole script as root.
2026-02-25 10:22:56 +08:00
tw93
ff00e9ba9c refactor(clean): extract shared purge hint helpers 2026-02-23 13:39:22 +08:00
tw93
4c9a71315f refactor(ui): unify action and list hints across commands 2026-02-23 11:34:22 +08:00
tw93
3112673ed3 feat(clean): add storage clues after large files 2026-02-23 11:34:04 +08:00
tw93
dc8d1bd948 refactor(clean): merge app cache/user essentials flow
- reorganize perform_cleanup sections and naming

- merge macOS + sandbox caches into clean_app_caches

- move recent items and mail downloads into user essentials

- update core/user tests for renamed internal helpers
2026-02-21 23:35:53 +08:00
tw93
a29cadbfd0 fix(purge): resolve trap conflict between purge.sh and project.sh
- Add guard flag in cleanup_monitor to prevent duplicate execution
- Check for existing trap in project.sh before setting new one
- Prevents crash when user presses Ctrl-C or scan process fails
2026-02-16 15:54:16 +08:00
tw93
52d333bc9e feat(uninstall): keep progress visible until app list is ready 2026-02-15 08:45:16 +08:00
tw93
9c8c25116b refactor(uninstall): centralize size and last-used display normalization 2026-02-10 16:33:14 +08:00
tw93
7d8bfbc9d9 improve uninstall scan metadata and list refresh UX 2026-02-10 16:23:15 +08:00
Tw93
9aa5a0a69d chore: auto format code 2026-02-10 07:07:52 +00:00
tw93
172afa83af refactor: centralize subcommand help handlers 2026-02-10 15:06:14 +08:00
Michael Wang 汪東陽
3820bf2be7 feat: add commands help flag (#429) 2026-02-10 15:02:57 +08:00
tw93
e6829b9a5d fix: improve cache freshness fallback and proxy detection 2026-02-07 17:48:55 +08:00
tw93
f3b288a21b feat(uninstall): implement metadata caching for faster app scanning 2026-02-07 10:26:53 +08:00
tw93
a4e084a4ed feat: improve app cleanup with orphaned LaunchAgent detection
New features:
- Add orphaned LaunchAgent/LaunchDaemon detection with 5-layer verification
  - Layer 1: Check if program path exists
  - Layer 2: Verify AssociatedBundleIdentifiers via mdfind
  - Layer 3: Check Application Support directory activity (7 days)
  - Layer 4: Fuzzy match app name in /Applications
  - Layer 5: Special handling for PrivilegedHelperTools
- Only process user-level ~/Library/LaunchAgents (safer than system-level)
- Unload agent before removal using launchctl

Bug fixes:
- Handle paths with spaces correctly in orphaned_app_data cleanup
  - Add nullglob state management to prevent word splitting
  - Use IFS=$'\n' for proper array iteration
- Only count successful deletions (check safe_clean return value)

Tests:
- Add 4 new tests for is_launch_item_orphaned edge cases
- Add tests for space handling and deletion count accuracy
2026-02-04 16:17:36 +08:00
tw93
c6e58c4ead fix: replace clear with clear_screen for better clarity in main function 2026-02-02 17:38:29 +08:00
tw93
f965ca25c3 uninstall: harden cache and removal flow 2026-02-02 17:05:42 +08:00
tw93
aaa3a6ae5a ui: add menu filtering support 2026-02-02 17:05:19 +08:00
tw93
e12a40f6bf fix: use \033[2K to fully clear spinner lines and prevent text remnants
Fixes text remnants and extra blank lines when spinner messages change.

Issues fixed:
1. Text remnants when switching from longer to shorter messages (e.g., 'Cleaning...ems...')
2. Extra blank lines appearing after section headers

Root causes:
- \033[K only clears from cursor to end of line, leaving remnants when new messages are shorter
- stop_section_spinner was clearing lines even when no spinner was running

Changes:
- lib/core/base.sh:
  - Changed stop_section_spinner(), safe_clear_line(), safe_clear_lines() to use \033[2K
  - Added guard in stop_section_spinner to only clear when spinner is actually running
- lib/core/ui.sh:
  - Clear line once when starting spinner (before loop) to ensure clean start
  - Normal spinner rotation uses \r without clearing (performance optimization)

Performance: Line clearing happens only once per spinner start, not on every loop iteration.

Fixes #390
2026-01-31 10:09:02 +08:00
tw93
0a46bf2077 fix: improve status icons and fix spinner cleanup
- Show ✓ for empty trash and discovered versions (normal states)
- Fix inline spinner not stopping, causing residual display artifacts
2026-01-28 20:15:26 +08:00
tw93
88da841ce9 refactor: remove mo log command, keep log recording only 2026-01-28 19:58:59 +08:00
Tw93
c12f76c9f3 chore: auto format code 2026-01-28 11:46:59 +00:00
tw93
64f79a59d8 feat: optimize log system and add mo log command
- Add get_timestamp() helper and optimize log rotation
- Create mo log viewer with search/filter capabilities
- Improve test coverage to 18.4% with better assertions
- Add security fixes for grep injection prevention
2026-01-28 19:46:01 +08:00
Gokul
9a109b2b39 fix(clean): handle singular 4K movie summary (#376) 2026-01-27 19:42:54 +08:00
Tw93
09f0cf9e53 chore: auto format code 2026-01-26 07:46:58 +00:00
tw93
b67d149cef Merge branch 'main' of https://github.com/tw93/Mole 2026-01-26 15:46:05 +08:00
tw93
0fbf88a6c6 fix: harden cleanup path validation 2026-01-26 15:43:11 +08:00
Tw93
f272d29490 chore: auto format code 2026-01-26 07:32:44 +00:00
tw93
43a92a1847 Merge branch 'main' of https://github.com/tw93/Mole 2026-01-26 15:31:43 +08:00
tw93
981c79cfd1 fix: clear cleaning spinner after cleanup 2026-01-26 15:31:30 +08:00
Tw93
587b127c01 chore: auto format code 2026-01-26 07:24:38 +00:00
tw93
8c4cd7f82e feat: log cleanup operations for troubleshooting 2026-01-26 15:22:07 +08:00
tw93
e966838c82 style: standardize punctuation across codebase
- Replace parentheses with commas for supplementary info
- Use commas instead of em-dashes for separators
- Update bullet points from - to * in some contexts
- Improve version extraction regex with fallback logic
2026-01-26 14:36:06 +08:00
Tw93
fbff0ec3bd fix: show spinner during cleanup phase
Add progress indicator when deleting files to prevent the terminal
from appearing frozen during long-running cleanup operations.

Closes #358
2026-01-24 08:31:04 +08:00
Tw93
d7a0d480bc fix: improve dry-run mode and error handling
- Export MOLE_DRY_RUN env var for subprocess visibility
- Add || true to grep commands to prevent pipeline failures
- Add dry-run test for clean_orphaned_system_services
- Simplify clean_local_snapshots tests
2026-01-23 18:05:09 +08:00
Tw93
7e40824fa3 optimize code syntax 2026-01-23 09:43:04 +08:00
Andrei Murariu
340a71056c bug-fix: mo uninstall unbound variable on empty tuples (#352)
This happens when no third party app is available to be uninstalled; this triggers an `unbound variable` on the app_data_tuple causing the utility to fail.

This is caused mostly because the bash version is 3.2 on MacOS; it seems that since Bash 4 this unbound_variable is set to 0 and would have not went to that error.

Added an alternative value in case of error of 0 for this topic. This should handle this corner case
2026-01-23 09:40:13 +08:00
Tw93
cde39aaeb2 feat(clean): add large file review and unify warnings 2026-01-22 20:15:13 +08:00
Tw93
dad15a5dc6 clean: auto-enable system cleanup when sudo session is active 2026-01-22 17:10:18 +08:00
Tw93
3f85c8238f Use gray color for warning icons to reduce visual noise 2026-01-20 15:07:37 +08:00
Tw93
b4b9b0c474 Add cleanup for orphaned system services
Detect and remove leftover LaunchDaemons, LaunchAgents, and
PrivilegedHelperTools from uninstalled apps like Sogou Input,
ClashX, ClashMac, and Nektony App Cleaner.
2026-01-20 14:25:32 +08:00
Tw93
46472bc86e chore: auto format code 2026-01-17 02:13:54 +00:00
Tw93
e6fc0613d5 perf: improve cleanup UI responsiveness and reduce visual flicker
- Speed up spinner animation from 100ms to 50ms for smoother visuals
- Fix spinner flicker by deferring stop until output is ready
- Remove unnecessary 'Preparing...' spinner at section start
- Hide whitelist-protected items from output (Trash, Finder metadata)
- Add spinner feedback for system diagnostic log cleanup
- Remove redundant stop_section_spinner calls in cleanup modules

The cleanup process now feels significantly faster and more polished,
with continuous visual feedback and no jarring gaps between operations.
2026-01-17 10:12:23 +08:00
Tw93
00a712711e chore: auto format code 2026-01-14 03:59:21 +00:00
Tw93
facaf5b34c fix: precision issue in battery metrics and adaptive purge UI
- cmd/status: use ParseUint to handle negative battery power values correctly
- bin/purge: make path truncation adaptive to terminal width
2026-01-14 11:57:10 +08:00
Tw93
c210aad3a3 Merge branch 'dev' into dev 2026-01-14 10:18:21 +08:00