Skip to content

feat: add /btw side-question support for Gemini and Codex providers#171

Merged
Zhang-Henry merged 2 commits intomainfrom
feat/btw-gemini-codex
Apr 13, 2026
Merged

feat: add /btw side-question support for Gemini and Codex providers#171
Zhang-Henry merged 2 commits intomainfrom
feat/btw-gemini-codex

Conversation

@davidliuk
Copy link
Copy Markdown
Collaborator

Summary

  • Extends the /btw ephemeral side-question overlay from Claude-only to also support Gemini and Codex providers
  • Gemini: calls the non-streaming generateContent REST API directly with systemInstruction and no tools field
  • Codex: bypasses the Codex SDK (which has no stateless mode) and calls the OpenAI Chat Completions API directly with no tools
  • Extracts shared BTW_SYSTEM_PROMPT, constants, and buildBtwUserMessage() into server/utils/btw.js for all three providers
  • Creates a unified POST /api/btw endpoint with provider dispatch, keeping the legacy /api/claude/btw for backward compatibility

Changed files

File Change
server/utils/btw.js New — shared system prompt, constants, helper
server/routes/btw.js New — unified /api/btw route with provider dispatch
server/claude-sdk.js Refactored runClaudeBtw() to use shared module
server/gemini-api.js Added runGeminiBtw() via Gemini REST API
server/openai-codex.js Added runCodexBtw() via OpenAI Chat Completions API
server/index.js Mount new /api/btw route
server/routes/commands.js Updated /btw description (removed "Claude only")
useChatComposerState.ts Support all 3 providers, send provider field, select correct model

Test plan

  • Test /btw <question> with Claude provider — should work as before
  • Test /btw <question> with Gemini provider — answer appears in overlay
  • Test /btw <question> with Codex provider — answer appears in overlay
  • Test /btw with unsupported provider (e.g. openrouter) — shows informative error message
  • Test /btw while a main session is streaming — overlay should work concurrently
  • Verify legacy /api/claude/btw endpoint still works

Made with Cursor

davidliuk and others added 2 commits April 12, 2026 20:54
Previously /btw was Claude-only. This extends the ephemeral side-question
overlay to Gemini (via direct generateContent API) and Codex (via OpenAI
Chat Completions API), both tool-free and session-independent.

- Extract shared BTW_SYSTEM_PROMPT and helpers into server/utils/btw.js
- Add runGeminiBtw() using non-streaming Gemini REST API
- Add runCodexBtw() bypassing Codex SDK with direct OpenAI API call
- Create unified POST /api/btw route with provider dispatch
- Update frontend to send provider field and select correct model
- Keep legacy /api/claude/btw endpoint for backward compatibility

Made-with: Cursor
Lets users point /btw (and other Gemini REST calls) at a self-hosted or
proxy endpoint instead of the hardcoded Google base URL.
@Zhang-Henry Zhang-Henry merged commit 1debf4b into main Apr 13, 2026
everett4320 added a commit to everett4320/LingZhi-Lab that referenced this pull request Apr 14, 2026
…res)

Merge upstream/main into topic/upstream/pr170-review-fixes to unblock
the PR merge. Conflicts arose from two upstream PRs landing on main
after our branch diverged:
- OpenLAIR#171 feat/btw-gemini-codex: added /btw side-question support for
  Gemini and Codex; resolved by keeping btw handler block from main
  before our existing builtin command handler in useChatComposerState.ts,
  and adding the btw/CODEX_MODELS imports alongside our
  buildCodexSessionCreatedEvent import in openai-codex.js.
- OpenLAIR#173 feat/file-preview-reader-modes: auto-merged cleanly.

All 149 tests pass.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
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