Skip to content

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

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

fix(pi): keep loopback models visible#1085
n3wr1ch wants to merge 16 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, and label their launch guidance neutrally
  • document the literal loopback placeholder and the Pi 0.83.0 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,418 pass, 8 skip, 0 fail
  • bun run privacy:scan
  • cd gui && bun test tests — 646 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 — 221 pages
  • focused client integration/export suites — 63 pass, 0 fail; focused GUI config panel — 13 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 resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

Summary by CodeRabbit

  • New Features

    • Pi and Kimi loopback exports now use the non-secret opencodex-loopback placeholder without API-key environment variables.
    • Model exports reflect provider routing, Codex modes, and client-specific context-limit support.
  • Bug Fixes

    • Client configuration dialogs provide clearer loopback guidance and avoid misleading environment-variable warnings.
    • Exported configurations do not serialize credentials or expose unavailable models.
  • Documentation

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

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

Deterministic PR hygiene checks passed.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

No new commits to review since the last review.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: a04753b5-da20-45c9-b706-272e70901707

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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 filtering, GUI behavior, tests, and localized documentation reflect the updated configuration.

Changes

Loopback credential handling

Layer / File(s) Summary
Shared export contract and validation
src/clients/config-export.ts, src/cli/export-command.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. Serializer metadata now reports client context-limit support.
Codex Direct model filtering
src/combos/types.ts, src/combos/index.ts, src/cli/opencode.ts, src/server/management/model-rows.ts, tests/management-client-config-route.test.ts, tests/cli-export-command.test.ts
Codex Direct filtering excludes native OpenAI models and combos that route through OpenAI. Routed-only combos remain available.
GUI API-key notice
gui/src/components/apikeys-workspace/ClientConfigDialog.tsx, gui/src/i18n/*.ts, 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 show loopback guidance without a missing-key warning.
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) | ~25 minutes

Possibly related PRs

Suggested reviewers: lidge-jun, wibias

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 70.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 and concisely describes the primary change: keeping Pi loopback models visible.
✨ 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.

@lidge-jun

Copy link
Copy Markdown
Owner

Reviewed in a sweep of the bug-labelled backlog. No correctness defect found; this is the closest PR in that set to mergeable.

The bug is real and the diagnosis is exact: dev exports Pi's apiKey as $OPENCODEX_API_KEY (src/clients/config-export.ts:110-114, 727-735), and Pi resolves that reference while building its model list — so an unset variable makes Pi hide the whole provider. Asking users to set a secret that is never checked, to satisfy a loopback-only client, is the wrong contract. Replacing it with the literal loopback placeholder is right.

It also stays inside the boundary that already exists: dev refuses remote Pi export because the format cannot carry the separate admission header (:948-961), so this change does not widen any exposure. Omitting Direct-mode native rows from file-client exports is defensible for the same reason — those rows need the user's actual ChatGPT bearer, and Pi would send the placeholder instead. Serializer, management API and GUI tests cover the changed output and the absence of the empty-variable warning.

Your remaining blocker is the security review, which your description already calls for. Anything touching credential material needs an explicit second-maintainer pass under MAINTAINERS.md, and I am not treating my read as a substitute — I looked for correctness defects, not for the credential boundary judgment that review is for.

One practical note: the head is 85 commits behind dev. The readiness gate wants the branch at most 10 behind, so a rebase is worth doing before the review rather than after, to avoid re-reviewing a moved diff.

Thanks for the locale coverage on the Pi guides — documenting the placeholder in every translation rather than only the English source is what keeps the next person from "fixing" it back.

@n3wr1ch
n3wr1ch force-pushed the fix/pi-loopback-model-visibility branch from 0c61a87 to 4994b12 Compare August 6, 2026 13:22
@n3wr1ch
n3wr1ch marked this pull request as ready for review August 6, 2026 13:35
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

@github-actions The readiness gate is complete at 4994b128197089ae007e02a5d13369cb723e9eb8.

I will review the current PR head. The review will verify the Pi loopback credential boundary, generated configuration serialization, Direct-mode model filtering, and regression coverage.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

expected_head='4994b128197089ae007e02a5d13369cb723e9eb8'
previous_reviewed='0c61a8731e89f35461988c386ed6c716bc78bfb4'

printf '%s\n' '== PR and checkout identity =='
gh pr view 1085 --json number,baseRefName,baseRefOid,headRefName,headRefOid,files \
  --jq '{number, baseRefName, baseRefOid, headRefName, headRefOid, files: [.files[].path]}'
printf 'HEAD: '
git rev-parse HEAD
git status --short

printf '%s\n' '== Incremental changes since the last reviewed head =='
git diff --name-status "$previous_reviewed...HEAD"
git diff --stat "$previous_reviewed...HEAD"
git diff --find-renames --unified=45 "$previous_reviewed...HEAD" -- \
  src/clients/config-export.ts \
  src/integrations/writer.ts \
  src/cli/opencode.ts \
  src/cli/export-command.ts \
  src/server/management/model-rows.ts \
  gui/src/components/apikeys-workspace/ClientConfigDialog.tsx \
  tests gui/tests docs-site/src/content/docs

printf '%s\n' '== Relevant source structure =='
ast-grep outline src/clients/config-export.ts --items all --view expanded
ast-grep outline src/integrations/writer.ts --items all --view expanded
ast-grep outline src/cli/opencode.ts --items all --view expanded
ast-grep outline src/server/management/model-rows.ts --items all --view expanded

printf '%s\n' '== Pi serialization and loopback enforcement =='
rg -n -C 10 \
  'LOOPBACK_API_KEY_PLACEHOLDER|opencodex-loopback|clientId:\s*"pi"|loopbackOnly|apiKeyEnv|non_loopback|buildContribution|writeFile' \
  src/clients/config-export.ts src/integrations/writer.ts src/cli/export-command.ts src/server \
  --glob '*.ts'

printf '%s\n' '== Direct-mode filtering and model-route helper =='
rg -n -C 10 \
  'modelRoutesThroughProvider|providerCodexAccountMode|codex.*direct|direct.*codex|canonical.*openai' \
  src/cli/opencode.ts src/server/management/model-rows.ts src/combos \
  --glob '*.ts'

printf '%s\n' '== Focused regression coverage =='
rg -n -C 8 \
  'opencodex-loopback|LOOPBACK_API_KEY_PLACEHOLDER|loopbackOnly|non_loopback|apiKeyEnv|Codex Direct|codex direct|combo|context limits|Hermes' \
  tests gui/tests \
  --glob '*.{ts,tsx}'

printf '%s\n' '== Pi image artifact status =='
git ls-files --error-unmatch devlog/_fin/260806_pi_loopback_models/evidence/pi-config-preview.png
file devlog/_fin/260806_pi_loopback_models/evidence/pi-config-preview.png

Length of output: 194782


🏁 Script executed:

#!/bin/bash
set -euo pipefail

previous_reviewed='0c61a8731e89f35461988c386ed6c716bc78bfb4'

printf '%s\n' '== Identity =='
printf 'HEAD: '; git rev-parse HEAD
gh pr view 1085 --json headRefOid,baseRefOid --jq '{headRefOid,baseRefOid}'

printf '%s\n' '== Incremental file list =='
git diff --name-status "$previous_reviewed...HEAD"

printf '%s\n' '== Incremental implementation and test patch =='
git diff --unified=24 "$previous_reviewed...HEAD" -- \
  src/clients/config-export.ts \
  src/integrations/writer.ts \
  src/cli/opencode.ts \
  src/cli/export-command.ts \
  src/server/management/model-rows.ts \
  src/combos/types.ts \
  tests/client-config-export.test.ts \
  tests/cli-export-command.test.ts \
  tests/management-client-config-route.test.ts \
  tests/integrations-writer.test.ts \
  gui/tests/client-config-panel.test.tsx

printf '%s\n' '== Pi client specification and serializer =='
rg -n -A45 -B12 'clientId:\s*"pi"|LOOPBACK_API_KEY_PLACEHOLDER' src/clients/config-export.ts

printf '%s\n' '== Loopback write guard =='
rg -n -A28 -B16 'loopbackOnly|non_loopback' src/integrations/writer.ts

printf '%s\n' '== Direct-mode export filtering =='
rg -n -A22 -B12 'modelRoutesThroughProvider|providerCodexAccountMode' \
  src/cli/opencode.ts src/server/management/model-rows.ts src/combos/types.ts

printf '%s\n' '== Focused test cases =='
rg -n -A38 -B5 \
  'opencodex-loopback|non_loopback|Codex Direct|context limits are not represented' \
  tests/client-config-export.test.ts \
  tests/cli-export-command.test.ts \
  tests/management-client-config-route.test.ts \
  tests/integrations-writer.test.ts \
  gui/tests/client-config-panel.test.tsx

printf '%s\n' '== Artifact PNG signature and dimensions =='
python3 - <<'PY'
from pathlib import Path
import struct
path = Path("devlog/_fin/260806_pi_loopback_models/evidence/pi-config-preview.png")
data = path.read_bytes()
assert data[:8] == b"\x89PNG\r\n\x1a\n"
assert data[12:16] == b"IHDR"
width, height = struct.unpack(">II", data[16:24])
print(f"{path}: {width}x{height}, {len(data)} bytes")
PY

Length of output: 125550


@github-actions[bot] Reviewed PR #1085 at 4994b128197089ae007e02a5d13369cb723e9eb8. I found no blocking defects.

  • src/clients/config-export.ts at Lines 727-736 serializes Pi with the non-secret opencodex-loopback placeholder. It does not serialize a user credential.
  • src/clients/config-export.ts at Lines 950-965 sets Pi apiKeyEnv to an empty string and keeps loopbackOnly: true.
  • src/integrations/writer.ts at Lines 226-237 rejects loopback-only clients on a non-loopback hostname before merge, serialization, or file write.
  • src/cli/opencode.ts at Lines 300-324 and src/server/management/model-rows.ts at Lines 117-125 exclude canonical OpenAI rows and combos that can route through OpenAI in Codex Direct mode.
  • src/combos/types.ts at Lines 74-82 implements the shared route check for physical providers and combo targets.
  • src/cli/export-command.ts reads the summary from the generated client document. Pi counts only serialized models. Hermes correctly reports that its format does not represent context limits.
  • The focused tests cover Pi serialization, non-serialization of real credentials, Direct-mode row and combo filtering, GUI loopback guidance, and remote-bind refusal.
  • The tracked Pi preview PNG is valid and matches the generated placeholder configuration.

I did not execute repository tests in this sandbox. The readiness gate reports green checks, and the inspected tests cover the changed behavior.

[approve]

You are interacting with an AI system.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@github-actions[bot] The readiness gate is complete at 4994b128197089ae007e02a5d13369cb723e9eb8.

CodeRabbit reviewed this same head. The review found no blocking defects and approved the PR.

You are interacting with an AI system.

@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: 4994b12819

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/cli/opencode.ts
Comment on lines +310 to +312
if (omitDirectOpenAi && (
modelRoutesThroughProvider(config, { provider: row.provider ?? "", id: row.id ?? "" }, "openai")
)) continue;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reject exports emptied by Direct-mode filtering

When canonical OpenAI in Direct mode is the only enabled provider, this predicate removes every /api/models row, after which handleExportCommand still serializes and may write a provider with zero models; the shared loadExportModels path does the same for management and integration exports. This contradicts the export contract in src/cli/export-command.ts that an empty models block is never emitted and leaves users with an apparently successful but unusable config. After applying the Direct-mode filter, return a clear no-compatible-models error instead of building or applying the document, and cover the OpenAI-Direct-only configuration.

Useful? React with 👍 / 👎.

@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/ja/reference/cli/agents.md`:
- Line 130: Update the Japanese documentation sentence around the opencodex
provider description by changing the link text from `円周率` to the product name
`Pi`, while preserving the existing `/guides/pi/` destination and surrounding
wording.
🪄 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: 99127b7e-ab00-4bb3-b93b-35bdca9d6444

📥 Commits

Reviewing files that changed from the base of the PR and between 43a1fdc and 4994b12.

⛔ 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 (30)
  • 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/src/i18n/de.ts
  • gui/src/i18n/en.ts
  • gui/src/i18n/ja.ts
  • gui/src/i18n/ko.ts
  • gui/src/i18n/ru.ts
  • gui/src/i18n/zh.ts
  • gui/tests/client-config-panel.test.tsx
  • src/cli/export-command.ts
  • src/cli/opencode.ts
  • src/clients/config-export.ts
  • src/combos/index.ts
  • src/combos/types.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/ja/reference/cli/agents.md Outdated
@github-actions
github-actions Bot marked this pull request as draft August 6, 2026 13:44
@n3wr1ch
n3wr1ch marked this pull request as ready for review August 6, 2026 13:44
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

@github-actions[bot] The readiness checklist is complete at 5c03a43e43dcaeb8912a0f728778bfaaa08fd88c. I will review the current PR head, including the Pi loopback credential boundary, configuration serialization, Direct-mode model filtering, and regression coverage.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

@github-actions[bot] The readiness checklist is complete at 5c03a43e43dcaeb8912a0f728778bfaaa08fd88c.

I will review the current PR head. The review will verify Pi loopback credential handling, configuration serialization, Direct-mode model filtering, and regression coverage.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

@github-actions[bot] The readiness checklist is complete at 5c03a43e43dcaeb8912a0f728778bfaaa08fd88c.

I will review the current PR head. The review will verify Pi loopback credential handling, configuration serialization, Direct-mode model filtering, and regression coverage.

⚠️ Action not completed

Already reviewed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@lidge-jun

Copy link
Copy Markdown
Owner

Thank you — the Pi loopback fix is landing as #1151, credited to you via Co-authored-by.

Your root cause was exactly right, and it is a subtle one: Pi resolves apiKey before building its model list and hides the provider when the reference is unset, so an unresolved env var did not degrade gracefully — it made every loopback model disappear. Pi now ships the same non-secret opencodex-loopback placeholder the Kimi and Grok blocks use, with no required environment variable, since a loopback bind needs no admission key.

What I did not take: the combo/direct-mode filtering, the cross-client contract changes, and the generalized export-policy churn — 31 files where the defect fix is a handful of lines. Those are worth reviewing on their own terms rather than as part of a visibility fix.

One follow-up worth knowing: your change makes two assertions in tests/cli-export-command.test.ts stale, because they expected the old export OPENCODEX_API_KEY= output — the very behavior you reported as broken. I updated them in the stack PR rather than leave a red suite. The security property they exist for is unchanged and still asserted: no ocx_ token ever reaches stdout.

Verified: 74 pass / 0 fail after rebase; full suite 9,556 pass / 0 fail; typecheck, GUI lint/build and privacy scan clean.

Leaving this PR open for you.

lidge-jun added a commit that referenced this pull request Aug 6, 2026
Both remaining phases executed: #1150 (Yuxin Qiao, test isolation + Desktop
allowlist docs) and #1151 (Eachann + n3wr1ch, effort picker + Pi loopback
export). 16 contributor PRs landed across 12 stack PRs.

Also records the one in-scope deviation: phase 140 marked
tests/cli-export-command.test.ts as DROP, but the Pi fix made two of its
assertions stale - they expected the exact output #1085 reports as the bug.
Updating them beat shipping a red suite; the no-secret-in-stdout property is
unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working review-ready

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants