Skip to content

feat(pi): wire session commands, provider UI, and docs - #557

Merged
ronak-guliani merged 3 commits into
t3code/add-pi-providerfrom
t3code/add-pi-provider-wiring
Sep 30, 2026
Merged

ronak-guliani merged 3 commits into
t3code/add-pi-providerfrom
t3code/add-pi-provider-wiring

Conversation

@ronak-guliani

@ronak-guliani ronak-guliani commented Sep 29, 2026 •

Copy link
Copy Markdown
Owner

Stacked on #554 (Pi provider core, phases 0-3). Completes phases 7-8 from upstream pingdotgg/t3code#13777, adapted to this fork.

Server wiring (phase 7)

  • provider.sessionCommand WS method + WsRpcGroup entry (packages/contracts/src/rpc.ts).
  • ProviderService.sessionCommand: decode → route → recover stopped sessions → typed unsupported-provider error.
  • ws.ts handler (maps failures to ProviderSessionCommandError), RpcAuthorization operate scope.
  • EnvironmentApi + LocalApi server passthroughs; web wsRpcClient facade entry.
  • Fork notes: resume-cursor persistence needs no change (fork persists sendTurn cursors generically); uploadFeedback-era harness lines, model-manifest.json, and upstream-only integration tests have no local counterpart and were skipped.

Clients (phase 8)

  • client-runtime: parsePiSessionCommand + sessionCommand atom command.
  • Web: Pi icon/picker entry/driver metadata + settings fields, model placeholder, removed Pi-Agent coming-soon entry, ChatComposer direct-run for argumentMode: none, ChatView send interception (copy → clipboard, export → download, share → link toast).
  • Mobile: Pi icon, composer menu filtering + direct-run, onSendMessage(providerCommand) threading, composer-state execution (copy/export/share handoffs), new-task guard, shareTextFile helper.
  • Thinking options need no client change: they flow from the server snapshot descriptors.
  • Docs: docs/providers/pi.md.

Verification

  • Typecheck/lint/fmt clean (one pre-existing warning in untouched GitHubCli.ts).
  • Tests: Pi text-gen (2), session-command parsing (5), contracts args (1), service routing incl. 2 new (40), full server.test.ts incl. 2 new ws tests (109), reactor/reaper suites (184), web ChatView/settings (69+12), mobile threads (280). Live adapter test ported, self-skips without T3_PI_LIVE_MODEL.

Feature captures

PR head at upload: 03ee4709c520028929a28ea62f7205632b07957e. See the testing notes for exercised behavior and limitations; uploading media is not a test result.

preview-snapshot-munctbgy-e5b4484d6341.png

preview-snapshot-muncw1eg-b31b1ae06e25.png

Stacks on the Pi provider core: routes copy/export/share session
commands end to end and exposes Pi across clients.

Server wiring:
- contracts rpc: provider.sessionCommand method + WsRpcGroup entry.
- ProviderService shape + routing impl (decode, route, recover stopped
  sessions, typed unsupported-provider error).
- ws handler with ProviderSessionCommandError mapping; RpcAuthorization
  operate scope; EnvironmentApi/LocalApi server passthroughs.
- Tests: service routing (recover + unsupported), websocket round-trip
  (success + actionable failure), harness stubs, live adapter test
  (opt-in via T3_PI_LIVE_MODEL), PiTextGeneration tests.

Clients:
- client-runtime parsePiSessionCommand + sessionCommand atom command.
- Web: Pi icon/picker/driver metadata/settings fields, model
  placeholder, ChatComposer argumentMode-none direct-run, ChatView
  send interception with copy/export/share handling.
- Mobile: Pi icon, composer menu (hide session cmds without thread,
  direct-run for argumentMode none), ThreadComposer/DetailScreen
  providerCommand threading, composer-state execution with
  copy/share/export handoffs, new-task guard, shareTextFile helper.
