Skip to content
Source
Sign inSign up
pingdotgg/t3code
Closedhafiezul(GitHub profile, opens in a new tab)wants to merge 11 commits intomain fromrefs/pull/4445/headopened View on GitHub

What Changed

Why

UI Changes

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Note

High Risk Large new subprocess/RPC provider path with session continuation rules and broad event-mapping surface; mistakes could affect thread lifecycle, prompts, or cross-instance session isolation.

Overview Introduces Pi as a first-class provider: managed RPC launch (--mode rpc, per-instance session dirs, blocked override flags), version gating (≥0.81.1), model/thinking catalog discovery, and a PiAdapter that maps streaming, tools, compaction, extension UI (confirm/select/input), interrupts, images, and transport failures into existing T3 provider events.

User input answers move from plain strings to ProviderUserInputAnswers, with cancelOptionLabel on questions and mobile buildPendingUserInputAnswers emitting { cancelled: true } vs { value: ... } for Pi-native extension dialogs.

Orchestration ingestion now surfaces context_compaction lifecycle activities and propagates tool status (including failed tone). Codex custom models can inherit reasoning pickers with an added Max option. Agent docs add CONTEXT.md Pi terminology and AGENTS.md issue-tracker/domain pointers.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 52bef096a6b22c97ae37feaf8e02eada2cdabdbc. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Add Pi as a first-class provider with full RPC session runtime integration

  • Introduces a new pi provider driver with settings schema, model discovery via RPC, session isolation per provider instance, and a status probe that validates Pi CLI version (≥ 0.81.1) and launch arguments
  • Adds PiAdapter and PiSessionRuntime to manage Pi RPC lifecycle, including image attachment loading, event streaming, transport failure handling, and continuation identity validation
  • Extends the composer UI to hide the runtime mode selector and show a Pi-managed tools notice when the selected provider's presentation flags indicate it
  • Adds cancelOptionLabel support to user input questions so answers encode either { value } or { cancelled: true } instead of an ambiguous string
  • Augments custom model capabilities with a Max reasoning option via addMaxReasoningOptionForCustomModel when an effort/reasoningEffort selector is present
  • Adds 13 ADRs and project/provider docs covering the Pi integration design decisions
  • Risk: threads that have a persisted resume cursor will receive a validation error if routed to a Pi instance with a different continuation identity, which is a new hard failure mode in ProviderService.startSession
📊 Macroscope summarized 52bef09. 45 files reviewed, 0 issues evaluated, 0 issues filtered, 0 comments posted

🗂️ Filtered Issues

