Skip to content

chore(ci): restore green engine-smoke after stdio-only bridge cut - #1

Merged
heikeyangle-code merged 11 commits into
mainfrom
pi-native-audit
Sep 7, 2026
Merged

chore(ci): restore green engine-smoke after stdio-only bridge cut#1
heikeyangle-code merged 11 commits into
mainfrom
pi-native-audit

Conversation

@heikeyangle-code

Copy link
Copy Markdown
Owner

CI red at HEAD (5ed4868 removed the WS/CC bridge but left CI/scripts importing deleted modules). This branch: drops dead cc-adapter check, fixes /workspace absolute imports in real-verify suites, deletes dead scripts (setup-launchd/dev-restart/cc-fullstack-e2e), prunes stale root scripts, adds bridge vitest to CI. Hygiene only — native pi chat reconnection follows in subsequent commits.

dsh-mobile added 11 commits September 7, 2026 02:14
HEAD (5ed4868) deleted the WebSocket/CC bridge server and its adapters but left
CI/scripts pointing at the removed modules:
- engine-smoke 'cc-adapter mapping assertions' imported dist/pi-host/cc-adapter.js (deleted) -> red CI
- scripts/real-verify hard-coded the old sandbox path /workspace/pi-x and one
  suite imported the deleted BridgeWebSocketServer

This commit:
- drops the dead cc-adapter check; engine-smoke now also runs the mock-engine
  PiGateway full-flow (e2e-full-flow.mjs, path fixed to repo-relative dist)
- fixes /workspace/pi-x absolute imports in the three surviving real-verify suites
- removes dead scripts (setup-launchd, dev-restart, cc-fullstack-e2e) and prunes
  the matching root package.json scripts (functions/shorebird/doctor leftovers)
- adds a bridge unit-test step to CI so the surviving vitest suite actually runs

Repo hygiene only; no runtime behavior change.
…ines for file-surface ops

Two on-device blockers found in the stdio-only bridge:

1. Home mismatch: pi has no PI_HOME — its agent dir is ~/.pi/agent or
   PI_CODING_AGENT_DIR. The gateway surfaces read/write <piHome>/.pi/agent
   (piAgentFiles) but the engine child inherited only PI_HOME (ignored), so on
   Android (HOME unset) engine settings/models/sessions landed nowhere near the
   files the management UI edits (or failed entirely). Every engine spawn now
   gets PI_CODING_AGENT_DIR=<piHome>/.pi/agent.

2. Every control op spawned an engine first, including pure file-surface ops
   (settings/models/skills/themes/templates/packages/runtime). With the
   synthetic engine-global projectId ('pi-x-engine', relative) that made the
   spawn-time mkdir run against the host cwd — on Android the host cwd is '/',
   so every management op failed EACCES before it could touch files. Surface
   ops now short-circuit (SURFACE_ONLY_OPS) and never start an engine; the
   stdio entry also maps non-absolute project ids into a writable
   <piHome>/engine-global dir for engine-required ops.

Regression tests: file-surface ops succeed with an unspawnable piEntry and
leave the pool empty; get_state on a fake engine echoes PI_CODING_AGENT_DIR
equal to <piHome>/.pi/agent.
…ntroller core

Starts the pi-native data plane (no WebSocket anywhere):
- pi_session_models.dart: session metadata + transcript item model
  (user/assistant/tool-call/tool-result/bash/error) mirroring pi's JSONL &
  wire content blocks (text/thinking/toolCall/images).