- Docs: docs/providers/pi.md; contracts slash-command argument tests.
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:XL labels Sep 29, 2026
Clipboard denial left the Running Pi command toast hanging. Update
the notice in place so the failure is visible and actionable.
@ronak-guliani

Copy link
Copy Markdown
Owner Author

E2E testing notes (real-client pass)

Tested revision: 8e8f525bd7 (stacked branch head; media captured at 03ee4709c5, identical except the copy-notice fix below). Isolated env: pnpm dev --home-dir /tmp/t3code-pi-e2e.AeYwqG, server :14536 / web :6496, real Pi binary 0.99.1 (>= 0.80.5 minimum).

Scenarios exercised

  1. Registration + discovery: Settings → Providers lists Pi / Early Access; toggled on in UI → snapshot became v0.99.1, Authenticated · pi (version probe + ephemeral RPC model/command discovery against the real binary). Settings change persisted across re-pair.
  2. Picker: model picker provider sidebar includes pi; Pi models listed (Pi default, Claude/GPT/Grok/Gemini via Pi); selected Pi default.
  3. Turn lifecycle: new thread in a scratch project, sent "Reply with exactly the word hello and nothing else." → assistant replied hello in 8.3s; context meter shows default · 26.1K tokens; no agent turn dispatched for utility commands.
  4. Session commands: /copy intercepted (no turn); server round-trip succeeded — headless clipboard denied the write (NotAllowedError: Document is not focused, environment limitation, verified directly). /export → Pi session exported success toast with file download.

Observations / limitations

  • Console: 0 app errors during Pi scenarios. Pre-existing noise only: OTLP traces POST 401s (dev telemetry), ERR_ABORTED navigations, and WS auth failures from an expired pairing window before re-pair.
  • Server log: one handled ThreadTitleReactor SchemaError — Pi text-gen returned plain "hello" instead of JSON for the thread title; logged, non-fatal. Worth a follow-up (fallback title when Pi ignores the JSON shape).
  • E2E found and fixed two gaps, both now in this PR: the legacy PROVIDER_SETTINGS static list in SettingsPanels.tsx hid the Pi card (added), and a clipboard failure left the Running notice hanging (now updates in place).
  • Mobile flows (composer menu, share sheet) covered by unit tests only — no on-device pass in this run.
  • /share (gist upload) not exercised — requires gh auth login on the test machine.

Copilot AI 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.

Copilot review overview

🟡 Changes recommended

Unresolved export-path file-overwrite risk and client command/error-handling issues remain.

Review effort: Lite
Findings: 2 High severity · 1 Medium severity · 1 Low severity

Open (4)
What changed in this PR

Adds end-to-end Pi session-command support (/copy, /export, /share) across RPCs, server services, web/mobile clients, provider UI, tests, and documentation.

Changes:

  • Wires authenticated session-command RPCs, authorization, routing, and recovery.
  • Adds Pi command parsing and web/mobile command execution flows.
  • Adds provider settings, icons, documentation, and test coverage.
