2.5 KiB
2.5 KiB
Native Electron Goose Integration
Problem Statement
The /goose command in GEN5 TUI doesn't work properly because:
- It requires Rust/Cargo to build Goose from source
- It needs a Goose web server running on a custom port
- The prerequisite detection blocks the launch
Proposed Solution
Create a true native Electron chat app that:
- Doesn't require the Goose Rust backend at all
- Uses the existing Qwen OAuth directly from
qwen-oauth.mjs - Provides a standalone desktop chat interface
- Works immediately without prerequisites
Proposed Changes
Component: Electron App (bin/goose-electron-app/)
[MODIFY] main.cjs
Transform from a simple URL wrapper into a full native chat application:
- Create BrowserWindow with embedded chat UI
- Load a local HTML file instead of external URL
- Set up IPC communication for Qwen API calls
[NEW] preload.js
Context bridge for secure communication between renderer and main process
[NEW] index.html
Native chat UI with:
- Modern dark theme matching OpenQode aesthetic
- Message input with streaming display
- Code block rendering with syntax highlighting
[NEW] renderer.js
Client-side logic for chat interface
[NEW] styles.css
Premium dark theme styling
Component: TUI Integration (bin/opencode-ink.mjs)
[MODIFY] opencode-ink.mjs
Update /goose command handler (around line 4140) to:
- Launch native Electron app directly without prerequisite checks
- Skip the Goose web backend entirely
- Use the new native chat implementation
Component: Qwen API Bridge
[NEW] qwen-bridge.cjs
Main process module that:
- Imports
qwen-oauth.mjsfor authentication - Handles API calls to Qwen
- Streams responses back to renderer via IPC
Verification Plan
Automated Tests
- Launch TUI:
node --experimental-require-module bin\opencode-ink.mjs - Type
/goosecommand - Verify Electron window opens
- Send a test message
- Verify response streams correctly
Manual Verification
- Start OpenQode launcher → Select GEN5 TUI (option #2)
- Type
/gooseand press Enter - Confirm native Electron chat window appears
- Test sending messages and receiving AI responses
- Verify window closes properly
Dependencies
- Electron (already in
goose-electron-app/package.json) - Existing
qwen-oauth.mjsfor authentication
Risk Assessment
- Low risk: Changes are isolated to the Goose integration
- Reversible: Original web-based flow can be kept as
/goose webfallback