Commit Graph

12 Commits

  • fix: OAuth token refresh failure returns undefined instead of throwing
    When OAuth refresh fails during model discovery, getApiKey() now returns
    undefined instead of throwing. This allows the app to start and fall back
    to other providers, so the user can /login to re-authenticate.
    
    fixes #498
  • Improve OAuth login UI with consistent dialog component
    - Add LoginDialogComponent with proper borders (top/bottom DynamicBorder)
    - Refactor all OAuth providers to use racing approach (browser callback vs manual paste)
    - Add onEscape handler to Input component for cancellation
    - Add abortable sleep for GitHub Copilot polling (instant cancel on Escape)
    - Show OS-specific click hint (Cmd+click on macOS, Ctrl+click elsewhere)
    - Clear content between login phases (fixes GitHub Copilot two-phase flow)
    - Use InteractiveMode's showStatus/showError for result messages
    - Reorder providers: Anthropic, ChatGPT, GitHub Copilot, Gemini CLI, Antigravity
  • feat(oauth): show paste input immediately during OpenAI Codex login (#468)
    Previously, users had to wait up to 60 seconds for the browser callback
    to timeout before being prompted to paste the authorization code. This
    was problematic for SSH/VPS sessions where the callback cannot work.
    
    Now the paste input is shown immediately alongside the browser flow:
    - Browser callback and manual paste race - whichever completes first wins
    - Desktop users: browser callback succeeds, input is cleaned up
    - SSH/VPS users: paste code immediately without waiting
    
    Changes:
    - Add cancelWait() to OAuth server for early termination of polling loop
    - Add onManualCodeInput callback that races with browser callback
    - Show paste input immediately in TUI for openai-codex provider
    - Clean up input on success, error, or when browser callback wins
    
    Co-authored-by: cc-vps <crcatala+vps@gmail.com>
  • Fix slow /model selector by deferring OAuth token refresh
    getAvailable() now uses hasAuth() which checks if auth is configured
    without triggering OAuth token refresh. Refresh happens later when
    the model is actually used.
  • refactor(hooks): split session events into individual typed events
    Major changes:
    - Replace monolithic SessionEvent with reason discriminator with individual
      event types: session_start, session_before_switch, session_switch,
      session_before_new, session_new, session_before_branch, session_branch,
      session_before_compact, session_compact, session_shutdown
    - Each event has dedicated result type (SessionBeforeSwitchResult, etc.)
    - HookHandler type now allows bare return statements (void in return type)
    - HookAPI.on() has proper overloads for each event with correct typing
    
    Additional fixes:
    - AgentSession now always subscribes to agent in constructor (was only
      subscribing when external subscribe() called, breaking internal handlers)
    - Standardize on undefined over null throughout codebase
    - HookUIContext methods return undefined instead of null
    - SessionManager methods return undefined instead of null
    - Simplify hook exports to 'export type * from types.js'
    - Add detailed JSDoc for skipConversationRestore vs cancel
    - Fix createBranchedSession to rebuild index in persist mode
    - newSession() now returns the session file path
    
    Updated all example hooks, tests, and emission sites to use new event types.
  • Add automatic session migration for v0.30.0 bug
    - Create migrations.ts with consolidated migrations
    - Move auth migration from AuthStorage.migrateLegacy() to migrations.ts
    - Add migrateSessionsFromAgentRoot() to fix misplaced sessions
    - Sessions in ~/.pi/agent/*.jsonl are auto-migrated on startup
    
    fixes #320
  • Refactor OAuth/API key handling: AuthStorage and ModelRegistry
    - Add AuthStorage class for credential storage (auth.json)
    - Add ModelRegistry class for model management with API key resolution
    - Add discoverAuthStorage() and discoverModels() discovery functions
    - Add migration from legacy oauth.json and settings.json apiKeys to auth.json
    - Remove configureOAuthStorage, defaultGetApiKey, findModel, discoverAvailableModels
    - Remove apiKeys from Settings type and SettingsManager methods
    - Rename getOAuthPath to getAuthPath
    - Update SDK, examples, docs, tests, and mom package
    
    Fixes #296
  • WIP: Add auth-storage.ts for credential management
    - AuthStorage class for reading/writing auth.json
    - Supports both api_key and oauth credential types
    - getApiKey() priority: auth.json api_key > auth.json oauth > env var