5 Commits
Author SHA1 Message Date
Willie 5307b3276e fix(server): use snapshot pattern to eliminate map races and narrow lock scope
Addresses P1 and P2 from code review on the RWMutex commit:

P1 — Stream handlers now snapshot config under RLock before streaming:
- handleDiffStream: clone Targets map to prevent concurrent map panic
- handleCheckStream, handleAuditStream: snapshot source/projectRoot
- handleUpdateStream: snapshot source (per-item Lock already correct)

P2 — All read handlers now use narrow snapshot instead of defer RUnlock:
- RLock → copy needed fields to locals → RUnlock → do work with locals
- Prevents slow I/O (git fetch, version check, audit scan) from blocking
  the auto-reload middleware's exclusive Lock on concurrent requests

Other changes:
- computeTargetDiff takes source parameter (no more s.cfg.Source access)
- Add cloneTargets() helper for safe map copying
- Add writeOpsLogTo/writeAuditLogTo for lock-free oplog writes
2026-03-17 04:48:42 +08:00
Willie 11f696cffe fix(server): upgrade Mutex to RWMutex for concurrent read safety
Addresses PR #82 review: read-only handlers accessed s.cfg without
synchronization, risking data races with concurrent config reloads.

- Upgrade sync.Mutex → sync.RWMutex (drop-in compatible)
- Add RLock to 26 non-streaming read handlers
- Keep exclusive Lock for write handlers (unchanged)
- Skip SSE streaming handlers to avoid blocking writes during streams
- Fix isConfigGitignored to propagate GitignoreContains errors
2026-03-17 04:48:42 +08:00
Willie 5f1521c3fd feat(log): comprehensive log improvements — partial status, instrumentation, retention, stats
- Report "partial" status for sync/install/update/uninstall when some
  items succeed and others fail
- Instrument 6 new commands: check, diff, trash, init, upgrade, and
  all mutating commands now log to operations.log
- Auto-truncation via WriteWithLimit with configurable log.max_entries
  (default 1000) and 20% hysteresis to avoid truncating every write
- Stats engine: computeLogStats with per-command breakdown
- CLI --stats flag with colored output and ✓ok/total ratios
- TUI stats panel (toggle with 's'): bar charts, status distribution,
  last operation timestamp
- TUI stats footer: compact always-visible summary line
- TUI detail panel: j/k scrolling for long entries, proportional
  list/detail layout (40%/60%)
- Web API: GET /api/log/stats endpoint
- Updated website docs for log command
2026-02-26 22:27:23 +08:00
Willie 84ba16802d feat: add log filtering, improve log UX, and custom dropdown
- Add --cmd, --status, --since, --json flags to CLI log command
- Auto-skip irrelevant log section when --cmd narrows to one file
- Add blank line separator between log entries for readability
- API returns totalAll and commands for smarter frontend filtering
- Custom HandSelect dropdown matching hand-drawn design system
- Empty state distinguishes "no matching entries" from "no entries"
- Update website docs and built-in skill reference with new flags
2026-02-11 03:40:54 +08:00
Willie 5a65993304 feat: add operation log — JSONL-based persistent audit trail for CLI, API, and web UI
Add oplog package (internal/oplog) that records every mutating command
(install, uninstall, sync, push, pull, collect, backup, restore, update,
audit) as a JSONL entry with timestamp, status, duration, and args.

- CLI: `skillshare log` with --audit, --tail, --clear, --project flags
- API: GET/DELETE /api/log endpoints with type and limit params
- Web UI: LogPage with ops/audit tabs, table view, clear and refresh
- Instrumentation across 12 command handlers (CLI + server)
2026-02-10 02:56:59 +08:00