Skip to content

feat: add support for Gmail tracking fields#796

Open
RaoufGhrissi wants to merge 1 commit intoActivityWatch:masterfrom
odoo:gmail-tracking-ui
Open

feat: add support for Gmail tracking fields#796
RaoufGhrissi wants to merge 1 commit intoActivityWatch:masterfrom
odoo:gmail-tracking-ui

Conversation

@RaoufGhrissi
Copy link
Copy Markdown

RaoufGhrissi added a commit to RaoufGhrissi/aw-watcher-web that referenced this pull request Apr 4, 2026
ActivityWatch is used in timesheet tracking, and knowing just "reading" or "composing" email info is not very useful on its own. Extracting involved email metadata (Sender, Recipients, Subject) helps determine the context of the activity relative to project models and workflows in the used software.

A new setting has been added to allow users to enable or disable Gmail tracking.

Also added a build.sh script to simplify the build and test process for Chrome and Firefox.

ui related changes: ActivityWatch/aw-webui#796
@RaoufGhrissi RaoufGhrissi marked this pull request as ready for review April 4, 2026 17:49
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 4, 2026

Greptile Summary

This PR adds support for Gmail tracking fields (gmail_activity, from, to, cc, bcc, subject) emitted by the companion aw-watcher-web PR, wiring them into the tooltip display, event editor modal, and event list.

  • src/util/tooltip.js: Gmail metadata rows are added inside the web.tab.current branch and properly sanitized via DOMPurify. The to/cc/bcc fields correctly handle both array and string inputs with Array.isArray(), but the from field only handles strings — if it ever arrives as an array it will render as [object Array] in the tooltip.
  • src/components/EventEditor.vue: A disabled read-only input is added for array-typed event data fields. It binds :value to event.data[k] (the original prop) instead of editedEvent.data[k] (the locally fetched edited copy), which is inconsistent with all other field types in the same iteration. Non-critical while the field is disabled.
  • src/visualizations/EventList.vue: A defensive (this.events || []) null guard was added to displayed_events — a clean and correct fix for cases where the prop is not yet populated.

Confidence Score: 4/5

This PR is safe to merge; changes are narrow in scope, properly sanitized, and the two flagged issues are low-severity style/robustness concerns rather than runtime bugs.

All user-controlled data passes through DOMPurify sanitization. The two comments (missing Array.isArray on from, inconsistent prop binding in EventEditor) are style and defensive robustness improvements rather than blocking bugs. The defensive null guard in EventList is a positive change.

src/util/tooltip.js (from field Array.isArray guard) and src/components/EventEditor.vue (event.data vs editedEvent.data binding)

Important Files Changed

