Move saveCredentialsForProfile calls inside the .then() callbacks and make
them async/await to ensure credentials are saved as part of the promise
chain. This prevents race conditions when multiple concurrent requests
share the same refresh promise.
Implements profile-scoped OAuth credentials for the OpenAI Codex provider,
enabling users to use different OpenAI accounts for different provider profiles
without manual logout/clearing sessions.
Changes:
- oauth.ts: Add profile-scoped credential storage using profile-specific keys
- Add Map-based in-memory caching per profile
- Add de-duplication of concurrent token refresh requests per profile
- Maintain backward compatibility with legacy global methods
- api.ts: Add apiConfigurationId to ApiHandlerOptions
- openai-codex.ts: Update to use profile-scoped OAuth methods
- webviewMessageHandler.ts: Update sign-in/sign-out/rate-limits handlers
- vscode-extension-host.ts: Add profileId to WebviewMessage and email to ExtensionState
- OpenAICodex.tsx: Add props for email display and profileId
- OpenAICodexRateLimitDashboard.tsx: Add profileId prop
- ClineProvider.ts: Update getStateToPostToWebview to use profile-scoped auth
- ApiOptions.tsx: Pass new props to OpenAICodex component
- webviewMessageHandler.spec.ts: Update tests for profile-scoped methods
Closes#11094
* feat(condense): add smart code folding with tree-sitter signatures
At context condensation time, use tree-sitter to generate folded code
signatures (function definitions, class declarations) for files read
during the conversation. Each file is included as its own <system-reminder>
block in the condensed summary, preserving structural awareness without
consuming excessive tokens.
- Add getFilesReadByRoo() method to FileContextTracker
- Create generateFoldedFileContext() using tree-sitter parsing
- Update summarizeConversation() to accept array of file sections
- Each file gets its own content block in the summary message
- Add comprehensive test coverage (12 tests)
* fix: skip tree-sitter error strings in folded file context
- Add isTreeSitterErrorString helper to detect error messages
- Skip files that return error strings instead of embedding them
- Add test for error string handling
* refactor: move generateFoldedFileContext() inside summarizeConversation()
- Update summarizeConversation() to accept filesReadByRoo, cwd, rooIgnoreController instead of pre-generated sections
- Move folded file context generation inside summarizeConversation() (lines 319-339)
- Update ContextManagementOptions type and manageContext() to pass new parameters
- Remove generateFoldedFileContext from Task.ts imports - folding now handled internally
- Update all tests to use new parameter signature
- Reduces Task.ts complexity by moving folding logic to summarization module
* fix: prioritize most recently read files in folded context
Files are now sorted by roo_read_date descending before folded context
generation, so if the character budget runs out, the most relevant
(recently read) files are included and older files are skipped.
* refactor: improve code quality in condense module
- Convert summarizeConversation to use options object instead of 11 positional params
- Extract duplicated getFilesReadByRoo error handling into helper method
- Remove unnecessary re-export of generateFoldedFileContext
- Update all test files to use new options object pattern
* fix: address roomote feedback - batch error logging and early budget exit
---------
Co-authored-by: Roo Code <roomote@roocode.com>
Co-authored-by: daniel-lxs <ricciodaniel98@gmail.com>
fix: prevent false validation error for local Ollama models
The validation logic was checking against an empty router models object
that was initialized but never populated for Ollama. This caused false
validation errors even when models existed locally.
Now only validates against router models if they actually contain data,
preventing the false error when using local Ollama models.
Fixes ROO-581
Co-authored-by: Roo Code <roomote@roocode.com>
- Modified VsCodeLmHandler.internalCountTokens() to create temporary cancellation tokens when needed
- Token counting now works both during and outside of active requests
- Added 4 new tests to verify the fix and prevent regression
- Resolves issue where VS Code LM API users experienced context overflow errors