Skip to content

fix(ssh): detect fish prompts without timeout fallback#1622

Merged
arnestrickmann merged 1 commit intogeneralaction:mainfrom
jasperan:fix/1597-ssh-fish-prompt-detection
Mar 29, 2026
Merged

fix(ssh): detect fish prompts without timeout fallback#1622
arnestrickmann merged 1 commit intogeneralaction:mainfrom
jasperan:fix/1597-ssh-fish-prompt-detection

Conversation

@jasperan
Copy link
Copy Markdown
Contributor

@jasperan jasperan commented Mar 28, 2026

Summary

  • buffer sanitized prompt output so fish prompts split across PTY chunks are detected immediately
  • keep the existing timeout fallback as a safety net
  • add regression coverage for split prompts, fish greeting output, and the remote ptyIpc init path

Fixes #1597

Test Plan

  • pnpm exec vitest run src/main/utils/__tests__/waitForShellPrompt.test.ts src/test/main/ptyIpc.test.ts
  • pnpm run type-check

Summary by CodeRabbit

  • Bug Fixes

    • Improved shell prompt detection to reliably identify and respond to prompts that arrive in fragmented data chunks, ensuring terminal initialization commands execute immediately upon complete prompt recognition rather than waiting for unnecessary timeout delays.
  • Tests

    • Added comprehensive test coverage for various fragmented prompt detection scenarios across different shell environments.

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 28, 2026

@jasperan is attempting to deploy a commit to the General Action Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 28, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f5a4e0a3-0f4e-4df1-bb05-9b1689018a87

📥 Commits

Reviewing files that changed from the base of the PR and between 668cf9b and 8e1a378.

📒 Files selected for processing (3)
  • src/main/utils/__tests__/waitForShellPrompt.test.ts
  • src/main/utils/waitForShellPrompt.ts
  • src/test/main/ptyIpc.test.ts

📝 Walkthrough

Walkthrough

The changes implement buffered prompt detection in the shell prompt wait mechanism to handle prompts split across multiple PTY data chunks. This fixes delayed prompt recognition for fish shell connections, eliminating the 15-second timeout delay. New tests validate prompt detection when contextual prefixes and prompt tokens arrive in separate chunks.

Changes

Cohort / File(s) Summary
Prompt Detection Logic
src/main/utils/waitForShellPrompt.ts
Refactored to use a rolling, sanitized promptBuffer that accumulates content across chunks instead of testing each chunk independently. Added heuristic check for expected prompt ending characters before regex matching, early returns for empty chunks, and maximum buffer size enforcement to handle split prompt sequences.
Test Coverage
src/main/utils/__tests__/waitForShellPrompt.test.ts, src/test/main/ptyIpc.test.ts
Added two test cases validating prompt detection when content arrives fragmented: bash-style prompts with split contextual prefix and token, and fish shell prompts with greeting text in early chunks and prompt terminator in later chunks. Verify write is called only when full prompt is detected.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

A rabbit hops through buffered streams,
Where prompts arrive in split-up beams,
No fifteen-second fish-shell waits—
The buffer catches split-up states! 🐠✨
Detection flows without delay,
Hooray for chunks that show the way!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: fixing fish prompt detection without timeout fallback, which directly addresses issue #1597.
Linked Issues check ✅ Passed The PR implements the objective from issue #1597: detecting fish prompts reliably by sanitizing buffered output to handle split PTY chunks, eliminating the 15-second timeout delay.
Out of Scope Changes check ✅ Passed All changes are scoped to the prompt detection fix: test additions validating split prompt scenarios and implementation updates to the prompt buffer logic.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@arnestrickmann
Copy link
Copy Markdown
Contributor

Looks great, thanks for addressing this.

@arnestrickmann arnestrickmann merged commit 4cb187d into generalaction:main Mar 29, 2026
3 of 4 checks passed
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.

[bug]: 15-second delay when connecting to SSH remote with fish shell

2 participants