amplify-backend icon indicating copy to clipboard operation
amplify-backend copied to clipboard

fix: maintain custom sandbox identifier after file changes

Open alexlau811 opened this issue 5 months ago • 2 comments

Summary

This PR fixes an issue where the sandbox identifier falls back to the default value (whoami) after file changes are detected by the file watcher.

  • Ensures custom identifier provided via --identifier flag persists throughout the entire sandbox session
  • Passes the sandboxIdentifier parameter to printSandboxNameInfo() when called from the file watcher

Issue

Fixes #2874

Description of Changes

In packages/sandbox/src/file_watching_sandbox.ts, the file watcher was calling printSandboxNameInfo() without passing the sandboxIdentifier parameter. This caused the method to fall back to using the default identifier (whoami) instead of the custom one provided by the user.

The fix is simple: pass options.identifier to the method call on line 224.

Test Plan

Manual Testing

  1. Run sandbox with a custom identifier:
    ampx sandbox --identifier my-custom-id
    
  2. Verify that the initial deployment shows the custom identifier
  3. Make a change to any watched file
  4. Verify that after the file change is detected, the console still shows the custom identifier

Expected Behavior

  • Before fix: Identifier reverts to default (username) after file changes
  • After fix: Identifier remains as the custom value throughout the session

Verification

  • ✅ All unit tests passed (56 tests in sandbox package)
  • ✅ Linting passed (npm run lint)
  • ✅ Build successful (npm run build)
  • ✅ Added changeset for version management

Checklist

  • [x] Unit tests passed
  • [x] Integration tests passed
  • [x] Manual testing completed
  • [x] No breaking changes

🤖 Generated with Claude Code

alexlau811 avatar Jun 29 '25 07:06 alexlau811