feat: automate API key detection and enhance login flow#565
Conversation
- Add 'auth_cache' table to SQLite to store validated API key results (24h TTL) - Implement global auth hook that validates keys from env vars/config on any command - Log "Authenticated as <identity>" on any first action using cached results - Enhance 'uncompact auth login' to automatically open browser to dashboard - Add github.com/pkg/browser dependency for reliable browser integration Co-Authored-By: Grey Newell <greyshipscode@gmail.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review infoConfiguration used: Organization UI Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (5)
WalkthroughThis PR adds authentication status caching to reduce redundant API calls during CLI command execution. It integrates browser-based dashboard access during login, validates API keys client-side, and persists authentication data (valid for 24 hours) to avoid repeated server validation checks. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI as CLI (auth.go)
participant Browser as Browser/Dashboard
participant API as Supermodel API
participant Cache as Local Cache
User->>CLI: Run login command
CLI->>Browser: Open dashboard URL
Browser->>User: Display login form
User->>Browser: Enter API key
Browser->>CLI: (user copies key)
User->>CLI: Provide API key
CLI->>API: Validate API key (5s timeout)
API-->>CLI: Return authenticated identity
CLI->>Cache: Store AuthStatus with Identity & Timestamp
Cache-->>CLI: Cached ✓
CLI-->>User: Authentication successful
sequenceDiagram
participant User
participant RootCmd as Root Command (root.go)
participant Cache as Local Cache
participant API as Supermodel API
participant Config as Config
User->>RootCmd: Execute CLI command
RootCmd->>RootCmd: checkAuth() pre-run hook
RootCmd->>Config: Load API key
Config-->>RootCmd: API key value
RootCmd->>Cache: GetAuthStatus(apiKeyHash)
alt Cache hit & fresh (< 24h)
Cache-->>RootCmd: Return cached AuthStatus
RootCmd->>RootCmd: Use cached identity
else Cache miss or stale
RootCmd->>API: Validate API key (5s timeout)
API-->>RootCmd: Return identity
RootCmd->>Cache: SetAuthStatus with new data
Cache-->>RootCmd: Updated ✓
end
RootCmd->>RootCmd: Proceed with command execution
RootCmd-->>User: Command result
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Comment |
This PR automates the detection and validation of API keys from environment variables and configuration files. It uses a new SQLite-based
auth_cacheto minimize redundant API calls by caching validation results for 24 hours. Theuncompact auth logincommand now also automatically opens the Supermodel dashboard in the browser for a smoother user experience.@claude please implement this
Summary by CodeRabbit
Release Notes