- pi_session_files.dart: session dir encoding (pi session-manager semantics),
  metadata scan + history replay straight from <agentDir>/sessions/*.jsonl.
- pi_chat_controller.dart: per-project engine chat over the stdio host —
  prompt/steer on send, abort, switch_session resume, new_session,
  set_session_name; consumes message_start/message_update/message_end,
  toolcall_* (contentIndex assembly), tool_execution_*, bash_execution_update,
  agent_*, compaction/retry/extension_error frames into a live transcript.
- PiHostService: expose launch dirs (piHome/agentDir/workspaces) and add
  controlWithId (caller-chosen request id for bash correlation).
- MainActivity: native extractRuntime also returns workspacesDir.

UI + wiring land next; compile checkpoint via CI.
…e as default

Landing after the native core (session store + chat controller):
- PiSessionsScreen: engine lifecycle state + recent pi sessions (from the
  agent-dir JSONL scan) grouped by project; new conversation creates a
  workspace under the app-private workspaces dir (native extractRuntime now
  returns workspacesDir); resume opens the tapped session file.
- PiChatScreen: transcript rendered 1:1 from pi frames — user/assistant
  bubbles, collapsible thinking, tool-call cards (arguments + streamed
  partial output + result), bash cards, errors; composer send/steer + stop;
  rename + new-conversation actions.
- AdaptiveHomeScreen ('/') now defaults to the pi-native home (pref
  'pi.nativeHome', legacy CC home kept behind legacyHomeOverride) so a fresh
  install lands on the working local-engine flow, not the dead WS surface.
- Pure-Dart tests for session dir encoding, metadata scan and history replay.
…ing literal

build_runner/aot flagged pi_session_files.dart:61 (RegExp ending in $ before
the closing quote parsed as interpolation). decodeProjectDirName was unused,
so drop it instead of escaping.
- FileStat has no existsSync; drop the check (statSync throws when missing)
- ValueNotifier has no listen(); use addListener/removeListener
- _push helper was missing on PiChatController
- assistantMessageEvent frames: type as Map<String,dynamic> before dispatch
- PiToolCallView.name mutable (toolcall_end may arrive before start)
- SelectableText has no overflow param; typed the switch arms (PiChatItem ->
  PiAssistantItem/PiBashItem)
- remove unused constant / dart:ui import
- fileMtimeSafe: FileStat has no existsSync (statSync throws when missing)
- chat controller: local-var promotion for the history load guard
New pi_session_files test caught the mismatch: messageCount now increments
for user/assistant/toolResult/bashExecution entries (pi counts every stored
message), toolResult no longer needs a separate activity-only branch.
…st launch raced

The global EngineInstallGate diagnoses only at app start; a slow host boot
used to let the native home through with no engine installed. PiSessionsScreen
now checks get_engine_versions itself and renders an install CTA with
progress/error feedback.
…untime

Root cause of 'engine never installs on the phone': install_engine runs
`npm install @earendil-works/pi-coding-agent`, but npm exists nowhere on the
device — the bundled bionic node zip ships bin/node+libs only, and the route-A
tools bootstrap has no npm either. Verified by downloading both artifacts:

- scripts/fetch-bionic-node.mjs now also stages termux's standalone npm
  (npm_11.19.1_all.deb, sha256-pinned) next to each abi runtime
  (<abi>/npm, incl. bin/npm-cli.js).
- MainActivity returns npmCli; PiHostRuntime passes PIX_NPM_CLI into the host.
- engine-provisioner defaultNpmInstall runs `node <npm-cli.js>` when
  PIX_NPM_CLI is set (PATH-independent; desktop/CI keep plain npm).
- pi-stdio-entry sets HOME=<piHome> when unset (Android HOME is missing),
  which npm config/cache and git/ssh in the engine bash tools need.

Bionic APK from the bionic-node-runtime workflow now contains the full
first-launch chain: extract node+host+npm → install_engine → engines/current
→ chat.
…rrent resolves

The stdio host resolves the engine entry (engines/current) once at boot; the
first-run flow downloaded the engine but never restarted the host, so every
chat op still tried to spawn an empty entry. PiHostService.restartHost()
kills + respawns the subprocess (generation counter stops the old exit
handler from double-respawning); the auto first-launch gate, the manual
EngineInstallFlow restart button and the sessions-home install CTA all use it.
@heikeyangle-code
heikeyangle-code merged commit 1b9fb76 into main Sep 7, 2026
4 checks passed
@heikeyangle-code
heikeyangle-code deleted the pi-native-audit branch September 7, 2026 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant