fix: restore paste focus and auto-refresh permissions - #24
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR improves macOS paste reliability by restoring focus to the exact previously frontmost app (using bundle IDs and verification) and improves the permissions UX by automatically rechecking permissions when the permissions window regains focus.
Changes:
- Auto-refresh permissions when the permissions window regains focus (plus a focused unit test).
- macOS paste now reactivates the previously frontmost app by bundle ID and verifies focus before issuing Cmd+V.
- Minor UX/docs updates (permissions hint text) and ignore local
.worktrees/directories.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/components/PermissionsModal.tsx | Updates hint text to reflect automatic permission rechecks. |
| src/App.tsx | Adds focus-based permission refresh logic for the permissions window. |
| src/App.test.tsx | Adds a test ensuring permissions are rechecked when the window regains focus. |
| src-tauri/src/platform/macos.rs | Restores focus to the last frontmost app by bundle ID and verifies focus before pasting. |
| .gitignore | Ignores local .worktrees/ directories. |
Comment on lines
8
to
12
| pub fn set_last_frontmost_app_name(name: String) { | ||
| let cell = LAST_FRONTMOST_APP_NAME.get_or_init(|| Mutex::new(None)); | ||
| let cell = LAST_FRONTMOST_APP.get_or_init(|| Mutex::new(None)); | ||
| let mut guard = cell.lock().unwrap_or_else(|e| e.into_inner()); | ||
| *guard = Some(name); | ||
| *guard = query_frontmost_app_bundle_id().map(|bundle_id| (name, bundle_id)); | ||
| } |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 9 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (2)
src/App.tsx:734
refreshPermissionscan still be invoked after the effect cleanup via a queuedfocusevent, which would callsetCheckingPermissions(true)even whencancelledis already true (potential setState-after-unmount warning). Add an earlycancelledguard before mutating local/state flags.
const refreshPermissions = async () => {
if (checking) return;
checking = true;
setCheckingPermissions(true);
try {
const res = await checkPermissions();
if (cancelled) return;
setPermissions(res);
src-tauri/src/platform/macos.rs:12
set_last_frontmost_app_namecurrently overwrites the stored last frontmost app withNonewhenquery_frontmost_app_bundle_id()returnsNone, which can erase a previously valid paste target and causeperform_pasteto fail with "no previous app available". Preserve the prior value when the bundle ID can’t be determined.
pub fn set_last_frontmost_app_name(name: String) {
let cell = LAST_FRONTMOST_APP.get_or_init(|| Mutex::new(None));
let mut guard = cell.lock().unwrap_or_else(|e| e.into_inner());
*guard = query_frontmost_app_bundle_id().map(|bundle_id| (name, bundle_id));
}
Comment on lines
+30
to
+34
| "@tauri-apps/api": "2.9.0", | ||
| "@tauri-apps/plugin-dialog": "^2", | ||
| "@tauri-apps/plugin-opener": "^2", | ||
| "@tauri-apps/plugin-process": "^2.3.1", | ||
| "@tauri-apps/plugin-updater": "^2.10.1", | ||
| "@tauri-apps/plugin-updater": "2.9.0", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
rand 0.10.worktrees/directoriesValidation
npm cinpm test -- --run src/App.test.tsxnpm run buildcargo check --manifest-path src-tauri/Cargo.tomlcargo test --manifest-path src-tauri/Cargo.toml --lib paste_target_bundle_must_be_frontmost_before_pastingnpm run tauri -- build --no-bundle