Skip to content

fix: preserve sessions when pane shells are signaled - #3418

Open
ogulcancelik wants to merge 2 commits into
masterfrom
issue/3415-preserve-signaled-panes
Open

fix: preserve sessions when pane shells are signaled#3418
ogulcancelik wants to merge 2 commits into
masterfrom
issue/3415-preserve-signaled-panes

Conversation

@ogulcancelik

@ogulcancelik ogulcancelik commented Aug 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • checkpoint the intact session before removing a signal-terminated pane
  • conservatively checkpoint unknown exits from live-handoff panes
  • keep that checkpoint when shutdown follows immediately
  • let normal autosave or a newer durable mutation replace the checkpoint

Refs #3415

Testing

  • just check
  • Linux SIGHUP shutdown reproduction repeated 10 times
  • live-handoff SIGHUP shutdown reproduction repeated 10 times
@coderabbitai

coderabbitai Bot commented Aug 30, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 12d319a9-d6a8-4de3-b508-efb26857a8a6

📥 Commits

Reviewing files that changed from the base of the PR and between 0402939 and 60d6a8f.

📒 Files selected for processing (2)
  • src/app/mod.rs
  • src/app/session.rs

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

PaneDied events now include whether a child process exited due to a signal. Signal-caused exits trigger a synchronous session checkpoint before pane cleanup. Shutdown skips saving when that checkpoint is pending, while normal autosaves clear the pending state. Application, headless-server, plugin, and pane-death tests now use the expanded event shape. Linux integration tests verify session preservation after shell signaling and live handoff.

Suggested reviewers: akbash-bot

Merge Risk: 🟡 Moderate · up to 60d6a

The change preserves sessions after signaled pane exits, but a failed checkpoint can still prevent shutdown from retrying the save and leave stale recovery state. Merge should wait for retryable failure handling or explicit owner acceptance of this bounded data-persistence risk.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 69.44% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 36 functions across 10 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: preserving sessions when pane shells receive signals.
Description check ✅ Passed The description directly explains the session checkpointing behavior, shutdown handling, autosave interactions, issue reference, and testing.
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.
  • Fix all pre-merge checks with AI

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.

@kangal-bot kangal-bot added the ai-review Trigger automated AI reviews for pull requests admitted by the PR gate label Aug 30, 2026
@ogulcancelik ogulcancelik added the greptile-review Trigger Greptile review for contributor-approved pull requests label Aug 30, 2026
@ogulcancelik

Copy link
Copy Markdown
Collaborator Author

CodeRabbit’s merge-risk note is intentionally handled by the conservative fallback here. Session writes are atomic, so a failed checkpoint leaves the previous session file untouched. Once the signaled panes have been removed, the shutdown path no longer has the intact state to retry; writing then would overwrite the safest available recovery state with the damaged session.

@greptile-apps

greptile-apps Bot commented Aug 30, 2026

Copy link
Copy Markdown

Greptile Summary

The PR preserves the last intact session snapshot when a pane shell is terminated by a signal, including panes imported through live handoff. It also ensures normal autosaves and newer durable mutations supersede that checkpoint.

  • Adds signal-aware checkpoint intent to pane-death events.
  • Checkpoints immediately before destructive pane removal and coordinates subsequent debounced persistence.
  • Preserves checkpoints during immediate interactive and headless shutdown.
  • Adds direct and live-handoff integration coverage for signal termination followed by shutdown.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
src/app/session.rs Adds the checkpoint lifecycle, replacement rules, and shutdown guard while preserving newer dirty state.
src/app/api.rs Checkpoints eligible tiled panes immediately before pane-death mutation and finalizes the checkpoint afterward.
src/pane.rs Propagates signal status for owned children and conservatively checkpoints imported handoff panes whose exit cause is unknowable.
src/server/headless.rs Uses checkpoint-aware final persistence during headless shutdown.
tests/api_ping.rs Covers signal termination followed by immediate server shutdown.
tests/live_handoff.rs Covers unknown imported-pane exit after live handoff followed by immediate shutdown.

Sequence Diagram

sequenceDiagram
    participant P as Pane runtime
    participant A as App
    participant D as Session storage
    participant S as Shutdown
    P->>A: "PaneDied(checkpoint_session=true)"
    A->>D: Save intact pre-removal snapshot
    A->>A: Remove terminated pane
    alt newer durable mutation
        A->>A: Mark dirty and invalidate checkpoint guard
        S->>D: Save newest session state
    else immediate shutdown
        S->>D: Retain intact checkpoint
    else debounce expires
        A->>D: Persist post-removal state
    end
Loading

Reviews (3): Last reviewed commit: "Merge branch 'master' into issue/3415-pr..." | Re-trigger Greptile

Comment thread src/pane.rs
Comment thread src/app/session.rs Outdated
@ogulcancelik
ogulcancelik force-pushed the issue/3415-preserve-signaled-panes branch from 95ac7c2 to 0402939 Compare August 30, 2026 22:55
Comment thread src/app/session.rs Outdated
@ogulcancelik
ogulcancelik force-pushed the issue/3415-preserve-signaled-panes branch from 0402939 to 60d6a8f Compare August 31, 2026 09:46
@ogulcancelik ogulcancelik removed the greptile-review Trigger Greptile review for contributor-approved pull requests label Aug 31, 2026
@ogulcancelik

Copy link
Copy Markdown
Collaborator Author

@greptileai please re-review the current head

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review Trigger automated AI reviews for pull requests admitted by the PR gate

2 participants