Skip to content

foundation: fix broken first-run + storage --json + reexec_in_venv#1

Open
halbothpa wants to merge 1 commit into
mainfrom
claude/cool-antonelli-e749e2
Open

foundation: fix broken first-run + storage --json + reexec_in_venv#1
halbothpa wants to merge 1 commit into
mainfrom
claude/cool-antonelli-e749e2

Conversation

@halbothpa
Copy link
Copy Markdown
Owner

Summary

Fixes 6 bugs (BUGS.md #1-6) that together broke the plugin's first-run experience end-to-end on a clean install.

  • bootstrap.py: track upstream rename app.protoapplication.proto, drop the (no-longer-published) subghz.proto, hold the .downloaded marker until all files succeed, make protoc failures fatal instead of silently warning, add a verify_proto_imports self-check, and skip reexec_in_venv when sys.argv[0] is -c / "" / - so python -c \"...bootstrap.reexec_in_venv()\" no longer crashes.
  • flipper_core.py: alias application_pb2 as app_pb2 (keeps existing references working), surface the real ImportError in RpcSession.__init__ instead of the misleading "bindings not generated" message.
  • flipper_storage.py: move --port / --json to a parent parser so they parse correctly whether placed before or after the subcommand (was: argparse rejected them after).
  • BUGS.md / .gitignore: mark fixed bugs, ignore renamed marker files.

Why now

Without this, every fresh install of the plugin failed:

  1. Bootstrap exited 0 ("Ready.") despite two 404s on app.proto / subghz.proto.
  2. protoc reported missing types and failed → warning swallowed.
  3. First RpcSession(...) raised "bindings not generated" (misleading).
  4. Skill's documented flipper_storage.py list /ext --json probe errored out.

PR 2 (reader-thread dispatcher) depends on a working proto import chain, so this lands first.

Test plan

  • rm -rf scripts/protobuf .venv then python scripts/bootstrap.py exits 0 with no warnings.
  • flipper_storage.py list /ext --json (after subcommand) works.
  • flipper_storage.py --json list /ext (before subcommand) works.
  • python -c "import bootstrap; bootstrap.reexec_in_venv()" returns cleanly instead of crashing.
  • Every *_pb2 module flipper_core.py imports actually loads.
  • /connect-flipper skill probes the device and reports firmware variant.

🤖 Generated with Claude Code

The plugin's first-run experience was broken end-to-end on a fresh
install. Six bugs (BUGS.md #1-6) chained into a confusing failure mode
where bootstrap exited 0, then every RpcSession() raised "bindings not
generated". This commit fixes all six in one pass so a clean install
just works.

* bootstrap.py:
  - Track upstream rename: app.proto -> application.proto. Drop
    subghz.proto which 404s from the dev branch and isn't imported.
  - Hold the .downloaded marker until ALL files download successfully;
    raise on any failure instead of warning-and-continuing.
  - Markers are now JSON recording the exact file set, so an upstream
    rename forces a re-download instead of trusting a stale marker.
  - Make protoc failures fatal (was: silent warning).
  - Add verify_proto_imports() self-check after generation.
  - Skip reexec_in_venv() when sys.argv[0] is "" / "-c" / "-" so
    ad-hoc `python -c "...bootstrap.reexec_in_venv()"` no longer
    crashes with `Argument expected for the -c option`.

* flipper_core.py:
  - Alias `application_pb2 as app_pb2` so existing references in this
    file keep working without a sweeping rename.
  - Surface the real ImportError in RpcSession.__init__ instead of the
    misleading "bindings not generated" message.

* flipper_storage.py:
  - Move --port / --json to a parent parser so they parse correctly
    whether placed before or after the subcommand (was: rejected
    after).

* BUGS.md / .gitignore: mark fixed bugs, ignore renamed marker files.

Unblocks PR 2 (reader-thread dispatcher) which needs working protos.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 14, 2026 10:24
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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.

2 participants