Skip to content

fix: prevent home shell session crash#183

Merged
Astro-Han merged 1 commit intodevfrom
codex/fix-home-shell-switch
Apr 23, 2026
Merged

fix: prevent home shell session crash#183
Astro-Han merged 1 commit intodevfrom
codex/fix-home-shell-switch

Conversation

@Astro-Han
Copy link
Copy Markdown
Owner

@Astro-Han Astro-Han commented Apr 23, 2026

Summary

Fix the renderer crash when shell mode starts from the new session home. The sidebar session row now renders its status indicator with a plain conditional helper instead of a Solid Switch that can evaluate with no matching branch during the new-session store flush. Added e2e coverage for the home shell path.

Why

PR #174 covered shell rendering inside an existing session, but the home path still crashed after typing ! and submitting a command because creating the session also inserts a sidebar row with a transient empty indicator state. This PR fixes that remaining path.

Related Issue

Fixes #182. Follow-up to PR #174.

How To Verify

bun --cwd packages/app test:e2e e2e/prompt/prompt-shell.spec.ts --project=chromium --grep "new session home"
bun --cwd packages/app test:e2e e2e/prompt/prompt-shell.spec.ts --project=chromium
bun --cwd packages/app typecheck
git diff --check

Screenshots or Recordings

Not applicable. This fixes a crash path without changing visible UI.

Checklist

  • I linked the related issue, or stated why there is no issue
  • This PR has type, scope, and priority labels, or I requested maintainer labeling
  • I listed the relevant verification steps, including tests when behavior changed
  • I manually checked visible UI or copy changes when needed, with screenshots or recordings
  • I considered macOS and Windows impact for desktop, packaging, updater, signing, paths, shell, or permissions changes
  • I called out docs, release notes, dependencies, permissions, credentials, deletion behavior, or generated/local file changes when relevant
  • I am targeting dev, and my PR title and commit messages use Conventional Commits in English

Summary by CodeRabbit

  • Tests

    • Added new end-to-end test coverage for shell mode, validating shell command execution and output verification in session workflows.
  • Refactor

    • Simplified session status indicator logic for improved code maintainability.

@Astro-Han Astro-Han added bug Something isn't working P2 Medium priority app Application behavior and product flows labels Apr 23, 2026
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new E2E test for shell mode session initialization and refactors the sidebar session indicator by replacing a SolidJS Switch component with a function. A review comment suggests using createMemo for the indicator to prevent unnecessary re-renders and potential UI flickering.

Comment thread packages/app/src/pages/layout/sidebar-items.tsx
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 23, 2026

📝 Walkthrough

Walkthrough

This pull request adds e2e test coverage for shell mode workflow and refactors session status indicator rendering. The e2e test starts a new session directly from home, executes shell commands, validates output, and ensures no renderer crashes occur. The sidebar component replaces Switch/Match conditional logic with a helper function while maintaining identical behavior.

Changes

Cohort / File(s) Summary
E2E Test Coverage
packages/app/e2e/prompt/prompt-shell.spec.ts
Introduces new e2e test for shell mode that captures page errors, runs platform-specific shell commands, polls for bash tool results, and validates command output includes README.md. Asserts no "switchFunc(...) is not a function" renderer crash occurs.
Session Indicator Refactor
packages/app/src/pages/layout/sidebar-items.tsx
Refactors session status indicator rendering from Solid's Switch/Match conditional tree into a single indicator() helper function, preserving decision order: isWorkinghasPermissionshasErrorunseenCount()null.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Possibly related PRs

Suggested labels

P1

Poem

🐰 A shell test hops along,
No switch crashes in the throng,
The sidebar's cleaner now,
One function helps us know-how,
Quality blooms where tests belong!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: prevent home shell session crash' directly addresses the main change—fixing a renderer crash in shell mode. It is clear, specific, and follows Conventional Commits format.
Description check ✅ Passed The PR description comprehensively covers all required template sections: Summary, Why, Related Issue, How To Verify with specific commands, Screenshots/Recordings rationale, and a fully completed checklist.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-home-shell-switch

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/app/e2e/prompt/prompt-shell.spec.ts`:
- Around line 135-136: The test creates a session via project.shell(cmd) and
assigns it to sessionID outside the withSession fixture but never registers it
for teardown; call project.trackSession(sessionID, directory?) immediately after
the session is created (and if you created a temp directory for the session call
project.trackDirectory(directory)) so the test harness can clean up resources;
locate the session creation around project.shell in prompt-shell.spec.ts and add
the trackSession/trackDirectory calls referencing sessionID and the directory
used.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 22b74016-03ed-4c8f-bce2-ae7d0aa98e41

📥 Commits

Reviewing files that changed from the base of the PR and between 53e5d56 and 7f4f007.

📒 Files selected for processing (2)
  • packages/app/e2e/prompt/prompt-shell.spec.ts
  • packages/app/src/pages/layout/sidebar-items.tsx
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: unit-windows-desktop
  • GitHub Check: unit-windows-opencode-server-tools
  • GitHub Check: unit-windows-opencode-session
  • GitHub Check: unit-windows-opencode-config-project
🧰 Additional context used
📓 Path-based instructions (2)
packages/app/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (packages/app/AGENTS.md)

Always prefer createStore over multiple createSignal calls in SolidJS

Files:

  • packages/app/e2e/prompt/prompt-shell.spec.ts
  • packages/app/src/pages/layout/sidebar-items.tsx
packages/app/e2e/**/*.spec.ts

📄 CodeRabbit inference engine (packages/app/e2e/AGENTS.md)

packages/app/e2e/**/*.spec.ts: Import test utilities from ../fixtures instead of @playwright/test
Test files should be named with the pattern feature-name.spec.ts
Use lowercase, descriptive test names (e.g., 'sidebar can be toggled')
Use camelCase for variable names in tests
Use SCREAMING_SNAKE_CASE for constants in tests
Use fixture-managed cleanup with withSession(sdk, title, callback) for temporary sessions instead of calling sdk.session.delete(...) directly
Prefer the project fixture for tests that need a dedicated project with LLM mocking
Use data-component, data-action, or semantic roles for selectors instead of CSS class names or IDs
Use modKey from utils for cross-platform keyboard shortcuts (Meta on Mac, Control on Linux/Windows)
In terminal tests, type through the browser using runTerminal() and waitTerminalReady() instead of writing to the PTY through the SDK
Never use wall-clock waits like page.waitForTimeout(...) to make a test pass
Wait on observable state with expect(...), expect.poll(...), or existing helpers instead of assuming work is finished after an action
Use locator assertions like toBeVisible(), toHaveCount(0), and toHaveAttribute(...) for normal UI state verification
Use expect.poll(...) for probing mock or backend state rather than transient DOM visibility
Prefer fluent helpers and drivers when they make intent obvious and reduce locator-heavy noise in tests
Use direct locators when the interaction is simple and a helper would not add clarity
When validating routing, assert against canonical or resolved workspace slugs using shared helpers from ../actions to account for Windows canonicalization
Test one feature per test file
Call project.trackSession(sessionID, directory?) and project.trackDirectory(directory) for any resources created outside the fixture so teardown can clean them up

Files:

  • packages/app/e2e/prompt/prompt-shell.spec.ts
🧠 Learnings (9)
📚 Learning: 2026-04-20T14:36:04.099Z
Learnt from: CR
Repo: Astro-Han/pawwork PR: 0
File: packages/app/e2e/AGENTS.md:0-0
Timestamp: 2026-04-20T14:36:04.099Z
Learning: Applies to packages/app/e2e/**/*.spec.ts : In terminal tests, type through the browser using `runTerminal()` and `waitTerminalReady()` instead of writing to the PTY through the SDK

Applied to files:

  • packages/app/e2e/prompt/prompt-shell.spec.ts
📚 Learning: 2026-04-22T08:49:44.563Z
Learnt from: Astro-Han
Repo: Astro-Han/pawwork PR: 126
File: packages/desktop-electron/src/main/index-sidecar-source.test.ts:3-11
Timestamp: 2026-04-22T08:49:44.563Z
Learning: In `packages/desktop-electron/src/main/index-sidecar-source.test.ts` (Astro-Han/pawwork), the test intentionally uses `expect(source).toContain` / `expect(source).not.toContain` string matching against the raw `index.ts` source text as a lightweight sidecar contract guard. The maintainer has explicitly chosen not to introduce an AST parser (e.g., `babel/parser` or acorn) for this purpose. Do not flag these string-based assertions as fragile or suggest converting them to AST-based matching.

Applied to files:

  • packages/app/e2e/prompt/prompt-shell.spec.ts
📚 Learning: 2026-04-20T14:36:04.099Z
Learnt from: CR
Repo: Astro-Han/pawwork PR: 0
File: packages/app/e2e/AGENTS.md:0-0
Timestamp: 2026-04-20T14:36:04.099Z
Learning: Applies to packages/app/e2e/**/*.spec.ts : Test one feature per test file

Applied to files:

  • packages/app/e2e/prompt/prompt-shell.spec.ts
📚 Learning: 2026-04-20T14:36:04.099Z
Learnt from: CR
Repo: Astro-Han/pawwork PR: 0
File: packages/app/e2e/AGENTS.md:0-0
Timestamp: 2026-04-20T14:36:04.099Z
Learning: Applies to packages/app/e2e/**/*.spec.ts : Prefer fluent helpers and drivers when they make intent obvious and reduce locator-heavy noise in tests

Applied to files:

  • packages/app/e2e/prompt/prompt-shell.spec.ts
📚 Learning: 2026-04-20T14:36:04.099Z
Learnt from: CR
Repo: Astro-Han/pawwork PR: 0
File: packages/app/e2e/AGENTS.md:0-0
Timestamp: 2026-04-20T14:36:04.099Z
Learning: Applies to packages/app/e2e/**/*.spec.ts : Use fixture-managed cleanup with `withSession(sdk, title, callback)` for temporary sessions instead of calling `sdk.session.delete(...)` directly

Applied to files:

  • packages/app/e2e/prompt/prompt-shell.spec.ts
📚 Learning: 2026-04-20T14:36:04.099Z
Learnt from: CR
Repo: Astro-Han/pawwork PR: 0
File: packages/app/e2e/AGENTS.md:0-0
Timestamp: 2026-04-20T14:36:04.099Z
Learning: Applies to packages/app/e2e/**/*.spec.ts : Test files should be named with the pattern `feature-name.spec.ts`

Applied to files:

  • packages/app/e2e/prompt/prompt-shell.spec.ts
📚 Learning: 2026-04-20T14:36:04.099Z
Learnt from: CR
Repo: Astro-Han/pawwork PR: 0
File: packages/app/e2e/AGENTS.md:0-0
Timestamp: 2026-04-20T14:36:04.099Z
Learning: Applies to packages/app/e2e/**/*.spec.ts : Use lowercase, descriptive test names (e.g., 'sidebar can be toggled')

Applied to files:

  • packages/app/e2e/prompt/prompt-shell.spec.ts
📚 Learning: 2026-04-20T14:36:04.099Z
Learnt from: CR
Repo: Astro-Han/pawwork PR: 0
File: packages/app/e2e/AGENTS.md:0-0
Timestamp: 2026-04-20T14:36:04.099Z
Learning: Applies to packages/app/e2e/**/*.spec.ts : Call `project.trackSession(sessionID, directory?)` and `project.trackDirectory(directory)` for any resources created outside the fixture so teardown can clean them up

Applied to files:

  • packages/app/e2e/prompt/prompt-shell.spec.ts
📚 Learning: 2026-04-20T14:36:04.099Z
Learnt from: CR
Repo: Astro-Han/pawwork PR: 0
File: packages/app/e2e/AGENTS.md:0-0
Timestamp: 2026-04-20T14:36:04.099Z
Learning: Applies to packages/app/e2e/**/*.spec.ts : Use `expect.poll(...)` for probing mock or backend state rather than transient DOM visibility

Applied to files:

  • packages/app/e2e/prompt/prompt-shell.spec.ts
🔇 Additional comments (1)
packages/app/src/pages/layout/sidebar-items.tsx (1)

104-127: Indicator refactor is solid and preserves behavior.

The new helper keeps status precedence clear and safely avoids the prior Switch rendering edge case while keeping null fallback behavior explicit.

Comment thread packages/app/e2e/prompt/prompt-shell.spec.ts
@Astro-Han Astro-Han merged commit 5e1a9c2 into dev Apr 23, 2026
27 checks passed
@Astro-Han Astro-Han deleted the codex/fix-home-shell-switch branch April 23, 2026 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app Application behavior and product flows bug Something isn't working P2 Medium priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Shell-mode any command triggers renderer Switch crash (beyond #174)

1 participant