Skip to content

fix: skip session upload from an empty directory or $HOME - #1113

Merged
norrietaylor merged 1 commit into
mainfrom
inbox-patch/skip-upload-empty-or-home-ea92eefc48f70840
Jul 31, 2026
Merged

fix: skip session upload from an empty directory or $HOME#1113
norrietaylor merged 1 commit into
mainfrom
inbox-patch/skip-upload-empty-or-home-ea92eefc48f70840

Conversation

@gominimal-aw-bot

@gominimal-aw-bot gominimal-aw-bot Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Routing-Key: inbox-route/I_kwDOSUhdos8AAAABK34wfQ

min session activate streams the project directory into the new session's workspace, but the upload gate only checked whether the directory was a VCS root. From an empty directory it prompted to upload nothing; from $HOME a single Enter uploaded the whole home tree; and a $HOME that was itself a VCS root uploaded with no prompt at all.

This adds an is_empty_or_home predicate and, ahead of the non-VCS-root confirmation, skips the upload without prompting for an empty directory or $HOME — even when $HOME holds files or is a VCS root — printing Starting with an empty box (nothing here to sync) to stderr while the session id stays the only stdout line. An explicit --sync tarball still uploads them as the escape hatch; --sync now records whether it was passed so the deliberate flag can be told from the default.

Verification

cargo fmt --all --check --manifest-path target/Cargo.toml — clean, no drift
cargo clippy --workspace --locked --manifest-path target/Cargo.toml -- -D warnings — 0 warnings
cargo build --workspace --locked --manifest-path target/Cargo.toml — Finished (exit 0)
cargo test --workspace --locked --manifest-path target/Cargo.toml — all tests passed, 0 failed; the 4 new is_empty_or_home unit tests pass (4 passed; 0 failed)

Generated by inbox-patch ·

Note

Skip session upload when the target directory is empty or is $HOME

  • Adds is_empty_or_home in file_upload.rs that returns true if a directory is the user's home directory or is empty (checked via canonical path comparison and read_dir).
  • In cmd_activate, the tarball upload is skipped when the resolved upload root is empty or equals $HOME, printing "Starting with an empty box (nothing here to sync)".
  • Passing --sync tarball explicitly bypasses this check and forces the upload regardless.
  • ActivateArgs.sync changes from SyncMode to Option<SyncMode>; absence defaults to Tarball in code rather than via clap.

Macroscope summarized b8ced5a.

Summary by CodeRabbit

  • New Features

    • Activation now recognizes empty directories and the home directory, including non-empty version-controlled home directories.
    • These directories are skipped silently instead of being uploaded by default.
    • Explicitly selecting tarball synchronization still uploads the directory when desired.
  • Bug Fixes

    • Improved home-directory detection across canonicalized and non-canonicalized paths.
    • Existing synchronization modes continue to behave as before.

Activating a session ran the non-VCS-root upload confirmation for
any directory that is not a recognized VCS root, with no regard for
whether it was empty or the user's home. From an empty directory the
prompt asked about uploading nothing; from $HOME a single Enter would
bulk-upload the whole home tree, and when $HOME was itself a VCS root
the upload ran with no prompt at all.

Add an is_empty_or_home predicate and, before the non-VCS-root gate,
skip the upload without prompting for an empty directory or $HOME --
even when $HOME holds files or is a VCS root -- printing "Starting
with an empty box (nothing here to sync)" to stderr while the session
id stays the only stdout line. An explicit --sync tarball restores
the upload as an escape hatch; to tell it apart from the default,
--sync now records whether it was passed.
@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Activation now detects empty directories and $HOME, skips their uploads by default, and preserves explicit --sync tarball uploads. Directory classification and CLI tests cover the new behavior.

Changes

Workspace upload suppression

Layer / File(s) Summary
Directory classification and coverage
crates/minimal/src/file_upload.rs
Adds is_empty_or_home with canonicalized home-path matching and tests for empty, home, VCS-root, and ordinary directories.
Activation upload flow
crates/minimal/src/lib.rs, crates/minimal/tests/cli.rs
Makes sync optional, defaults internally to tarball behavior, skips eligible uploads unless explicitly overridden, and updates activation tests.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related issues

  • gominimal/inbox#433 — Covers the empty-directory and $HOME upload-suppression behavior implemented here.

Possibly related PRs

Suggested reviewers: norrietaylor, twitchyliquid64, 0chroma

Poem

A rabbit found a home-path nook,
Where empty bundles should not cook.
“Skip,” said Hare, “unless tarballs call,”
Then tested VCS roots, one and all.
The workspace rests, upload-free.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Title check ✅ Passed The title clearly and concisely describes the primary change: skipping uploads from empty directories or $HOME.
Description check ✅ Passed The description explains the change and rationale and provides detailed verification results, though it omits the template's Checklist section.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch inbox-patch/skip-upload-empty-or-home-ea92eefc48f70840

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

@norrietaylor
norrietaylor marked this pull request as ready for review July 30, 2026 23:54
@norrietaylor
norrietaylor requested a review from a team as a code owner July 30, 2026 23:54
@norrietaylor
norrietaylor enabled auto-merge (squash) July 30, 2026 23:54

@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 `@crates/minimal/src/lib.rs`:
- Around line 1427-1430: Update the activation flow around skip_empty_or_home so
the synchronous file_upload::is_empty_or_home inspection runs inside
tokio::task::spawn_blocking rather than on the async runtime thread. Preserve
the existing condition and arguments, await the blocking task, and propagate any
task join error through the surrounding result path.

In `@crates/minimal/tests/cli.rs`:
- Line 224: Extend the integration fixtures in crates/minimal/tests/cli.rs to
cover implicit sync behavior with sync: None, including the default upload path
and skipped empty/$HOME roots. Assert the expected workspace and stderr
contracts for each case, while retaining existing explicit SyncMode::Tarball
coverage; run the relevant integration test command afterward.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f977076c-03e6-4557-8155-34cfcea6e972

📥 Commits

Reviewing files that changed from the base of the PR and between 957c076 and b8ced5a.

📒 Files selected for processing (3)
  • crates/minimal/src/file_upload.rs
  • crates/minimal/src/lib.rs
  • crates/minimal/tests/cli.rs

Comment thread crates/minimal/src/lib.rs
Comment on lines +1427 to +1430
let skip_empty_or_home = !sync_explicit
&& upload_root.as_ref().is_some_and(|root| {
file_upload::is_empty_or_home(root.as_std_path(), std::env::home_dir().as_deref())
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Move directory inspection off the async runtime thread.

is_empty_or_home performs synchronous canonicalize and read_dir here. A stalled filesystem can block the Tokio worker during activation; run this check in tokio::task::spawn_blocking and propagate the join error.

Proposed fix
-    let skip_empty_or_home = !sync_explicit
-        && upload_root.as_ref().is_some_and(|root| {
-            file_upload::is_empty_or_home(root.as_std_path(), std::env::home_dir().as_deref())
-        });
+    let skip_empty_or_home = if !sync_explicit {
+        if let Some(root) = upload_root.as_ref() {
+            let root = root.clone();
+            let home = std::env::home_dir();
+            tokio::task::spawn_blocking(move || {
+                file_upload::is_empty_or_home(root.as_std_path(), home.as_deref())
+            })
+            .await
+            .context("checking whether upload directory is empty or home")?
+        } else {
+            false
+        }
+    } else {
+        false
+    };

Based on learnings, avoid direct std::fs work from async tasks; use spawn_blocking.

📝 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
let skip_empty_or_home = !sync_explicit
&& upload_root.as_ref().is_some_and(|root| {
file_upload::is_empty_or_home(root.as_std_path(), std::env::home_dir().as_deref())
});
let skip_empty_or_home = if !sync_explicit {
if let Some(root) = upload_root.as_ref() {
let root = root.clone();
let home = std::env::home_dir();
tokio::task::spawn_blocking(move || {
file_upload::is_empty_or_home(root.as_std_path(), home.as_deref())
})
.await
.context("checking whether upload directory is empty or home")?
} else {
false
}
} else {
false
};
🤖 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 `@crates/minimal/src/lib.rs` around lines 1427 - 1430, Update the activation
flow around skip_empty_or_home so the synchronous file_upload::is_empty_or_home
inspection runs inside tokio::task::spawn_blocking rather than on the async
runtime thread. Preserve the existing condition and arguments, await the
blocking task, and propagate any task join error through the surrounding result
path.

Source: Learnings

name: Some("test-session".to_string()),
path: Some(project.path().to_string_lossy().to_string()),
sync: SyncMode::Tarball,
sync: Some(SyncMode::Tarball),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Add integration coverage for implicit sync behavior.

These fixtures all use Some(SyncMode::Tarball), so they only exercise the explicit escape hatch. Add activation coverage using sync: None for the default upload path and for skipped empty/$HOME roots, asserting the workspace and stderr contract.

As per coding guidelines, “When changing VM or daemon behavior, add or update the appropriate integration tests and run just e2e and/or just test-vm.”

Also applies to: 266-266, 345-345

🤖 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 `@crates/minimal/tests/cli.rs` at line 224, Extend the integration fixtures in
crates/minimal/tests/cli.rs to cover implicit sync behavior with sync: None,
including the default upload path and skipped empty/$HOME roots. Assert the
expected workspace and stderr contracts for each case, while retaining existing
explicit SyncMode::Tarball coverage; run the relevant integration test command
afterward.

Source: Coding guidelines

@norrietaylor
norrietaylor merged commit f10f38b into main Jul 31, 2026
30 checks passed
@norrietaylor
norrietaylor deleted the inbox-patch/skip-upload-empty-or-home-ea92eefc48f70840 branch July 31, 2026 00:01
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