Skip to content

Studio Code Assistant - #2870

Merged
sejas merged 38 commits into
trunkfrom
studio-code-assistant
Apr 20, 2026
Merged

Studio Code Assistant#2870
sejas merged 38 commits into
trunkfrom
studio-code-assistant

Conversation

@sejas

@sejas sejas commented Mar 23, 2026

Copy link
Copy Markdown
Member

Related issues

How AI was used in this PR

Currently mostly vibe-coded with superpowers.

Proposed Changes

  • It adds Studio Code assistant behind a feature flag.
  • Users can interact with Studio Code through CLI process
  • This is a first iteration. We'll add more features as a follow-up such as:
    • Default empty chat
    • Invoking slash commands/skills
    • Switching providers
    • API key authentication
    • Switching sites
    • Save messages in the same session. Currently each message is saved in a separate session
    • Consider streaming responses in future iterations.

Testing Instructions

  • Run ENABLE_STUDIO_CODE_UI=true npm start
  • Go to the assistant tab
  • Ask questions and prompts about your site.
studio-code-assistant.mp4

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?
sejas and others added 8 commits March 22, 2026 21:14
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…l, permission)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add AiEnginePanel to AI settings modal for switching between Studio Code
(local agent) and Studio Assistant (WordPress.com). Modify ContentTabAssistant
to check engine preference and provider availability on mount, rendering
StudioCodeChat when Studio Code is selected and available.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…component

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Remove redundant proc.start() in studioCodeStart IPC handler
  (getOrCreateProcess already starts the process)
- Fix useEffect dependency array to use individual properties
  instead of full selectedSite object reference
- Replace console.warn with console.error in StudioCodeProcess

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Use AbortController to cleanly terminate the cancel listener when
  a turn completes, preventing it from stealing stdin lines
- Add command type validation in parseCommand() to reject unknown types
- Use crypto.randomUUID() for permission request IDs
- Handle cancel commands in waitForCommand() by throwing AbortError

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Create headless-types.ts with HeadlessEvent and HeadlessCommand types
- Add --headless, --site, --site-name, --site-url options to studio ai command
- Route to runHeadlessCommand() when --headless is set

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sejas
sejas marked this pull request as draft March 23, 2026 10:07
@wpmobilebot

wpmobilebot commented Mar 23, 2026

Copy link
Copy Markdown
Collaborator

📊 Performance Test Results

Comparing b3da4f4 vs trunk

app-size

Metric trunk b3da4f4 Diff Change
App Size (Mac) 1439.63 MB 1439.72 MB +0.09 MB ⚪ 0.0%

site-editor

Metric trunk b3da4f4 Diff Change
load 1836 ms 1870 ms +34 ms ⚪ 0.0%

site-startup

Metric trunk b3da4f4 Diff Change
siteCreation 9141 ms 9104 ms 37 ms ⚪ 0.0%
siteStartup 4949 ms 4947 ms 2 ms ⚪ 0.0%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)

sejas and others added 4 commits March 26, 2026 23:23
# Conflicts:
#	apps/cli/commands/ai/index.ts
#	apps/studio/src/components/ai-settings-modal.tsx
#	apps/studio/src/index.ts
#	apps/studio/src/preload.ts
- Resolve CLI ai command: keep both headless and session-persistence options
- Resolve index.ts imports: keep studio-code + add SiteServer, remove deleted setup-wp-server-files
- Resolve preload.ts: keep both studio-code IPC methods and new WordPress skills methods
- Keep ai-settings-modal.tsx (deleted in trunk, needed for studio-code feature)
- Fix authToken access: read from SharedConfig instead of UserData
- Remove unused onOpenSettings prop from studio-code-chat

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sejas
sejas marked this pull request as ready for review April 14, 2026 15:24
sejas and others added 2 commits April 14, 2026 16:41
…nt turn

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…n JSON mode

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sejas
sejas requested review from a team, wesleyfantinel and youknowriad April 14, 2026 17:54
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@@ -357,6 +359,16 @@ const UnauthenticatedView = ( { onAuthenticate }: { onAuthenticate: () => void }
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to access the UI even when I was logged out and it threw an error in a response message. I think we might want to improve this experience by either hiding it behind the login screen or find another alternative:

Image

@katinthehatsite katinthehatsite left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another bit that I found strange (although I understand why it is needed) is that you can type but can't send a message while the assistant is answering. With tools like Claude or Cursor, you can either queue the message or interrupt the ongoing request and send a new message:

Screen.Recording.2026-04-15.at.10.49.03.AM.mov
}

export function studioCodeAbort( _event: IpcMainInvokeEvent, siteId: string ): void {
abortTurn( siteId );

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we have a user facing option to abort a running turn. Should we? (similar comment to the other one I made about not being able to send a message while assistant is thinking)

@@ -0,0 +1,34 @@
// Event types matching the JSON mode output from `studio code --json`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a file that is named the same in apps/studio/src/components/studio-code-types.ts and I am wondering if we should rename them to make them cleaner e.g 👍

  • studio-code-ui-types.ts (the component/renderer types)
  • studio-code-event-types.ts (the CLI wire format types)
@youknowriad

Copy link
Copy Markdown
Contributor

With tools like Claude or Cursor, you can either queue the message or interrupt the ongoing request and send a new message.

Let's track that. I think it's a bug on Studio Code (not just here but also in CLI)

@sejas

sejas commented Apr 15, 2026

Copy link
Copy Markdown
Member Author

With tools like Claude or Cursor, you can either queue the message or interrupt the ongoing request and send a new message.

Let's track that. I think it's a bug on Studio Code (not just here but also in CLI)

Created STU-1574

sejas and others added 3 commits April 15, 2026 21:23
…io Code chat

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
<span className="ltr:pl-2 rtl:pl-2">{ __( 'Build with Telex' ) }</span>
<ArrowIcon />
</MenuItem>
{ showTelexLink && (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH, I don't think we should have this link to Telex.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I'll create a follow-up issue to remove it and we can discuss it there. This PR just keeps intact the experience of Studio Assistant.

adapter: AiOutputAdapter;
initialMessage?: string;
resumeSession?: LoadedAiSession;
resumeSessionId?: string;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the fact we can resume sessions now.

Comment thread apps/cli/commands/ai/index.ts Outdated
Comment thread apps/cli/commands/ai/index.ts Outdated

@wesleyfantinel wesleyfantinel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that this is adding good changes to the headless (--json) mode. I haven’t looked at the studio app changes yet.

sejas and others added 5 commits April 17, 2026 11:58
Splits the two identically-named files so readers can tell at a glance which
defines renderer/UI types and which defines the CLI JSON wire format:
- apps/studio/src/components/studio-code-types.ts -> studio-code-ui-types.ts
- apps/studio/src/modules/studio-code/studio-code-types.ts -> studio-code-event-types.ts

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Two changes from PR #2870 review:

- Throw when --resume-session points at a missing session instead of
  silently creating a fresh one. Silent creation is misleading for
  callers (notably the desktop app, which spawns the CLI with a
  specific session ID) and hides real bugs.
- Call maybeAutoSwitchProvider() once from inside runAgentTurn so every
  mode (JSON, initial message, slash/skill commands, interactive loop)
  consistently re-evaluates provider availability before a turn. The
  initial-message path was previously missing this check.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
# Conflicts:
#	apps/cli/commands/ai/index.ts
#	apps/studio/src/ipc-handlers.ts
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sejas

sejas commented Apr 20, 2026

Copy link
Copy Markdown
Member Author

@wesleyfantinel , @katinthehatsite , I addressed your feedback and added a logout page state. Could you take another look? I would like to merge the PR behind a feature flag and create follow-up issues for the rest of improvements.

@wesleyfantinel
wesleyfantinel self-requested a review April 20, 2026 11:53
@sejas
sejas merged commit cf48391 into trunk Apr 20, 2026
10 checks passed
@sejas
sejas deleted the studio-code-assistant branch April 20, 2026 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

6 participants