Filename Overview
src/components/EventEditor.vue Adds disabled array field rendering for Gmail array fields; minor inconsistency uses event.data[k] instead of editedEvent.data[k] for the value binding
src/util/tooltip.js Adds Gmail metadata rows to the web.tab.current tooltip with proper sanitization; from field lacks the Array.isArray guard present on to/cc/bcc
src/visualizations/EventList.vue Adds defensive `(this.events

Sequence Diagram

sequenceDiagram
    participant W as Gmail Watcher (aw-watcher-web)
    participant S as ActivityWatch Server
    participant UI as aw-webui
    participant TT as tooltip.js
    participant EE as EventEditor.vue
    participant EL as EventList.vue

    W->>S: POST event {gmail_activity, from, to[], cc[], bcc[], subject}
    S->>UI: Events fetched via API
    UI->>TT: buildTooltip(bucket, event)
    Note over TT: from → plain string (no Array guard)
    Note over TT: to/cc/bcc → Array.isArray() guarded
    TT-->>UI: Sanitized HTML tooltip string
    UI->>EL: events prop passed
    Note over EL: (events || []) guards undefined prop
    UI->>EE: event prop on Edit click
    Note over EE: Array fields bind :value to event.data[k]
    Note over EE: Other fields bind v-model to editedEvent.data[k]
Loading

Reviews (1): Last reviewed commit: "feat: add support for Gmail tracking fie..." | Re-trigger Greptile

b-checkbox(v-if="typeof event.data[k] === typeof true", v-model="editedEvent.data[k]", style="margin: 0.25em")
b-input(v-if="typeof event.data[k] === typeof 'string'", v-model="editedEvent.data[k]", size="sm")
b-input(v-if="typeof event.data[k] === 'number'", v-model.number="editedEvent.data[k]", size="sm", type="number")
b-input(v-if="Array.isArray(event.data[k])", :value="event.data[k].join(', ')", size="sm", disabled)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Inconsistent prop binding for array field value

The new array input binds :value to event.data[k].join(', ') — the original component prop — while every other field type in this table uses editedEvent.data[k] (the locally fetched/edited copy). Although this has no visible effect while the field is disabled, it's inconsistent and would silently show stale data if the field ever becomes editable, or if event and editedEvent ever diverge.

Suggested change
b-input(v-if="Array.isArray(event.data[k])", :value="event.data[k].join(', ')", size="sm", disabled)
b-input(v-if="Array.isArray(event.data[k])", :value="editedEvent.data[k].join(', ')", size="sm", disabled)

Comment on lines +36 to +37
if (e.data.from)
inner += `<tr><th>From</th><td>${sanitize(e.data.from)}</td></tr>`;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Missing Array.isArray guard on from field

The to, cc, and bcc fields all defensively handle both array and string via Array.isArray(), but from is always treated as a plain string. Some email APIs do represent multiple senders as an array — if e.data.from ever arrives as an array, it would render as [object Array] in the tooltip rather than a readable email address.

For consistency with the other address fields:

Suggested change
if (e.data.from)
inner += `<tr><th>From</th><td>${sanitize(e.data.from)}</td></tr>`;
if (e.data.from)
inner += `<tr><th>From</th><td>${sanitize(
Array.isArray(e.data.from) ? e.data.from.join(', ') : e.data.from
)}</td></tr>`;

RaoufGhrissi added a commit to RaoufGhrissi/aw-watcher-web that referenced this pull request Apr 4, 2026
ActivityWatch is used in timesheet tracking, and knowing just "reading" or "composing" email info is not very useful on its own. Extracting involved email metadata (Sender, Recipients, Subject) helps determine the context of the activity relative to project models and workflows in the used software.

A new setting has been added to allow users to enable or disable Gmail tracking.

Also added a build.sh script to simplify the build and test process for Chrome and Firefox.

ui related changes: ActivityWatch/aw-webui#796
RaoufGhrissi added a commit to RaoufGhrissi/aw-watcher-web that referenced this pull request Apr 4, 2026
ActivityWatch is used in timesheet tracking, and knowing just "reading" or "composing" email info is not very useful on its own. Extracting involved email metadata (Sender, Recipients, Subject) helps determine the context of the activity relative to project models and workflows in the used software.

A new setting has been added to allow users to enable or disable Gmail tracking.

Also added a build.sh script to simplify the build and test process for Chrome and Firefox.

ui related changes: ActivityWatch/aw-webui#796
RaoufGhrissi added a commit to RaoufGhrissi/aw-watcher-web that referenced this pull request Apr 4, 2026
ActivityWatch is used in timesheet tracking, and knowing just "reading" or "composing" email info is not very useful on its own. Extracting involved email metadata (Sender, Recipients, Subject) helps determine the context of the activity relative to project models and workflows in the used software.

A new setting has been added to allow users to enable or disable Gmail tracking.

Also added a build.sh script to simplify the build and test process for Chrome and Firefox.

ui related changes: ActivityWatch/aw-webui#796
RaoufGhrissi added a commit to RaoufGhrissi/aw-watcher-web that referenced this pull request Apr 4, 2026
ActivityWatch is used in timesheet tracking, and knowing just "reading" or "composing" email info is not very useful on its own. Extracting involved email metadata (Sender, Recipients, Subject) helps determine the context of the activity relative to project models and workflows in the used software.

A new setting has been added to allow users to enable or disable Gmail tracking.

Also added a build.sh script to simplify the build and test process for Chrome and Firefox.

ui related changes: ActivityWatch/aw-webui#796
RaoufGhrissi added a commit to RaoufGhrissi/aw-watcher-web that referenced this pull request Apr 4, 2026
ActivityWatch is used in timesheet tracking, and knowing just "reading" or "composing" email info is not very useful on its own. Extracting involved email metadata (Sender, Recipients, Subject) helps determine the context of the activity relative to project models and workflows in the used software.

A new setting has been added to allow users to enable or disable Gmail tracking.

Also added a build.sh script to simplify the build and test process for Chrome and Firefox.

ui related changes: ActivityWatch/aw-webui#796
RaoufGhrissi added a commit to RaoufGhrissi/aw-watcher-web that referenced this pull request Apr 4, 2026
ActivityWatch is used in timesheet tracking, and knowing just "reading" or "composing" email info is not very useful on its own. Extracting involved email metadata (Sender, Recipients, Subject) helps determine the context of the activity relative to project models and workflows in the used software.

A new setting has been added to allow users to enable or disable Gmail tracking.

Also added a build.sh script to simplify the build and test process for Chrome and Firefox.

ui related changes: ActivityWatch/aw-webui#796
RaoufGhrissi added a commit to RaoufGhrissi/aw-watcher-web that referenced this pull request Apr 5, 2026
ActivityWatch is used in timesheet tracking, and knowing just "reading" or "composing" email info is not very useful on its own. Extracting involved email metadata (Sender, Recipients, Subject) helps determine the context of the activity relative to project models and workflows in the used software.

A new setting has been added to allow users to enable or disable Gmail tracking.

Also added a build.sh script to simplify the build and test process for Chrome and Firefox.

ui related changes: ActivityWatch/aw-webui#796
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant