Skip to content

1.0.50

Choose a tag to compare

@morapelker morapelker released this 03 Mar 10:12
· 2830 commits to main since this release

What's Changed

Add Claude API usage indicator to sidebar (#92)

Adds a real-time Claude API usage indicator to the left sidebar, showing 5-hour and 7-day utilization with color-coded progress bars. The feature reads OAuth credentials from macOS Keychain (Claude Code v2.x) with a fallback to the legacy ~/.claude/.credentials.json file, and fetches utilization data from the Anthropic API.

What's included

  • Backend usage service (src/main/services/usage-service.ts): Reads Claude OAuth tokens from macOS Keychain (v2.x) or legacy credentials file, fetches usage data from api.anthropic.com/api/oauth/usage with a 10s timeout and abort controller
  • IPC handlers (src/main/ipc/usage-handlers.ts): Registers usage:fetch channel, wired through preload as window.usageOps.fetch()
  • Preload bridge: Exposes window.usageOps namespace with typed declarations
  • Zustand store (useUsageStore): Manages usage state with a 3-minute debounce to avoid excessive API calls
  • UsageIndicator component: Compact two-row display showing 5h/7d usage with:
    • Color-coded progress bars (green → yellow → orange → red based on utilization %)
    • Percentage display and reset time formatting
    • Tooltip with detailed usage info including extra usage credits when enabled
  • Settings toggle: New "Show usage indicator" switch in Settings → General, gated behind showUsageIndicator setting (stored in useSettingsStore)
  • Auto-refresh on idle: Triggers a usage fetch when any OpenCode session goes idle (only when the indicator is enabled)
  • Shared types (src/shared/types/usage.ts): UsageData and UsageResult types used across all three processes

Architecture

Follows the standard Hive three-process pattern:

  1. Main process service fetches data from Anthropic API
  2. IPC handler exposes it through preload bridge
  3. Renderer consumes via Zustand store + React component

Key decisions

  • 3-minute debounce on fetch calls to be respectful of the API
  • Keychain-first token resolution for Claude Code v2.x compatibility, with legacy file fallback
  • Gated behind settings — users opt in via Settings → General toggle
  • Replaces SpacesTabBar in the sidebar when enabled; loadSpaces() moved to ProjectList where space data is actually consumed

Fix Supercharge button hover transparency for light and dark themes (#91)

  • Fixed hover state on the "Supercharge" (Plan Ready / Implement) FAB button in PlanReadyImplementFab.tsx
  • Replaced the semi-transparent hover:bg-violet-600/10 background with explicit light and dark theme variants:
    • Light mode: hover:bg-violet-100 — a solid, visible hover highlight
    • Dark mode: dark:hover:bg-violet-950 — a subtle, theme-appropriate hover highlight
  • This resolves the issue where the hover state appeared too faint or inconsistent across themes due to the use of an alpha-transparency value

Fix missing files in file indexing with batched event processing (#90)

  • Batch file-tree change events: Instead of debouncing to a single event (last-write-wins), the file watcher now accumulates all events during the 100ms debounce window and sends them as a deduplicated batch. This fixes the core issue where rapid file changes (e.g. during branch switches or npm install) caused files to go missing from the index.
  • Smart event deduplication: Added deduplication logic (deduplicateEvents) that collapses redundant events per path — add+change keeps only add, add+unlink cancels out, unlink+add keeps add (recreated file), and duplicate changes collapse to one.
  • Full re-scan threshold: When a batch exceeds 20 events (e.g. branch switch, npm install), the store skips incremental index updates entirely and does a full re-scan for safety.
  • Treat change as implicit add: If a change event arrives for a path not in the index, it's treated as an add — recovering from missed watcher events or debounce races.
  • Decouple watcher from FileTree component: loadFileIndex() now auto-starts the file watcher subscription, ensuring incremental updates flow even when the Files sidebar tab is hidden.
  • Updated types across all layers: Introduced FileTreeChangeEventItem (batched payload item), FileTreeIndividualChangeEvent (for EventBus/GraphQL backward compat), and FileEventType union type in src/shared/types/file-tree.ts. Updated preload declarations, preload bridge, EventBus, and GraphQL subscription resolvers accordingly.

Fix duplicate breed name collisions in worktree creation (#89)

  • Added retry logic (up to 3 attempts) for worktree breed-name collisions in GitService across all three worktree creation methods: createWorktree, duplicateWorktree, and createWorktreeFromBranch
  • Added filesystem directory scanning (readdirSync) to detect path collisions from incomplete worktree cleanups that git branches/worktrees alone wouldn't catch
  • Moved invariant setup outside retry loops — ensureWorktreesDir(), getCurrentBranch(), and PR fetch calls execute once before the retry loop since they don't change between attempts
  • Re-fetch branch/worktree state on each retry so subsequent attempts see the latest git state after a collision
  • Only retry on "already exists" errors — non-collision errors (e.g. "not a git repository") propagate immediately without wasting retries
  • Added comprehensive test suite (worktree-breed-collision-retry.test.ts) with 5 tests covering: successful retry after collision, failure after 3 collisions, no retry on non-collision errors, success on first attempt, and source code verification of retry patterns