refactor: chat module. - #147
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
User-facing credential terminology is inconsistent (“API key”/“key” vs “GitHub token”), which can confuse users and breaks message-matching logic unless aligned.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Refactors the AI chat implementation by moving it out of the GitHub-specific module namespace into a dedicated src/modules/chat/ area, while keeping the app wiring functional and updating docs/tests to match.
Changes:
- Moved chat API constants/headers/error parsing into
src/modules/chat/api/*and updated chat completion request/stream functions. - Extracted/introduced chat helpers for payload sizing/summarization, proposal parsing, tab targeting, and tab-scoped undo state.
- Decoupled chat UI wiring from
github-workflowsby addingapp-core/chat-workflows.js, updatingsrc/app.js, docs, tests, and CI branch triggers.
File summaries
| File | Description |
|---|---|
| src/modules/github/api/core.js | Removes chat-specific header helper from shared GitHub API core exports. |
| src/modules/github/api/constants.js | Leaves only githubApiBaseUrl after moving chat-specific constants. |
| src/modules/chat/workspace-actions.js | Renames exported factory to createChatWorkspaceActions. |
| src/modules/chat/utils.js | Updates chat model defaults and model-access status/error messaging. |
| src/modules/chat/tab-target-resolver.js | Adds tab target resolution logic for proposals (id/path/name + language scoping). |
| src/modules/chat/tab-scoped-undo-state.js | Adds per-tab snapshot storage for undo/apply behavior. |
| src/modules/chat/proposals.js | Adds tool-call and markdown parsing to extract editor update proposals. |
| src/modules/chat/payload.js | Adds bounded payload building with conversation summarization and mode-aware system policy. |
| src/modules/chat/drawer.js | Updates drawer to use the new chat/api/completions.js entrypoints and new constants. |
| src/modules/chat/api/request.js | Introduces chat request headers + shared error/rate-limit parsing utilities. |
| src/modules/chat/api/constants.js | Defines chat completions URL, default model, and model option list. |
| src/modules/chat/api/completions.js | Refactors completion request/stream logic to the new constants + request helpers and exports new names. |
| src/modules/chat/active-tab-context.js | Adds editor context builder including “available tab targets” + active-tab source embedding. |
| src/modules/app-core/github-workflows.js | Removes chat drawer wiring from GitHub workflows initialization/return value. |
| src/modules/app-core/github-workflows-setup.js | Stops passing chat-specific runtime/actions into GitHub workflows setup. |
| src/modules/app-core/chat-workflows.js | New workflow initializer dedicated to chat drawer wiring. |
| src/app.js | Switches to new chat workspace actions + chat workflows initializer and updates wiring. |
| playwright/github-byot-ai.spec.ts | Updates default model import to the new chat module export. |
| docs/ai-chat-context-and-payload-strategy.md | Updates file references to new chat module paths. |
| .github/workflows/playwright.yml | Runs Playwright workflow for PRs targeting chat branch in addition to main. |
Review details
Suppressed comments (5)
src/modules/chat/api/completions.js:288
- Token validation errors in this module say "API key", but the rest of the app (including the chat drawer UI) consistently refers to a "GitHub token". This inconsistency is user-facing and can be confusing; align the wording with the UI.
This issue also appears on line 403 of the same file.
src/modules/chat/api/completions.js:405
- Token validation errors in this module say "API key", but the rest of the app (including the chat drawer UI) consistently refers to a "GitHub token". Please keep the error message consistent with the UI wording.
src/modules/chat/utils.js:39 - This status/error copy says "key", but the rest of the UI uses "GitHub token". Aligning terminology avoids confusing users about what credential they need to provide.
This issue also appears on line 46 of the same file.
src/modules/chat/utils.js:48
- This status-message detector looks for "key" wording, but other parts of the UI refer to the credential as a "GitHub token". Keep the sentinel text consistent so status clearing/replacement logic continues to work with the displayed message.
src/app.js:1388 - This spread uses the "githubChatWorkspaceActions" identifier, which is now a bit misleading given the refactor to generic chat modules (createChatWorkspaceActions / chat workflows). Consider renaming this usage to match the updated, non-GitHub naming.
...githubChatWorkspaceActions,
- Files reviewed: 15/20 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| }) | ||
|
|
||
| const githubChatWorkspaceActions = createGitHubChatWorkspaceActions({ | ||
| const githubChatWorkspaceActions = createChatWorkspaceActions({ |
No description provided.