Skip to content

feat: migrate chat to openrouter. - #152

Merged
knightedcodemonkey merged 8 commits into
mainfrom
chat
Sep 7, 2026
Merged

feat: migrate chat to openrouter.#152
knightedcodemonkey merged 8 commits into
mainfrom
chat

Conversation

@knightedcodemonkey

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI lite review requested due to automatic review settings September 7, 2026 19:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

There are a couple of UI/security correctness issues in the changed CSS/HTML (status text visibility fallback and key input masking) that should be addressed before merging.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR migrates the in-app AI chat feature from GitHub Models to OpenRouter, introducing a dedicated chat module with OpenRouter BYOK (bring your own key) handling while keeping GitHub PAT usage scoped to PR/repository workflows.

Changes:

  • Replace GitHub Models chat transport with OpenRouter chat completions + model catalog loading.
  • Add OpenRouter key UI/storage (localStorage) and gate chat composer/model picker on key presence.
  • Refactor chat drawer into smaller modules (request runner, message renderer, proposal actions) and update Playwright coverage + docs.
File summaries
File Description
src/styles/ai-controls.css Adds OpenRouter key section styling and pending-status shimmer animation.
src/modules/github/chat/drawer.js Removes the old GitHub-models chat drawer implementation.
src/modules/github/api/core.js Drops GitHub-chat-specific header helper no longer needed.
src/modules/github/api/constants.js Removes GitHub Models chat constants/model lists.
src/modules/chat/workspace-actions.js Renames/generalizes workspace actions for the new chat module.
src/modules/chat/utils.js Switches defaults/error handling to OpenRouter-oriented semantics (key vs token).
src/modules/chat/tab-target-resolver.js New shared resolver for mapping proposal targets to open tabs.
src/modules/chat/tab-scoped-undo-state.js New shared per-tab undo snapshot store for apply/undo.
src/modules/chat/request-runner.js New OpenRouter request orchestration (stream + fallback) with tool gating.
src/modules/chat/proposals.js Adds allowMarkdownFallback guard for proposal extraction.
src/modules/chat/proposal-actions.js Extracts apply/undo proposal logic from drawer into a dedicated module.
src/modules/chat/payload.js Adds “explicit edit intent” gating for tool enablement and updates system prompt guidance.
src/modules/chat/model-picker.js Adds model picker with free/paid grouping and optional catalog loading.
src/modules/chat/message-renderer.js Extracts message rendering + streaming update behavior from drawer.
src/modules/chat/key-store.js Adds OpenRouter key persistence/masking helpers (localStorage).
src/modules/chat/key-controls.js Adds key connect/remove UI behavior and key-change notifications.
src/modules/chat/drawer.js New top-level chat drawer wiring the new modules together.
src/modules/chat/drawer-events.js Centralizes chat drawer DOM event handling and action dispatch.
src/modules/chat/api/request.js Adds OpenRouter request headers + error parsing helpers.
src/modules/chat/api/models.js Adds OpenRouter model catalog fetch + normalization logic.
src/modules/chat/api/constants.js Defines OpenRouter endpoints and fallback model catalog.
src/modules/chat/api/completions.js Migrates chat completions implementation to OpenRouter endpoints.
src/modules/chat/active-tab-context.js Extracts active-tab context builder for payload editor context.
src/modules/app-core/github-workflows.js Removes chat wiring from GitHub workflows (PR/BYOT-only).
src/modules/app-core/github-workflows-setup.js Removes chat-specific dependencies from GitHub workflow setup.
src/modules/app-core/github-pr-context-ui.js Renames token visibility sync to PR-surface-only behavior.
src/modules/app-core/chat-workflows.js Adds dedicated initializer for chat drawer wiring in app-core.
src/modules/app-core/app-bindings-startup.js Updates startup to use new PR-surface visibility sync.
src/index.html Updates chat drawer markup for OpenRouter key controls and relocates chat toggle.
src/app.js Switches to new chat workflows + workspace actions; wires OpenRouter key elements.
README.md Adds docs link and clarifies PAT vs OpenRouter key responsibilities.
playwright/helpers/app-test-helpers.ts Adds helpers to connect OpenRouter key and tightens selectors.
playwright/github-byot-ai.spec.ts Updates BYOT visibility expectations (chat available without PAT) and removes old GitHub-chat tests.
playwright/chat/ai-chat.spec.ts Adds comprehensive OpenRouter-based chat coverage (key gating, streaming/fallback, proposals).
docs/openrouter-byok.md New OpenRouter BYOK setup guide.
docs/next-steps.md Updates guidance and adds a future item for safe Markdown rendering in chat.
docs/localstorage-state.md Documents the new OpenRouter key localStorage entry.
docs/byot.md Clarifies BYOT scope (PR/repo workflows only) and points chat to OpenRouter BYOK.
docs/ai-chat-context-and-payload-strategy.md Updates implementation references to the new chat module paths.
Review details
  • Files reviewed: 36/39 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/index.html
Comment thread src/styles/ai-controls.css
@knightedcodemonkey
knightedcodemonkey merged commit 0222858 into main Sep 7, 2026
7 checks passed
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.

3 participants