No issues evaluated.

    1. Important

      Review skipped

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

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: 669a5d02-f875-4e18-937a-b3c5ee16bb48

      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
      ✨ 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.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. @@ -0,0 +8,21 @@
      8+Install and authenticate Pi before adding it in T3 Code:
      9+
      10+```bash
      11+npm install -g @earendil-works/pi-coding-agent
      12+pi
      13+```
      14+
      15+## Provider And Model Configuration
      16+
      17+Configure credentials, built-in providers, custom providers, and models in Pi. T3 Code uses the
      18+provider and model configuration Pi exposes, while separately managing runtime-instance settings and
      19+UI-only preferences.
      20+
      21+## Multiple Pi Instances
      22+
      23+T3 Code supports multiple Pi runtime instances. Use separate instances when you need isolated Pi
      24+configuration environments or session storage; configure the providers and models inside each Pi
      25+environment.
      26+
      27+An instance may optionally select a Pi configuration directory. When left empty, it uses the user's
      28+normal Pi configuration; when set, T3 Code passes the directory as `PI_AGENT_DIR`. Session storage
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟢 Low providers/pi.md:28

      The docs say T3 Code passes the configuration directory as PI_AGENT_DIR, but the provider actually sets PI_CODING_AGENT_DIR. Users who follow this documentation to reproduce or troubleshoot an instance environment will set the wrong variable, causing Pi to fall back to its normal configuration instead of the selected directory. Consider correcting the environment variable name to match the implementation.

      🤖 Copy this AI Prompt to have your agent fix this:
      In file @docs/providers/pi.md around line 28:
      
      The docs say T3 Code passes the configuration directory as `PI_AGENT_DIR`, but the provider actually sets `PI_CODING_AGENT_DIR`. Users who follow this documentation to reproduce or troubleshoot an instance environment will set the wrong variable, causing Pi to fall back to its normal configuration instead of the selected directory. Consider correcting the environment variable name to match the implementation.
      @@ -0,0 +444,21 @@
      444+ Effect.matchEffect({
      445+ onFailure: (cause) =>
      446+ finishUnexpectedTransportFailure(
      447+ new PiSessionRuntimeError({
      448+ operation: "process-exit",
      449+ detail: "Could not read Pi process exit status.",
      450+ cause,
      451+ }),
      452+ ),
      453+ onSuccess: (code) =>
      454+ finishUnexpectedTransportFailure(
      455+ new PiSessionRuntimeError({
      456+ operation: "process-exit",
      457+ detail:
      458+ code === 0
      459+ ? "Pi RPC process exited."
      460+ : `Pi RPC process exited with code ${String(code)}.`,
      461+ }),
      462+ ),
      463+ }),
      464+ Effect.forkIn(runtimeScope),
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium Drivers/PiSessionRuntime.ts:464

      When the Pi subprocess exits while its stdout pipe still contains buffered JSONL records, the final lifecycle events are silently dropped. The child.exitCode fiber immediately calls finishUnexpectedTransportFailure, which calls Queue.end(rawEvents), without waiting for outputFiber to finish draining stdout. Subsequent Queue.offer calls from the stdout fiber occur after Queue.end and are discarded, so the final turn/tool completion events never reach consumers and higher-level lifecycle mapping is left incorrect. Consider coordinating the exit-code handler to wait for outputFiber to complete before ending rawEvents.

      🤖 Copy this AI Prompt to have your agent fix this:
      In file @apps/server/src/provider/Drivers/PiSessionRuntime.ts around line 464:
      
      When the Pi subprocess exits while its stdout pipe still contains buffered JSONL records, the final lifecycle events are silently dropped. The `child.exitCode` fiber immediately calls `finishUnexpectedTransportFailure`, which calls `Queue.end(rawEvents)`, without waiting for `outputFiber` to finish draining stdout. Subsequent `Queue.offer` calls from the stdout fiber occur after `Queue.end` and are discarded, so the final turn/tool completion events never reach consumers and higher-level lifecycle mapping is left incorrect. Consider coordinating the exit-code handler to wait for `outputFiber` to complete before ending `rawEvents`.
      @@ -0,0 +375,21 @@
      375+
      376+ if (method === "confirm") {
      377+ const message = nonEmptyString(value.message) ?? title;
      378+ return {
      379+ id,
      380+ method,
      381+ question: {
      382+ id,
      383+ header: title,
      384+ question: message,
      385+ options: [
      386+ { label: PI_EXTENSION_CONFIRM_LABEL, description: PI_EXTENSION_CONFIRM_LABEL },
      387+ { label: PI_EXTENSION_CANCEL_LABEL, description: PI_EXTENSION_CANCEL_LABEL },
      388+ ],
      389+ multiSelect: false,
      390+ },
      391+ };
      392+ }
      393+
      394+ if (method === "select") {
      395+ const options = Array.isArray(value.options)
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium Layers/PiAdapter.ts:395

      piExtensionDialog trims every select option via nonEmptyString, so the returned options array stores trimmed values. When the user picks an option, the trimmed label is sent back to the extension instead of the original value — an option like " indented" is returned as "indented". The Set deduplication also collapses options that differ only in surrounding whitespace, silently dropping choices. Consider preserving the original (non-trimmed) non-empty string as the stored and returned value.

      🤖 Copy this AI Prompt to have your agent fix this:
      In file @apps/server/src/provider/Layers/PiAdapter.ts around line 395:
      
      `piExtensionDialog` trims every `select` option via `nonEmptyString`, so the returned `options` array stores trimmed values. When the user picks an option, the trimmed label is sent back to the extension instead of the original value — an option like `"  indented"` is returned as `"indented"`. The `Set` deduplication also collapses options that differ only in surrounding whitespace, silently dropping choices. Consider preserving the original (non-trimmed) non-empty string as the stored and returned value.
      @@ -105,12 +105,13 @@
      105105 export function buildPendingUserInputAnswers(
      106106 questions: ReadonlyArray<UserInputQuestion>,
      107107 draftAnswers: Record<string, PendingUserInputDraftAnswer>,
      108-): Record<string, string | string[]> | null {
      109- const answers: Record<string, string | string[]> = {};
      108+): ProviderUserInputAnswers | null {
      109+ const answers: Record<string, unknown> = {};
      110110
      111111 for (const question of questions) {
      112- const answer = resolvePendingUserInputAnswer(question, draftAnswers[question.id]);
      112+ const draft = draftAnswers[question.id];
      113+ const answer = resolvePendingUserInputAnswer(question, draft);
      113114 if (!answer) {
      114115 return null;
      115116 }
      116- answers[question.id] = answer;
      117+ const customAnswer = normalizeDraftAnswer(draft?.customAnswer);
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium src/pendingUserInput.ts:117

      buildPendingUserInputAnswers misses cancellation for multi-select questions. When question.multiSelect is true and the user selects only the cancel option, resolvePendingUserInputAnswer returns an array like ["Cancel"], but the check answer === question.cancelOptionLabel compares the array to a string, so it never matches. The selected cancel option is then stored as a normal answer value instead of { cancelled: true }, so the dialog cannot be cancelled. Consider detecting cancel-option selection in a multi-select-aware way before building the result.

      🤖 Copy this AI Prompt to have your agent fix this:
      In file @apps/web/src/pendingUserInput.ts around line 117:
      
      `buildPendingUserInputAnswers` misses cancellation for multi-select questions. When `question.multiSelect` is true and the user selects only the cancel option, `resolvePendingUserInputAnswer` returns an array like `["Cancel"]`, but the check `answer === question.cancelOptionLabel` compares the array to a string, so it never matches. The selected cancel option is then stored as a normal answer value instead of `{ cancelled: true }`, so the dialog cannot be cancelled. Consider detecting cancel-option selection in a multi-select-aware way before building the result.
      @@ -0,0 +6,21 @@
      6+ "continue",
      7+ "fork",
      8+ "mode",
      9+ "no-extensions",
      10+ "no-session",
      11+ "resume",
      12+ "session",
      13+ "session-dir",
      14+ "session-id",
      15+]);
      16+const MANAGED_SHORT_FLAGS = new Set(["-c", "-r"]);
      17+
      18+export type PiLaunchPlan =
      19+ | {
      20+ readonly _tag: "Success";
      21+ readonly args: ReadonlyArray<string>;
      22+ readonly environment: NodeJS.ProcessEnv;
      23+ }
      24+ | { readonly _tag: "Failure"; readonly message: string };
      25+
      26+export function validatePiLaunchArgs(launchArgs: string): string | undefined {
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium Drivers/PiRuntime.ts:26

      validatePiLaunchArgs treats every token as a potential flag, so a value that happens to equal a managed flag causes a false rejection. For example, --system-prompt "--mode" is valid Pi syntax (parseArgs consumes the next token as the prompt value), but the validator sees the value token --mode and rejects the configuration as an attempted managed override. Any value-taking option whose value equals a managed flag (--mode, --session, -c, etc.) triggers the same false rejection. The validator needs to track which tokens are consumed as option values rather than scanning all tokens as standalone flags.

      🤖 Copy this AI Prompt to have your agent fix this:
      In file @apps/server/src/provider/Drivers/PiRuntime.ts around line 26:
      
      `validatePiLaunchArgs` treats every token as a potential flag, so a value that happens to equal a managed flag causes a false rejection. For example, `--system-prompt "--mode"` is valid Pi syntax (`parseArgs` consumes the next token as the prompt value), but the validator sees the value token `--mode` and rejects the configuration as an attempted managed override. Any value-taking option whose value equals a managed flag (`--mode`, `--session`, `-c`, etc.) triggers the same false rejection. The validator needs to track which tokens are consumed as option values rather than scanning all tokens as standalone flags.
      @@ -0,0 +476,21 @@
      476+ ),
      477+ Effect.flatMap((encoded) =>
      478+ writeLock.withPermit(
      479+ Stream.run(Stream.encodeText(Stream.make(`${encoded}\n`)), child.stdin),
      480+ ),
      481+ ),
      482+ Effect.mapError((cause) =>
      483+ isPiSessionRuntimeError(cause)
      484+ ? cause
      485+ : new PiSessionRuntimeError({
      486+ operation: "write-stdin",
      487+ detail: "Could not write Pi RPC command.",
      488+ cause,
      489+ }),
      490+ ),
      491+ Effect.tapError((error) =>
      492+ error.operation === "write-stdin" ? finishUnexpectedTransportFailure(error) : Effect.void,
      493+ ),
      494+ );
      495+
      496+ const request = Effect.fn("PiSessionRuntime.request")(function* (
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium Drivers/PiSessionRuntime.ts:496

      request checks closed and registers its deferred in pendingRequests as two separate steps. If close or finishUnexpectedTransportFailure runs after the closed check but before the pendingRequests update, it drains the old (empty) map, then this request inserts a new entry that is never failed. The caller then waits the full 15/30-second timeout and receives a misleading timeout error instead of the immediate close/transport failure. Consider registering the deferred in pendingRequests before checking closed, and removing it if the session is already closed, so the race window cannot strand the request.

      🤖 Copy this AI Prompt to have your agent fix this:
      In file @apps/server/src/provider/Drivers/PiSessionRuntime.ts around line 496:
      
      `request` checks `closed` and registers its `deferred` in `pendingRequests` as two separate steps. If `close` or `finishUnexpectedTransportFailure` runs after the `closed` check but before the `pendingRequests` update, it drains the old (empty) map, then this request inserts a new entry that is never failed. The caller then waits the full 15/30-second timeout and receives a misleading timeout error instead of the immediate close/transport failure. Consider registering the `deferred` in `pendingRequests` before checking `closed`, and removing it if the session is already closed, so the race window cannot strand the request.
      @@ -0,0 +46,21 @@
      46+The first release targets provider parity for normal coding work:
      47+
      48+- persistent, resumable Pi sessions
      49+- streaming assistant text and tool activity
      50+- image attachments
      51+- stop/abort
      52+- provider and model configuration
      53+- Pi's configured enabled-tool policy
      54+- streaming text and thinking
      55+- tool calls, execution progress, and results
      56+- retries, compaction, and queued work
      57+
      58+## Tool Access
      59+
      60+Pi manages tool access in the first release. Every tool enabled in the selected Pi runtime instance
      61+may run without a T3 Code confirmation prompt. Configure Pi's enabled and disabled tools in Pi; T3
      62+Code does not show its usual runtime-mode selector for Pi.
      63+
      64+## Extensions
      65+
      66+Pi loads the user's normal trusted global and project-local extensions. T3 Code does not install,
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium providers/pi.md:66

      The Extensions section states that Pi loads the user's normal trusted global and project-local extensions, but per ADR 0006-preserve-user-pi-extensions.md every Pi runtime is launched with --no-extensions and only explicitly supplied --extension <path> entries are loaded. This tells users their normal extensions are active when they are actually disabled. Consider correcting this section to describe the --no-extensions launch behavior, or document the rationale if the ADR has since been superseded.

      🤖 Copy this AI Prompt to have your agent fix this:
      In file @docs/providers/pi.md around line 66:
      
      The Extensions section states that Pi loads the user's normal trusted global and project-local extensions, but per ADR `0006-preserve-user-pi-extensions.md` every Pi runtime is launched with `--no-extensions` and only explicitly supplied `--extension <path>` entries are loaded. This tells users their normal extensions are active when they are actually disabled. Consider correcting this section to describe the `--no-extensions` launch behavior, or document the rationale if the ADR has since been superseded.
    4. Approvability

      Verdict: Needs human review

      6 blocking correctness issues found. Diff is too large for automated approval analysis. A human reviewer should evaluate this PR.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).

Sign in to join this conversation.