1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-04 14:26:46 +00:00
Commit Graph

150 Commits

Author SHA1 Message Date
Dylan Joss
f815a5f28c test: add tests for byte formatters and disk helpers (#382)
Add unit tests for additional utility functions in `cmd/status/view_test.go`:
- `humanBytes`: byte formatting with decimals and units
- `humanBytesCompact`: compact byte formatting
- `splitDisks`: separates internal/external disks
- `diskLabel`: generates numbered disk labels

Coverage for cmd/status improved from 6.9% to 8.4%.
2026-01-28 19:12:04 +08:00
tw93
ab4433d9c0 Merge branch 'main' of https://github.com/tw93/Mole 2026-01-28 11:43:41 +08:00
tw93
61a3238f19 fix(scan): prevent hang on cyclic symlinks (#378, #379) 2026-01-28 11:43:39 +08:00
Tw93
6036b4606c chore: auto format code 2026-01-28 03:26:51 +00:00
Dylan Joss
a9c5794ec4 test: add tests for utility functions and heap implementations (#380)
Add unit tests for utility functions in cmd/status/view_test.go:
- formatRate: MB/s rate formatting with adaptive precision
- shorten: string truncation with ellipsis
- humanBytesShort: byte formatting with binary units

Add unit tests for heap implementations in cmd/analyze/heap_test.go:
- entryHeap: min-heap for dirEntry (basic ops, empty, single element)
- largeFileHeap: min-heap for fileEntry (basic ops, top N pattern)
2026-01-28 11:25:08 +08:00
tw93
86c9005381 Merge branch 'dwjoss/cleanable-tests' of https://github.com/dwjoss/Mole; branch 'main' of https://github.com/tw93/Mole 2026-01-27 10:30:43 +08:00
Dylan Joss
162ba949ee test: expand cleanable directory detection tests
Enhance test coverage for `isCleanableDir` and add new tests for
`isHandledByMoClean` in `cmd/analyze/analyze_test.go`.

`TestIsHandledByMoClean` (new, 12 test cases):
- Paths `mo clean` handles (caches, logs, saved state, trash, reports)
- Paths `mo clean` does NOT handle (project dirs, home, random)
- Case sensitivity verification

`TestIsCleanableDir` (expanded from 3 to 24 test cases):
- Project dependencies (`node_modules`, `venv`, `pycache`, `build`, etc.)
- Xcode/iOS directories (DerivedData, Pods)
- Build outputs (dist, target, .next, coverage)
- Paths excluded because `mo clean` handles them
- Edge cases (empty string, root path, just basename)
2026-01-26 14:05:02 -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
83166f2fe8 fix: avoid orphan service false positives and warm large file threshold 2026-01-23 20:16:06 +08:00
Tw93
7e359c57d9 fix(analyze): correct top list and thresholds 2026-01-23 18:27:05 +08:00
Tw93
d862d58672 test: stabilize formatUnusedTime by using UTC baseline 2026-01-22 17:24:55 +08:00
Tw93
6be7f7d0f8 Merge branch 'pr-348' 2026-01-22 17:22:48 +08:00
Dylan Joss
217eb986e2 test: add formatUnusedTime tests and fix duplicate comment
Add unit tests for formatUnusedTime in cmd/analyze/format_test.go:
- Zero time (time.Time{}) returns empty string
- Recent files (< 90 days) return empty string
- Boundary tests at 89/90 days threshold
- Month formatting (3mo, 4mo, 6mo, 11mo, 12mo)
- Year formatting (1yr, 2yr, 3yr)
- Boundary tests at year transitions

Also remove duplicate "Memory pressure penalty" comment in
cmd/status/metrics_health.go (line 72-73).
2026-01-21 22:42:13 -08:00
Andrei Murariu
192ea08f8d bug-fix: mo analyze keybindings misalignment (#342)
* bug-fix: mo analyze keybindings misalignment

handle also uppercase R together with lowercase r

* bug-fix: mo analyze keybindings misalignment

Fix the logic also for:
- q with Q
- k with K
- j with J
- l with L
- b with B
- h with H
- o with O
2026-01-22 11:16:42 +08:00
Tw93
74c9b51cc9 Merge pull request #344 from dwjoss/dwjoss/add-ring-buffer-tests
test: add unit tests for RingBuffer in cmd/status
2026-01-22 11:10:30 +08:00
Dylan Joss
3c761865f8 Uses slices for equality comparison 2026-01-21 11:46:50 -08:00
Dylan Joss
046843a012 Add more tests 2026-01-21 11:29:37 -08:00
Dylan Joss
3148971506 test: add unit tests for RingBuffer in cmd/status
Add comprehensive test coverage for the RingBuffer circular buffer
data structure used in network history tracking.

Test cases:
- Constructor initialization (NewRingBuffer)
- Empty buffer returns nil slice
- Adding elements within capacity
- Exact capacity boundary
- Wrap-around behavior with chronological ordering
- Multiple wrap-arounds stress test
- Single-element buffer edge case
- Slice returns independent copy (not reference)
2026-01-21 00:15:35 -08:00
Tw93
7a5bdac385 feat: add uptime display to status header (#329)
Show system uptime in the header row with a concise format (e.g., "up 1d 5h").
Simplify title from "Mole Status" to "Status" for better fit.
2026-01-18 16:52:44 +08:00
Tw93
72f42a363e chore: remove redundant sensors card and bump version to 1.22.1
- Disable sensors data collection (CPU temp already shown in CPU card)
- Remove unused sensor-related functions (collectSensors, prettifyLabel, hasSensorData, renderSensorsCard)
- Remove unused gopsutil/sensors import
- Fix inline spinner disown call with explicit PID
- Update version from 1.22.0 to 1.22.1
- Update SECURITY_AUDIT.md to match new version and date
2026-01-17 10:46:11 +08:00
Tw93
4fb754e927 Merge pull request #326 from bikraj2/fix/unchecked_history_addition
fix(history): prevent adding multiple history entries with same path when scanning
2026-01-17 08:24:36 +08:00
Tw93
a8a9b2f4f6 Merge branch 'main' into dev 2026-01-17 08:22:02 +08:00
Oleksandr Redko
9b16601117 chore: format code; fix lint issues 2026-01-16 17:39:05 +02:00
Oleksandr Redko
a589b9f2e1 chore(deps): bump shirou/gopsutil from v3 to v4 2026-01-16 17:23:00 +02:00
bikraj2
c99535c2d7 fix(history): prevent adding multiple history entries with same path when scanning 2026-01-16 19:28:32 +05:30
Tw93
d8217235bd chore: clean up dev comments and remove AI-style formatting from README 2026-01-16 15:26:15 +08:00
Tw93
8cc39585ea feat: improve network status graph with sparklines and responsive width 2026-01-16 14:50:10 +08:00
Andrei Murariu
205f3adbd2 imp: mo status network graph 2026-01-15 14:53:34 +02: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
9b3220bfe4 fix: handle uint64 overflow in battery power metrics
- Fix display of invalid large values like 18446744073709544W
- macOS ioreg returns negative values as uint64 (two's complement)
- Detect overflow pattern (value > 2^63) and convert to signed
- Validate reasonable power range (-200W to 200W) for battery
- Add range validation for SystemPower (0 to 1000W)

Root cause: During charging, battery power is negative but ioreg
formats it as unsigned uint64, causing overflow. This fix properly
converts these values back to signed integers.
2026-01-14 11:26:37 +08:00
Tw93
5afd602027 refactor: optimize CPU temp feature with tests and performance fix
- Restore performance test threshold to 200ms (from 500ms)
  User caching is highly effective (~8ms for 100 calls)
- Add unit tests for colorizeTemp() covering thresholds and edge cases
2026-01-14 10:31:01 +08:00
Copper-Eye
fae1c88fa2 add cpu temp display and optimize user check 2026-01-13 17:21:03 -04:00
Tw93
93dee7b94d Implemented safer temp cleanup and error reporting while fixing folded-directory size fallback to prevent double counting and aligning Homebrew cleanup traps with safe removal. 2026-01-12 15:45:31 +08:00
Tw93
3bae4f356a Merge branch 'dev' into pr-300 2026-01-12 14:20:24 +08:00
Jack Phallen
47ce1cb75b fix(analyze): Fix race condition in currentPath 2026-01-11 23:44:55 -05:00
Jack Phallen
1e2cf97b47 fix(analyze): Additional improvements to limit sem blocking 2026-01-11 23:28:44 -05:00
Tw93
df2f00c92f Merge branch 'pr-296' into dev 2026-01-12 11:52:19 +08:00
Tw93
f21fc833b5 Merge pull request #295 from JackPhallen/fix/cap-scanner-buffer-size
fix: cap entryChan buffer to prevent memory spikes
2026-01-12 11:46:00 +08:00
Tw93
8aee56b7fa fix: enhance overview scan UI and invalidate cache on refresh
- Invalidate disk cache for overview entries on refresh to ensure fresh data.

- Show dynamic status messages (e.g., 'Scanning Applications...') instead of static text in Overview.

- Adjust spinner animation speed to 100ms for smoother visual experience.
2026-01-12 11:42:07 +08:00
frozturk
08c577d24a fix: refresh not working in overview mode 2026-01-11 19:38:56 +01:00
Jack Phallen
8870141923 Cap entryChan buffer to prevent memory spikes
Cap buffer at 4096. All entries still process normally—producers just briefly block if
the buffer fills, which is negligible since the collector drains it quickly.
2026-01-11 11:06:00 -05:00
Jack Phallen
b8ab9511fd Create separate limiter for du subprocesses
Introduce duSem to cap concurrent du subprocess spawns while keeping
the existing sem to limit overall scan fan-out (dir recursion/task concurrency).
This prevents du from monopolizing scan concurrency and reduces resource
spikes during folded-dir sizing.
2026-01-11 10:58:45 -05:00
Jack Phallen
cf4690191e Fix semaphore acquisition order
Acquire semaphore before spawning goroutine in calculateDirSizeFast to prevent goroutine
explosion. Previously, all subdirectory goroutines were spawned immediately and blocked on
the semaphore—now the spawning itself is throttled.
2026-01-11 10:58:45 -05:00
Oleksandr Redko
14b8fa688e refactor: simplify with slices.Clone 2026-01-10 20:41:05 +02:00
Tw93
7d43e669a8 fix(analyze): improve deletion safety and UI clarity
- Update UI status to 'Moving to Trash...' for clarity
- Use os.Lstat instead of os.Stat to correctly handle broken symlinks during deletion checks
2026-01-10 08:51:14 +08:00
Tw93
ebb4f7a1e9 feat(analyze): safer deletion with Trash and two-key confirm
- Change delete confirmation from double-delete to Delete→Enter
- Move files to macOS Trash instead of permanent deletion
- Allow file recovery from Trash if accidentally deleted
- Update UI prompts to show 'Press Enter to confirm'
- Skip Finder-dependent tests in CI environments
- Update SECURITY_AUDIT.md with new safety mechanisms

Closes #288
2026-01-10 07:24:58 +08:00
Tw93
2b5dd3f44c feat: show scanning progress as percentage in disk analyzer
- Implemented progress percentage display (e.g., `(45%)`) in `cmd/analyze` to show scanning status based on cached total files.
- Kept the UI clean by avoiding a full progress bar.
- fix: formatting improvements in `bin/touchid.sh`.
2026-01-09 14:16:29 +08:00
Tw93
180037c22b feat(status): persist cat visibility preference
- Add loadCatHidden/saveCatHidden functions
- Save preference to ~/.config/mole/status_prefs
- Load preference on startup
2026-01-08 15:58:50 +08:00
Tw93
79a19ffbfe Go code formatting optimization 2026-01-08 15:26:35 +08:00