Skip to content

fix(pty): avoid exiting ordinary fish shells - #1102

Open
ShiroKSH wants to merge 1 commit into
crynta:mainfrom
ShiroKSH:fix/fish-conf-d-guard
Open

fix(pty): avoid exiting ordinary fish shells#1102
ShiroKSH wants to merge 1 commit into
crynta:mainfrom
ShiroKSH:fix/fish-conf-d-guard

Conversation

@ShiroKSH

@ShiroKSH ShiroKSH commented Aug 1, 2026

Copy link
Copy Markdown

What

Return from the globally sourced Fish integration file instead of exiting the whole shell when Terax integration is not active.

Why

Opening a Terax Fish terminal installs terax.fish in Fish's global conf.d directory. A later ordinary Fish shell sources that file without TERAX_TERMINAL; the former exit 0 terminates that shell before it can run user commands or configuration.

How

Use Fish's return in the two guard branches, then exercise an ordinary fish --no-config process in the existing Fish harness.

Testing

  • pnpm lint exits successfully; the repository reports 103 existing warnings in untouched frontend files
  • pnpm check-types
  • pnpm test (547 tests)
  • cargo clippy --all-targets --locked -- -D warnings
  • cargo nextest run --locked (276 tests)
  • git diff --check
  • Added Fish regression harness; Linux CI executes it with Fish installed

Screenshots / GIFs

Not applicable. No UI change.

Notes for reviewer

The guards still skip all Terax prompt setup outside a Terax terminal. They now leave the calling Fish shell running.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed shell initialization so sourcing the configuration no longer closes ordinary Fish sessions.
    • Improved handling when terminal-specific settings are unavailable or have already been loaded.
  • Tests

    • Added coverage confirming standard shell sessions remain active during initialization.

@ShiroKSH
ShiroKSH requested a review from crynta as a code owner August 1, 2026 17:52
@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The Fish initialization script now returns from sourced execution when guards fail. Tests verify that ordinary shells survive before running terminal-specific prompt checks.

Changes

Fish initialization behavior

Layer / File(s) Summary
Sourced guard behavior and validation
src-tauri/src/modules/pty/scripts/init.fish, src-tauri/src/modules/pty/scripts/init.test.fish
init.fish uses return instead of exit 0 for terminal and hook guards. The test first checks ordinary-shell survival, then enables TERAX_TERMINAL for terminal-specific checks.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title uses valid Conventional Commits syntax and accurately describes the Fish shell exit behavior fix.
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.

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

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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src-tauri/src/modules/pty/scripts/init.test.fish`:
- Around line 3-6: Update the child Fish command in the ordinary-shell check
around `init.fish` so it exits immediately when `source $argv[1]` fails, before
emitting `ordinary-shell-survived`; keep the existing output assertion and
environment setup unchanged.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 1f13c3d5-1650-4752-a3b5-b6eaa0ac8271

📥 Commits

Reviewing files that changed from the base of the PR and between 70bfbde and 0114e7a.

📒 Files selected for processing (2)
  • src-tauri/src/modules/pty/scripts/init.fish
  • src-tauri/src/modules/pty/scripts/init.test.fish

Comment on lines +3 to +6
set -l ordinary (env -u TERAX_TERMINAL fish --no-config -c 'source $argv[1]; echo ordinary-shell-survived' -- "$script_dir/init.fish")
test "$ordinary" = ordinary-shell-survived; or exit 1

set -gx TERAX_TERMINAL 1

Copy link
Copy Markdown

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 the child when source fails.

The assertion checks only the captured output. Fish can continue to echo ordinary-shell-survived after source returns a non-zero status, so a broken init.fish can pass this check. Make the child exit before printing the sentinel:

Proposed test hardening
- set -l ordinary (env -u TERAX_TERMINAL fish --no-config -c 'source $argv[1]; echo ordinary-shell-survived' -- "$script_dir/init.fish")
+ set -l ordinary (env -u TERAX_TERMINAL fish --no-config -c 'source $argv[1]; or exit 1; echo ordinary-shell-survived' -- "$script_dir/init.fish")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
set -l ordinary (env -u TERAX_TERMINAL fish --no-config -c 'source $argv[1]; echo ordinary-shell-survived' -- "$script_dir/init.fish")
test "$ordinary" = ordinary-shell-survived; or exit 1
set -gx TERAX_TERMINAL 1
set -l ordinary (env -u TERAX_TERMINAL fish --no-config -c 'source $argv[1]; or exit 1; echo ordinary-shell-survived' -- "$script_dir/init.fish")
test "$ordinary" = ordinary-shell-survived; or exit 1
set -gx TERAX_TERMINAL 1
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src-tauri/src/modules/pty/scripts/init.test.fish` around lines 3 - 6, Update
the child Fish command in the ordinary-shell check around `init.fish` so it
exits immediately when `source $argv[1]` fails, before emitting
`ordinary-shell-survived`; keep the existing output assertion and environment
setup unchanged.

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