Commit 0ab26ef
Add a mousedown handler to also signal user activity in the app (#2976)
`mousedown` activity signaling was structured such that async telemetry
concerns leaked into event handling. This change moves fire-and-forget
behavior to the model boundary and keeps telemetry failures non-fatal.
- **`mousedown` handler path**
- `AppKeyHandlers` now calls `GlobalModel.getInstance().setIsActive()`
directly (no async wrapper in the handler).
- **`GlobalModel.setIsActive` structure**
- `setIsActive()` is now synchronous (`void`).
- Throttle logic remains unchanged.
- Electron telemetry call is executed via `util.fireAndForget(...)`
inside `setIsActive()`.
- **Telemetry error containment**
- `getApi().setIsActive()` is wrapped in `try/catch` inside the
fire-and-forget callback.
- Errors are logged with `console.log("setIsActive error", e)` and do
not bubble.
- **Focused coverage**
- Added `frontend/app/store/global-model.test.ts` for:
- fire-and-forget invocation + throttling behavior
- error logging/swallowing on rejected telemetry call
```ts
setIsActive(): void {
const now = Date.now();
if (now - this.lastSetIsActiveTs < GlobalModel.IsActiveThrottleMs) {
return;
}
this.lastSetIsActiveTs = now;
util.fireAndForget(async () => {
try {
await getApi().setIsActive();
} catch (e) {
console.log("setIsActive error", e);
}
});
}
```
<!-- START COPILOT CODING AGENT TIPS -->
---
🔒 GitHub Advanced Security automatically protects Copilot coding agent
pull requests. You can protect all pull requests by enabling Advanced
Security for your repositories. [Learn more about Advanced
Security.](https://gh.io/cca-advanced-security)
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sawka <2722291+sawka@users.noreply.github.com>
Co-authored-by: sawka <mike@commandline.dev>1 parent 7f5487d commit 0ab26ef
5 files changed
Lines changed: 27 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
317 | 318 | | |
318 | 319 | | |
319 | 320 | | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
320 | 325 | | |
321 | 326 | | |
322 | 327 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
74 | 75 | | |
75 | 76 | | |
76 | 77 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
203 | 207 | | |
204 | | - | |
| 208 | + | |
205 | 209 | | |
206 | 210 | | |
207 | 211 | | |
208 | | - | |
| 212 | + | |
209 | 213 | | |
210 | 214 | | |
211 | 215 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
| 12 | + | |
10 | 13 | | |
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
| 17 | + | |
14 | 18 | | |
15 | 19 | | |
16 | 20 | | |
| |||
47 | 51 | | |
48 | 52 | | |
49 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
50 | 63 | | |
51 | 64 | | |
52 | | - | |
| 65 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
| 135 | + | |
135 | 136 | | |
136 | 137 | | |
137 | 138 | | |
| |||
0 commit comments