`project: unknown` heartbeats split real editor events, so durations collapse to zero
@BeatLink is already working on this.
Since Oct 21, 2026.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 69/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript, vscode
- Domain
- developer-experience
Research direction
Read src/extension.ts around _onEvent and _createHeartbeat, then check the event tests or smoke test steps referenced by #55. Confirm that a missing active text editor does not send an unknown heartbeat and that normal editor heartbeats still work; the packaged build smoke test is still needed for completion.
Written by the indexing model from the issue text.
Description
project: unknown heartbeats split real editor events, so durations collapse to zero
On a machine where most editing happens with an agent panel open in the editor
area, this watcher records 0.16 h against the window watcher's 44.78 h of
focused VS Code time over 30 days — 0.4%. 187 of its 218 stored events have
duration: 0.0.
I think this is the root cause of #10, and it is distinct from the feature
request in #43. #43 asks for terminal and sidebar time to be tracked. This is
narrower and worse: focus leaving the text editor destroys the measurement of
the editor time the watcher is already observing.
Mechanism
_onEvent fires on onDidChangeTextEditorSelection and
onDidChangeActiveTextEditor. When the focused tab is not a document — a
webview tab, the Settings UI, an agent chat panel — window.activeTextEditor
is undefined, onDidChangeActiveTextEditor still fires, and
_createHeartbeat sends {file: 'unknown', project: 'unknown', language: 'unknown'} (plus branch: 'unknown', since the git-branch support added for #41).
aw-server extends the open event only while the incoming heartbeat's data
is identical. So a single unknown between two heartbeats for the same file
ends that event and opens a new one — both at duration 0.
Probed directly against aw-server-rust v0.14.0, pulsetime=20, heartbeats 5 s
apart:
# three identical heartbeats
00:00:00 a.ts | 00:00:05 a.ts | 00:00:10 a.ts
-> 1 stored event, duration 10.0
# identical, with one `unknown` interleaved
00:00:00 b.ts | 00:00:05 unknown | 00:00:10 b.ts
-> 3 stored events, duration 0.0, 0.0, 0.0
In the real bucket the pair arrives 21 ms apart, because switching tabs emits
undefined before the new editor:
16:40:18.837 dur 0.0 unknown
16:40:18.850 dur 0.0 /temp/readonly/Bash tool output (6jjs8r)
16:40:32.404 dur 0.0 unknown
16:40:32.425 dur 0.0 .../docs/hour-app-plan.md
84 of 218 events are that unknown. Note this is not the sidebar case
@TimeToBuildBob tested in #43: a sidebar leaves activeTextEditor intact, so
it emits nothing. A webview tab in the editor group clears it, so it emits
unknown.
Fix
Return early instead of reporting unknown. Letting the event lapse costs
nothing — pulsetime closes it anyway — whereas unknown actively ends it.
Against master, and it does not touch anything #52 moves:
--- a/src/extension.ts
+++ b/src/extension.ts
@@ -103,6 +103,18 @@
return;
}
+ // Nothing is reportable when no document has the focus: a webview tab,
+ // the Settings UI, a diff of a deleted file or an agent chat panel all
+ // leave `activeTextEditor` undefined. Returning here rather than
+ // sending `unknown` is not cosmetic. aw-server extends the open event
+ // only while the incoming heartbeat's `data` is identical, so one
+ // `unknown` between two heartbeats for the same file ends that event
+ // and opens another — both at duration 0. Letting the event lapse on
+ // its own costs nothing by comparison: pulsetime closes it anyway.
+ if (!window.activeTextEditor) {
+ return;
+ }
+
// Create and send heartbeat
try {
const heartbeat = this._createHeartbeat();
I have not run a packaged build of this, so it wants the same smoke test #55
lists as an open sub-task; the reasoning above is what I verified, by probing
the server directly.
What this does not fix
Coverage. There is still no heartbeat while reading without moving the
cursor, which is the other half of #10. A periodic heartbeat gated on
window.state.focused && window.activeTextEditor would close it, and I think
it answers @johan-bjareholt's objection in #10 about overshooting: that is the
same condition the window watcher bills on, not a guess about attention. Happy
to open that separately if there's appetite — it is a policy change, where the
above is just a bug.
Environment
VS Code 1.129.1, extension 0.5.0 (the Marketplace build; the code path is
unchanged on master), aw-server-rust v0.14.0, macOS 26.5.2.
- Dominant language
- TypeScript
- Stars
- 285
- Forks
- 50
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ActivityWatch/aw-watcher-vscode
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
-
[feature] maxHeartbeatsPerSec as a decimal number like 0.5 for heartbeat every 2 seconds (or more)Possibly taken @TimeToBuildBob claimed this 17 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 52/100
ActivityWatch/aw-watcher-vscode#49 · 1 comment ·
-
track terminal and other tabsPossibly taken @TimeToBuildBob claimed this 17 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
ActivityWatch/aw-watcher-vscode#43 · 3 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 28/100
ActivityWatch/aw-watcher-vscode#41 · 5 comments · 4 reactions ·
-
Spams debug console while working on other extensions in Extension HostMay be free again A pull request for this issue was closed without being merged. Open
Difficulty 3/5 Half a day Newbie friendliness 32/100
All issues in ActivityWatch/aw-watcher-vscode
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 66/100
-
Difficulty 1/5 Under an hour Newbie friendliness 65/100
prometheus/docs#3198 ·
Maintainers usually reply within 3 days
-
[Bug]: OpenCode v2 skips an assistant message that gains text after an earlier capturePossibly taken @jianyx1 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
volcengine/OpenViking#8354 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ARTPARK-SAHAI-ORG/calibrate-frontend#842 ·
Maintainers usually reply within 1 day
-
Chat: Copying a selection that includes the end of a message also copies the actions menu labelsOpen
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
suitenumerique/hub#176 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day