feat(agent): unify button Down/Up/Cancel lifecycle - #933
Merged
Conversation
Co-authored-by: Xuan Zhang <xuan@arcbox.dev>
Greptile SummaryThe PR consolidates OS-hook and HID++ button handling into one tokenized lifecycle worker.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| crates/openlogi-agent-core/src/runtime/button.rs | Implements the unified tokenized lifecycle state machine and fixes the prior shutdown-bound issue with a separate unbounded shutdown channel. |
| crates/openlogi-agent-core/src/runtime.rs | Owns the lifecycle worker and exposes source-independent action dispatch and cancellation operations. |
| crates/openlogi-agent-core/src/runtime/hook.rs | Adapts OS-hook events to the unified button lifecycle while retaining non-blocking fail-open handling. |
| crates/openlogi-agent-core/src/watchers/gesture.rs | Correlates HID++ gesture input with exact capture sessions and press tokens. |
| crates/openlogi-agent/src/main.rs | Integrates lifecycle-worker startup and bounded shutdown into agent ownership. |
| crates/openlogi-device/src/session/gesture.rs | Converts held-control snapshots into deduplicated edges and balanced firmware-only pulses. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
OS[OS hook] -->|Down / Up| Worker[Button lifecycle worker]
Mouse[HID++ mouse] -->|Down / Up / Pulse| Worker
Keyboard[HID++ keyboard] -->|Down / Up / Pulse| Worker
Worker -->|Started| Executor[Action executor]
Worker -->|Triggered while token is live| Executor
Worker -->|Ended: Released or Canceled| Terminal[Terminal lifecycle event]
Shutdown[Out-of-band shutdown request] --> Worker
Reviews (3): Last reviewed commit: "refactor(agent): organize action runtime..." | Re-trigger Greptile
Co-authored-by: Xuan Zhang <xuan@arcbox.dev>
Co-authored-by: Xuan Zhang <xuan@arcbox.dev>
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
Up + actionor a source-authored cancellation are unrepresentable.Endedevent for each accepted press while preserving existing one-shot action and gesture behavior.Changes
ButtonDown/ButtonUpedges.runtime.rs, with the hidden lifecycle state machine inruntime/button.rsand OS-hook interpretation inruntime/hook.rs.Down,Up,Pulse, andTriggerWhilePressedinputs and emitStarted,Ended(Released | Canceled(reason)), andTriggeredoutputs.PressToken; stale timers, gestures, and superseded presses cannot trigger newer lifecycles.HidppSessionIdrather than independent primitive fields.ActionServicesaggregate, abort startup when the worker cannot start, and shut it down after the hook stops.Testing
export RUSTFLAGS="-D warnings"; cargo fmt --all -- --check && cargo clippy --workspace --all-targets -- -D warnings && cargo test --workspace && RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-items --exclude openlogi-ui --exclude openlogi-desktop --exclude openlogi-overlay --exclude openlogi-agentcargo test -p openlogi-agent-core -p openlogi-agentcargo clippy -p openlogi-agent-core -p openlogi-agent --all-targets -- -D warningsRUSTDOCFLAGS="-D warnings" cargo doc -p openlogi-agent-core --no-deps --document-private-itemscargo xtask ci clippy-windowscargo xtask ci wasmFixes #930