Skip to content

fix(pi): use leverage's client field and start sessions with the first prompt - #1

Merged
aripiprazole merged 3 commits into
mainfrom
fix/message-client-field
Oct 14, 2026
Merged

aripiprazole merged 3 commits into
mainfrom
fix/message-client-field

Conversation

@aripiprazole

@aripiprazole aripiprazole commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Purpose

Pi cannot use a session on the current Leverage server. On 3 Oct Leverage changed two message shapes, and Pi still sends and reads the old ones.

  • Messages: Leverage renamed the field that names the sending app from harness to client. Pi requires harness, so it rejects every session read that has a message, never sees its own sends confirmed, and drops teammates' messages. Leverage also ignored Pi's harness: "pi", so nobody saw Pi as the sending app.
  • New sessions: Leverage now starts a session with its first message and refuses one without text or an attachment. Pi created an empty session and sent the prompt afterward, so every new session failed.

Now Pi reads and sends client, and its first prompt (with any images) creates the session.

Before                                   After
session.create  prompt: ""   -> refused  session.create  content: "Map the modules",
session.message harness: "pi"                            attachmentIds, client: "pi"   -> session
read message    no harness   -> rejected read message    client: "codex"  -> "Sent from Codex"

The fake Leverage server in the tests now matches the real one, so these tests fail on main.

Verification

  • Changed only the fake server to send client and refuse an empty create, then ran bun run test on the old code: 9, then 6 tests fail (sends not confirmed, sessions not created).
  • Ran bun run check with the fix: format, lint and typecheck clean, 116 tests pass, build succeeds.
  • Parsed Pi's frames and a message with Leverage's own contract schemas (tlc main bcbd3f5ac). On main: the message fails Pi's schema and the create is refused. With the fix: the message parses, and the server accepts both frames with client: "pi".
  • Ran the real Pi 0.99.1 TUI with each plugin checkout against a local Leverage stack on tlc main (3f0824e24), signed in through the CLI device flow, and checked each step in the database:
    • Pi main: /leverage new and a first prompt fail with "Invalid event" and create no session. Reopening a session fails with "invalid data … (messages.0.harness)".
    • This branch: the first prompt and its image create the session, stored as sent from Pi. A second message is stored as sent from Pi and confirmed. Reopening shows both prompts.

# Conflicts:
#	src/index.ts
#	src/render.ts
#	src/session.ts
#	src/workspace/ui.ts
#	src/workspace/view.ts
@aripiprazole
aripiprazole marked this pull request as ready for review October 14, 2026 02:29
@aripiprazole
aripiprazole added this pull request to the merge queue Oct 14, 2026
Merged via the queue into main with commit c6d68a1 Oct 14, 2026
2 checks passed
@aripiprazole
aripiprazole deleted the fix/message-client-field branch October 14, 2026 02:30
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