Skip to content
This repository was archived by the owner on Sep 15, 2026. It is now read-only.

Add user-controlled app lifecycle and login launch - #52

Merged
VdustR merged 4 commits into
mainfrom
codex/issue-51-app-lifecycle-controls
Sep 2, 2026
Merged

VdustR merged 4 commits into
mainfrom
codex/issue-51-app-lifecycle-controls

Conversation

@VdustR

@VdustR VdustR commented Sep 2, 2026

Copy link
Copy Markdown
Owner

TL;DR

Adds a complete user-controlled lifecycle for Agent Touch Bar. Users can now hide or quit it, relaunch it from ~/Applications, and control login launch without upgrades resetting their preference.

Closes #51.

Changes

  • Add native Show, Hide, Open at Login, and Quit menu commands.
  • Add a capability-gated close button to the system-modal Touch Bar.
  • Stop both bridge and renderer LaunchAgents on Quit.
  • Relaunch the bridge automatically when the app is opened manually.
  • Install the app at ~/Applications/Agent Touch Bar.app.
  • Preserve Open at Login across upgrades and update both LaunchAgent plists atomically.
  • Restart abnormal LaunchAgent exits while allowing intentional quit.
  • Migrate and remove the old Application Support app location after validated installation.

Verification

  • swift test --package-path native
  • PYTHONPATH=src python3 -m unittest discover -s tests -v
  • pyright src tests
  • python3 -m compileall -q src tests
  • bash -n native/build-app.sh scripts/install.sh scripts/install-renderer.sh scripts/uninstall.sh skills/setup-agent-touchbar/scripts/check.sh
  • ./native/build-app.sh <temporary app path>
  • git diff --check

Remaining device verification

After merge, install on the target Mac and verify menu controls, Touch Bar dismissal, Quit process cleanup, Spotlight/Finder relaunch, and LaunchAgent preference readback.

@changeset-bot

changeset-bot Bot commented Sep 2, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 1911825

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@VdustR
VdustR marked this pull request as ready for review September 2, 2026 04:02
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-02T04:13:41.068707Z 1911825 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 70fbfe5de7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread native/Sources/AgentTouchBarHost/AppLifecycleController.swift Outdated
Comment thread native/Sources/AgentTouchBarHost/AppLifecycleController.swift Outdated

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 191182507a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

/usr/bin/plutil -insert RunAtLoad -bool true "$PLIST"
/usr/bin/plutil -insert KeepAlive -bool true "$PLIST"
/usr/bin/plutil -insert RunAtLoad -bool "$OPEN_AT_LOGIN" "$PLIST"
/usr/bin/plutil -insert KeepAlive -json '{"SuccessfulExit":false}' "$PLIST"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Stop KeepAlive from overriding the login preference

When Open at Login is disabled, both generated plists still set KeepAlive.SuccessfulExit to false here and in src/agent_touchbar/cli.py. The launchd.plist manual states that SuccessfulExit implies RunAtLoad, so launchd starts these jobs at sign-in despite the explicitly false RunAtLoad; use a crash-restart configuration that does not implicitly launch the jobs, or remove this condition when login launch is disabled.

Useful? React with 👍 / 👎.

Comment thread scripts/uninstall.sh
fi
rm -f "$RENDERER_PLIST"
rm -rf "$RENDERER_APP"
rm -rf "$RENDERER_APP" "$LEGACY_RENDERER_APP"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Terminate manually launched renderers during uninstall

When the renderer was opened from Finder or Spotlight while its LaunchAgent was unloaded, it is an independent process: launchctl bootout only removes the named service from its domain, and deleting the app bundle here does not terminate that process. Consequently uninstall.sh can report success while the menu bar item and Touch Bar integration continue running from the deleted executable until the user quits or logs out; explicitly terminate any surviving renderer before removing the bundle.

Useful? React with 👍 / 👎.

Comment thread scripts/install.sh
VENV="$INSTALL_ROOT/venv"
VENV_BACKUP="$INSTALL_ROOT/venv.rollback"
APP_PATH="$INSTALL_ROOT/Agent Touch Bar.app"
APP_PATH="${AGENT_TOUCHBAR_APP_PATH:-$HOME/Applications/Agent Touch Bar.app}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Restore legacy rollback apps to their original path

If an update using the previous installer was interrupted after moving the app into Agent Touch Bar.app.rollback, this version's startup recovery treats that backup as belonging to the new APP_PATH and moves it into ~/Applications. The concurrently restored renderer plist still points to the old app under INSTALL_ROOT, so if the retry subsequently fails and invokes rollback_install, the supposedly restored LaunchAgent references a missing executable and the previous installation cannot restart. Distinguish legacy-path backups during recovery or rewrite the restored plist consistently.

Useful? React with 👍 / 👎.

@VdustR
VdustR merged commit 9bba2c8 into main Sep 2, 2026
1 check passed
@VdustR
VdustR deleted the codex/issue-51-app-lifecycle-controls branch September 2, 2026 04:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add user-controlled app lifecycle and login launch

1 participant