Skip to content

Fix Codex skill preview terminal artifacts - #6940

Merged
Jinwoo-H merged 4 commits into
mainfrom
Jinwoo-H/fix-tui-typing-glitches
Jun 30, 2026
Merged

Jinwoo-H merged 4 commits into
mainfrom
Jinwoo-H/fix-tui-typing-glitches

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • wait for visible local startup-command terminal panes to report a stable grid before spawning the PTY/TUI
  • add a frame-driven startup grid settle helper with focused unit coverage
  • add a real workspace setup-split Codex skill preview repro harness

Tests

  • pnpm exec oxlint src/renderer/src/components/terminal-pane/pty-connection.ts src/renderer/src/components/terminal-pane/terminal-startup-grid-settle.ts src/renderer/src/components/terminal-pane/terminal-startup-grid-settle.test.ts tests/e2e/terminal-codex-skill-preview-artifact-repro.spec.ts
  • pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/terminal-pane/pty-connection.test.ts src/renderer/src/components/terminal-pane/pty-size-reconcile.test.ts src/renderer/src/components/terminal-pane/split-right-white-screen.test.ts src/renderer/src/components/terminal-pane/terminal-startup-grid-settle.test.ts
  • pnpm exec electron-vite build --mode e2e
  • SKIP_BUILD=1 ORCA_E2E_CODEX_SKILL_PREVIEW_REPRO=1 ORCA_E2E_EXPECT_NO_CODEX_SKILL_PREVIEW_ARTIFACTS=1 pnpm run test:e2e:headful -- tests/e2e/terminal-codex-skill-preview-artifact-repro.spec.ts --grep "real Orca repo setup-split"

Made with Orca 🐋


Open in Stage

@ghost

ghost commented Jun 30, 2026 •

Copy link
Copy Markdown

Ready to review this PR? Stage has broken it down into 6 individual chapters for you:

Title
1 Define startup grid settle utility and tests
2 Update types for setup split synchronization
3 Implement startup grid settling in PTY connection
4 Wire setup split state through lifecycle
5 Verify PTY connection stability with tests
6 Add E2E repro for Codex skill artifacts
Open in Stage

Chapters generated by Stage for commit 9b2890e on Jun 30, 2026 10:15pm UTC.

@coderabbitai

coderabbitai Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 7bbb9c98-2da1-48dc-8822-4905c1e73ba4

📥 Commits

Reviewing files that changed from the base of the PR and between 4980fe2 and d24be5f.

📒 Files selected for processing (2)
  • src/renderer/src/components/terminal-pane/pty-connection.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/renderer/src/components/terminal-pane/pty-connection.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection.ts

📝 Walkthrough

Walkthrough

This PR adds waitForStableStartupGrid, a frame-based utility for settling terminal startup-grid dimensions, plus unit tests for stability, readiness-gating, max-frame, null, and cancellation behavior. PTY connection and lifecycle code now pass setup-split direction through startup deps, wait for startup-grid settling before deferred connect in selected startup-command cases, and cancel the pending settle on teardown. Reattach sizing now uses a fresh fit result. A new Playwright/Electron E2E spec reproduces a Codex skill preview terminal artifact and captures screenshots, pane text, and diff evidence.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description includes Summary and Testing, but omits required Screenshots, AI Review Report, Security Audit, and Notes sections. Add the missing template sections, especially screenshots, AI review with cross-platform checks, security audit, and notes.
Docstring Coverage ⚠️ Warning Docstring coverage is 2.70% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main user-facing fix in the PR.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/renderer/src/components/terminal-pane/terminal-startup-grid-settle.ts (1)

84-88: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Document why the first stable grid waits until maxFrames.

This branch intentionally refuses to settle an unchanged initial grid and only falls back at the cap. That behavior is non-obvious enough to read like a bug without a short Why: note here. As per coding guidelines, "When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does."

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: ce6e6653-17fd-4346-9280-6df8f49259f5

📥 Commits

Reviewing files that changed from the base of the PR and between 2c0ac2a and 117144e.

📒 Files selected for processing (4)
  • src/renderer/src/components/terminal-pane/pty-connection.ts
  • src/renderer/src/components/terminal-pane/terminal-startup-grid-settle.test.ts
  • src/renderer/src/components/terminal-pane/terminal-startup-grid-settle.ts
  • tests/e2e/terminal-codex-skill-preview-artifact-repro.spec.ts

Comment on lines +201 to +221
const createdId = await page.evaluate((workspaceName) => {
const state = window.__store?.getState()
const worktree = Object.values(state?.worktreesByRepo ?? {})
.flat()
.find(
(candidate) =>
candidate.displayName === workspaceName || candidate.path.endsWith(workspaceName)
)
return worktree?.id ?? null
}, workspaceName)
if (!createdId) {
throw new Error(`Workspace ${workspaceName} disappeared after creation`)
}
await expect
.poll(() => getActiveWorktreeId(page), {
timeout: 30_000,
message: 'Created real Orca workspace did not become active'
})
.toBe(createdId)
expect(createdId).not.toBe(previousWorktreeId)
return createdId

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.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Register the created worktree for cleanup before later assertions can throw.

createdId is known by Line 211, but cleanup is only registered after createWorkspaceThroughComposer returns. If the active-worktree assertion on Lines 214-220 fails, this real repo worktree is left behind.

Suggested fix
-async function createWorkspaceThroughComposer(page: Page, workspaceName: string): Promise<string> {
+async function createWorkspaceThroughComposer(
+  page: Page,
+  workspaceName: string,
+  onCreated?: (worktreeId: string) => void
+): Promise<string> {
@@
   if (!createdId) {
     throw new Error(`Workspace ${workspaceName} disappeared after creation`)
   }
+  onCreated?.(createdId)
   await expect
@@
-    const worktreeId = await createWorkspaceThroughComposer(orcaPage, workspaceName)
-    createdWorktreeIds.push(worktreeId)
+    const worktreeId = await createWorkspaceThroughComposer(orcaPage, workspaceName, (id) => {
+      createdWorktreeIds.push(id)
+    })

Also applies to: 551-553

Comment on lines +406 to +424
async function waitForPaneVisibleContentChanges(
page: Page,
pane: PaneDescriptor,
expectedChanges: number,
timeoutMs: number
): Promise<number> {
const deadline = Date.now() + timeoutMs
let changes = 0
let previous = await readPaneVisibleContent(page, pane.tabId, pane.ptyId)
while (Date.now() < deadline && changes < expectedChanges) {
await page.waitForTimeout(450)
const next = await readPaneVisibleContent(page, pane.tabId, pane.ptyId)
if (next !== previous) {
changes += 1
previous = next
}
}
return changes
}

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Fail when the expected setup-pane activity never happens.

waitForPaneVisibleContentChanges silently returns too-low counts, so the repro can capture evidence even when the setup pane did not keep changing during preview.

Suggested fix
   while (Date.now() < deadline && changes < expectedChanges) {
@@
   }
+  if (changes < expectedChanges) {
+    throw new Error(
+      `Terminal pane changed ${changes} times before timeout; expected ${expectedChanges}`
+    )
+  }
   return changes
 }

Also applies to: 583-599

Jinwoo-H and others added 2 commits June 30, 2026 18:02
…ng-glitches

# Conflicts:
#	src/renderer/src/components/terminal-pane/pty-connection.ts

@coderabbitai coderabbitai Bot 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/renderer/src/components/terminal-pane/pty-connection.ts (1)

2491-2547: 🩺 Stability & Availability | 🔴 Critical | 🏗️ Heavy lift

Grid-settle wait has no timeout fallback — can hang local startup-command panes forever on broken-rAF environments.

shouldSettleStartupGridBeforeConnect() now gates every visible local startup-command pane (not just setup-split ones) into settleStartupGridBeforeConnect, whose waitForStableStartupGrid is driven purely by requestAnimationFrame. Entering this branch explicitly cancels connectFallbackTimer (the 250ms setTimeout safety net) without re-arming any timer-based fallback for the new wait. The comment a few lines below (connectFallbackTimer = setTimeout(...)) documents exactly why that fallback exists: Why: Wayland/CI compositors can keep timers and CDP responsive while the next rAF never arrives; the terminal must still start its PTY once. In that same scenario, the grid-settle wait now has no analogous escape hatch — if rAF never fires, the PTY never spawns for any visible local startup-command pane.

🐛 Proposed fix: re-arm an independent timeout fallback for the settle wait
   const settleStartupGridBeforeConnect = (connect: () => void): void => {
     startupGridSettleHandle?.cancel()
     let settledSynchronously = false
+    // Why: rAF can stall indefinitely on Wayland/CI compositors (see the
+    // connectFallbackTimer rationale below); without an independent timeout
+    // this wait can hang forever and the PTY never spawns.
+    const settleFallbackTimer = setTimeout(() => {
+      startupGridSettleHandle?.cancel()
+      startupGridSettleHandle = null
+      connect()
+    }, STARTUP_GRID_SETTLE_FALLBACK_MS)
     const handle = waitForStableStartupGrid({
       isAlive: () => !disposed,
       isReadyToSettle: paneStartup?.waitForSetupSplitDirection
         ? isStartupGridReadyForConnect
         : undefined,
       measure: measureStartupGrid,
       onSettled: () => {
+        clearTimeout(settleFallbackTimer)
         settledSynchronously = true
         startupGridSettleHandle = null
         connect()
       },
       requestFrame: (callback) => requestAnimationFrame(callback),
       cancelFrame: (handle) => {
         if (typeof cancelAnimationFrame === 'function') {
           cancelAnimationFrame(handle)
         }
       }
     })
     if (!settledSynchronously) {
       startupGridSettleHandle = handle
     }
   }

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 95cc7986-643f-47d1-8633-9bb127030e15

📥 Commits

Reviewing files that changed from the base of the PR and between 117144e and 4980fe2.

📒 Files selected for processing (6)
  • src/renderer/src/components/terminal-pane/pty-connection-types.ts
  • src/renderer/src/components/terminal-pane/pty-connection.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection.ts
  • src/renderer/src/components/terminal-pane/terminal-startup-grid-settle.test.ts
  • src/renderer/src/components/terminal-pane/terminal-startup-grid-settle.ts
  • src/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/renderer/src/components/terminal-pane/terminal-startup-grid-settle.ts

@Jinwoo-H
Jinwoo-H merged commit 1a3d561 into main Jun 30, 2026
2 checks passed
@Jinwoo-H
Jinwoo-H deleted the Jinwoo-H/fix-tui-typing-glitches branch June 30, 2026 22:29
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
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