Skip to content

test(ui): strengthen attach return guards - #1787

Open
terminalchai wants to merge 2 commits into
asheshgoplani:mainfrom
terminalchai:test/1772-attach-follow-cwd-guards
Open

test(ui): strengthen attach return guards#1787
terminalchai wants to merge 2 commits into
asheshgoplani:mainfrom
terminalchai:test/1772-attach-follow-cwd-guards

Conversation

@terminalchai

@terminalchai terminalchai commented Jul 28, 2026

Copy link
Copy Markdown

What problem does this solve?

The attach-return regression coverage could miss two ways the blank-screen race might return: attachWindowCmd had no direct cleanup test, and the source guard neither covered every local attach site nor rejected an inverted follow-CWD gate. Closes #1772.

Why this change

This stays tests-only. It exercises attachWindowCmd.onExit directly, checks all three local attach call sites, and requires the actual disabled-or-nil early-return condition before GetWorkDir.

The issue also noted that no test sets isReloading; current main already covers that in TestShiftReorder_PersistsDuringReload_Issue1582, so this PR does not duplicate it.

User impact

None, internal regression coverage only. Future detach-path regressions should fail during review instead of reaching users.

Evidence

  • GOOS=linux GOARCH=amd64 go test -c ./internal/ui - passed
  • GOOS=linux GOARCH=amd64 go vet ./... - passed
  • GOOS=linux GOARCH=amd64 go build ./... - passed
  • gofmt -l internal/ui/issue1753_detach_return_test.go - clean
  • git diff --check - clean
  • The full sandboxed runtime suite could not complete locally: the Windows host cannot compile the repository's Unix syscall paths, and the local Docker engine terminated during the Linux run. CI remains the runtime verification source.

AI disclosure

  • Human-written
  • AI-assisted (I directed and reviewed it)
  • AI-authored (a model wrote most of it)

Model(s), if AI helped: gpt-5-codex

Prompt / session log (optional): Not published.

What actually bothered you

My human asked: "oss contribution of the day mate"

Checklist

  • Targeted diff: one problem, no unrelated changes
  • Tests added or updated for new behavior
  • Test suite passes sandboxed: HOME=$(mktemp -d) XDG_CONFIG_HOME= XDG_DATA_HOME= XDG_CACHE_HOME= go test ./...
  • If this touches a hot path (list, status, session output, startup, tmux layer): before/after timing evidence included
  • CHANGELOG.md untouched (entries are added at landing)
  • AI-assisted? Disclosed above, with validation evidence, and I can answer questions about the code
  • "Allow edits from maintainers" is enabled

Summary by CodeRabbit

  • Tests
    • Added a new regression test to ensure the attachment state flag is cleared before returning from an attachment command (preventing a blank frame/early exit issues).
    • Strengthened the existing source-level validation to confirm the same on-exit clearing behavior across session attach, window attach, and sandbox terminal attach paths.
    • Tightened follow-CWD gating validation using regex-based source checks, ensuring the early probe path is prevented when follow-CWD is disabled (or when no tmux session is available).

@github-actions github-actions Bot added needs-info ai-authored Primarily authored by an AI agent labels Jul 28, 2026
@github-actions

github-actions Bot commented Jul 28, 2026

Copy link
Copy Markdown

👋 Thanks for the contribution — intake looks complete.

Your PR body carries everything the maintainer's validation pipeline reads first: the problem, the reasoning, the human intent behind it, and an AI-disclosure. It will be applied, built, and tested against main, and you'll get a structured result within about a day. Merges are always human.

gate marker read: ai=authored model=gpt-5-codex intent=yes

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 872c100f-ba04-4f0e-9b31-f0695bcff5c0

📥 Commits

Reviewing files that changed from the base of the PR and between 17c867a and 6306f65.

📒 Files selected for processing (1)
  • internal/ui/issue1753_detach_return_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/ui/issue1753_detach_return_test.go

📝 Walkthrough

Walkthrough

Expanded Issue 1753 regression coverage for window attach cleanup, generalized source checks across attach entry points, and tightened validation of the follow-CWD gate.

Changes

Attach regression coverage

Layer / File(s) Summary
Window attach cleanup test
internal/ui/issue1753_detach_return_test.go
Adds a regression test verifying attachWindowCmd clears isAttaching before Run() returns.
Attach guard validation
internal/ui/issue1753_detach_return_test.go
Extends source-level checks to session, window, and sandbox terminal attach paths, adds brace-block extraction, and validates the follow-CWD early-return gate with a regular expression.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: asheshgoplani

🚥 Pre-merge checks | ✅ 7
✅ Passed checks (7 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title uses Conventional Commits style and accurately describes the test-focused attach return guard changes.
Linked Issues check ✅ Passed The PR covers attachWindowCmd.onExit, all local attach sites, and the follow-CWD gate checks requested by #1772.
Out of Scope Changes check ✅ Passed The changes stay within test coverage improvements and do not introduce unrelated product or behavior changes.
Docstring Coverage ✅ Passed Docstring coverage is 83.33% which is sufficient. The required threshold is 70.00%.
Remote_parity ✅ Passed Tests-only UI change; the new Issue1753 coverage explicitly exercises RemoteSession behavior and no TUI runtime code was altered.
Test_coverage_per_surface ✅ Passed This commit only changes a ui test file and adds regression coverage; it introduces no new feature surface to test across TUI/Web/CLI/remote.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@github-actions github-actions Bot added intake:clean PR/issue passed the intake contract and removed needs-info labels Jul 28, 2026

@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: 2

🤖 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 `@internal/ui/issue1753_detach_return_test.go`:
- Around line 382-414: Extend the attach-path coverage in the test around
attachSites to include the RemoteSession/remoteAttachCmd flow, verifying its
applicable cleanup behavior. If that remote flow intentionally does not use
local onExit/isAttaching cleanup, add a dedicated t.Skip with that rationale
instead of applying the local assertions to it.
- Around line 406-413: Narrow the source assertions in the attach checks over
attachSites and attachSession to the exact command and workDirIfFollowing helper
bodies. Extract those bodies before validating them, then assert that the attach
literal’s onExit callback directly guards GetWorkDir() with
isAttaching.Store(false), preventing unrelated handler code from satisfying the
checks.
🪄 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: 21d1de58-bc4c-4944-a2cb-fcef248439ce

📥 Commits

Reviewing files that changed from the base of the PR and between 580e772 and 17c867a.

📒 Files selected for processing (1)
  • internal/ui/issue1753_detach_return_test.go

Comment thread internal/ui/issue1753_detach_return_test.go
Comment thread internal/ui/issue1753_detach_return_test.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-authored Primarily authored by an AI agent intake:clean PR/issue passed the intake contract

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: cover attachWindowCmd.onExit + the follow-cwd gate (#1764 follow-up)

1 participant