Skip to content

AI chat panel: build watchfaces and apps from a description - #78

Draft
ericmigi wants to merge 1 commit into
mainfrom
claude/agent-chat-panel
Draft

AI chat panel: build watchfaces and apps from a description#78
ericmigi wants to merge 1 commit into
mainfrom
claude/agent-chat-panel

Conversation

@ericmigi

@ericmigi ericmigi commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Adds an AI assistant to the CloudPebble IDE. You describe what you want in the
chat panel; it writes the code, builds it on the existing build farm, installs it
into the emulator already running in your browser tab, screenshots the result and
iterates until it looks right.

Draft: it runs on dev today and has been driven end to end by hand, but it has
not been through review, and there are open items listed at the bottom.

How it fits together

Nothing new was built where something already existed. The agent has no
filesystem, no shell and no Pebble SDK — every action is either an HTTPS call to
CloudPebble's own API or a frame on the emulator's phone websocket, which is the
same channel the IDE's own buttons and installer use.

  • Panel — a third column in the IDE (ide/static/ide/js/agent.js), server
    events over SSE, no new frontend framework.
  • Server (ide/api/agent.py) — mints a scoped token for one project, relays
    a turn to the agent VM, streams events back, and owns the credential storage.
  • Agent VM (cloudpebble-agent/) — the Claude Agent SDK driving MCP tools
    that call back into CloudPebble. Stateless; the transcript lives in the
    database.

The scoped token is the security boundary: it is minted per turn for a single
project, accepted by a hand-picked list of views, and refused for every sibling
project. ide/tests/test_agent_api.py covers that boundary specifically.

What a user can do

Bring their own model — Claude subscription (browser sign-in or claude setup-token), an Anthropic key, or an OpenRouter key for anything else. Without
one they get a free shared tier: a cheap text-only model plus a vision describer,
so it still verifies its own screenshots.

The agent can do what the IDE can: source files across every target (C, pkjs,
Alloy embeddedjs), resources, binary assets, project settings including npm
dependencies, builds, installs, screenshots, logs, and — as of the last commits —
pressing the watch buttons to drive an app it has written.

Evidence

Two rounds of end-to-end testing as a non-coding user, written up in
AGENT_E2E_RUN.md: four projects built through the browser on the free tier —
two watchfaces (one animated) and two apps (one pulling live data from a public
API). Both rounds found real defects, all fixed in this branch.

Not included, on purpose

  • Touch input. Emery and gabbro have touchscreens, but touch reaches the
    emulator as VNC pointer events rather than over the control channel these
    tools use.
  • GitHub sync, app-store publishing, project interdependencies, deletion and
    ownership transfer — each reaches outside the single project a token is for.
  • Anthropic browser sign-in is off unless AGENT_ANTHROPIC_OAUTH_CLIENT_ID is
    set, which it is not in production. See the comment in ide/api/agent.py.

Known open items

  • One emulator per user, shared across projects: two projects open at once
    overwrite each other's installed app. Pre-existing, but the agent makes it easy
    to hit.
  • The relay is a thread in a web worker, so a deploy interrupts in-flight turns.
    Startup now releases them with a message saying "continue" resumes; moving the
    relay to celery would remove the interruption.
  • No way to start a second conversation on a project.
  • The transcript replays in full on every page load.

Config

Off unless AGENT_ENABLED_USERS names someone. Needs AGENT_URL and
AGENT_AUTH_HEADER for the agent service; the free tier needs AGENT_FREE_*
and AGENT_VISION_*. No secrets are committed — every key is read from the
environment.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Vznsfu5P4sCmohtJCKJU2f

You describe what you want in a panel beside the editor; it writes the code,
builds it on the existing build farm, installs it into the emulator already
running in your browser tab, screenshots the result, and iterates until it looks
right.

Nothing new was built where something already existed. The agent has no
filesystem, no shell and no Pebble SDK: every action is either an HTTPS call to
CloudPebble's own API or a frame on the emulator's phone websocket -- the same
channel the IDE's own install button and emulator buttons already use. The
websocket framing was verified against a real emulator before any of this was
written.

Three pieces:

  * The panel (ide/static/ide/js/agent.js) -- a third IDE column, server events
    over SSE, no new frontend dependency.
  * The server (ide/api/agent.py) -- mints a token scoped to one project, relays
    a turn to the agent service, streams events back, stores credentials.
  * The agent (cloudpebble-agent/) -- the Claude Agent SDK driving MCP tools that
    call back into CloudPebble. Stateless: the transcript lives in the database,
    so a turn can be resumed from anywhere.

The scoped token is the security boundary of the feature. It is minted per turn
for a single project, accepted by a hand-picked list of views, and refused for
every sibling project; ide/tests/test_agent_api.py exists mostly to hold that
line. Two pre-existing IDOR holes in the resource views were found and closed
while opening them to the agent.

Users bring their own model -- a Claude subscription, an Anthropic key, or an
OpenRouter key for anything else -- or fall back to a free shared tier. That tier
is a text-only model plus a vision describer rather than a weak vision model: a
model that cannot see is told so and behaves honestly, whereas one handed an
image it cannot read invents a description and edits code against it.

The agent can do what the IDE can: source files across every target (C, pkjs,
Alloy embeddedjs), resources, binary assets, project settings including npm
dependencies, builds, installs, screenshots, logs, and pressing the watch buttons
to drive an app it has written.

Two rounds of end-to-end testing as a user who cannot code, written up in
AGENT_E2E_RUN.md: four projects built entirely through the browser on the free
tier -- two watchfaces, one of them animated, and two apps, one pulling live data
from a public API. Both rounds found real defects and all of them are fixed here.

Deliberately absent: touch input (it reaches the emulator as VNC pointer events,
not over this control channel), and anything that reaches outside the one project
a token is for -- GitHub sync, publishing, interdependencies, deletion, ownership.
Anthropic browser sign-in stays off unless a client id is configured, which it is
not in production.

Off unless AGENT_ENABLED_USERS names someone. Every key is read from the
environment; none is committed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vznsfu5P4sCmohtJCKJU2f
@ericmigi
ericmigi force-pushed the claude/agent-chat-panel branch from 3e8ee79 to 8651988 Compare August 8, 2026 18:49
@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown

Code Coverage

Package Line Rate Branch Rate Complexity Health
js 0% 16% 0
js.ib 0% 0% 0
js.ib.layers 0% 0% 0
js.libpebble 0% 0% 0
Summary 0% (15 / 14919) 10% (7 / 68) 0

@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown

Code Coverage

Package Line Rate Complexity Health
. 0% 0
apptools 32% 0
auth 32% 0
cloudpebble 89% 0
ide 56% 0
ide.api 40% 0
ide.management 100% 0
ide.management.commands 0% 0
ide.models 78% 0
ide.tasks 55% 0
ide.utils 80% 0
ide.utils.sdk 58% 0
ide.views 48% 0
qr 57% 0
root 68% 0
utils 58% 0
Summary 52% (3386 / 6574) 0

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