You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(copilot): follow a user-started --ui-server Copilot in Chat - #2666
On Linux, Copilot Chat follows the foreground session of a Copilot the user started with --ui-server themselves. It reads that session through the CLI's local API (connect and session.getForeground only), and only after it has verified the following on the pane's own process:
the process's UID and birth time;
that --ui-server is on its command line;
that it holds exactly one listening loopback socket;
that Ovis's own connection was accepted by that process.
History is rejected as stale after a session switch, a lifecycle change or a lost connection. This originates in #2665 and YuuuXie#12, by @YuuuXie.
The opt-in launch setting this PR first proposed (copilotApiEnabled, which added --ui-server --port 0 to new launches) was dropped. Copilot CLI 1.0.105's API accepted session.create and other control methods from an unauthenticated local client, and COPILOT_CONNECTION_TOKEN did not change that. Ovis never adds the flag. docs/copilot-chat.md says the API has no authentication and that using it is the user's choice.
Also from review:
A peer pane whose API cannot answer falls back to its lifecycle log and report, instead of taking Chat from every Copilot pane.
Peers are asked at once.
This pane's foreground is re-read after the peer scan.
Validation
bun run check fast on the pushed head: see the maintainer comment.
server/copilot.contract.test.ts needs the isolated Copilot stand-in. It is not detected on the maintainer's machine (on main too), so CI is the evidence for it.
Keep the experiment outside Chat while protected transport remains unresolved. Query only an explicitly opted-in process-owned loopback endpoint, invalidate switched observations, and never turn a foreground observation into transcript authority.
Co-authored-by: Copilot <[email protected]>
Copilot-Session: 88b3fe6d-1ac4-4bcc-a615-85748478224c
Use the existing opted-in TUI API without enabling listeners or sending control requests. Bind Chat history and tool output to continuous foreground lifecycle evidence and reject stale identities after switches, API failures or reconnects.
Co-authored-by: Copilot <[email protected]>
Copilot-Session: 88b3fe6d-1ac4-4bcc-a615-85748478224c
Keep the shared launch preference off by default, warn before opt-in, and limit API launches to Linux. Existing sessions are never restarted. API authentication remains unverified; production enablement is not part of this change.
Co-authored-by: Copilot <[email protected]>
Copilot-Session: 88b3fe6d-1ac4-4bcc-a615-85748478224c
Auto incremental reviews are disabled on this repository.
Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.
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
Summary
Summary by CodeRabbit
New Features
Added an opt-in setting to enable the Copilot local API for new Linux sessions. It’s off by default and requires confirmation acknowledging that authentication is unverified and the port must not be exposed or forwarded.
Copilot Chat can follow live conversations through the enabled API, with checks to avoid using stale session history.
Bug Fixes
API-enabled Copilot launches are rejected on unsupported platforms. Existing and resumed sessions are unaffected.
This change adds a shared opt-in setting for launching new Copilot sessions with the TUI API on Linux. It adds a process- and socket-verified foreground reader and uses selected sessions to resolve transcripts, with checks for session changes, peer conflicts, and unproved transcript paths.
Adds a shared, default-off boolean setting. The UI asks for confirmation before enabling it. Enabled Copilot launches add --ui-server --port 0; the server rejects API-enabled launches outside Linux. Tests cover persistence, sanitization, launch arguments, and session creation.
Documents the opt-in, Linux-only launch setting, its effect on new sessions, and the unverified authentication status.
Copilot foreground transcript resolution
Layer / File(s)
Summary
Foreground reader and observation tests server/copilot-foreground.ts, scripts/copilot-foreground-prototype.ts, scripts/copilot-foreground-prototype.test.ts
Adds a Linux reader that verifies process and socket ownership, validates RPC responses, and checks that consecutive foreground reads agree. Tests cover lifecycle changes, malformed or failed responses, endpoint proof, process changes, and cleanup.
Issue 2458 proposes reading Copilot’s foreground API. This change adds that reader and the opt-in launch setting; the issue’s separate protected or supported enablement follow-up remains outside this change.
Suggested reviewers:devswha
Merge Risk: Moderate · previous review 65cee
The setting defaults off, but syncing can enable API launches on another device without its warning. Production enablement also conflicts with the documented transport prerequisite. Resolve these enablement safeguards before merging.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 55.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta…
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 4 passed
Check name
Status
Explanation
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Title check
The title clearly describes the main change: following a user-started Copilot session through its foreground API in Chat.
Description check
The description includes the required Change and Validation sections. It explains the Linux behavior, security limits, issue references, test coverage, and known validation limits.
Full details: Docstring Coverage
Explanation
Docstring coverage is 55.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 20 functions across 23 files. (3 skipped: 3 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Tip
🎯 Customize your risk assessments
Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using Merge Risk Instructions and Security Risk Instructions in your review settings. Security architecture risk assessments require the Advanced plan or above.
✅ Automatic approvals, with your rules
Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable Automatic approvals in review settings, with overrides for teams or file paths.
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.
Reviewing files that changed from the base of the PR and between 4bc043d and 65cee01.
Files selected for processing: 26
DESIGN.md
changelog.d/copilot-api-launch-option.md
changelog.d/copilot-foreground-api.md
scripts/copilot-foreground-prototype.test.ts
scripts/copilot-foreground-prototype.ts
server/agent-launch.test.ts
server/agent-launch.ts
server/conversation-diagnostics.test.ts
server/conversation-shared.ts
server/conversation.ts
server/copilot-foreground.ts
server/copilot-store.ts
server/copilot.contract.test.ts
server/preferences.test.ts
shared/preferences.ts
src/components/AgentsSettings.tsx
src/lib/agentLaunchMode.test.ts
src/lib/agentLaunchMode.ts
src/lib/i18n/setup.ja.ts
src/lib/i18n/setup.ko.ts
src/lib/i18n/setup.zh.ts
src/lib/newSession.test.ts
src/lib/newSession.ts
src/lib/settings.legacy-fixture.ts
src/lib/settings.test.ts
src/lib/settings.ts
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.
… peer or a non-Linux PC
- a peer pane whose API cannot answer falls back to its lifecycle log and report
instead of taking Chat from every other Copilot pane
- read peer claims after this pane's last API check, so a peer that switched
sessions meanwhile is still caught as a conflict
- off Linux, drop the shared setting's --ui-server --port 0 and start Copilot
without the API instead of refusing the launch
- fixture output is read until the whole line arrives
Thanks @YuuuXie! I pushed maintainer edits to this branch so it can move forward. The rest of the change is still your work:
Merged origin/main and resolved the server/preferences.test.ts conflict. Both sides' tests are kept.
A peer pane whose Copilot API cannot answer no longer takes Chat from other panes.gatherPeerClaims used to throw when any other Copilot pane's API was unavailable. That turned every Copilot pane's Chat into scrollback, including for people who never enabled the setting. That peer now falls back to its lifecycle log and report, the same evidence main uses (server/conversation.ts).
Peer claims are now read after this pane's last API check, so a peer that switches to the same session during the read is still caught as copilot_peer_conflict.
Off Linux, Copilot starts without the API instead of being refused. The setting is shared by every PC, so enabling it on Linux used to block normal Copilot launches on a connected Mac or Windows PC. The bridge now drops --ui-server --port 0 there and keeps any other arguments (server/agent-launch.ts, with tests). DESIGN.md and the changelog say the same.
DESIGN.md now describes the setting as a warned opt-in. The earlier text said it "must stay off in production", which contradicted the toggle. It is off by default, the confirmation dialog states the risk, and the default stays off until protected transport exists.
Foreground fixture tests read the child's output until the whole ready/ack line arrives, rather than assuming one pipe read holds it.
On CodeRabbit's per-device acknowledgement point: the setting stays shared, like claudeLaunchMode/codexLaunchMode. It changes how new agents start on the PC that serves those browsers. Anyone who can change shared launch settings there already has the same reach, e.g. turning on bypassPermissions.
Validation: bun run check fast passed on 0240a9a3 (workflow syntax, generated files, typecheck, build, unit tests). That run did not include the origin/main merge on top, 9445715e. After that merge only server/agent-launch.test.ts and src/lib/agentLaunchMode.test.ts were run, and both passed. The foreground fixture file passed 5 of 5 repeated runs; one earlier run timed out while the machine was heavily loaded. server/copilot.contract.test.ts could not run on my machine (its stand-in is not detected there, on main as well), so CI is the evidence for it.
…-ui-server
Copilot CLI 1.0.105's --ui-server accepts session.create and other control
methods from any local client without authentication (COPILOT_CONNECTION_TOKEN
did not change that), so Ovis does not add the flag on a user's behalf.
Chat still follows a Copilot the user started with --ui-server; the docs say
the API is unauthenticated.
Also from review: ask peer panes at once rather than one after another, and
re-read this pane's foreground after the peer scan.
devswha
changed the title
feat(copilot): add an opt-in foreground API launch setting
feat(copilot): follow a user-started --ui-server Copilot in Chat
Nov 5, 2026
@YuuuXie, thank you for keeping the risk in plain sight in this PR. Your "unresolved enablement gate" note was right, and we checked it. We've dropped the settings toggle and kept your foreground reader. Here's why.
What we found. We started the real Copilot CLI 1.0.105 with exactly the arguments the toggle adds (--ui-server --port 0), in an isolated HOME/COPILOT_HOME. A separate local client with no credentials could call:
connect, which answered with protocol 3;
session.getForeground, which returned the session ID and workspace path;
session.create, which created a new interactive session.
Setting COPILOT_CONNECTION_TOKEN did not change any of this. So the endpoint is not just unverified: it has no authentication, and it accepts control methods. Loopback TCP does no per-user check either. A setting that turns that on for every new session, shared across devices, is more than we want Ovis to do on a user's behalf, even behind a warning.
What changed on this branch (076b22d8):
Removed the copilotApiEnabled setting, its UI and copy, the launch arguments, and the related tests and changelog fragment. Those files now match main.
Kept the reader: Chat still follows a Copilot that the user started with --ui-server themselves. docs/copilot-chat.md now says this API has no authentication and that running Copilot with it is the user's choice.
From review: peer panes are now asked at once rather than one after another, so several slow peers don't add up. This pane's foreground is now re-read after the peer scan.
We'd be glad to revisit a launch option once Copilot offers real transport protection, such as an owner-only socket or a token it actually enforces. Because this branch now carries the reader on its own, #2665 becomes redundant once this lands.
…quest
Each ownership proof parses the whole network-namespace TCP table
synchronously; a warm read did about ten of them, which stalled the event
loop for hundreds of ms on a host with many sockets. Prove it on connect and
once at the end of each read.
Each ownership proof reads and parses the whole /proc/<pid>/net/tcp and tcp6 tables synchronously. A warm read used to do about ten of them, and on a host with many sockets the review measured event-loop stalls of up to 265 ms. Ownership is now proven when the connection is made and once at the end of each read, about three table scans instead of ten. Process and birth checks at the start of each read are unchanged.
Left as notes (LOW, not changed here):
A tcp table over 4 MiB makes the read unavailable instead of falling back.
An API-selected session with no events.jsonl yet shows Terminal instead of an empty Chat.
The reader's unit tests run through scripts/copilot-foreground-prototype.ts.
Validation: bun run check fast passed on 151a76a9 (workflow syntax, generated files, typecheck, build, unit tests).
Thanks @YuuuXie! We kept the Chat reader for a Copilot started with --ui-server and dropped the setting that launches it that way: on Copilot 1.0.105 any local program could call session.create on that API without authentication (reproduced; COPILOT_CONNECTION_TOKEN did not stop it). The docs say so, so users decide. We can revisit the toggle once Copilot offers an owner-only socket or an enforced token. We also fixed a few edge cases on your branch. Merging; this includes #2665's reader, so #2665 closes too.
Merge note: external PR; supply-chain check done; omo CLEAR at 151a76a; Codex/omo MEDIUMs fixed; required checks green.
Merge the full upstream main, which now carries the Copilot log-rotation
fix (devswha#2724) and the foreground API reader (devswha#2665 via devswha#2666). Conflicts
from the pre-merge PR versions resolve to upstream. Drop the opt-in
Copilot API launch setting (fork PR #12), which upstream rejected because
the CLI API accepts control methods without authentication.
Co-authored-by: Copilot <[email protected]>
Copilot-Session: 03511a3a-c861-4657-b123-934fa3dbd976
…sion (#3076)
## Summary
When Chat falls back to terminal output for a single Copilot process on
Linux that was started without `--ui-server`, Chat now shows a notice:
> Copilot chat is unavailable. On Linux, starting Copilot with copilot
--ui-server --port=0 may help. Its local API has no authentication: any
program on this PC can control that session.
This respects the earlier decision in #2666. Ovis still never adds the
flag and has no toggle for it. The notice only names the option and its
risk where the problem shows, as `docs/copilot-chat.md` already leaves
the choice to the user. The wording says "may" because some failures,
such as an unproved store, an unreadable transcript or a peer claiming
the session, could persist with the flag. We still want to point users
to the more stable route whenever Chat cannot bind the session.
## How
- `shared/protocol.ts`: a new optional field,
`ConversationResponse.hint?: "copilot_ui_server"`. This is an HTTP
contract addition. Older clients ignore it.
- `server/conversation.ts`: in `copilotTranscriptPath`, once Copilot's
own API check returns `not_opted_in` for the one foreground process,
every later `ConversationUnavailable` carries the hint
(`report_invalid`, a report peer conflict, and the final throw). It is
never sent:
- when the flag is present (the API path and `copilot_api_*` errors),
- for a two-process `--resume` handoff,
- on non-Linux or when the process set is unproved,
- for a first-turn `ConversationNotStarted`.
- `server/pane-routes.ts`: passes `hint` on the scrollback answer, next
to `recovery`.
- `src/components/ChatView.tsx`: an inline footer notice for `copilot` +
`scrollback` + the hint. It follows the existing Grok and Antigravity
notices (#816) for design precedent. Translations for ja/ko/zh are
included. A waiting recovery that keeps the shown history doesn't show
it.
- Docs and a changelog fragment.
## Validation
- `bun run check fast`: workflow syntax, generated types/themes,
typecheck and build all ok. Unit tests passed except
`scripts/build-cache.test.ts`, `scripts/self-hosted-runner.test.ts`,
`scripts/ci-runner-route.test.ts` and `scripts/relay-ios-sim.test.ts`.
These four fail identically on clean `main` in my environment and are
unrelated.
- `bun run check run bun test --timeout 15000
./server/copilot.contract.test.ts`: 8 pass. The no-flag case asserts the
hint. The `--ui-server` fixture's API rejection, race and peer cases
strictly assert no hint, as does the two-process handoff peer conflict.
- `server/copilot.test.ts`: a new test checks that a held marker with no
report, then with a peer claim, then with a peer-conflicting report all
carry the hint.
- `server/pane-routes.test.ts`: the hint passes through next to
`recovery: "waiting"`.
- Independent code-review agent rounds; their findings are fixed.
---------
Co-authored-by: Yu Xie <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Hako <[email protected]>
Copilot-Session: 03511a3a-c861-4657-b123-934fa3dbd976
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change
On Linux, Copilot Chat follows the foreground session of a Copilot the user started with
--ui-serverthemselves. It reads that session through the CLI's local API (connectandsession.getForegroundonly), and only after it has verified the following on the pane's own process:--ui-serveris on its command line;History is rejected as stale after a session switch, a lifecycle change or a lost connection. This originates in #2665 and YuuuXie#12, by @YuuuXie.
The opt-in launch setting this PR first proposed (
copilotApiEnabled, which added--ui-server --port 0to new launches) was dropped. Copilot CLI 1.0.105's API acceptedsession.createand other control methods from an unauthenticated local client, andCOPILOT_CONNECTION_TOKENdid not change that. Ovis never adds the flag.docs/copilot-chat.mdsays the API has no authentication and that using it is the user's choice.Also from review:
Validation
bun run check faston the pushed head: see the maintainer comment.server/copilot.contract.test.tsneeds the isolated Copilot stand-in. It is not detected on the maintainer's machine (onmaintoo), so CI is the evidence for it.