Skip to content

fix(update): derive stop identity from lab run copy#16

Merged
BlackHole1 merged 2 commits into
mainfrom
improve-dev
Jun 13, 2026
Merged

fix(update): derive stop identity from lab run copy#16
BlackHole1 merged 2 commits into
mainfrom
improve-dev

Conversation

@BlackHole1

Copy link
Copy Markdown
Member

The update lab stop path exited before reading the run copy metadata, so variant runs could kill the wrong process and clear the wrong defaults domain. Loading identity from the staged app copy keeps stop cleanup aligned with the app that was actually launched.

The update lab stop path exited before reading the run copy metadata,
so variant runs could kill the wrong process and clear the wrong
defaults domain. Loading identity from the staged app copy keeps stop
cleanup aligned with the app that was actually launched.

Signed-off-by: Kevin Cui <bh@bugs.cc>
@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 75b3cd84-4776-42eb-946d-4663083ae751

📥 Commits

Reviewing files that changed from the base of the PR and between 6a7da70 and 9dad242.

📒 Files selected for processing (1)
  • scripts/update-lab/update-lab.sh
🚧 Files skipped from review as they are similar to previous changes (1)
  • scripts/update-lab/update-lab.sh

Summary by CodeRabbit

  • Refactor
    • Centralized app identity handling to ensure consistent behavior across lab workflows.
    • Streamlined setup and teardown logic so app-specific cleanup runs only when a staged run copy is identified.
  • Bug Fixes
    • Improved error handling for unreadable configuration files to avoid accidental teardown of the development app.

Walkthrough

The PR refactors scripts/update-lab/update-lab.sh to consolidate app-bundle identity loading. Two new helper functions—load_app_identity and load_run_copy_identity—extract CFBundleIdentifier and CFBundleExecutable from Info.plist files and populate shared globals. The stop scenario now attempts to load the identity of a previously copied app before cleanup, the main flow replaces multiple inline PlistBuddy reads with a single helper call (failing fast on unreadable plist), and the post-scenario teardown now invokes stop_lab --with-app.

Possibly related PRs

  • oomol-lab/LockIME#15: Both PRs modify scripts/update-lab/update-lab.sh to derive/use the "LockIME Dev" app identity dynamically (bundle ID/name/executable) so the run/stop logic targets the correct dev app instead of hardcoded LockIME.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title follows the required format <type>(<scope>): <subject> with type 'fix', scope 'update', and subject accurately describing the main change of deriving stop identity from the lab run copy.
Description check ✅ Passed The description is directly related to the changeset, explaining the bug being fixed (stop path not reading run copy metadata) and the solution (loading identity from staged run copy).
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch improve-dev

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

@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: 1

🤖 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 `@scripts/update-lab/update-lab.sh`:
- Around line 89-91: The stop flow currently masks failures by using
"load_run_copy_identity || true" which allows stop_lab to proceed with
potentially wrong defaults (BUNDLE_ID / EXECUTABLE_NAME); remove the "|| true"
and instead let load_run_copy_identity propagate its non-zero exit so the script
aborts on identity resolution failures, or explicitly check its return and exit
with an error before calling stop_lab (affecting the SCENARIO == "stop" branch
and the functions load_run_copy_identity and stop_lab).
🪄 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: 69b9596d-7461-4da6-a91f-d7274479de86

📥 Commits

Reviewing files that changed from the base of the PR and between 5cfed2b and 6a7da70.

📒 Files selected for processing (1)
  • scripts/update-lab/update-lab.sh

Comment thread scripts/update-lab/update-lab.sh Outdated
The stop path now derives the app identity from the staged run copy, but
fell back to the env-var defaults (LockIME Dev / com.oomol.LockIME.dev)
when no run copy was present — which alias the real dev app, so stop could
pkill the developer's running dev build and clear its defaults domain.

Gate the app-specific cleanup (process kill, skip-key clearing) behind a
--with-app flag that callers pass only when an identity was actually
resolved: from the run copy in the stop branch, or from APP_SRC in the
main flow. Server teardown and dir removal stay unconditional, so
`make update-test-stop` remains an idempotent no-op when nothing is staged.

Also fix load_run_copy_identity crashing under bash 3.2 (macOS's default):
"${apps[@]}" on an empty array is fatal with `set -u`, so guard the loop
with an explicit length check. CI runs bash 5.x and never hit this.

Signed-off-by: Kevin Cui <bh@bugs.cc>
@BlackHole1 BlackHole1 merged commit fd62310 into main Jun 13, 2026
3 checks passed
@BlackHole1 BlackHole1 deleted the improve-dev branch June 13, 2026 01:19
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