Skip to content

feat(workspaces): quick-chat AI-config injection for loginless runtimes (opencode/pi)#367

Merged
luokerenx4 merged 2 commits into
masterfrom
feat/quickchat-ai-config-injection
Jun 22, 2026
Merged

feat(workspaces): quick-chat AI-config injection for loginless runtimes (opencode/pi)#367
luokerenx4 merged 2 commits into
masterfrom
feat/quickchat-ai-config-injection

Conversation

@luokerenx4

Copy link
Copy Markdown
Contributor

Summary

  • Closes the opencode/pi dead-end in quick-chat. claude/codex launch on their own CLI login; opencode/pi are provider-agnostic and the chat template injects nothing, so picking them in the "Ask Alice" composer spawned an agent that instantly died on a missing key. Quick-chat now seeds a loginless runtime from the credential vault before spawn.
  • Composer gains a credential dropdown for opencode/pi only (claude/codex unchanged). Defaults to the cred today's workspace already uses, else the first wire-compatible one. Zero compatible creds → an inline "Configure an AI provider" bounce to Settings instead of a silent failure. An overwrite notice fires when the pick differs from the workspace's current cred ("提示一下", not a block).
  • lastModel on credentials — a cred carries no model of its own, so quick-chat and the per-workspace config save remember the last pick (absent ⇒ vendor catalog flagship). Optional field, no migration.
  • Reuses existing injection primitives; new pure helpers (compatibleCredentials / matchCredentialByApiKey / resolveInjectionModel), a detection route (GET /:id/agent-config/:agent/credential), and an ?agent= compatibility filter on /credentials. i18n en/zh/zh-Hant/ja + demo handler synced.

Test plan

  • npx tsc --noEmit clean (Alice src/)
  • cd ui && npx tsc -b clean (UI strict)
  • pnpm test — 2026 passing (14 new: injection-helper units + quick-chat route branches: no-cred bounce, inject-default-flagship, explicit-slug→lastModel, claude-never-injected)
  • Manual: demo/dev — pick opencode in the composer, confirm the cred dropdown + bounce-when-empty + overwrite notice

Boundary touch

Touches the credential vault (core/config.ts credentialSchema + a setCredentialLastModel writer) and AI-config injection. No trading / auth / broker-credential / migration paths; the schema change is an additive optional field (no migration by design).

🤖 Generated with Claude Code

…imes (opencode/pi)

claude/codex run on their own CLI login, so quick-chat could launch them
directly. opencode/pi are provider-agnostic — no login of their own — and the
chat template injects no credentials, so picking them in the composer spawned an
agent that instantly ENOENT-died on a missing key: a dead-end front door.

Quick-chat now seeds a loginless runtime from the credential vault before spawn,
reusing the existing injection primitives:

- /quick-chat accepts an optional `credentialSlug`; for opencode/pi it picks the
  user's choice, else the cred the day's workspace already uses (detected by
  apiKey→slug), else the first wire-compatible one. No compatible credential at
  all → 400 no_ai_credential, which the composer turns into a "Configure an AI
  provider" bounce to Settings instead of a silent failure.
- Credentials gain an optional `lastModel` — a cred carries no model of its own,
  so quick-chat (and the per-workspace config save) remember the last pick to
  spare re-typing; absent ⇒ the vendor's catalog flagship. No migration (optional
  field). DEFAULT_MODEL_BY_VENDOR added to the preset catalog.
- New pure helpers in credential-injection.ts (compatibleCredentials,
  matchCredentialByApiKey, resolveInjectionModel) + a detection route
  (GET /:id/agent-config/:agent/credential) and `?agent=` filter on /credentials.
- Composer: a credential dropdown for opencode/pi only (claude/codex unchanged),
  defaulting to the workspace's current cred; an overwrite notice when the pick
  differs; the zero-cred bounce. i18n en/zh/zh-Hant/ja + demo handler synced.

Tests: 14 new (helper units + quick-chat route branches — no-cred bounce,
inject-default-flagship, explicit-slug-lastModel, claude-never-injected).
tsc (Alice + UI) clean; pnpm test 2026 passing.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
openalice-demo Ready Ready Preview, Comment Jun 22, 2026 1:36pm

Request Review

…aterfall

The credential dropdown's fetch was gated on [needsCred, effectiveAgent], so it
only started after the agents list resolved and the user landed on opencode/pi —
a second, late-starting request whose data visibly lagged behind the agent
button (which comes from the already-loaded agents context). The backend wasn't
slow: /agents does a cheap per-call PATH probe (by design), and /credentials is
a plain config read — the lag was purely the frontend request waterfall.

Fetch the loginless credential set once on mount instead, in parallel with the
agents load, so the picker is ready the instant opencode/pi is chosen. opencode
and pi share one compatibility set (provider-agnostic → any wire), so a single
fetch serves both; claude/codex never show the picker.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@luokerenx4 luokerenx4 merged commit f8b45fd into master Jun 22, 2026
5 checks passed
@luokerenx4 luokerenx4 mentioned this pull request Jun 22, 2026
3 tasks
yodaliu pushed a commit to yodaliu/OpenAlice that referenced this pull request Jun 22, 2026
Since beta.3:
- feat(workspaces): auto-detect installed agent runtimes + install guidance (TraderAlice#366)
- feat(workspaces): quick-chat AI-config injection for loginless runtimes opencode/pi (TraderAlice#367)

Co-Authored-By: Claude Opus 4.8 (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.

1 participant