Skip to content

Fix CLI progress line deduping for Studio Code#3286

Merged
youknowriad merged 2 commits intotrunkfrom
codex/fix-cli-log-deduping
Apr 29, 2026
Merged

Fix CLI progress line deduping for Studio Code#3286
youknowriad merged 2 commits intotrunkfrom
codex/fix-cli-log-deduping

Conversation

@youknowriad
Copy link
Copy Markdown
Contributor

Summary

  • Preserve the progress update flag from CLI logger callbacks so Studio Code updates the previous loader line instead of appending duplicates
  • Coalesce captured push/pull progress output in captureCommandOutput
  • Add regression coverage for the loader callback path and captured progress output

Testing

  • npm test -- apps/cli/ai/tests/tools.test.ts apps/cli/commands/ai/tests/ai.test.ts
  • Added unit tests covering progress-line replacement behavior

@wpmobilebot
Copy link
Copy Markdown
Collaborator

wpmobilebot commented Apr 29, 2026

📊 Performance Test Results

Comparing da3403b vs trunk

app-size

Metric trunk da3403b Diff Change
App Size (Mac) 1505.37 MB 1505.37 MB +0.00 MB ⚪ 0.0%

site-editor

Metric trunk da3403b Diff Change
load 1799 ms 1790 ms 9 ms ⚪ 0.0%

site-startup

Metric trunk da3403b Diff Change
siteCreation 8090 ms 8087 ms 3 ms ⚪ 0.0%
siteStartup 4945 ms 4945 ms 0 ms ⚪ 0.0%

Results are median values from multiple test runs.

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

@youknowriad youknowriad merged commit a7f5668 into trunk Apr 29, 2026
5 checks passed
@youknowriad youknowriad deleted the codex/fix-cli-log-deduping branch April 29, 2026 19:56
youknowriad added a commit that referenced this pull request May 4, 2026
Brings in 53 commits since the last merge. Conflict resolution + ports:

- `apps/cli/ai/agent.ts`: kept the dual-runtime dispatch from this branch;
  absorbed trunk's drop of `maxTurns` (no longer destructured, no longer
  threaded to runtimes). Body contention with #3272's inline `query()`
  changes (mcpServers, remoteSession, STUDIO_REMOTE_SESSION env detection)
  was resolved by deferring those to the Anthropic runtime layer where the
  `query()` call now lives.
- `apps/cli/ai/runtimes/anthropic/index.ts`: ported #3272's improvements —
  `STUDIO_REMOTE_SESSION` env → `remoteSession` flag → systemPromptOptions
  (the Telegram bridge sets this when it spawns `studio code --json`).
  Dropped maxTurns from query() options to match trunk.
- `apps/cli/ai/runtimes/types.ts`, `apps/cli/ai/runtimes/openai/index.ts`,
  tests: dropped maxTurns from `AgentRuntimeConfig` and all callers.
- `apps/cli/ai/tools.ts` deleted on our side, modified on trunk: deleted
  in resolution. Trunk's #3272 additions were ported into our split-tools
  layout:
    - `apps/cli/ai/tools/screenshot-helpers.ts` (new): shared
      `captureScreenshotPng` + viewport constants.
    - `apps/cli/ai/tools/share-screenshot.ts` (new): the `share_screenshot`
      tool that emits a `media.share` event for the remote-session bridge.
    - `apps/cli/ai/tools/take-screenshot.ts`: refactored onto the shared
      helper; updated description to point at share_screenshot.
    - `apps/cli/ai/tools/index.ts`: registry includes shareScreenshotTool;
      `resolveStudioToolDefinitions` now uses an exclusion-set model so
      both preview-steering and (when not enabled) share_screenshot get
      filtered consistently. `createRemoteSiteTools` includes
      shareScreenshotTool when `isRemoteSessionEnabled()`.
- `apps/cli/ai/tools/utils.ts`: ported #3286's progress-update coalescing
  — `update: true` now overwrites the last progress message in
  `captureCommandOutput` instead of appending.
- `apps/cli/ai/tools/wp-cli.ts`: ported #3264's smarter `--post_content=`
  quote handling (flags after a quoted post_content are now parsed
  correctly) and the typographic-dash rejection that catches
  `‐porcelain` / `–color` etc. before they hit WP-CLI as silent garbage.
- `apps/ui/src/components/session-view/composer/index.tsx`: trunk
  converted Composer to `forwardRef` with a `ComposerHandle.appendDraft`
  imperative method (used by trunk's annotate-toolbar hand-off). Merged
  the forwardRef structure with our composer-owned cross-family swap
  state, dialog, and hooks. Kept trunk's Escape-to-interrupt keydown
  handler and the textareaRef.
- `apps/ui/src/components/session-view/index.tsx`: absorbed trunk's
  annotation handler (`handleAnnotationsDone`), the Annotation type
  import, and the SitePreview `onAnnotationsDone` prop. Dropped the
  unused-by-the-merged-body `useConnector` import.

Verified: typecheck has only the pre-existing #3320 (`@wp-playground` bump)
error in `apply-blueprint-form-values.ts` that's also present on plain
trunk; 1532 tests pass; lint clean; CLI builds.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
youknowriad added a commit that referenced this pull request May 4, 2026
Brings in 53 commits since the last merge. Conflict resolution + ports:

- `apps/cli/ai/agent.ts`: kept the dual-runtime dispatch from this branch;
  absorbed trunk's drop of `maxTurns` (no longer destructured, no longer
  threaded to runtimes). Body contention with #3272's inline `query()`
  changes (mcpServers, remoteSession, STUDIO_REMOTE_SESSION env detection)
  was resolved by deferring those to the Anthropic runtime layer where the
  `query()` call now lives.
- `apps/cli/ai/runtimes/anthropic/index.ts`: ported #3272's improvements —
  `STUDIO_REMOTE_SESSION` env → `remoteSession` flag → systemPromptOptions
  (the Telegram bridge sets this when it spawns `studio code --json`).
  Dropped maxTurns from query() options to match trunk.
- `apps/cli/ai/runtimes/types.ts`, `apps/cli/ai/runtimes/openai/index.ts`,
  tests: dropped maxTurns from `AgentRuntimeConfig` and all callers.
- `apps/cli/ai/tools.ts` deleted on our side, modified on trunk: deleted
  in resolution. Trunk's #3272 additions ported into our split-tools
  layout:
    - `apps/cli/ai/tools/screenshot-helpers.ts` (new): shared
      `captureScreenshotPng` + viewport constants.
    - `apps/cli/ai/tools/share-screenshot.ts` (new): the `share_screenshot`
      tool that emits a `media.share` event for the remote-session bridge.
    - `apps/cli/ai/tools/take-screenshot.ts`: refactored onto the shared
      helper; updated description to point at share_screenshot.
    - `apps/cli/ai/tools/index.ts`: registry includes shareScreenshotTool;
      `resolveStudioToolDefinitions` now uses an exclusion-set model so
      both preview-steering and (when not enabled) share_screenshot get
      filtered consistently. `createRemoteSiteTools` includes
      shareScreenshotTool when `isRemoteSessionEnabled()`.
- `apps/cli/ai/tools/utils.ts`: ported #3286's progress-update coalescing
  — `update: true` now overwrites the last progress message in
  `captureCommandOutput` instead of appending.
- `apps/cli/ai/tools/wp-cli.ts`: ported #3264's smarter `--post_content=`
  quote handling (flags after a quoted post_content are now parsed
  correctly) and the typographic-dash rejection that catches
  `‐porcelain` / `–color` etc. before they hit WP-CLI as silent garbage.
- `apps/ui/src/components/session-view/composer/index.tsx`: trunk
  converted Composer to `forwardRef` with a `ComposerHandle.appendDraft`
  imperative method (used by trunk's annotate-toolbar hand-off). Merged
  the forwardRef structure with our composer-owned cross-family swap
  state, dialog, and hooks. Kept trunk's Escape-to-interrupt keydown
  handler and the textareaRef.
- `apps/ui/src/components/session-view/index.tsx`: absorbed trunk's
  annotation handler (`handleAnnotationsDone`), the Annotation type
  import, and the SitePreview `onAnnotationsDone` prop. Dropped the
  unused-by-the-merged-body `useConnector` import.

Verified: typecheck has only the pre-existing #3320 (`@wp-playground` bump)
error in `apply-blueprint-form-values.ts` that's also present on plain
trunk; 1532 tests pass; lint clean; CLI builds.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

2 participants