Skip to content

fix(watch): reload direct files outside repositories - #1054

Merged
benvinegar merged 1 commit into
mainfrom
fix/direct-file-reload-bounds
Sep 8, 2026
Merged

benvinegar merged 1 commit into
mainfrom
fix/direct-file-reload-bounds

Conversation

@benvinegar

Copy link
Copy Markdown
Member

Problem

Direct-file reviews launched outside a Git repository could not reload. Automatic --watch refreshes and the manual r shortcut both passed through session reload bounds with no permitted roots or files, so updates were silently left stale until Hunk was reopened.

Approach

  • permit the exact two initial direct-file inputs when no repository root safely contains them
  • retain the existing boundary against reading other files or switching to repository-backed reloads
  • exercise atomic-save watch behavior from a real PTY outside any repository
  • move manual reload coverage outside the checkout and add focused reload-boundary tests

The VM's root user was not the determining factor; the missing repository root was.

Validation

  • bun run typecheck
  • bun run lint
  • bun run deps:check
  • bun run test:integration — 163 passed, 1 skipped
  • focused reload bounds and manual reload tests
  • bun run test — 2,049 passed, 2 skipped; one unrelated environment-sensitive failure because this checkout is nested in a Jujutsu workspace and the existing test expects Git detection

This PR description was generated by Pi using GPT-5.6-sol

@vercel

vercel Bot commented Sep 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
hunk-web Ignored Ignored Sep 8, 2026 12:47pm UTC

Request Review

@greptile-apps

greptile-apps Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR restores reload support for direct-file comparisons when no repository root safely contains the inputs.

  • Records the two canonical initial files as exact reload permissions when repository roots are unavailable.
  • Continues rejecting other files, explicit source directories, and repository-backed input transitions.
  • Adds focused boundary, manual-refresh, and real-PTY atomic-save coverage outside a repository.

Confidence Score: 5/5

The PR appears safe to merge; it restores the intended reload behavior while retaining exact-file and repository-transition boundaries.

The changed bounds canonicalize both initial resources and reload candidates, internal manual and watch refreshes omit unnecessary source paths, and the new tests cover successful reloads plus the important rejection cases.

Important Files Changed

Filename Overview
packages/hunk/src/app/session/reloadBounds.ts Adds canonical exact-file reload permissions for direct comparisons lacking a safe repository root while preserving existing filesystem boundaries.
packages/hunk/src/app/session/reloadBounds.test.ts Verifies exact initial files are accepted while unrelated files, source paths, and repository-backed transitions remain rejected.
packages/hunk/src/ui/AppHost.interactions.test.tsx Moves manual direct-file refresh coverage to a temporary directory outside the checkout.
test/pty/harness.ts Removes fixture Git initialization so the atomic-save PTY test exercises non-repository direct-file reloads.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Direct-file session starts] --> B{One repository root safely contains both files?}
  B -->|Yes| C[Permit reloads within repository root]
  B -->|No| D[Record the two canonical files]
  D --> E{Reload requests the same exact files?}
  E -->|Yes| F[Permit manual or watch reload]
  E -->|No| G[Reject filesystem access]
  D --> H{Repository-backed reload requested?}
  H -->|Yes| G
Loading

Reviews (1): Last reviewed commit: "fix(watch): reload direct files outside ..." | Re-trigger Greptile

@benvinegar
benvinegar enabled auto-merge (squash) September 8, 2026 12:51
@benvinegar
benvinegar merged commit c5bb30d into main Sep 8, 2026
13 checks passed
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