Skip to content

test(e2e): open and close structured chat tabs with an isolated Claude stand-in - #30011

Merged
Jinwoo-H merged 2 commits into
mainfrom
e2-chat-tabs-e2e
Oct 17, 2026
Merged

Jinwoo-H merged 2 commits into
mainfrom
e2-chat-tabs-e2e

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​322 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​322
Prod 0 0 0 0

ELI5

Adds an automated end-to-end test that opens chat tabs (the structured agent chat view), checks they appear in the tab bar, and closes them. It runs Orca against a tiny stand-in for the Claude command-line tool, and it proves the stand-in is the only Claude program Orca can start, so the test never runs a real Claude install on the machine.

What Changed

Test-only. No app code changes.

  • tests/e2e/structured-chat-tabs-open-close.spec.ts (new). In one hidden Orca run it:
    1. creates two chats on the host, the way the CLI or a paired phone does (agentSession.create), and checks both tabs are visible in the tab bar;
    2. closes the first from its tab's close button and the second from the host (session.tabs.close), and checks each tab leaves the tab bar;
    3. opens a chat from the New tab menu (Claude), checks its tab is visible, and closes it from its close button.
  • tests/e2e/fixtures/structured-claude-stub.cjs (new). A small stand-in for Claude: answers --version, and answers the startup handshake of Claude's streaming JSON protocol if a session is started. Every time it starts, it appends its arguments to a log file the spec reads.

How the stand-in is kept apart from a real Claude, route by route:

  • Command setting. The spec sets Claude's Command setting to the stand-in's absolute path. For chat sessions an absolute Command setting is used as-is or the start is refused (resolveStructuredAgentCommand); it never falls back to a lookup.
  • PATH. Orca is launched with PATH set to only the stand-in's directory plus /usr/bin, /bin, /usr/sbin and /sbin. No user bin directory, Homebrew or npm prefix. The stand-in's wrapper calls node and the script by absolute path, so it needs nothing from PATH to run.
  • Login shell PATH. Orca puts PATH entries from the user's login shell ahead of the launch PATH. HOME is the test's disposable home, so no user rc file runs. On macOS, /etc/paths and /etc/paths.d still apply.
  • Known install directories (~/.local/bin, ~/.claude/local, nvm and other version managers, Homebrew, /usr/local/bin, snap, linuxbrew, nix). The home-relative ones resolve under the disposable HOME, which is empty. Before Orca launches, the spec runs Orca's own lookup (resolveCliCommand) over the system directories, the macOS /etc/paths entries and the install-directory fallback. If that finds any claude, the test skips and Orca is never started.
  • Proof inside the spec. At the end it reads Orca's own PATH and HOME from the running main process, runs the same lookup, and requires the stand-in's exact path. It also requires the stand-in's log to show Orca started it, and every recorded start to be either a --version probe or a launch for one of this test's chats.

Windows: skipped with a reason. The stand-in runs through a POSIX sh wrapper, a .cmd version is unverified, and the full e2e suite runs on Linux CI only.

Why

No e2e test covered chat tabs being opened by the host or the New tab menu and then closed. Unit tests of the tab store cannot catch a tab that the store holds but the tab bar never draws. Other e2e fakes prepend their directory to the inherited PATH. That is not enough here: Orca also looks in fixed install directories and in the login shell's PATH, and a real Claude in any of them could be the one that runs. So this spec narrows PATH, pins the absolute command, refuses to start Orca when a system-wide Claude is present, and checks Orca's own lookup result at the end.

Chat sessions start their Claude process when the first message is sent, and this test sends none. So the stand-in's log records Orca's version probe, which uses the same resolved command, and not a session launch. Sending a message would mean a much larger fake protocol, for behaviour this test is not about.

Linked Issue

N/A (maintainer, test-only).

Visual Proof

N/A: test-only change, no UI or behaviour change.

Testing

On macOS, all hidden (ORCA_BACKGROUND_LAUNCH=1, isolated profile and HOME):

  • Normal build (layout switch off, VITE_EXPOSE_STORE=true pnpm exec electron-vite build --mode e2e && pnpm run build:cli): --repeat-each=5, 5/5 passed.

  • Switch-on build (ORCA_LAYOUT_OWNER=main, confirmed by its build marker file): 1/1 passed.

  • pnpm tc, pnpm run check:code-quality:changed, oxlint on the changed files, and the anti-slop lint all pass.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Security: the test never runs a real Claude, and skips rather than start Orca when one could be reached. Cross-platform: macOS and Linux run it; Windows skips cleanly. SSH, mobile, backwards compatibility, performance: not affected (test-only).

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

Adds a Claude Code stream-JSON stub and a POSIX-only end-to-end test. The test creates structured Claude chats through the host runtime and New tab menu, checks that their tabs appear, closes chats through the tab bar and host runtime, and verifies that recorded launches use the stub for version probes or test sessions.

Priority: ⬇️ Low

Merge Risk: 🔵 Low · up to e757c

The tab test does not yet prove that the created Claude sessions launch. Add a per-session launch assertion before relying on it for that coverage; this is a bounded test gap, not an established production failure.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the added end-to-end test and its purpose: opening and closing structured Claude chat tabs with an isolated stand-in.
Description check Passed The description is complete and relevant. It explains the test scope, implementation, isolation strategy, rationale, platform behavior, validation results, and checklist status. The maintainer-specifi…
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.
Full details: Description check

Explanation

The description is complete and relevant. It explains the test scope, implementation, isolation strategy, rationale, platform behavior, validation results, and checklist status. The maintainer-specific N/A for the linked issue is consistent with the template exception.

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

🧹 Nitpick comments: 1
tests/e2e/structured-chat-tabs-open-close.spec.ts: 1

220-242: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Assert one non-probe launch for each created session.

The current check passes when the log contains only a --version probe. Tab visibility does not prove that the provider launched, because the host publishes the tab before it calls context.wakeDelivery. Require every derived provider ID in the launch log.

Suggested fix
     const providerIds = [first, second, opened!.entityId].map((id) =>
       claudeSessionIdForOrcaSession(id)
     )
-    await expect.poll(() => readStubLaunches(claudeStub.launchLog).length).toBeGreaterThan(0)
+    await expect
+      .poll(() => {
+        const launches = readStubLaunches(claudeStub.launchLog)
+        return providerIds.every((id) => launches.some((args) => args.includes(id)))
+      })
+      .toBe(true)
     for (const args of readStubLaunches(claudeStub.launchLog)) {

ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8d3c52af-c60e-41bc-9037-eb96c6789e87
📥 Commits

Reviewing files that changed from the base of the PR and between 29fa3cf and e757ca0.

📒 Files selected for processing: 2
  • tests/e2e/fixtures/structured-claude-stub.cjs
  • tests/e2e/structured-chat-tabs-open-close.spec.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

@Jinwoo-H

Copy link
Copy Markdown
Contributor Author

@coderabbitai Not adopting the per-session launch check. A chat session starts its Claude process when the first message is sent, and this test sends none. An earlier draft of this spec required each chat's provider id in the stub log and failed after 30 s with only --version entries recorded. The proof here is a different one: Orca's own lookup, run on the main process's PATH and HOME, must return the stub's exact path, and every recorded start must be a version probe or a launch for one of these chats. The PR body explains this under Why.

@Jinwoo-H
Jinwoo-H merged commit 95580d9 into main Oct 17, 2026
37 checks passed
@coderabbitai

coderabbitai Bot commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail
fd '^structured-chat-tabs-open-close\.spec\.ts$'
ast-grep outline tests/e2e/structured-chat-tabs-open-close.spec.ts --items all
sed -n '1,280p' tests/e2e/structured-chat-tabs-open-close.spec.ts

Length of output: 11420


@Jinwoo-H Thanks for clarifying. I withdraw the per-session launch-check suggestion.

The spec sends no messages, so requiring a Claude process for each chat is not appropriate. I verified that it checks the stub’s exact path using Orca’s resolver with the main process’s PATH and HOME. It also checks that each recorded start is a version probe or includes one of the test chats’ provider IDs.

These checks fit the tab lifecycle scope. No additional launch assertion is needed.


✏️ Learnings added
Learnt from: Jinwoo-H
URL: https://github.com/stablyai/orca/pull/30011

Timestamp: 2026-10-17T07:25:44.959Z
Learning: In stablyai/orca, a structured Claude chat session starts its Claude process when the first message is sent, not when the tab is created. The Playwright spec tests/e2e/structured-chat-tabs-open-close.spec.ts tests tab creation, visibility, and closure without sending messages. Do not require a stub launch for each session in this spec. Its isolation checks require Orca's command resolver, using the main process's PATH and HOME, to return the stub's exact path and require each recorded stub start to be a version probe or include one of the test chats' provider IDs. Version-only launch logs are valid for this test.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

You are interacting with an AI system.

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