Skip to content

fix(pi): keep loopback models visible - #1085

Open
n3wr1ch wants to merge 7 commits into
lidge-jun:devfrom
n3wr1ch:fix/pi-loopback-model-visibility
Open

fix(pi): keep loopback models visible#1085
n3wr1ch wants to merge 7 commits into
lidge-jun:devfrom
n3wr1ch:fix/pi-loopback-model-visibility

Conversation

@n3wr1ch

@n3wr1ch n3wr1ch commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • keep Pi's opencodex provider visible without requiring an unused OPENCODEX_API_KEY environment variable on loopback
  • avoid rendering a missing-key warning for file clients that intentionally have no key environment variable
  • document the literal loopback placeholder and the Pi 0.83.x validation in every translated Pi guide

Root cause

Pi resolves apiKey while building its model list and hides the entire provider when the value is an unset environment-variable reference. The integration previously emitted $OPENCODEX_API_KEY, even though Pi is loopback-only and opencodex does not require admission authentication on loopback.

The generated Pi block now carries the existing non-secret opencodex-loopback placeholder shared by loopback-only clients. Non-loopback integration writes remain refused.

Security review

This changes credential-destination behavior and needs explicit maintainer security review. The change does not serialize a user or provider secret: the literal placeholder is accepted only for the loopback-only Pi integration, where the data-plane admission key is not checked. Upstream provider credentials remain in opencodex's own configuration.

Verification

  • bun run typecheck
  • bun run test — 9,015 pass, 8 skip, 0 fail
  • bun run privacy:scan
  • cd gui && bun test tests — 601 pass, 0 fail
  • cd gui && bun run lint
  • cd gui && bun run lint:i18n
  • cd gui && bun run build
  • cd docs-site && bun install --frozen-lockfile && bun run build — 216 pages
  • focused client integration/export suites — 220 pass, 0 fail
  • real Pi 0.83.0: pi --list-models changed from 0 to 25 opencodex models with no OPENCODEX_API_KEY; an actual xai/grok-4.5 request returned PI_OK

Screenshot

The Pi config preview shows the literal loopback placeholder and the routed model array; the empty environment-variable warning is no longer rendered.

Pi config preview

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults; explicit maintainer security review is requested above.

Review readiness checklist

This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:

  • All CI tests are green on my local testing.

  • I pushed my PR to the latest dev commit.

  • I fixed all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

Summary by CodeRabbit

  • New Features

    • Pi exports now use the opencodex-loopback placeholder without requiring an API-key environment variable.
    • Loopback authentication requires no stored access key; provider credentials remain in OpenCodeX configuration.
    • Model exports now correctly include or omit native models based on Codex operating mode.
  • Bug Fixes

    • Client configuration dialogs no longer show empty environment-variable names.
  • Documentation

    • Updated Pi export guidance and translations, including Pi 0.83.x verification, provider visibility, output details, and credential handling.

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

Deterministic PR hygiene checks passed.

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review readiness checklist

This PR is kept in draft until every requirement below is fulfilled. The tickable checklist has been added to your PR description — tick all four boxes there.

  • ✅ All CI tests are green on my local testing.
  • ✅ I pushed my PR to the latest dev commit.
  • ✅ I fixed all correct Codex and CodeRabbit findings.
  • ✅ My PR is ready for review.

4/4 boxes ticked.

All four boxes are ticked.
Completed against head df7fcaa; new commits after this will reset the checklist.
This pull request has been marked Ready for Review.
Maintainers notified: @lidge-jun @Ingwannu @Wibias

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Pi and Kimi exports now use the literal opencodex-loopback placeholder. Pi no longer defines an API-key environment variable or export command. Codex Direct model filtering, GUI behavior, tests, and localized documentation now reflect the updated loopback configuration.

Changes

Loopback credential handling

Layer / File(s) Summary
Shared export contract and validation
src/clients/config-export.ts, tests/client-config-export*.test.ts, tests/client-config-new-clients.test.ts, tests/management-client-config-route.test.ts, tests/cli-export-command.test.ts
Pi and Kimi use LOOPBACK_API_KEY_PLACEHOLDER. Pi no longer exposes an API-key environment variable or shell export hint. Tests expect the literal placeholder and empty apiKeyEnv.
Codex Direct model filtering
src/server/management/model-rows.ts, tests/management-client-config-route.test.ts
loadExportModels excludes native model rows in Codex Direct mode and continues to exclude disabled rows. Tests cover pool and direct modes.
GUI API-key notice
gui/src/components/apikeys-workspace/ClientConfigDialog.tsx, gui/tests/client-config-panel.test.tsx
The no-key notice requires a non-empty API-key environment variable. Pi fixtures use inline provider credentials and do not show the notice.
Pi integration guides
docs-site/src/content/docs/guides/*, docs-site/src/content/docs/{ja,ko,ru,zh-cn}/guides/pi.md
The guides document loopback behavior, provider credential storage, updated export output, and Pi 0.83.x validation.
CLI export reference
docs-site/src/content/docs/reference/cli/agents.md, docs-site/src/content/docs/{ja,ko,ru,zh-cn}/reference/cli/agents.md
The references distinguish Pi’s literal placeholder from OpenCode’s environment credential and describe provider visibility and credential serialization.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant ExportCommand
  participant ConfigExport
  participant ModelRows
  participant Pi
  User->>ExportCommand: request Pi configuration export
  ExportCommand->>ConfigExport: build provider configuration
  ConfigExport->>ModelRows: load exportable models
  ModelRows-->>ConfigExport: return filtered model rows
  ConfigExport->>ConfigExport: embed opencodex-loopback
  ConfigExport-->>ExportCommand: omit API-key environment export
  ExportCommand-->>Pi: write models.json configuration
  Pi->>Pi: resolve apiKey for model visibility
Loading

Possibly related PRs

Suggested reviewers: ingwannu, lidge-jun, wibias

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the primary change: keeping Pi loopback models visible without requiring an API key.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the bug Something isn't working label Aug 5, 2026
@n3wr1ch
n3wr1ch force-pushed the fix/pi-loopback-model-visibility branch from 382f424 to ad837c9 Compare August 5, 2026 23:15
@github-actions
github-actions Bot marked this pull request as ready for review August 5, 2026 23:16
@github-actions
github-actions Bot marked this pull request as draft August 5, 2026 23:18

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs-site/src/content/docs/ja/reference/cli/agents.md`:
- Around line 152-160: Update the localized output summaries to describe
client-specific launch guidance rather than implying every client uses
environment exports: in docs-site/src/content/docs/ja/reference/cli/agents.md
lines 152-160, docs-site/src/content/docs/ru/reference/cli/agents.md lines
185-190, and docs-site/src/content/docs/zh-cn/reference/cli/agents.md lines
153-161, revise the surrounding summary using consistent wording that reflects
Pi’s prose “Before launching:” hint while preserving environment-variable
guidance for clients that support it.

In `@docs-site/src/content/docs/ru/reference/cli/agents.md`:
- Around line 185-190: Update the credential paragraph in the localized agents
documentation to distinguish the clients: state that opencode stores an
environment-variable reference, while Pi stores the literal `opencodex-loopback`
placeholder. Remove wording that implies the loopback reference is unused for
both clients, matching the distinction in the English source.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 3deb26aa-f662-4b71-8af7-922671d20dfa

📥 Commits

Reviewing files that changed from the base of the PR and between 6e1a4e4 and ad837c9.

⛔ Files ignored due to path filters (1)
  • devlog/_fin/260806_pi_loopback_models/evidence/pi-config-preview.png is excluded by !**/*.png
📒 Files selected for processing (19)
  • docs-site/src/content/docs/guides/integrations.md
  • docs-site/src/content/docs/guides/pi.md
  • docs-site/src/content/docs/ja/guides/pi.md
  • docs-site/src/content/docs/ja/reference/cli/agents.md
  • docs-site/src/content/docs/ko/guides/pi.md
  • docs-site/src/content/docs/ko/reference/cli/agents.md
  • docs-site/src/content/docs/reference/cli/agents.md
  • docs-site/src/content/docs/ru/guides/pi.md
  • docs-site/src/content/docs/ru/reference/cli/agents.md
  • docs-site/src/content/docs/zh-cn/guides/pi.md
  • docs-site/src/content/docs/zh-cn/reference/cli/agents.md
  • gui/src/components/apikeys-workspace/ClientConfigDialog.tsx
  • gui/tests/client-config-panel.test.tsx
  • src/clients/config-export.ts
  • tests/cli-export-command.test.ts
  • tests/client-config-export-new-clients.test.ts
  • tests/client-config-export.test.ts
  • tests/client-config-new-clients.test.ts
  • tests/management-client-config-route.test.ts

Comment thread docs-site/src/content/docs/ja/reference/cli/agents.md
Comment thread docs-site/src/content/docs/ru/reference/cli/agents.md Outdated
@github-actions
github-actions Bot marked this pull request as ready for review August 5, 2026 23:23

@coderabbitai coderabbitai Bot 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs-site/src/content/docs/ja/reference/cli/agents.md (1)

154-154: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Scope the no-environment-variable claim to the generated Pi export.

The localized paragraphs say that Pi never uses environment variables, then describe Pi resolving apiKey environment references. State that the generated Pi export uses the literal opencodex-loopback placeholder and does not require an environment variable. Keep the separate behavior for existing Pi configurations that contain environment references.

  • docs-site/src/content/docs/ja/reference/cli/agents.md#L154-L154: revise the absolute Pi claim.
  • docs-site/src/content/docs/ru/reference/cli/agents.md#L187-L190: revise the absolute Pi claim.
  • docs-site/src/content/docs/zh-cn/reference/cli/agents.md#L155-L155: revise the absolute Pi claim.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs-site/src/content/docs/ja/reference/cli/agents.md` at line 154, Revise
the absolute Pi environment-variable claim in
docs-site/src/content/docs/ja/reference/cli/agents.md lines 154-154,
docs-site/src/content/docs/ru/reference/cli/agents.md lines 187-190, and
docs-site/src/content/docs/zh-cn/reference/cli/agents.md lines 155-155: clarify
that the generated Pi export uses the literal opencodex-loopback placeholder and
requires no environment variable, while preserving the separate behavior for
existing Pi configurations containing environment references.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@docs-site/src/content/docs/ja/reference/cli/agents.md`:
- Line 154: Revise the absolute Pi environment-variable claim in
docs-site/src/content/docs/ja/reference/cli/agents.md lines 154-154,
docs-site/src/content/docs/ru/reference/cli/agents.md lines 187-190, and
docs-site/src/content/docs/zh-cn/reference/cli/agents.md lines 155-155: clarify
that the generated Pi export uses the literal opencodex-loopback placeholder and
requires no environment variable, while preserving the separate behavior for
existing Pi configurations containing environment references.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 032d7207-3014-47bd-b0bc-39f1826bbc9b

📥 Commits

Reviewing files that changed from the base of the PR and between ad837c9 and b62f378.

📒 Files selected for processing (3)
  • docs-site/src/content/docs/ja/reference/cli/agents.md
  • docs-site/src/content/docs/ru/reference/cli/agents.md
  • docs-site/src/content/docs/zh-cn/reference/cli/agents.md

@n3wr1ch

n3wr1ch commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the remaining CodeRabbit outside-diff finding in 58216c4: all five locales now scope the no-env claim to the generated Pi export while preserving Pi’s behavior for existing unset env references. Docs build and privacy scan pass.

@github-actions
github-actions Bot marked this pull request as draft August 5, 2026 23:28
@github-actions
github-actions Bot marked this pull request as ready for review August 5, 2026 23:29

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 58216c4f4b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/clients/config-export.ts
@lidge-jun

Copy link
Copy Markdown
Owner

Maintainer triage (code-level, against dev @ 6e1a4e429): this one is in good shape. Verified independently:

  • The KIMI_LOOPBACK_PLACEHOLDER → LOOPBACK_API_KEY_PLACEHOLDER rename is complete (no stale references on dev outside the touched files), swaps an inert env reference for the existing non-secret literal, and loopbackOnly: true stays on Pi so non-loopback writes remain refused. No credential is serialized.
  • All four translated Pi guides (ko/ja/ru/zh-cn) carry the same three changes as the English source — no locale contradicts it.
  • The ClientConfigDialog.tsx guard is regression-tested, and five server-side test files cover serializer, registry, CLI output, and the management route.
  • No conflict with dev or with the open bug-fix stack (fix(deepseek): advertise the ladder each V4 model actually honors (#1057) #1069fix(codex): warn when a startup write leaves an app-server stale (#1046) #1072).

Since this touches credential-destination behavior in src/clients/config-export.ts, treating the requested security review as the merge gate is right — requesting that review now. One optional nit: devlog/_fin/260806_pi_loopback_models/ carries only an evidence PNG; a one-page closeout doc would match the usual _fin shape.

@n3wr1ch
n3wr1ch force-pushed the fix/pi-loopback-model-visibility branch from 58216c4 to 1397890 Compare August 6, 2026 00:29
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@github-actions
github-actions Bot marked this pull request as draft August 6, 2026 00:29
@github-actions
github-actions Bot marked this pull request as ready for review August 6, 2026 00:30

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs-site/src/content/docs/guides/pi.md`:
- Around line 72-78: Update the Pi guide sections in
docs-site/src/content/docs/guides/pi.md:72-78,
docs-site/src/content/docs/ja/guides/pi.md:63-65,
docs-site/src/content/docs/ko/guides/pi.md:73-81,
docs-site/src/content/docs/ru/guides/pi.md:74-80, and
docs-site/src/content/docs/zh-cn/guides/pi.md:63-65 to consistently describe
opencodex-loopback as a non-secret literal apiKey placeholder in Pi’s normal
request format, not an admission credential or upstream provider key. State that
Pi normally calls /chat/completions with Bearer authentication, while the
loopback proxy ignores this value and requires no credential.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 7cbdc7e5-3404-41b8-9f97-4a4c927df2ea

📥 Commits

Reviewing files that changed from the base of the PR and between ad38b5f and 1397890.

⛔ Files ignored due to path filters (1)
  • devlog/_fin/260806_pi_loopback_models/evidence/pi-config-preview.png is excluded by !**/*.png
📒 Files selected for processing (20)
  • docs-site/src/content/docs/guides/integrations.md
  • docs-site/src/content/docs/guides/pi.md
  • docs-site/src/content/docs/ja/guides/pi.md
  • docs-site/src/content/docs/ja/reference/cli/agents.md
  • docs-site/src/content/docs/ko/guides/pi.md
  • docs-site/src/content/docs/ko/reference/cli/agents.md
  • docs-site/src/content/docs/reference/cli/agents.md
  • docs-site/src/content/docs/ru/guides/pi.md
  • docs-site/src/content/docs/ru/reference/cli/agents.md
  • docs-site/src/content/docs/zh-cn/guides/pi.md
  • docs-site/src/content/docs/zh-cn/reference/cli/agents.md
  • gui/src/components/apikeys-workspace/ClientConfigDialog.tsx
  • gui/tests/client-config-panel.test.tsx
  • src/clients/config-export.ts
  • src/server/management/model-rows.ts
  • tests/cli-export-command.test.ts
  • tests/client-config-export-new-clients.test.ts
  • tests/client-config-export.test.ts
  • tests/client-config-new-clients.test.ts
  • tests/management-client-config-route.test.ts

Comment thread docs-site/src/content/docs/guides/pi.md Outdated
@github-actions
github-actions Bot marked this pull request as draft August 6, 2026 00:38
@github-actions
github-actions Bot marked this pull request as ready for review August 6, 2026 00:39

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs-site/src/content/docs/ru/guides/pi.md`:
- Around line 74-75: В русском тексте вокруг `Bearer` уберите перенос строки
после дефиса, чтобы в отрендеренном предложении не появлялось `Bearer-
авторизации`; используйте формулировку `авторизации Bearer` или разместите
составную фразу на одной строке.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 706b0d8d-f410-45e9-ada9-64119bbef8e6

📥 Commits

Reviewing files that changed from the base of the PR and between 1397890 and a28bd16.

📒 Files selected for processing (5)
  • docs-site/src/content/docs/guides/pi.md
  • docs-site/src/content/docs/ja/guides/pi.md
  • docs-site/src/content/docs/ko/guides/pi.md
  • docs-site/src/content/docs/ru/guides/pi.md
  • docs-site/src/content/docs/zh-cn/guides/pi.md

Comment thread docs-site/src/content/docs/ru/guides/pi.md Outdated
@github-actions
github-actions Bot marked this pull request as draft August 6, 2026 00:43
@github-actions
github-actions Bot marked this pull request as ready for review August 6, 2026 00:44
@lidge-jun

Copy link
Copy Markdown
Owner

Verdict from triage: READY pending a credential-destination security pass, since the change affects which loopback destinations models stay visible for without an env export. No code defects found; the branch is current against dev, so after the security pass and a green rerun it is ready for final review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants