Skip to content

Multidevice query always fails with QueryParseException: generated AQL contains // comments, which AQL does not support (#988 regression) #999

Description

@Adiyogue

What happens

With Settings → Developer settings → "Use multidevice query" enabled, the Activity view fails to load and shows a syntax error that contains the text of a comment the query builder injects into the generated query:

Syntax error: // app_events is computed from events directly, not chained off // title_events: aw-watcher-android events have no "title" key, so // merge_events_by_keys(events, ["app", "title"]) drops them from // title_events entirely (see canonicalEvents). Chaining app_events off // title_events would silently exclude mobile hosts' app-level // breakdown even though their duration is counted; title breakdown // (which mobile hosts can't provide) stays desktop-only. title_events

Cause

multideviceQuery() in src/queries.ts emits // comment lines inside the generated AQL string. These were added in #988 (commit 22cb53b):

export function multideviceQuery(params: MultiQueryParams): string[] {
  return querystr_to_array(
    `
    ${canonicalMultideviceEvents(params)}
    // app_events is computed from events directly, not chained off
    // title_events: aw-watcher-android events have no "title" key, so
    ...
    title_events = sort_by_duration(merge_events_by_keys(events, ["app", "title"]));
    app_events   = sort_by_duration(merge_events_by_keys(events, ["app"]));

AQL has no comment syntax, and both server implementations reject it.

Minimal reproduction

Any query with a comment line fails on both servers:

// a comment
events = query_bucket(find_bucket("aw-watcher-window_"));
RETURN = events;
  • aw-server (Python) v0.14.0b8 → {"type": "QueryParseException", "message": "Syntax error: // a comment\nevents"}
  • aw-server-rust v0.14.0-beta.8 → ParsingError("(Some((Slash, Span { lo: 0, hi: 1, line: 1 })), \"expected Bool, Ident, If, LBrace, ...\")")

The same query with the comment line removed parses and runs correctly, and # comments are rejected as well — so no comment syntax is available.

The identical pattern appears a second time in the same file, in the activity-context/AI-summary query builder (// Note: browser_domains is intentionally NOT limited here. ...), so that query would fail to parse too.

Why the tests don't catch it

test/multidevice.test.node.ts asserts on the generated query text and never sends it to a server, so the parse failure is invisible to the suite.

Impact

Multidevice is unusable on every server (Python and Rust) in v0.14.0b8, whose bundled web UI reports COMMIT_HASH=22cb53b, and the comments are still present on master. The failure is not host- or data-dependent: it happens before any events are read.

Reproduced with two hosts — a macOS desktop and an Android phone synced via aw-sync — but it is independent of that setup.

Suggested fix

Move those lines out of the template literal into ordinary JS comments (as done elsewhere in the file), or drop them. Removing the 12 comment lines from the built chunk makes the query parse and the Activity view work.

Environment

  • macOS 26.5.1 (arm64)
  • ActivityWatch desktop v0.14.0b8, bundled web UI COMMIT_HASH=22cb53b
  • aw-server (Python) v0.14.0b8 as the running server; parser rejection also confirmed against aw-server-rust v0.14.0-beta.8

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions