Skip to content

Conversation

@zhangmo8
Copy link
Collaborator

@zhangmo8 zhangmo8 commented Dec 19, 2025

users can customize the GitHub Client Id to handle Copilot's authorization

link #1073

Summary by CodeRabbit

  • New Features
    • Added custom GitHub Copilot Client ID configuration in settings. Users can now optionally provide a client ID through the UI instead of relying solely on environment variables.
    • Extended localization support across 12 languages for the new Client ID settings field.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 19, 2025

Walkthrough

This PR enables customizable GitHub Copilot Client IDs throughout the application. Users can override the default client ID via settings, which is threaded through OAuth and Device Flow authentication mechanisms, backed by type definitions, i18n support across 13 languages, and provider rebuild configuration.

Changes

Cohort / File(s) Summary
GitHub Copilot Authentication Logic
src/main/presenter/githubCopilotDeviceFlow.ts, src/main/presenter/githubCopilotOAuth.ts, src/main/presenter/oauthPresenter.ts, src/main/presenter/llmProviderPresenter/providers/githubCopilotProvider.ts
Added optional clientIdOverride parameter to factory and global getter functions. Enhanced getGlobalGitHubCopilotDeviceFlow with state tracking (globalDeviceFlowClientId) to detect changes and recreate instances. Updated error messages to reference Copilot settings as an alternative source. Wired provider-specific client IDs through auth initialization calls.
Type Definitions
src/shared/types/presenters/legacy.presenters.d.ts, src/shared/types/presenters/llmprovider.presenter.d.ts, src/types/i18n.d.ts
Added optional copilotClientId?: string field to LLM_PROVIDER interface and i18n type definitions to support custom client ID configuration.
UI Component and Settings
src/renderer/settings/components/GitHubCopilotOAuth.vue
Introduced client ID input field with local state binding, blur/enter-key save logic, watcher for provider synchronization, and saveClientId() method with error handling via providerStore.updateProviderConfig.
Internationalization
src/renderer/src/i18n/{da-DK,en-US,fa-IR,fr-FR,he-IL,ja-JP,ko-KR,pt-BR,ru-RU,zh-CN,zh-HK,zh-TW}/settings.json
Added githubCopilotClientId label and githubCopilotClientIdHint description keys across 12 locales, with translations describing the optional client ID field and its effect on authentication.
Provider Configuration
src/shared/provider-operations.ts
Added copilotClientId to REBUILD_REQUIRED_FIELDS constant to trigger provider instance rebuild when the client ID is updated.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–25 minutes

  • State management logic in githubCopilotDeviceFlow.ts: Review the globalDeviceFlowClientId tracking and instance recreation condition to ensure correct behavior when client ID changes and cleanup on dispose.
  • Provider-specific client ID threading: Verify that provider?.copilotClientId is correctly passed through both OAuth and Device Flow paths in oauthPresenter.ts and githubCopilotProvider.ts.
  • UI save flow: Confirm error handling in saveClientId() and proper synchronization via the provider watcher in GitHubCopilotOAuth.vue.
  • Note: i18n files follow a repetitive pattern across 12 languages; spot-check a few for consistency rather than reviewing each individually.

Possibly related PRs

Suggested reviewers

  • zerob13

Poem

🐰 A client ID in settings now dwells,
Custom Copilot? The rabbit knows well!
Through OAuth it flows, Device Flow takes flight,
Thirteen tongues cheer—authentication's tight! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: custom clientId for github copilot' directly and accurately summarizes the main change: adding support for customizing the GitHub Client ID for Copilot authentication.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@chatgpt-codex-connector
Copy link

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (10)
src/renderer/src/i18n/pt-BR/settings.json (1)

413-414: Localize new Copilot Client ID strings to pt-BR

Keys and placement look correct, but the values are still in English in this pt-BR file. Consider translating for consistency with the rest of the locale, for example:

Suggested pt-BR translations
-    "githubCopilotClientId": "Custom Client ID",
-    "githubCopilotClientIdHint": "Optional. Leave empty to use the built-in default Client ID. Only affects GitHub Copilot auth.",
+    "githubCopilotClientId": "ID de Cliente Personalizado",
+    "githubCopilotClientIdHint": "Opcional. Deixe em branco para usar o ID de Cliente padrão integrado. Afeta apenas a autenticação do GitHub Copilot."
src/renderer/src/i18n/fr-FR/settings.json (1)

413-414: Localize new Copilot Client ID strings to fr-FR

The new keys are correct structurally, but the values remain in English in this fr-FR file. For consistency, consider translating them, for example:

Suggested fr-FR translations
-    "githubCopilotClientId": "Custom Client ID",
-    "githubCopilotClientIdHint": "Optional. Leave empty to use the built-in default Client ID. Only affects GitHub Copilot auth.",
+    "githubCopilotClientId": "ID client personnalisé",
+    "githubCopilotClientIdHint": "Facultatif. Laissez vide pour utiliser l’ID client par défaut intégré. N’affecte que l’authentification GitHub Copilot."
src/main/presenter/llmProviderPresenter/providers/githubCopilotProvider.ts (1)

42-47: Device flow correctly wired to provider-specific Copilot Client ID

Passing this.provider.copilotClientId into getGlobalGitHubCopilotDeviceFlow makes the GitHub Copilot device flow respect the per-provider client ID while still falling back to the default env client ID when unset. This is aligned with the new copilotClientId field on LLM_PROVIDER and the factory’s clientIdOverride behavior.

If you ever revisit this method, you might consider moving this.isInitialized = true to after deviceFlow and model initialization succeed so the flag more accurately reflects a fully initialized provider, but that’s pre-existing and non-blocking.

src/renderer/src/i18n/fa-IR/settings.json (1)

413-414: Localize new Copilot Client ID strings for fa-IR for consistency

Keys and placement look right, but the values are still English in an otherwise Persian locale. Consider translating the label and hint to Persian to keep UX consistent with the rest of this file.

src/renderer/src/i18n/da-DK/settings.json (1)

401-402: Consider translating Copilot Client ID strings to Danish

The new githubCopilotClientId and githubCopilotClientIdHint keys are structurally correct and aligned with other locales, but their values are still English in a Danish file. If full localization is a goal, consider providing Danish translations.

src/renderer/src/i18n/ko-KR/settings.json (1)

413-414: Optional: localize Copilot Client ID label/hint to Korean

The newly added githubCopilotClientId and githubCopilotClientIdHint keys are correctly placed alongside the other Copilot strings and match the cross‑locale key structure, but their values are English. For a fully localized ko-KR experience, consider providing Korean translations. Based on learnings, this keeps the i18n surface consistent across locales.

src/renderer/src/i18n/ja-JP/settings.json (1)

413-414: Translate Copilot Client ID strings to Japanese for consistency

The new githubCopilotClientId and githubCopilotClientIdHint keys are correctly wired into the provider section, but their values remain in English in an otherwise Japanese locale file. If you aim for full ja-JP localization, consider providing Japanese text here.

src/renderer/src/i18n/he-IL/settings.json (1)

413-414: Optional: Hebrew translation for Copilot Client ID strings

githubCopilotClientId and githubCopilotClientIdHint are added in the right place and match the shared i18n key structure, but their values are still English. To keep he-IL UX consistent, you may want to translate these strings to Hebrew.

src/renderer/settings/components/GitHubCopilotOAuth.vue (1)

167-172: Consider watching a specific property for precision.

The watcher watches the entire props.provider object reference. While this works when the provider object is replaced, consider watching the specific property for more precise reactivity:

 watch(
-  () => props.provider,
-  (next) => {
-    copilotClientId.value = next.copilotClientId || ''
+  () => props.provider.copilotClientId,
+  (next) => {
+    copilotClientId.value = next || ''
   }
 )

This ensures the watcher only triggers when copilotClientId changes, not when other provider properties change.

src/main/presenter/githubCopilotOAuth.ts (1)

231-248: Consider reducing verbose logging in production.

The current implementation logs detailed OAuth configuration information including environment variable status. While helpful for debugging, this verbose output may clutter logs in production.

Consider guarding the detailed logs with a development check:

+if (is.dev) {
   console.log('GitHub OAuth Configuration:')
   console.log('- Client ID configured:', clientId ? '✅' : '❌')
   console.log('- Client ID override provided:', clientIdOverride ? '✅' : '❌')
   // ... remaining log statements
+}

This aligns with the existing pattern at line 268 where is.dev guards the final config log.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f6aabcb and 193d4b7.

📒 Files selected for processing (21)
  • src/main/presenter/githubCopilotDeviceFlow.ts (3 hunks)
  • src/main/presenter/githubCopilotOAuth.ts (2 hunks)
  • src/main/presenter/llmProviderPresenter/providers/githubCopilotProvider.ts (1 hunks)
  • src/main/presenter/oauthPresenter.ts (2 hunks)
  • src/renderer/settings/components/GitHubCopilotOAuth.vue (3 hunks)
  • src/renderer/src/i18n/da-DK/settings.json (1 hunks)
  • src/renderer/src/i18n/en-US/settings.json (1 hunks)
  • src/renderer/src/i18n/fa-IR/settings.json (1 hunks)
  • src/renderer/src/i18n/fr-FR/settings.json (1 hunks)
  • src/renderer/src/i18n/he-IL/settings.json (1 hunks)
  • src/renderer/src/i18n/ja-JP/settings.json (1 hunks)
  • src/renderer/src/i18n/ko-KR/settings.json (1 hunks)
  • src/renderer/src/i18n/pt-BR/settings.json (1 hunks)
  • src/renderer/src/i18n/ru-RU/settings.json (1 hunks)
  • src/renderer/src/i18n/zh-CN/settings.json (1 hunks)
  • src/renderer/src/i18n/zh-HK/settings.json (1 hunks)
  • src/renderer/src/i18n/zh-TW/settings.json (1 hunks)
  • src/shared/provider-operations.ts (1 hunks)
  • src/shared/types/presenters/legacy.presenters.d.ts (1 hunks)
  • src/shared/types/presenters/llmprovider.presenter.d.ts (1 hunks)
  • src/types/i18n.d.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (25)
src/renderer/src/i18n/**/*.json

📄 CodeRabbit inference engine (.cursor/rules/i18n.mdc)

src/renderer/src/i18n/**/*.json: Translation key naming convention: use dot-separated hierarchical structure with lowercase letters and descriptive names (e.g., 'common.button.submit')
Maintain consistent key-value structure across all language translation files (zh-CN, en-US, ko-KR, ru-RU, zh-HK, fr-FR, fa-IR)

Files:

  • src/renderer/src/i18n/zh-HK/settings.json
  • src/renderer/src/i18n/ru-RU/settings.json
  • src/renderer/src/i18n/he-IL/settings.json
  • src/renderer/src/i18n/en-US/settings.json
  • src/renderer/src/i18n/da-DK/settings.json
  • src/renderer/src/i18n/pt-BR/settings.json
  • src/renderer/src/i18n/zh-TW/settings.json
  • src/renderer/src/i18n/zh-CN/settings.json
  • src/renderer/src/i18n/fa-IR/settings.json
  • src/renderer/src/i18n/ja-JP/settings.json
  • src/renderer/src/i18n/ko-KR/settings.json
  • src/renderer/src/i18n/fr-FR/settings.json
src/**/*

📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)

New features should be developed in the src directory

Files:

  • src/renderer/src/i18n/zh-HK/settings.json
  • src/shared/types/presenters/llmprovider.presenter.d.ts
  • src/shared/provider-operations.ts
  • src/renderer/src/i18n/ru-RU/settings.json
  • src/renderer/src/i18n/he-IL/settings.json
  • src/renderer/src/i18n/en-US/settings.json
  • src/renderer/src/i18n/da-DK/settings.json
  • src/renderer/src/i18n/pt-BR/settings.json
  • src/renderer/src/i18n/zh-TW/settings.json
  • src/main/presenter/llmProviderPresenter/providers/githubCopilotProvider.ts
  • src/types/i18n.d.ts
  • src/renderer/src/i18n/zh-CN/settings.json
  • src/renderer/src/i18n/fa-IR/settings.json
  • src/renderer/src/i18n/ja-JP/settings.json
  • src/renderer/src/i18n/ko-KR/settings.json
  • src/renderer/settings/components/GitHubCopilotOAuth.vue
  • src/renderer/src/i18n/fr-FR/settings.json
  • src/main/presenter/oauthPresenter.ts
  • src/main/presenter/githubCopilotDeviceFlow.ts
  • src/shared/types/presenters/legacy.presenters.d.ts
  • src/main/presenter/githubCopilotOAuth.ts
src/renderer/**

📄 CodeRabbit inference engine (.cursor/rules/vue-shadcn.mdc)

Use lowercase with dashes for directories (e.g., components/auth-wizard)

Files:

  • src/renderer/src/i18n/zh-HK/settings.json
  • src/renderer/src/i18n/ru-RU/settings.json
  • src/renderer/src/i18n/he-IL/settings.json
  • src/renderer/src/i18n/en-US/settings.json
  • src/renderer/src/i18n/da-DK/settings.json
  • src/renderer/src/i18n/pt-BR/settings.json
  • src/renderer/src/i18n/zh-TW/settings.json
  • src/renderer/src/i18n/zh-CN/settings.json
  • src/renderer/src/i18n/fa-IR/settings.json
  • src/renderer/src/i18n/ja-JP/settings.json
  • src/renderer/src/i18n/ko-KR/settings.json
  • src/renderer/settings/components/GitHubCopilotOAuth.vue
  • src/renderer/src/i18n/fr-FR/settings.json
**/*.{ts,tsx,js,jsx,vue}

📄 CodeRabbit inference engine (CLAUDE.md)

Use English for logs and comments (Chinese text exists in legacy code, but new code should use English)

Files:

  • src/shared/types/presenters/llmprovider.presenter.d.ts
  • src/shared/provider-operations.ts
  • src/main/presenter/llmProviderPresenter/providers/githubCopilotProvider.ts
  • src/types/i18n.d.ts
  • src/renderer/settings/components/GitHubCopilotOAuth.vue
  • src/main/presenter/oauthPresenter.ts
  • src/main/presenter/githubCopilotDeviceFlow.ts
  • src/shared/types/presenters/legacy.presenters.d.ts
  • src/main/presenter/githubCopilotOAuth.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Enable and maintain strict TypeScript type checking for all files

**/*.{ts,tsx}: Always use try-catch to handle possible errors in TypeScript code
Provide meaningful error messages when catching errors
Log detailed error logs including error details, context, and stack traces
Distinguish and handle different error types (UserError, NetworkError, SystemError, BusinessError) with appropriate handlers in TypeScript
Use structured logging with logger.error(), logger.warn(), logger.info(), logger.debug() methods from logging utilities
Do not suppress errors (avoid empty catch blocks or silently ignoring errors)
Provide user-friendly error messages for user-facing errors in TypeScript components
Implement error retry mechanisms for transient failures in TypeScript
Avoid logging sensitive information (passwords, tokens, PII) in logs

Files:

  • src/shared/types/presenters/llmprovider.presenter.d.ts
  • src/shared/provider-operations.ts
  • src/main/presenter/llmProviderPresenter/providers/githubCopilotProvider.ts
  • src/types/i18n.d.ts
  • src/main/presenter/oauthPresenter.ts
  • src/main/presenter/githubCopilotDeviceFlow.ts
  • src/shared/types/presenters/legacy.presenters.d.ts
  • src/main/presenter/githubCopilotOAuth.ts
**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

Do not include AI co-authoring information (e.g., 'Co-Authored-By: Claude') in git commits

Files:

  • src/shared/types/presenters/llmprovider.presenter.d.ts
  • src/shared/provider-operations.ts
  • src/main/presenter/llmProviderPresenter/providers/githubCopilotProvider.ts
  • src/types/i18n.d.ts
  • src/main/presenter/oauthPresenter.ts
  • src/main/presenter/githubCopilotDeviceFlow.ts
  • src/shared/types/presenters/legacy.presenters.d.ts
  • src/main/presenter/githubCopilotOAuth.ts
**/*.{js,ts,jsx,tsx,mjs,cjs}

📄 CodeRabbit inference engine (.cursor/rules/development-setup.mdc)

Write logs and comments in English

Files:

  • src/shared/types/presenters/llmprovider.presenter.d.ts
  • src/shared/provider-operations.ts
  • src/main/presenter/llmProviderPresenter/providers/githubCopilotProvider.ts
  • src/types/i18n.d.ts
  • src/main/presenter/oauthPresenter.ts
  • src/main/presenter/githubCopilotDeviceFlow.ts
  • src/shared/types/presenters/legacy.presenters.d.ts
  • src/main/presenter/githubCopilotOAuth.ts
src/shared/**/*.d.ts

📄 CodeRabbit inference engine (.cursor/rules/electron-best-practices.mdc)

Define type definitions in shared/*.d.ts files for objects exposed by the main process to the renderer process

Files:

  • src/shared/types/presenters/llmprovider.presenter.d.ts
  • src/shared/types/presenters/legacy.presenters.d.ts
src/shared/**/*.{js,ts}

📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)

Shared type definitions and utilities between main and renderer processes should be placed in src/shared

Files:

  • src/shared/types/presenters/llmprovider.presenter.d.ts
  • src/shared/provider-operations.ts
  • src/shared/types/presenters/legacy.presenters.d.ts
src/shared/**/*.ts

📄 CodeRabbit inference engine (AGENTS.md)

Shared types and utilities should be placed in src/shared/

Files:

  • src/shared/types/presenters/llmprovider.presenter.d.ts
  • src/shared/provider-operations.ts
  • src/shared/types/presenters/legacy.presenters.d.ts
src/**/*.{ts,tsx,vue,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use Prettier with single quotes, no semicolons, and 100 character width

Files:

  • src/shared/types/presenters/llmprovider.presenter.d.ts
  • src/shared/provider-operations.ts
  • src/main/presenter/llmProviderPresenter/providers/githubCopilotProvider.ts
  • src/types/i18n.d.ts
  • src/renderer/settings/components/GitHubCopilotOAuth.vue
  • src/main/presenter/oauthPresenter.ts
  • src/main/presenter/githubCopilotDeviceFlow.ts
  • src/shared/types/presenters/legacy.presenters.d.ts
  • src/main/presenter/githubCopilotOAuth.ts
src/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use OxLint for linting JavaScript and TypeScript files

Files:

  • src/shared/types/presenters/llmprovider.presenter.d.ts
  • src/shared/provider-operations.ts
  • src/main/presenter/llmProviderPresenter/providers/githubCopilotProvider.ts
  • src/types/i18n.d.ts
  • src/main/presenter/oauthPresenter.ts
  • src/main/presenter/githubCopilotDeviceFlow.ts
  • src/shared/types/presenters/legacy.presenters.d.ts
  • src/main/presenter/githubCopilotOAuth.ts
src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

src/**/*.{ts,tsx}: Use camelCase for variable and function names in TypeScript files
Use PascalCase for type and class names in TypeScript
Use SCREAMING_SNAKE_CASE for constant names

Files:

  • src/shared/types/presenters/llmprovider.presenter.d.ts
  • src/shared/provider-operations.ts
  • src/main/presenter/llmProviderPresenter/providers/githubCopilotProvider.ts
  • src/types/i18n.d.ts
  • src/main/presenter/oauthPresenter.ts
  • src/main/presenter/githubCopilotDeviceFlow.ts
  • src/shared/types/presenters/legacy.presenters.d.ts
  • src/main/presenter/githubCopilotOAuth.ts
src/**/*.ts

📄 CodeRabbit inference engine (AGENTS.md)

Use EventBus for inter-process communication events

Files:

  • src/shared/types/presenters/llmprovider.presenter.d.ts
  • src/shared/provider-operations.ts
  • src/main/presenter/llmProviderPresenter/providers/githubCopilotProvider.ts
  • src/types/i18n.d.ts
  • src/main/presenter/oauthPresenter.ts
  • src/main/presenter/githubCopilotDeviceFlow.ts
  • src/shared/types/presenters/legacy.presenters.d.ts
  • src/main/presenter/githubCopilotOAuth.ts
src/main/presenter/**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

Organize core business logic into dedicated Presenter classes, with one presenter per functional domain

Files:

  • src/main/presenter/llmProviderPresenter/providers/githubCopilotProvider.ts
  • src/main/presenter/oauthPresenter.ts
  • src/main/presenter/githubCopilotDeviceFlow.ts
  • src/main/presenter/githubCopilotOAuth.ts
src/main/presenter/llmProviderPresenter/providers/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

src/main/presenter/llmProviderPresenter/providers/*.ts: Each LLM provider must implement the coreStream method following the standardized event interface for tool calling and response streaming
Convert MCP tools to provider-specific formats and normalize streaming responses to standard events in each provider implementation

src/main/presenter/llmProviderPresenter/providers/*.ts: In Provider implementations (src/main/presenter/llmProviderPresenter/providers/*.ts), the coreStream(messages, modelId, temperature, maxTokens) method should perform a single-pass streaming API request for each conversation round without containing multi-turn tool call loop logic
In Provider implementations, handle native tool support by converting MCP tools to Provider format using convertToProviderTools and including them in the API request; for Providers without native function call support, prepare messages using prepareFunctionCallPrompt before making the API call
In Provider implementations, parse Provider-specific data chunks from the streaming response and yield standardized LLMCoreStreamEvent objects conforming to the standard stream event interface, including text, reasoning, tool calls, usage, errors, stop reasons, and image data
In Provider implementations, include helper methods for Provider-specific operations such as formatMessages, convertToProviderTools, parseFunctionCalls, and prepareFunctionCallPrompt

Files:

  • src/main/presenter/llmProviderPresenter/providers/githubCopilotProvider.ts
src/main/**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

Use EventBus from src/main/eventbus.ts for main-to-renderer communication, broadcasting events via mainWindow.webContents.send()

src/main/**/*.ts: Use EventBus pattern for inter-process communication within the main process to decouple modules
Use Electron's built-in APIs for file system and native dialogs instead of Node.js or custom implementations

src/main/**/*.ts: Electron main process code belongs in src/main/ with presenters in presenter/ (Window/Tab/Thread/Mcp/Config/LLMProvider) and eventbus.ts for app events
Use the Presenter pattern in the main process for UI coordination

Files:

  • src/main/presenter/llmProviderPresenter/providers/githubCopilotProvider.ts
  • src/main/presenter/oauthPresenter.ts
  • src/main/presenter/githubCopilotDeviceFlow.ts
  • src/main/presenter/githubCopilotOAuth.ts
{src/main/presenter/**/*.ts,src/renderer/**/*.ts}

📄 CodeRabbit inference engine (.cursor/rules/electron-best-practices.mdc)

Implement proper inter-process communication (IPC) patterns using Electron's ipcRenderer and ipcMain APIs

Files:

  • src/main/presenter/llmProviderPresenter/providers/githubCopilotProvider.ts
  • src/main/presenter/oauthPresenter.ts
  • src/main/presenter/githubCopilotDeviceFlow.ts
  • src/main/presenter/githubCopilotOAuth.ts
src/main/presenter/llmProviderPresenter/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/llm-agent-loop.mdc)

Define the standardized LLMCoreStreamEvent interface with fields: type (text | reasoning | tool_call_start | tool_call_chunk | tool_call_end | error | usage | stop | image_data), content (for text), reasoning_content (for reasoning), tool_call_id, tool_call_name, tool_call_arguments_chunk (for streaming), tool_call_arguments_complete (for complete arguments), error_message, usage object with token counts, stop_reason (tool_use | max_tokens | stop_sequence | error | complete), and image_data object with Base64-encoded data and mimeType

Files:

  • src/main/presenter/llmProviderPresenter/providers/githubCopilotProvider.ts
src/main/**/*.{js,ts}

📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)

Main process code for Electron should be placed in src/main

Files:

  • src/main/presenter/llmProviderPresenter/providers/githubCopilotProvider.ts
  • src/main/presenter/oauthPresenter.ts
  • src/main/presenter/githubCopilotDeviceFlow.ts
  • src/main/presenter/githubCopilotOAuth.ts
**/*.vue

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.vue: Use Vue 3 Composition API for all components instead of Options API
Use Tailwind CSS with scoped styles for component styling

Files:

  • src/renderer/settings/components/GitHubCopilotOAuth.vue
src/renderer/**/*.vue

📄 CodeRabbit inference engine (CLAUDE.md)

src/renderer/**/*.vue: All user-facing strings must use i18n keys via vue-i18n for internationalization
Ensure proper error handling and loading states in all UI components
Implement responsive design using Tailwind CSS utilities for all UI components

src/renderer/**/*.vue: Use composition API and declarative programming patterns; avoid options API
Structure files: exported component, composables, helpers, static content, types
Use PascalCase for component names (e.g., AuthWizard.vue)
Use Vue 3 with TypeScript, leveraging defineComponent and PropType
Use template syntax for declarative rendering
Use Shadcn Vue, Radix Vue, and Tailwind for components and styling
Implement responsive design with Tailwind CSS; use a mobile-first approach
Use Suspense for asynchronous components
Use <script setup> syntax for concise component definitions
Prefer 'lucide:' icon family as the primary choice for Iconify icons
Import Icon component from '@iconify/vue' and use with lucide icons following pattern '{collection}:{icon-name}'

Files:

  • src/renderer/settings/components/GitHubCopilotOAuth.vue
src/renderer/**/*.{vue,js,ts}

📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)

Renderer process code should be placed in src/renderer (Vue 3 application)

Files:

  • src/renderer/settings/components/GitHubCopilotOAuth.vue
src/renderer/**/*.{ts,tsx,vue}

📄 CodeRabbit inference engine (.cursor/rules/vue-shadcn.mdc)

src/renderer/**/*.{ts,tsx,vue}: Write concise, technical TypeScript code with accurate examples
Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError)
Avoid enums; use const objects instead
Use arrow functions for methods and computed properties
Avoid unnecessary curly braces in conditionals; use concise syntax for simple statements

Vue 3 app code in src/renderer/src should be organized into components/, stores/, views/, i18n/, lib/ directories with shell UI in src/renderer/shell/

Files:

  • src/renderer/settings/components/GitHubCopilotOAuth.vue
src/renderer/**/*.{ts,vue}

📄 CodeRabbit inference engine (.cursor/rules/vue-shadcn.mdc)

src/renderer/**/*.{ts,vue}: Use useFetch and useAsyncData for data fetching
Leverage ref, reactive, and computed for reactive state management
Use provide/inject for dependency injection when appropriate
Use Iconify/Vue for icon implementation

Files:

  • src/renderer/settings/components/GitHubCopilotOAuth.vue
🧠 Learnings (22)
📚 Learning: 2025-11-25T05:26:43.510Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/i18n.mdc:0-0
Timestamp: 2025-11-25T05:26:43.510Z
Learning: Applies to src/renderer/src/i18n/**/*.json : Maintain consistent key-value structure across all language translation files (zh-CN, en-US, ko-KR, ru-RU, zh-HK, fr-FR, fa-IR)

Applied to files:

  • src/renderer/src/i18n/zh-HK/settings.json
  • src/renderer/src/i18n/ru-RU/settings.json
  • src/renderer/src/i18n/he-IL/settings.json
  • src/renderer/src/i18n/en-US/settings.json
  • src/renderer/src/i18n/pt-BR/settings.json
  • src/renderer/src/i18n/zh-TW/settings.json
  • src/renderer/src/i18n/zh-CN/settings.json
  • src/renderer/src/i18n/fa-IR/settings.json
  • src/renderer/src/i18n/ja-JP/settings.json
  • src/renderer/src/i18n/ko-KR/settings.json
  • src/renderer/src/i18n/fr-FR/settings.json
📚 Learning: 2025-11-25T05:27:12.209Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/llm-agent-loop.mdc:0-0
Timestamp: 2025-11-25T05:27:12.209Z
Learning: Implement separation of concerns where `src/main/presenter/llmProviderPresenter/index.ts` manages the Agent loop and conversation history, while Provider files handle LLM API interactions, Provider-specific request/response formatting, tool definition conversion, and native vs non-native tool call mechanisms

Applied to files:

  • src/shared/types/presenters/llmprovider.presenter.d.ts
  • src/main/presenter/llmProviderPresenter/providers/githubCopilotProvider.ts
  • src/shared/types/presenters/legacy.presenters.d.ts
📚 Learning: 2025-11-25T05:27:12.209Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/llm-agent-loop.mdc:0-0
Timestamp: 2025-11-25T05:27:12.209Z
Learning: Applies to src/main/presenter/llmProviderPresenter/**/*.ts : Define the standardized `LLMCoreStreamEvent` interface with fields: `type` (text | reasoning | tool_call_start | tool_call_chunk | tool_call_end | error | usage | stop | image_data), `content` (for text), `reasoning_content` (for reasoning), `tool_call_id`, `tool_call_name`, `tool_call_arguments_chunk` (for streaming), `tool_call_arguments_complete` (for complete arguments), `error_message`, `usage` object with token counts, `stop_reason` (tool_use | max_tokens | stop_sequence | error | complete), and `image_data` object with Base64-encoded data and mimeType

Applied to files:

  • src/shared/types/presenters/llmprovider.presenter.d.ts
  • src/shared/types/presenters/legacy.presenters.d.ts
📚 Learning: 2025-11-25T05:27:12.209Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/llm-agent-loop.mdc:0-0
Timestamp: 2025-11-25T05:27:12.209Z
Learning: Applies to src/main/presenter/llmProviderPresenter/providers/*.ts : In Provider implementations, include helper methods for Provider-specific operations such as `formatMessages`, `convertToProviderTools`, `parseFunctionCalls`, and `prepareFunctionCallPrompt`

Applied to files:

  • src/shared/types/presenters/llmprovider.presenter.d.ts
  • src/shared/types/presenters/legacy.presenters.d.ts
📚 Learning: 2025-11-25T05:26:11.312Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T05:26:11.312Z
Learning: Applies to src/main/presenter/llmProviderPresenter/providers/*.ts : Convert MCP tools to provider-specific formats and normalize streaming responses to standard events in each provider implementation

Applied to files:

  • src/shared/types/presenters/llmprovider.presenter.d.ts
  • src/shared/types/presenters/legacy.presenters.d.ts
📚 Learning: 2025-11-25T05:26:11.312Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T05:26:11.312Z
Learning: Applies to src/main/presenter/llmProviderPresenter/providers/*.ts : Each LLM provider must implement the `coreStream` method following the standardized event interface for tool calling and response streaming

Applied to files:

  • src/shared/types/presenters/llmprovider.presenter.d.ts
  • src/shared/types/presenters/legacy.presenters.d.ts
📚 Learning: 2025-11-25T05:27:39.200Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/provider-guidelines.mdc:0-0
Timestamp: 2025-11-25T05:27:39.200Z
Learning: Applies to **/*Provider**/index.ts : Output only discriminated union `LLMCoreStreamEvent` in Provider implementations, do not use single interface with optional fields

Applied to files:

  • src/shared/types/presenters/llmprovider.presenter.d.ts
  • src/shared/types/presenters/legacy.presenters.d.ts
📚 Learning: 2025-11-25T05:27:12.209Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/llm-agent-loop.mdc:0-0
Timestamp: 2025-11-25T05:27:12.209Z
Learning: Applies to src/main/presenter/llmProviderPresenter/providers/*.ts : In Provider implementations, handle native tool support by converting MCP tools to Provider format using `convertToProviderTools` and including them in the API request; for Providers without native function call support, prepare messages using `prepareFunctionCallPrompt` before making the API call

Applied to files:

  • src/shared/types/presenters/llmprovider.presenter.d.ts
  • src/shared/types/presenters/legacy.presenters.d.ts
📚 Learning: 2025-11-25T05:27:12.209Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/llm-agent-loop.mdc:0-0
Timestamp: 2025-11-25T05:27:12.209Z
Learning: Applies to src/main/presenter/llmProviderPresenter/providers/*.ts : In Provider implementations, parse Provider-specific data chunks from the streaming response and `yield` standardized `LLMCoreStreamEvent` objects conforming to the standard stream event interface, including text, reasoning, tool calls, usage, errors, stop reasons, and image data

Applied to files:

  • src/shared/types/presenters/llmprovider.presenter.d.ts
  • src/shared/types/presenters/legacy.presenters.d.ts
📚 Learning: 2025-11-25T05:27:12.209Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/llm-agent-loop.mdc:0-0
Timestamp: 2025-11-25T05:27:12.209Z
Learning: Applies to src/main/presenter/llmProviderPresenter/index.ts : In `src/main/presenter/llmProviderPresenter/index.ts`, listen for standardized events yielded by `coreStream` and handle them accordingly: buffer text content (`currentContent`), handle `tool_call_start/chunk/end` events by collecting tool details and calling `presenter.mcpPresenter.callTool`, send frontend events via `eventBus` with tool call status, format tool results for the next LLM call, and set `needContinueConversation = true`

Applied to files:

  • src/shared/types/presenters/llmprovider.presenter.d.ts
📚 Learning: 2025-11-25T05:26:43.510Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/i18n.mdc:0-0
Timestamp: 2025-11-25T05:26:43.510Z
Learning: Applies to src/renderer/src/i18n/**/*.json : Translation key naming convention: use dot-separated hierarchical structure with lowercase letters and descriptive names (e.g., 'common.button.submit')

Applied to files:

  • src/renderer/src/i18n/ru-RU/settings.json
  • src/renderer/src/i18n/en-US/settings.json
  • src/renderer/src/i18n/pt-BR/settings.json
  • src/renderer/src/i18n/zh-CN/settings.json
  • src/renderer/src/i18n/ja-JP/settings.json
📚 Learning: 2025-11-25T05:26:11.312Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T05:26:11.312Z
Learning: Applies to **/*.{ts,tsx,js,jsx,vue} : Use English for logs and comments (Chinese text exists in legacy code, but new code should use English)

Applied to files:

  • src/renderer/src/i18n/zh-TW/settings.json
  • src/renderer/src/i18n/zh-CN/settings.json
📚 Learning: 2025-11-25T05:26:43.510Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/i18n.mdc:0-0
Timestamp: 2025-11-25T05:26:43.510Z
Learning: Applies to src/renderer/src/**/*.{vue,ts,tsx} : Avoid hardcoding user-facing text and ensure all user-visible text uses the i18n translation system

Applied to files:

  • src/types/i18n.d.ts
  • src/renderer/settings/components/GitHubCopilotOAuth.vue
📚 Learning: 2025-11-25T05:26:43.510Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/i18n.mdc:0-0
Timestamp: 2025-11-25T05:26:43.510Z
Learning: Applies to src/renderer/src/**/*.{vue,ts,tsx} : Import and use useI18n() composable with the t() function to access translations in Vue components and TypeScript files

Applied to files:

  • src/renderer/settings/components/GitHubCopilotOAuth.vue
📚 Learning: 2025-11-25T05:28:04.454Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-11-25T05:28:04.454Z
Learning: Applies to src/renderer/**/composables/*.ts : Use VueUse for common composables and utility functions

Applied to files:

  • src/renderer/settings/components/GitHubCopilotOAuth.vue
📚 Learning: 2025-11-25T05:28:04.454Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-11-25T05:28:04.454Z
Learning: Applies to src/renderer/**/*.{ts,vue} : Use Iconify/Vue for icon implementation

Applied to files:

  • src/renderer/settings/components/GitHubCopilotOAuth.vue
📚 Learning: 2025-11-25T05:28:04.454Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-11-25T05:28:04.454Z
Learning: Applies to src/renderer/**/*.vue : Import Icon component from 'iconify/vue' and use with lucide icons following pattern '{collection}:{icon-name}'

Applied to files:

  • src/renderer/settings/components/GitHubCopilotOAuth.vue
📚 Learning: 2025-11-25T05:28:04.454Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-11-25T05:28:04.454Z
Learning: Applies to src/renderer/**/*.vue : Use Shadcn Vue, Radix Vue, and Tailwind for components and styling

Applied to files:

  • src/renderer/settings/components/GitHubCopilotOAuth.vue
📚 Learning: 2025-11-25T05:28:04.454Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-11-25T05:28:04.454Z
Learning: Applies to src/renderer/**/*.{ts,vue} : Leverage ref, reactive, and computed for reactive state management

Applied to files:

  • src/renderer/settings/components/GitHubCopilotOAuth.vue
📚 Learning: 2025-11-25T05:27:45.545Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/vue-best-practices.mdc:0-0
Timestamp: 2025-11-25T05:27:45.545Z
Learning: Applies to src/renderer/src/**/*.{vue,ts,tsx,js,jsx} : Use the Composition API for better code organization and reusability in Vue.js applications

Applied to files:

  • src/renderer/settings/components/GitHubCopilotOAuth.vue
📚 Learning: 2025-11-25T05:28:04.454Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-11-25T05:28:04.454Z
Learning: Applies to src/renderer/**/*.vue : Use composition API and declarative programming patterns; avoid options API

Applied to files:

  • src/renderer/settings/components/GitHubCopilotOAuth.vue
📚 Learning: 2025-11-25T05:28:04.454Z
Learnt from: CR
Repo: ThinkInAIXYZ/deepchat PR: 0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-11-25T05:28:04.454Z
Learning: Applies to src/renderer/(components|composables)/**/*.{ts,vue} : Utilize Nuxt's auto-imports feature for components and composables

Applied to files:

  • src/renderer/settings/components/GitHubCopilotOAuth.vue
🧬 Code graph analysis (2)
src/main/presenter/llmProviderPresenter/providers/githubCopilotProvider.ts (1)
src/main/presenter/githubCopilotDeviceFlow.ts (1)
  • getGlobalGitHubCopilotDeviceFlow (622-634)
src/main/presenter/oauthPresenter.ts (2)
src/main/presenter/githubCopilotDeviceFlow.ts (1)
  • getGlobalGitHubCopilotDeviceFlow (622-634)
src/main/presenter/githubCopilotOAuth.ts (1)
  • createGitHubCopilotOAuth (224-278)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build-check (x64)
🔇 Additional comments (16)
src/renderer/src/i18n/zh-TW/settings.json (1)