File Description
packages/​contracts/​src/​server.test.ts Tests command argument validation.
packages/​contracts/​src/​rpc.ts Defines the session-command RPC.
packages/​contracts/​src/​ipc.ts Extends API contracts.
packages/​client-runtime/​src/​state/​threads.ts Exports Pi command parsing.
packages/​client-runtime/​src/​state/​threadCommands.ts Adds the command atom.
packages/​client-runtime/​src/​state/​piSessionCommands.ts Parses Pi commands.
packages/​client-runtime/​src/​state/​piSessionCommands.test.ts Tests parser behavior.
docs/​providers/​pi.md Documents Pi setup and commands.
apps/​web/​src/​session-logic.ts Registers Pi provider options.
apps/​web/​src/​rpc/​wsRpcClient.ts Adds web RPC support.
apps/​web/​src/​localApi.ts Adds local API passthrough.
apps/​web/​src/​environmentApi.ts Adds environment API passthrough.
apps/​web/​src/​components/​settings/​SettingsPanels.tsx Adds Pi settings.
apps/​web/​src/​components/​settings/​ProviderModelsSection.tsx Adds Pi model UI.
apps/​web/​src/​components/​settings/​providerDriverMeta.ts Adds Pi metadata and fields.
apps/​web/​src/​components/​settings/​AddProviderInstanceDialog.tsx Removes the obsolete Pi Agent entry.
apps/​web/​src/​components/​Icons.tsx Updates Pi icons.
apps/​web/​src/​components/​ChatView.tsx Handles web session commands.
apps/​web/​src/​components/​ChatView.browser.tsx Updates browser test mocks.
apps/​web/​src/​components/​chat/​providerIconUtils.ts Maps the Pi icon.
apps/​web/​src/​components/​chat/​ChatComposer.tsx Adds direct command execution.
apps/​server/​src/​ws.ts Routes session-command RPCs.
apps/​server/​src/​server.test.ts Tests WebSocket routing.
apps/​server/​src/​provider/​Services/​ProviderService.ts Extends the service contract.
apps/​server/​src/​provider/​Layers/​ProviderSessionReaper.test.ts Updates provider fixtures.
apps/​server/​src/​provider/​Layers/​ProviderService.ts Implements routing and recovery.
apps/​server/​src/​provider/​Layers/​ProviderService.test.ts Tests routing behavior.
apps/​server/​src/​provider/​Layers/​PiAdapter.live.test.ts Adds opt-in live coverage.
apps/​server/​src/​orchestration/​Layers/​ProviderRuntimeIngestion.test.ts Updates service harnesses.
apps/​server/​src/​orchestration/​Layers/​ProviderCommandReactor.test.ts Updates service fixtures.
apps/​server/​src/​orchestration/​Layers/​CheckpointReactor.test.ts Updates service fixtures.
apps/​server/​src/​git/​Layers/​PiTextGeneration.test.ts Tests Pi text generation.
apps/​server/​src/​auth/​RpcAuthorization.ts Authorizes session commands.
apps/​mobile/​src/​state/​use-thread-composer-state.ts Implements mobile command execution.
apps/​mobile/​src/​lib/​attachmentDownload.ts Adds generated-file sharing.
apps/​mobile/​src/​features/​threads/​use-composer-command-menu.ts Adds mobile direct commands.
apps/​mobile/​src/​features/​threads/​ThreadDetailScreen.tsx Threads provider commands through the UI.
apps/​mobile/​src/​features/​threads/​ThreadComposer.tsx Connects command selection.
apps/​mobile/​src/​features/​threads/​NewTaskDraftScreen.tsx Guards commands on new tasks.
apps/​mobile/​src/​components/​ProviderIcon.tsx Adds the mobile Pi icon.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread apps/server/src/ws.ts
Comment on lines +1646 to +1650
[WS_METHODS.providerSessionCommand]: (input) =>
observeRpcEffect(
WS_METHODS.providerSessionCommand,
Option.match(providerService, {
onNone: () =>
Comment on lines +23 to +24
const outputPath = match[1]?.trim();
return { command: "export", ...(outputPath ? { outputPath } : {}) };
Comment on lines +3432 to +3439
onClick: () =>
void navigator.clipboard?.writeText(result.url).catch(() =>
toastManager.add(
stackedThreadToast({
type: "error",
title: "Could not copy the share link",
}),
),
Comment on lines +230 to +242
/** Save generated text through the same cache and native handoff as downloaded files. */
export async function shareTextFile(input: {
readonly name: string;
readonly mimeType: string;
readonly text: string;
}) {
const cached = await createCachedAttachmentFile(input);
try {
cached.file.write(input.text);
await cached.preview.share(new AbortController().signal);
} finally {
cached.preview.dispose();
}
@ronak-guliani
ronak-guliani merged commit e55002d into t3code/add-pi-provider Sep 30, 2026
5 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants