Skip to content

Commit 0595ed8

Browse files
authored
Merge branch 'master' into feat/g502-hero-support
2 parents 6f71449 + 16d8cba commit 0595ed8

70 files changed

Lines changed: 1416 additions & 280 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.agents/rules/objc-ffi.md‎

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,19 @@ notifications — the `com.apple.accessibility.api` distributed notification and
6969
tccd's `com.apple.tcc.access.changed` Darwin notification — are observed by the
7070
external [`axwatch`](https://crates.io/crates/axwatch) crate
7171
(`CFNotificationCenter` there, not here); `openlogi-hook`'s `grant::ProbeCue`
72-
and `openlogi-agent-core`'s grant watchers only consume its wakes.
73-
74-
The rest of `openlogi-desktop/src/platform/` (`updater.rs`, on `gpui_updater`)
75-
carries **no** ObjC FFI — don't add any. Neither do `openlogi-core`'s
76-
`single_instance.rs` (fs4 lock) or `openlogi-agent`'s `autostart/macos.rs`
77-
(legacy-plist cleanup via `std::fs`).
72+
and `openlogi-agent-core`'s grant watchers only consume its wakes. The System
73+
Settings drag guide for the agent's Accessibility and Input Monitoring grants
74+
lives in the external [`gpui-tcc`](https://github.com/AprilNEA/gpui-tcc) crate
75+
(the `NSWorkspace` icon and frontmost-app reads, the
76+
`CGWindowListCopyWindowInfo` lookup of the System Settings window, and the
77+
overlay `NSWindow` level and `NSVisualEffectView` material are there, not
78+
here); `openlogi-desktop/src/platform/permission_guide.rs` only decides when
79+
to present it and which agent bundle it holds.
80+
81+
The rest of `openlogi-desktop/src/platform/` (`updater.rs`, on `gpui_updater`,
82+
and `permission_guide.rs`, on `gpui_tcc`) carries **no** ObjC FFI — don't add
83+
any. Neither do `openlogi-core`'s `single_instance.rs` (fs4 lock) or
84+
`openlogi-agent`'s `autostart/macos.rs` (legacy-plist cleanup via `std::fs`).
7885

7986
## Ownership: `Retained<T>`, never raw `id`
8087

@@ -157,13 +164,14 @@ Rules:
157164
- **Checking never prompts; prompting belongs to whoever owns the resource.**
158165
The agent raises the Accessibility prompt (it owns the tap) and calls
159166
`IOHIDRequestAccess` before opening HID; the GUI only reads status and
160-
deep-links to System Settings (`open_pane`). Never call the prompting half from
161-
the GUI — the grant would land on the wrong code-signing identity (issue #214,
162-
see `disclaim`). This split is also why the ready-made permission crates don't
163-
fit: they model one app asking for itself. `permission-flow` additionally
164-
brings its own onboarding UI and links the Swift runtime into every downstream
165-
binary; `macos-accessibility-client` is a raw-`extern` wrapper where this file
166-
requires typed bindings.
167+
deep-links to System Settings (`open_pane`, or the `gpui-tcc` drag guide,
168+
which opens the same pane and prompts nothing). Never call the prompting
169+
half from the GUI — the grant would land on the wrong code-signing identity
170+
(issue #214, see `disclaim`). This split is also why the ready-made
171+
permission crates don't fit: they model one app asking for itself.
172+
`permission-flow` additionally brings its own onboarding UI and links the
173+
Swift runtime into every downstream binary; `macos-accessibility-client` is
174+
a raw-`extern` wrapper where this file requires typed bindings.
167175
- **TCC matches the full Designated Requirement, not the bundle ID** ([TN3127]).
168176
Re-signing one bundle ID with a different *kind* of certificate leaves a record
169177
that can never match again, and toggling the checkbox does not rewrite the

‎.cargo/deny.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,6 @@ unknown-git = "deny"
5959
# that appears as `git+…` in Cargo.lock must be listed here.
6060
allow-git = [
6161
"https://github.com/AprilNEA/appicon",
62+
"https://github.com/AprilNEA/gpui-tcc",
6263
"https://github.com/longbridge/gpui-kit",
6364
]

‎.claude/skills/openlogi-macos-permissions/SKILL.md‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,18 @@ Rules that drive most reports:
5858
app bundle. Bundles built before the rename spell that directory
5959
`OpenLogiAgent.app`; both are the same identity (`org.openlogi.agent`), and
6060
the grant survived the rename because the path is not part of the designated
61-
requirement. The System Settings `+` picker will not browse into a bundle, so
62-
they have to use Go-to-Folder. Say this explicitly; do not tell someone to
63-
"grant OpenLogi permission".
61+
requirement. Say this explicitly; do not tell someone to "grant OpenLogi
62+
permission".
63+
- The System Settings `+` picker cannot browse into a bundle. To add the agent
64+
to the Accessibility or Input Monitoring list, give the steps for the
65+
reporter's release:
66+
- After 0.9.0: click **Open** on that permission in OpenLogi's Settings →
67+
Permissions, then drag **OpenLogi Agent** from the panel over System
68+
Settings into the list. The panel appears unless the agent already reports
69+
the grant, and it closes when the agent reports the grant.
70+
- 0.9.0 and earlier, or when no panel appears: click `+`, press ⇧⌘G (Go to
71+
Folder), enter `/Applications/OpenLogi.app/Contents/Library/LoginItems`,
72+
and choose the agent bundle there.
6473
- A grant to the GUI does nothing for the agent, and vice versa. There is no
6574
bundle-wide grant.
6675
- **Every copy is its own identity.** A dev build (`org.openlogi.agent-dev`), a
@@ -185,7 +194,9 @@ Re-check linked upstream transport issues before attributing a probe timeout to
185194

186195
Say so plainly rather than promising a fix:
187196

188-
- Apple's `+` picker not browsing into bundles.
197+
- Apple's `+` picker not browsing into bundles. The drag guide (§2) avoids the
198+
picker only when the user starts from OpenLogi's **Open** button. A user who
199+
opens System Settings another way still needs Go to Folder.
189200
- `IOHIDDeviceOpen`'s silent denial — we can only infer it by checking access
190201
separately.
191202
- A stale `tccd` decision that needs a full logout, or an MDM policy.

‎Cargo.lock‎

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎crates/openlogi-agent-core/src/runtime.rs‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,17 @@ struct HeldShortcuts {
152152

153153
impl HeldShortcuts {
154154
fn start(&mut self, press: &PressToken, action: &Action) -> bool {
155+
if let Some(mods) = action.held_modifier() {
156+
match self.by_press.entry(press.clone()) {
157+
std::collections::hash_map::Entry::Occupied(mut held) => {
158+
held.get_mut().replace_modifier(mods);
159+
}
160+
std::collections::hash_map::Entry::Vacant(slot) => {
161+
slot.insert(openlogi_inject::press_hold_modifier(mods));
162+
}
163+
}
164+
return true;
165+
}
155166
let Some((combo, keys)) = action.held_chord() else {
156167
return false;
157168
};
@@ -731,7 +742,9 @@ impl ButtonEventHandler {
731742
device_key: Option<&str>,
732743
target: ActionDispatchTarget,
733744
) {
734-
if action.held_chord().is_some() && target.resolve(action).is_none() {
745+
if (action.held_chord().is_some() || action.held_modifier().is_some())
746+
&& target.resolve(action).is_none()
747+
{
735748
return;
736749
}
737750
if matches!(action, Action::DpiShift) {

‎crates/openlogi-agent-core/src/runtime/hook.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -714,9 +714,9 @@ pub fn start(
714714
}
715715
}
716716
// Function-key remapper: ordinary actions remain one-shot, while a
717-
// HoldShortcut enters the same down/up/cancel lifecycle as a mouse
718-
// button. The active set pairs key-up even if modifier state or config
719-
// changes while the key is down.
717+
// held chord or held modifiers enter the same down/up/cancel
718+
// lifecycle as a mouse button. The active set pairs key-up even if
719+
// modifier state or config changes while the key is down.
720720
HookEvent::Key(event) => handle_key(
721721
event,
722722
&keyboard_bindings,

‎crates/openlogi-agent-core/src/runtime/hook/tests.rs‎

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -374,43 +374,50 @@ fn queued_key_action_retains_its_press_time_target() {
374374
/// A held action needs the key's release, which the one-shot action queue
375375
/// never delivers.
376376
#[test]
377-
fn dpi_shift_on_a_key_runs_as_a_held_press() {
377+
fn held_actions_on_a_key_run_as_held_presses() {
378378
use super::super::button::ButtonRuntimeEvent;
379379

380-
let (dispatcher, mut owner, events) = test_dispatcher();
381-
let keycode = 0x7a;
382-
let modifiers = KeyModifiers::default();
383-
let bindings = Arc::new(RwLock::new(BTreeMap::from([(
384-
KeyTrigger { keycode, modifiers },
380+
for action in [
385381
Action::DpiShift,
386-
)])));
387-
let (actions, queued) = mpsc::sync_channel(1);
388-
let key = |pressed| {
389-
handle_key(
390-
KeyEvent {
391-
keycode,
392-
pressed,
393-
modifiers,
394-
},
395-
&bindings,
396-
&actions,
397-
&dispatcher,
398-
ActionDispatchTarget::capture,
399-
)
400-
};
382+
Action::HoldShortcut("Ctrl+F18".parse().expect("valid chord")),
383+
Action::TapKeyHoldingModifiers("Alt+F19".parse().expect("valid chord")),
384+
Action::HoldModifier("Ctrl+Shift".parse().expect("valid modifiers")),
385+
] {
386+
let (dispatcher, mut owner, events) = test_dispatcher();
387+
let keycode = 0x7a;
388+
let modifiers = KeyModifiers::default();
389+
let bindings = Arc::new(RwLock::new(BTreeMap::from([(
390+
KeyTrigger { keycode, modifiers },
391+
action,
392+
)])));
393+
let (actions, queued) = mpsc::sync_channel(1);
394+
let key = |pressed| {
395+
handle_key(
396+
KeyEvent {
397+
keycode,
398+
pressed,
399+
modifiers,
400+
},
401+
&bindings,
402+
&actions,
403+
&dispatcher,
404+
ActionDispatchTarget::capture,
405+
)
406+
};
401407

402-
assert_eq!(key(true), EventDisposition::Suppress);
403-
queued.try_recv().unwrap_err();
404-
assert!(matches!(
405-
events.recv_timeout(Duration::from_secs(1)),
406-
Ok(ButtonRuntimeEvent::Started(_))
407-
));
408-
assert_eq!(key(false), EventDisposition::Suppress);
409-
assert!(matches!(
410-
events.recv_timeout(Duration::from_secs(1)),
411-
Ok(ButtonRuntimeEvent::Ended { .. })
412-
));
413-
assert!(owner.shutdown());
408+
assert_eq!(key(true), EventDisposition::Suppress);
409+
queued.try_recv().unwrap_err();
410+
assert!(matches!(
411+
events.recv_timeout(Duration::from_secs(1)),
412+
Ok(ButtonRuntimeEvent::Started(_))
413+
));
414+
assert_eq!(key(false), EventDisposition::Suppress);
415+
assert!(matches!(
416+
events.recv_timeout(Duration::from_secs(1)),
417+
Ok(ButtonRuntimeEvent::Ended { .. })
418+
));
419+
assert!(owner.shutdown());
420+
}
414421
}
415422

416423
#[test]

‎crates/openlogi-agent-core/src/runtime/pointer.rs‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,12 @@ fn needs_focus(action: &Action) -> bool {
191191
| Effect::Text(_)
192192
| Effect::Script(_)
193193
| Effect::Native(NativeAction::AppExpose) => true,
194+
Effect::AgentSide => action.held_modifier().is_some(),
194195
Effect::None
195196
| Effect::Click(_)
196197
| Effect::Scroll { .. }
197198
| Effect::Media(_)
198-
| Effect::Native(_)
199-
| Effect::AgentSide => false,
199+
| Effect::Native(_) => false,
200200
}
201201
}
202202

@@ -218,11 +218,12 @@ mod tests {
218218
PointerPress { target, focus }
219219
}
220220

221-
fn keyboard_actions() -> [Action; 5] {
221+
fn keyboard_actions() -> [Action; 6] {
222222
let shortcut = "Ctrl+Tab".parse().expect("valid shortcut");
223223
[
224224
Action::BrowserForward,
225225
Action::CustomShortcut(shortcut),
226+
Action::HoldModifier("Ctrl".parse().expect("valid modifier")),
226227
Action::TypeText("hello".into()),
227228
Action::AppExpose,
228229
Action::Copy,
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Owner: openlogi_core::binding::Modifiers — the shortcut modifier bit layout
2+
# and the names a binding spells them with (`Modifiers::from_token`).
3+
id: core-binding-modifier-tokens-owner
4+
language: rust
5+
severity: error
6+
message: Shortcut modifier names belong to openlogi_core::binding::Modifiers; parse a chord or a modifier set with KeyCombo's or BareModifiers' FromStr instead of matching the names here.
7+
note: |
8+
KeyCombo once kept its own token table and bit constants, so any other
9+
parser of the same names would have had to track them by hand.
10+
`config/key_trigger.rs` is exempt: a function-key trigger has its own
11+
vocabulary (`KeyModifiers`, no Super), not a shortcut's.
12+
See "Single source of truth" in AGENTS.md.
13+
files:
14+
- crates/**/*.rs
15+
- xtask/**/*.rs
16+
ignores:
17+
- crates/openlogi-core/src/binding/modifiers.rs
18+
- crates/openlogi-core/src/config/key_trigger.rs
19+
rule:
20+
kind: string_literal
21+
regex: '^"(cmd|command|ctrl|control|alt|option|shift|super|win|meta)"$'
22+
inside:
23+
kind: match_pattern
24+
stopBy: end

‎crates/openlogi-core/src/binding.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ mod g_keys;
2121
mod gaming;
2222
mod gesture;
2323
mod key_combo;
24+
mod modifiers;
2425
mod swipe;
2526
mod value;
2627

@@ -47,6 +48,7 @@ pub use gaming::{
4748
};
4849
pub use gesture::GestureDirection;
4950
pub use key_combo::{KeyCombo, KeyComboParseError, KeyboardUsage, KeyboardUsageError};
51+
pub use modifiers::{BareModifiers, BareModifiersParseError, Modifiers};
5052
pub use swipe::{
5153
GESTURE_HOLD_FOR_SWIPE, GESTURE_REARM_PAUSE, GESTURE_REPEAT_DISTANCE, GESTURE_SWIPE_DEADZONE,
5254
GESTURE_SWIPE_THRESHOLD, SwipeAccumulator, detect_swipe,

0 commit comments

Comments
 (0)