413-414: LGTM! Translation is accurate and well-positioned.

The Traditional Chinese translations for the GitHub Copilot Client ID settings are clear and grammatically correct. The keys follow the existing camelCase naming convention used throughout the provider section, and they're logically placed alongside other GitHub Copilot authentication settings.

The translations appropriately:

  • Preserve technical terms like "Client ID" in English
  • Clearly convey the optional nature of the setting
  • Explain the default behavior and scope of impact

Based on the AI summary, similar keys have been added across 13 language files. While I cannot verify all locales in this review, the implementation here is consistent with the established patterns in the codebase.

src/renderer/src/i18n/zh-CN/settings.json (1)

480-481: LGTM for new Copilot Client ID i18n entries

Keys are consistent with other locales and the i18n type definition, and the Chinese strings clearly describe the optional custom Client ID behavior.

src/types/i18n.d.ts (1)

846-847: Provider i18n typings correctly extended for Copilot Client ID

Adding githubCopilotClientId and githubCopilotClientIdHint under provider keeps the TypeScript locale message shape aligned with the new i18n keys; no issues.

src/shared/types/presenters/legacy.presenters.d.ts (1)

709-717: LLM_PROVIDER extended with copilotClientId is consistent and backward compatible

Adding copilotClientId?: string to LLM_PROVIDER cleanly exposes the new configuration without breaking existing code (field is optional and inherited by the provider-specific types). This matches how the Copilot provider and device/OAuth flows consume the client ID.

src/shared/types/presenters/llmprovider.presenter.d.ts (1)

45-61: Type surface for copilotClientId on LLM_PROVIDER looks correct

Adding copilotClientId?: string to LLM_PROVIDER cleanly exposes a per‑provider Copilot client ID override and composes correctly into the AWS/Vertex provider types and Partial<LLM_PROVIDER> update paths.

src/shared/provider-operations.ts (1)

39-57: Including copilotClientId in rebuild-triggering fields is appropriate

Treating copilotClientId as a REBUILD_REQUIRED_FIELDS entry ensures provider instances are rebuilt whenever the Copilot Client ID override changes, keeping auth/device‑flow state in sync with configuration.

src/renderer/src/i18n/zh-HK/settings.json (1)

413-414: Copilot Client ID i18n keys are well-integrated for zh-HK

githubCopilotClientId and githubCopilotClientIdHint are correctly named, localized, and placed next to the existing GitHub Copilot auth strings, matching the shared i18n structure across locales.

src/renderer/src/i18n/en-US/settings.json (1)

413-414: LGTM!

The new translation keys follow the existing naming convention in this file (camelCase within the provider section) and provide clear, helpful text for the custom Client ID feature.

src/main/presenter/oauthPresenter.ts (2)

46-49: LGTM!

The device flow login correctly retrieves the provider and passes the copilotClientId to reinitialize the global device flow instance when needed.


100-101: LGTM!

The OAuth login path correctly fetches the provider configuration and passes the copilotClientId to the OAuth factory function, enabling provider-specific client ID support.

src/renderer/settings/components/GitHubCopilotOAuth.vue (2)

7-22: LGTM!

The Client ID input UI is well-structured with proper labeling, hint text, and event handlers. The implementation uses Shadcn components and follows Vue 3 best practices.


174-189: LGTM!

The saveClientId function properly trims the input, updates the local state, persists via the store, and handles errors with user-friendly feedback through validationResult.

src/main/presenter/githubCopilotOAuth.ts (1)

224-226: LGTM!

The factory function correctly accepts an optional clientIdOverride, trims whitespace, and falls back to the environment variable when not provided.

src/main/presenter/githubCopilotDeviceFlow.ts (3)

594-600: LGTM!

The factory function correctly accepts an optional clientIdOverride, prioritizes it over the environment variable, and provides a clear error message when no client ID is available.


620-634: LGTM!

The global device flow singleton is correctly managed:

  • Tracks the active client ID separately
  • Disposes the existing instance before creating a new one when the client ID changes
  • Properly handles the case where no override is provided by falling back to the environment variable

636-641: LGTM!

The dispose function properly cleans up both the instance and the tracked client ID state.

Comment on lines +413 to +414
"githubCopilotClientId": "Custom Client ID",
"githubCopilotClientIdHint": "Optional. Leave empty to use the built-in default Client ID. Only affects GitHub Copilot auth.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Translation values are in English, not Russian.

The keys githubCopilotClientId and githubCopilotClientIdHint have English values instead of Russian translations. For consistency with the rest of the file, these should be translated.

Suggested Russian translations:

  • githubCopilotClientId: "Пользовательский Client ID"
  • githubCopilotClientIdHint: "Необязательно. Оставьте пустым для использования встроенного Client ID по умолчанию. Влияет только на авторизацию GitHub Copilot."
🤖 Prompt for AI Agents
In src/renderer/src/i18n/ru-RU/settings.json around lines 413 to 414, the values
for githubCopilotClientId and githubCopilotClientIdHint are in English; replace
them with the provided Russian translations: set githubCopilotClientId to
"Пользовательский Client ID" and githubCopilotClientIdHint to "Необязательно.
Оставьте пустым для использования встроенного Client ID по умолчанию. Влияет
только на авторизацию GitHub Copilot.", preserving the JSON key names and
quoting/escaping exactly as the surrounding entries.

@zerob13 zerob13 merged commit 6166012 into ThinkInAIXYZ:dev Dec 19, 2025
2 checks passed
@zhangmo8 zhangmo8 deleted the github-copilot branch December 19, 2025 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants