Add regression tests for issue #1362: panic on empty directory launch#1364
Open
Add regression tests for issue #1362: panic on empty directory launch#1364
Conversation
Add 8 regression tests covering scenarios that could trigger the panic reported in #1362 (unwrap on None when buffer missing from self.buffers): - Empty directory launch (basic + full startup sequence) - Stale workspace with all files deleted (single + split view) - Mixed existing/deleted files in workspace - Dead terminal in workspace - Parent directory workspace isolation from subdirectory - Remount scenario (delete all + recreate empty dir) The existing fix from #1278 (guard in restore_split_view_state) handles all reproducible scenarios. The exact trigger for #1362 appears to be environment-specific (possibly stale workspace files on the user's system for /mnt/* paths). https://claude.ai/code/session_01TQ3KUMX2wRLR9fvXfUsXAH
Expand the test coverage with: - Manually crafted split workspace JSON with all-deleted files - Backward-compat workspace format (open_files) with deleted files - Direct close_buffer on initial buffer → verify replacement works All 11 regression tests pass. The #1278 fix correctly handles every workspace restore scenario tested. The exact trigger for #1362 appears to require environment-specific conditions not reproducible in tests. https://claude.ai/code/session_01TQ3KUMX2wRLR9fvXfUsXAH
Test the editor on a separate ext4 filesystem mounted under /mnt: - Fresh launch from a loop-mounted directory - Stale workspace after unmount+remount (reformatted filesystem) Both tests pass - the separate filesystem boundary does not trigger the panic. Tests skip gracefully when not running as root. https://claude.ai/code/session_01TQ3KUMX2wRLR9fvXfUsXAH
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds comprehensive regression tests for issue #1362, which caused the editor to panic when launching from an empty directory or when workspace files were deleted. The tests ensure the editor handles various edge cases gracefully without panicking during render.
Changes
test_no_panic_launching_in_empty_directory: Tests basic startup in an empty directory with minimal operations (process async messages + render)
test_no_panic_full_startup_in_empty_directory: Tests the full production startup sequence (workspace restore → file explorer → process messages → render) in a fresh directory
test_no_panic_when_workspace_references_deleted_files: Tests workspace restore when referenced files no longer exist, ensuring orphan cleanup doesn't remove buffers still referenced by the split manager
test_no_panic_when_split_workspace_references_deleted_files: Tests the split restoration path with multiple panes when all referenced files are deleted
test_no_panic_when_workspace_has_dead_terminal: Tests workspace restore when a terminal split can't be recreated (terminal process exited)
test_no_panic_parent_workspace_does_not_affect_subdirectory: Tests that workspaces are properly isolated per directory and a parent directory's workspace doesn't interfere with subdirectory launches
test_no_panic_after_remount_empty_directory: Tests the scenario where a directory is unmounted and remounted empty (simulating mount/unmount cycles), using the full
startup()helpertest_no_panic_when_workspace_has_mix_of_existing_and_deleted_files: Tests workspace restore with partial file loss (some files exist, others deleted)
Implementation Details
All tests follow a consistent pattern:
The tests exercise different code paths in workspace restoration, orphan cleanup, and the render pipeline to ensure robustness across various edge cases.
https://claude.ai/code/session_01TQ3KUMX2wRLR9fvXfUsXAH