Desktop shared libraries
The desktop shared libraries provide the common runtime for Gauzy's Electron applications. They separate local state, activity capture, window behavior, main-process work, server processes, authentication, offline continuity, and Angular screens so the desktop timer, agent, and server applications can share one product model. This page complements desktop time tracking, Electron desktop applications, and desktop agent capture and sync.
Shared library boundaries
The five packages divide the desktop product by responsibility. An application joins these boundaries through Electron inter-process communication (IPC), local state, and shared data contracts instead of placing all desktop behavior in one application module.
Package roles
Each package owns one part of the desktop experience. The public entry points make these roles available to desktop applications and keep operating-system work separate from the Angular user experience.
| Package | Product responsibility |
|---|---|
@gauzy/desktop-core | Shared local state, logging, and named Electron window identity. |
@gauzy/desktop-activity | Keyboard, mouse, active-window, away-from-keyboard, and durable activity work. |
@gauzy/desktop-window | Reusable Electron windows, navigation rules, provider sign-in surfaces, and small desktop widgets. |
@gauzy/desktop-lib | Main-process coordination for tracking, servers, screenshots, offline work, networking, sound, IPC, trays, updates, and authentication. |
@gauzy/desktop-ui-lib | Reusable Angular screens and services for setup, sign-in, tracking, settings, activity review, connectivity, sound, and updates. |
References: packages/…/index.ts• L1-13 packages/…/index.ts• L1-11 packages/…/index.ts• L1-18 packages/…/index.ts• L1-33 packages/…/index.ts• L1-64
Runtime layers
The layers move from shared resources to user actions. desktop-core supplies common state and window identity. desktop-activity turns operating-system signals into tracking data. desktop-window creates the views that display or receive desktop actions. desktop-lib coordinates the main process, local servers, and external services. desktop-ui-lib presents state and sends user actions through that boundary.
This split lets an application reuse a screen without copying local state or activity rules. It also keeps native work, storage, and child-process control out of Angular components.
References: packages/…/package.json• L30-62 packages/…/package.json• L29-34 packages/…/package.json• L29-37 packages/…/package.json• L26-67
Core runtime services
desktop-core provides services that must behave in the same way across desktop processes. It gives applications a local store for session and tracking context, a named window registry, and a shared logger.
Local application state
The local store keeps the context needed to set up the application and resume tracking. It includes server mode, network access policy, account scope, selected work context, capture policy, notification display choice, application settings, window positions, and paths used by Electron windows.
The state stays local so tracking can continue while the server is unavailable. A setting can route timer writes into a persistent queue that survives a quit or crash. Native services are created after Electron is ready because they need Electron paths and native modules.
Application settings also carry the computer's screenshot sound and the optional timer start and stop sound. New installs use GitHub as the live update source and keep durable timer-data sync off until the user enables it.
References: packages/…/types.ts• L28-45 packages/…/types.ts• L66-88 packages/…/types.ts• L113-162 packages/…/application-setting-store.service.ts• L8-50 packages/…/desktop-store.ts• L34-65
Window registry
The window registry gives the main process one identity model for important views. Stable names such as MAIN, TIMER, SETTINGS, and CAPTURE let tray actions, IPC handlers, authentication, and shutdown logic find and control a view without keeping separate references.
Normal closing usually hides a view or clears its registry entry instead of stopping the desktop process. This lets the tray and tracking session continue after a user closes a window.
References: packages/…/iwindow.manager.ts• L3-42 packages/…/window.manager.ts• L5-21 packages/…/window.manager.ts• L28-65 packages/…/window.manager.ts• L140-169
Window position memory
Window position memory preserves the user's placement for movable desktop surfaces. It restores a saved position only when a connected display still contains the window and otherwise lets the window use its normal default.
The always-on widget keeps compact and expanded placements separate because their sizes differ. The screenshot notice resolves its target display again each time it appears, so display changes and a disconnected selected display do not strand the notice.
References: packages/…/types.ts• L41-45 packages/…/window-position.ts• L30-67 packages/…/window-position-memory.ts• L11-18 packages/…/window-position-memory.ts• L25-79 packages/…/always-on.ts• L13-33 packages/…/screen-capture-notification.ts• L109-149
Logging boundary
The shared logger gives Electron processes one path for information, warning, error, and debug records. The desktop server and timer paths pass configuration through a common redaction boundary before they write diagnostic data, so local API secrets, database passwords, proxy keys, and token-like values do not become log artifacts.
References: packages/…/logger.ts• L5-31 packages/…/types.ts• L1-22 packages/…/desktop-secrets.ts• L70-117 packages/…/server-task.ts• L73-85
Activity collection
desktop-activity turns operating-system signals into time-tracking measures. It focuses on what happens during a tracking session rather than on the screen that starts the session or the server that later receives the result.
Input signals
The activity layer observes keyboard and mouse input and can read the active application or URL. It groups these signals into useful tracking records and resets the away-from-keyboard clock when input returns.
References: packages/…/kb-mouse.ts• L8-17 packages/…/kb-mouse.ts• L27-65 packages/…/kb-mouse-event-counter.ts• L13-77 packages/…/activity-window.ts• L4-28
Time-slice signals
The activity timer provides the clock for collection. It checks the active window, marks away-from-keyboard time after a period without input, and emits a time range when the flush period ends. A flush can include activity state and a request for a screenshot when the capture period is due.
These signals are not server records. The main process combines them with the selected work context, account scope, external activity sources, and local timer state before it sends a time slot onward.
References: packages/…/kb-mouse-timer.ts• L3-30 packages/…/kb-mouse-timer.ts• L69-86 packages/…/kb-mouse-timer.ts• L108-146 packages/…/kb-mouse-timer.ts• L163-214 packages/…/i-kb-mouse.ts• L52-92
Local queue
The activity package provides queue boundaries for work that must outlive a short network outage or an application restart. Its durable queue stores JSON-safe jobs before execution, runs named queues through their processors, retries failures, and can wait for a readiness check.
The timer uses this queue when asynchronous timer data sync is enabled. Queue processors must be safe to run again because unfinished work can resume on the next start. Stored work stays ahead of newer fallback work so a failed store operation cannot reorder updates.
References: packages/…/desktop-queue.ts• L10-62 packages/…/desktop-queue.ts• L76-130 packages/…/desktop-queue.ts• L246-369 packages/…/persistent-queue.ts• L127-139 packages/…/persistent-queue.ts• L159-205 packages/…/queue-store.ts• L4-27
Electron window services
desktop-window supplies reusable Electron window types. Each type defines a product surface with a route, display behavior, and lifecycle so different desktop applications can use the same window model.
Application windows
The package covers the main Gauzy view, timer, setup, authentication, settings, server, updater, About, image viewer, plug-in marketplace, splash, and always-on surfaces. It also provides a short-lived capture notice that shows a preview without taking focus from the user's work.
The window manager reuses these creators. A request to open settings, a preview, or the always-on view therefore targets the existing surface instead of creating an unwanted duplicate.
References: packages/…/index.ts• L1-18 packages/…/desktop-window.ts• L22-82 packages/…/desktop-window-timer.ts• L20-68 packages/…/screen-capture-notification.ts• L13-19 packages/…/screen-capture-notification.ts• L96-149 packages/…/app-window-manager.ts• L26-159
Window lifecycle
Normal views open hidden and become visible when the main process asks for them. Closing one hides it so the tray and tracking process can continue. Special views such as the splash, plug-in, and always-on surfaces destroy themselves when closed.
A shared URL helper maps a page to a route hash such as /time-tracker, /settings, or /viewer. The navigation guard keeps privileged windows on their own page or on a configured server origin. A link that cannot be trusted opens in the user's browser instead of loading inside a window with native access.
References: packages/…/desktop-window-utils.ts• L14-64 packages/…/navigation-guard.ts• L31-44 packages/…/navigation-guard.ts• L63-135 packages/…/desktop-window-timer.ts• L40-64
Provider sign-in
Provider sign-in uses a separate popup for social provider pages. The desktop application accepts only the result from the popup it opened, then sends either a sign-in token or a workspace code to the sign-in window. A registration result opens in the user's browser, and an insecure provider redirect is refused.
References: packages/…/provider-sign-in.ts• L14-44 packages/…/provider-sign-in.ts• L65-95 packages/…/provider-sign-in.ts• L97-116 packages/…/provider-sign-in.ts• L158-205
Main-process coordination
desktop-lib is the coordination layer for a running desktop application. It joins shared state and windows with activity collection, timer state, screenshots, offline records, server access, network discovery, sound choices, tray actions, updates, plug-ins, authentication, and external activity sources.
Tracking orchestration
The timer service starts and stops a local tracking session. During a session it combines active-window data, external activity data, keyboard and mouse measures, selected work context, and screenshot timing into local activity records. It sends timer, time-slot, screenshot, and synchronization changes through one shared processor.
This layer owns the change from a user action to a recoverable tracking record. Offline state is kept local so a later sync can send the work without creating a second timer record. Local updates ignore unset fields, so a partial timer change does not erase existing values or fail as an empty database update.
References: packages/…/desktop-timer.ts• L35-44 packages/…/desktop-timer.ts• L115-158 packages/…/desktop-timer.ts• L374-390 packages/…/desktop-timer.ts• L489-629 packages/…/timer-queue-processor.ts• L56-126 packages/…/timer.service.ts• L46-63 packages/…/update-payload.ts• L9-47
Asynchronous timer data
Asynchronous timer data sync is an opt-in path for local timer writes that must survive a quit or crash. The session chooses the in-memory or durable path when its first timer job is queued, then keeps that choice for the session.
The durable path preserves timer updates, time-slot links, activity events, and clean-up actions in order. On restart, leftover work runs before new work. Sync waits for stored timer jobs before it reads local records to upload, while a bounded retry rule prevents a stuck queue from blocking sync forever.
References: packages/…/types.ts• L157-162 packages/…/async-timer-sync-queue.ts• L9-18 packages/…/async-timer-sync-queue.ts• L33-145 packages/…/desktop-timer.ts• L773-809 packages/…/desktop-timer.ts• L841-875 packages/…/desktop-timer.ts• L1002-1067
IPC bridge
IPC is the message boundary between the Electron main process and renderer windows. desktop-lib handles requests for timer changes, screen capture, permissions, server setup, local state, audit records, display choices, sound, authentication, networking, and synchronization.
The bridge keeps operating-system and local-data actions in the main process. Angular views request an action or listen for a result. The main process then updates local state, window state, queue state, or server-facing work and returns the data needed by the view. Native and storage services stay behind the Electron-ready lifecycle.
References: packages/…/desktop-ipc.ts• L58-121 packages/…/desktop-ipc.ts• L127-173 packages/…/desktop-ipc.ts• L377-393 packages/…/desktop-ipc.ts• L694-719 packages/…/desktop-ipc.ts• L766-832 packages/…/desktop-ipc.ts• L1657-1711 packages/…/desktop-network-ipc.ts• L5-15 packages/…/screenshot-sound.ipc.ts• L5-19 packages/…/sound-settings.ipc.ts• L5-19
Local server lifecycle
desktop-lib manages the integrated API and web UI processes when an application runs a local server. The server task starts a child process, forwards logs and running state to the setup window, records its process identity, and supports stop and restart actions.
The listen policy separates a local-only desktop server from server applications that may accept LAN connections. Integrated desktop services always use loopback. Gauzy Server and Gauzy API Server can use every interface unless the user turns LAN access off. Client URLs are changed to a reachable loopback address when the server is local-only.
The web UI receives its API address at serve time, so read-only installs do not need a write to their install directory. A writable install may still keep the same value in index.html as a fallback. Server applications can expose the computer's usable network addresses to setup and settings so a user can choose a host that other computers can reach.
References: packages/…/desktop-listen-host.ts• L1-77 packages/…/server-config.ts• L13-41 packages/…/server-config.ts• L51-94 packages/…/read-write-file.ts• L4-44 packages/…/ui-runtime-config.ts• L1-19 packages/…/ui-runtime-config.ts• L58-95 packages/…/desktop-server.ts• L14-22 packages/…/ui-service.ts• L6-22 packages/…/ui-service.ts• L45-75 packages/…/desktop-network-addresses.ts• L19-63 packages/…/desktop-network-ipc.ts• L5-15
Server host selection
Server host selection helps Gauzy Server and Gauzy API Server choose a usable address without guessing from an external service. The main process lists non-loopback addresses and places normal LAN IPv4 addresses before virtual, VPN, and IPv6 addresses.
The shared UI validates the typed host, warns about values that may not work with SSL or LAN reachability, and keeps Save disabled for invalid input. Detecting an address fills the field only after the user asks for it.
References: packages/…/desktop-network-addresses.ts• L7-17 packages/…/desktop-network-addresses.ts• L19-72 packages/…/network-address.service.ts• L5-30 packages/…/server-host.util.ts• L4-11 packages/…/server-host.util.ts• L61-86 packages/…/server-host.util.ts• L158-227 packages/…/server-host-input.component.ts• L9-19 packages/…/server-host-input.component.ts• L51-86 packages/…/setup.component.ts• L402-445
Local credentials
Local server startup creates per-install signing and session secrets when stored values are missing or use known published defaults. It saves the values before starting the API and passes them to the child process through its environment. Empty database seed accounts also receive per-install passwords.
The seed flow records which accounts were created and shows their credentials in a one-time native dialog until the user confirms that they saved them. Existing accounts that still use a published password receive a warning instead of an automatic password change.
References: packages/…/desktop-secrets.ts• L4-67 packages/…/desktop-seed-credentials.ts• L20-106 packages/…/desktop-seed-credentials.ts• L137-202 packages/…/api-service.ts• L110-148 packages/…/desktop-sign-in-notices.ts• L38-53 packages/…/desktop-sign-in-notices.ts• L65-129
Offline continuity
Offline continuity separates local tracking from server reachability. The desktop process records timer and activity work locally, then waits for network and server checks before it sends pending work.
When the connection returns, synchronization sends timer work before dependent time slots and sends screenshots after a time slot has an identifier. This order protects local records and lets tracking continue during a short outage.
References: packages/…/connectivity-timing.ts• L1-11 packages/…/api-server-connectivity.ts• L9-43 packages/…/desktop-timer.ts• L841-875 packages/…/desktop-timer.ts• L1002-1009 packages/…/desktop-ipc.ts• L799-827 packages/…/desktop-queue.ts• L331-369
Screenshot flow
Screen capture is a policy-controlled part of a time slice. The desktop process checks permission, selects all monitors or the monitor under the cursor, stores a temporary image, and sends a preview to the renderer or capture notice. A later sync operation uploads the image with its time-slot context.
Capture is allowed only when both the employee and the organization allow it. The path can still leave the timer usable when platform permission blocks screenshots. The selected display for the capture notice is resolved again before each show, with primary-display fallback when the saved display is absent.
References: packages/…/desktop-screenshot.ts• L21-49 packages/…/desktop-screenshot.ts• L248-266 packages/…/desktop-screenshot.ts• L318-379 packages/…/desktop-screenshot.ts• L443-500 packages/…/desktop-screenshot.ts• L528-547 packages/…/time-tracker.component.ts• L137-145 packages/…/settings.component.ts• L910-929
Screenshot sound
Screenshot sound is a local notification choice. The settings page asks the main process to copy a supported sound into the app data area, while the timer plays that copy or the bundled sound when the copy is no longer usable.
The choice is kept behind IPC and is safe to reset. Muting still takes priority, and a bad setting falls back to the bundled sound instead of disabling the notification.
References: packages/…/screenshot-sound.ts• L4-8 packages/…/screenshot-sound.service.ts• L21-37 packages/…/screenshot-sound.service.ts• L62-105 packages/…/screenshot-sound.ipc.ts• L5-19 packages/…/screenshot-sound-setting.service.ts• L23-77 packages/…/settings.component.ts• L1015-1052
Update delivery
The update service gives desktop applications one flow for automatic checks, manual checks, and local package updates. The settings page selects the update source, release channel, prerelease choice, and check delay, then sends changes through IPC.
References: packages/…/desktop-updater.ts• L31-56 packages/…/desktop-updater.ts• L98-138 packages/…/automatic-update.ts• L22-89 packages/…/settings.component.ts• L1075-1090 packages/…/settings.component.ts• L1368-1395
Angular desktop experience
desktop-ui-lib contains the reusable Angular experience for desktop applications. It turns main-process events and server data into screens for setup, authentication, time tracking, settings, activity review, capture feedback, connectivity, sound, updates, and plug-ins.
Authentication experience
The UI library provides password, workspace, provider, token-refresh, and logout flows. Token refresh retries ordinary expired requests, while callers can mark an intentional 401 as their own outcome. This lets an organization switch report that the selected organization refused access without logging out a valid session.
The authentication strategy also prevents an older refresh response from overwriting credentials after an organization switch. A desktop sign-in passes the account and token data to the main process through IPC, and an organization switch waits for that save before it reloads the timer.
References: packages/…/auth.service.ts• L68-176 packages/…/auth.service.ts• L179-217 packages/…/auth-strategy.service.ts• L57-99 packages/…/auth-strategy.service.ts• L160-217 packages/…/refresh-token.interceptor.ts• L17-92 packages/…/skip-token-refresh.token.ts• L1-12
Timer interface
The time tracker is the main user control surface. It shows the current timer, selected work context, daily and weekly totals, screenshots, offline state, and pending sync state. It sends timer, task, screenshot, and synchronization actions through the desktop services.
Before a timer starts, organization rules can require a project, task, client, description, or team. The same work-context controls appear when an active timer is changed, and dependent choices are reloaded before the new context is applied.
Timer starts and organization switches are mutually exclusive. The interface also reflects remote timer changes and main-process events, so tray actions, offline recovery, and local buttons converge on one visible timer state.
References: packages/…/time-tracker.component.ts• L174-240 packages/…/time-tracker.component.ts• L432-459 packages/…/time-tracker.component.ts• L595-749 packages/…/time-tracker.component.ts• L986-1000 packages/…/time-tracker.component.ts• L1081-1137 packages/…/timer-required-fields.ts• L3-48 packages/…/timer-required-fields.spec.ts• L26-97 packages/…/timer-tracker-change-dialog.component.ts• L53-129 packages/…/timer-tracker-change-dialog.component.html• L7-40
Organization context
The organization selector represents the organization named by the current access token. A selection first asks the API for new credentials, then saves the account in both app halves, clears old work choices, and reloads the tracker. The selector stays on the old organization when the switch is refused.
The switch holds a lock until the new tracker state is ready. This prevents a timer start from using the employee, token, screenshots, or work context of the organization left.
References: packages/…/organization-selector.component.ts• L48-65 packages/…/organization-selector.component.ts• L93-129 packages/…/organization-selector.component.ts• L200-218 packages/…/organization-switch.service.ts• L51-65 packages/…/organization-switch.service.ts• L152-221 packages/…/organization-switch.service.ts• L295-341
Selection continuity
Selection continuity keeps the timer's client, project, team, task, and note useful across reloads and devices. When the local form is empty, the shared UI can take the employee's last time log and apply its choices in dependency order.
The prefill stops when the user chooses something, the timer starts, the organization changes, or a list cannot be loaded. Selector requests also reject late answers from an old organization or an old search so stale work cannot return to the form.
References: packages/…/selection-prefill.service.ts• L24-35 packages/…/selection-prefill.service.ts• L79-132 packages/…/find-choice.ts• L31-67 packages/…/last-log-selection.ts• L17-45 packages/…/list-request-guard.ts• L3-29 packages/…/selector.service.ts• L10-15 packages/…/selector.service.ts• L66-70
Connectivity feedback
Connectivity feedback connects the main process's reachability state to the time tracker. The main process probes the active API on a bounded schedule and switches to local tracking when the probe fails.
The renderer shows the state in the footer and gives one persistent warning when the connection is lost. When the connection returns, it closes that warning and reports whether entries are waiting for sync.
References: packages/…/connectivity-timing.ts• L1-11 packages/…/api-server-connectivity.ts• L9-43 packages/…/desktop-offline-mode-handler.ts• L43-127 packages/…/connectivity-notice.ts• L8-38 packages/…/connectivity-notifier.service.ts• L7-51 packages/…/toastr-notification.service.ts• L6-54 packages/…/time-tracker.component.ts• L455-459
Timer sound feedback
Timer sound feedback gives a short local cue when this computer starts or stops tracking. It ignores remote timer changes and internal restarts such as the midnight rollover, so the sound describes a user-visible action rather than every state transition.
The setting is read through a narrow IPC response for each cue. The sound is optional and never blocks timer work when audio is unavailable.
References: packages/…/sound-settings.ts• L4-12 packages/…/sound-settings.ipc.ts• L5-19 packages/…/timer-sound-cues.ts• L20-68 packages/…/timer-sound-cues.ts• L70-129 packages/…/timer-sound.service.ts• L37-49 packages/…/timer-sound.service.ts• L88-121 packages/…/time-tracker.component.ts• L461-468 packages/…/time-tracker.component.ts• L982-983
Date and recap interface
The shared date controls turn a user's local selection into whole local days or the selected time unit. They apply the organization's future-date rule and week start, then emit a stable range for recap and time queries.
The picker reads wall-clock fields from its date library instead of applying a second UTC shift. This keeps selected days stable across time zones and daylight-saving changes.
References: packages/…/date-picker.utils.ts• L59-143 packages/…/date-range-picker.component.ts• L209-235 packages/…/date-range-picker.component.ts• L275-343 packages/…/date-range-picker.component.ts• L346-369
Settings interface
The settings screen is the user-facing control point for capture policy, timer behavior, server choice, LAN access for server applications, permissions, language, sound choices, and update behavior. It loads local state through IPC and sends changed values back to the main process.
The screen lists connected displays for screenshot notices and refreshes that list when the main process reports a display change. It compares new values with the last saved snapshot before sending a write, so local form changes do not create duplicate IPC messages or success notices.
References: packages/…/settings.component.html• L26-279 packages/…/settings.component.html• L798-872 packages/…/settings.component.ts• L661-725 packages/…/settings.component.ts• L910-977 packages/…/settings.component.ts• L1015-1052 packages/…/settings.component.ts• L1540-1582
Setup and server interface
Setup selects an integrated local server, a custom server, or the live Gauzy service. It also selects database and activity options, checks connectivity, and sends one configuration to the main process before the application starts or restarts.
Server setup shows process logs and state through IPC. The setup screen exposes LAN access only for server applications; an integrated desktop server remains local to the computer. Server applications validate the host again immediately before save so a value changed during a connection check cannot bypass the boundary.
References: packages/…/setup.component.html• L379-457 packages/…/setup.component.ts• L94-118 packages/…/setup.component.ts• L183-203 packages/…/setup.component.ts• L319-370 packages/…/setup.component.ts• L402-445 packages/…/setup.component.ts• L469-513
Shared controls and errors
The UI library includes shared selectors, activity sync, capture feedback, sound feedback, and error handling. These controls make queue, capture, and server state visible without moving queue or native capture control into the renderer. Shared selectors protect their lists from late responses when their organization or filter context changes.
The HTTP error boundary retries transient requests once, marks the app offline for server failures, and reports readable errors unless the caller owns the message. A selector restores the end of a type-ahead search when the underlying select control closes.
For lookups where a missing record is a valid result, the caller marks the request as not-found-safe. The error boundary suppresses only the API's own 404 response for that request; proxy or gateway 404 responses and all other errors still reach the normal error path. The time tracker turns a missing time log into a skipped offline sequence and turns a missing time slot into a cleared capture view. This prevents deleted server data from blocking later sync or leaving stale screenshots on screen.
References: packages/…/select.component.ts• L192-239 packages/…/list-request-guard.ts• L9-29 packages/…/client-selector.service.ts• L58-108 packages/…/project-selector.service.ts• L67-115 packages/…/team-selector.service.ts• L29-70 packages/…/task-selector.service.ts• L72-127 packages/…/activity-sync.component.ts• L14-78 packages/…/screen-capture.component.ts• L11-71 packages/…/server-error.interceptor.ts• L16-47 packages/…/skip-not-found-notification.token.ts• L1-23 packages/…/time-tracker.service.ts• L485-552 packages/…/sequence-queue.ts• L90-97 packages/…/time-tracker.component.ts• L2157-2184
Timer operation ordering
The time tracker serializes timer mutations that can affect the same server time log. Starts, stops, updates, and offline-created logs wait in call order, while a bounded timeout releases the chain if one request never settles.
This ordering keeps an online action from racing an offline recovery action. A failed operation reaches its caller without blocking the next queued operation.
References: packages/…/time-tracker.service.ts• L72-136 packages/…/time-tracker.service.ts• L595-747
Web portal link
The web portal link gives the time tracker a safe path to the employee's time and activity page. It appears only when the app can identify Gauzy Cloud or a web UI served on the same computer.
Custom server API addresses do not imply a web UI address, so the link stays hidden rather than opening a guessed or unsafe page. The final browser link accepts only an HTTP(S) web app, uses the local calendar day, and requires both organization and employee identity.
References: packages/…/web-portal-url.ts• L1-15 packages/…/web-portal-url.ts• L17-70 packages/…/web-portal-url.ts• L72-106 packages/…/web-portal-url.spec.ts• L10-70 packages/…/web-portal-url.spec.ts• L73-130 packages/…/web-portal.service.ts• L7-15 packages/…/web-portal.service.ts• L35-75 packages/…/desktop-ipc.ts• L694-699
End-to-end desktop flow
The shared packages turn a user timer action into local activity and then into a server-ready result. The diagram shows the main relationships without tying the flow to one application entry point.
flowchart LR
U[User action in desktop UI] --> I[Electron IPC]
I --> O[desktop-lib coordination]
O --> S[desktop-core local state]
O --> A[desktop-activity collection]
A --> D[Activity and time-slice data]
O --> W[desktop-window views]
D --> Q[Local queue]
Q --> N{Network and server available?}
N -- No --> Q
N -- Yes --> R[Server sync]
O --> C[Screen capture policy and sound]
C --> P[Preview and temporary image]
P --> Q
O --> X[Local server and network lifecycle]
X --> N
R --> V[Updated UI state]
The user action starts in an Angular view. IPC moves it to the main process, where the coordinator updates local state and starts activity sources. The queue preserves the result until the server accepts it. Authentication, server setup, network discovery, and local notification choices use the same bridge before or during normal tracking.
References: packages/…/time-tracker.component.ts• L1081-1137 packages/…/desktop-ipc.ts• L799-832 packages/…/desktop-timer.ts• L115-149 packages/…/persistent-queue.ts• L127-139 packages/…/desktop-screenshot.ts• L318-379 packages/…/desktop-server.ts• L44-75 packages/…/ui-service.ts• L45-59
Change checklist
When these files or sections are changed, remember to consider these:
- Package export changes must preserve the public symbols used by application entry points and sibling desktop packages.
- Store shape changes must keep server mode, LAN access, account scope, selected work context, capture policy, display choice, sound choices, window positions, and asynchronous sync settings aligned.
- Window names must match window creators, application window manager references, tray actions, IPC handlers, navigation rules, and cleanup paths.
- IPC channel changes must update the main-process handler and every renderer sender or listener.
- Server listen-host changes must keep integrated-server loopback behavior, server-app LAN access, client URLs, UI runtime configuration, and setup controls aligned.
- Local secret changes must keep stored fields, child-process environment names, save-before-start behavior, seed-password state, and log redaction aligned.
- Authentication changes must keep renderer credentials, main-process credentials, organization context, employee data, timer state, and logout cleanup aligned.
- Organization-switch changes must preserve the no-overlap rule with timer starts, waited main-process save, old work reset, and tracker reload.
- Activity and queue payload changes must preserve the order from local timer data to time slot to screenshot upload.
- Persistent queue jobs must remain JSON-safe and safe to run again. Queue names must keep unique processors and storage records.
- Route and navigation changes must update both the window URL creator and the Angular route while keeping privileged content on trusted origins.
- Provider sign-in changes must preserve popup ownership, HTTPS provider redirects, workspace-code handling, and external registration behavior.
- Display-list changes must keep the settings selector, display-change event, capture-notification placement, and primary-display fallback aligned.
- Window-position changes must keep stored positions separate from whole-settings writes and must keep display bounds, window size, clamping, and default placement aligned.
- Date-range changes must keep local wall-clock selection, organization week start, UTC conversion, future-date policy, and query ranges aligned.
- Settings changes must compare against the last sent value, not only the mutable form model.
- Host-field changes must keep address discovery, validation, normalization, LAN reachability, SSL warnings, and the final save check aligned.
- UI runtime configuration changes must keep the serve-time script, fallback file update, browser host replacement, and API port or scheme aligned.
- Connectivity changes must keep probe timing, offline state events, footer state, toasts, and pending-sync counts aligned.
- Selector changes must preserve request invalidation when organization, search, project, or team context changes.
- Timer requirement changes must keep organization flags, start validation, change-dialog validation, selector errors, and the team compatibility default aligned.
- Last-log prefill changes must preserve dependency order, user-choice protection, organization checks, and retry after a failed load.
- Screenshot-sound changes must keep file validation, app-data copies, reset cleanup, IPC results, muted behavior, and renderer playback aligned.
- Timer-sound changes must keep the main-process setting response, local-versus-remote ignition rules, quiet internal restarts, and audio failure behavior aligned.
- Web-portal changes must keep local UI discovery, Gauzy Cloud API matching, HTTP(S)-only opening, hash routing, local dates, and required identifiers aligned.
- Update-feed changes must keep the selected strategy, release channel, platform metadata, and automatic or manual check paths aligned.
- Not-found handling changes must keep the request context, API-shaped 404 check, caller's null or clear behavior, and ordinary outage notifications aligned.
- Timer mutation changes must preserve serialized ordering and the timeout escape so online and offline actions cannot race or deadlock.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A native store, queue, or server service is created before Electron is ready | Startup can fail before the application has a valid user-data path. | Construct native services behind the Electron-ready lifecycle. |
A server app listens on every interface while its client URL still uses 0.0.0.0 | Local windows or browsers can try to open an unusable destination. | Resolve listen hosts separately from reachable client URLs. |
| LAN access is applied to the integrated desktop server | A local API becomes reachable from other computers. | Integrated services always pass the local-only policy. |
| The UI server depends only on a writable install directory for its API address | A read-only package can start without a usable web UI API URL. | Pass the runtime script to the UI server and keep file writing as a fallback. |
| A local API secret is missing or uses a published default | Network users can forge tokens or sessions. | Generate and save per-install secrets before API startup. |
| An IPC channel changes on one side only | The UI can show stale timer, server, authentication, capture, sound, or sync state. | Change the main handler and every renderer sender or listener together. |
| A privileged window follows an untrusted task link | User content can load a page with native Electron access. | Block untrusted navigation and open supported external links in the browser. |
| A provider result comes from a popup the app did not open | Another page can sign the desktop app into the wrong account or consume a workspace code. | Accept sign-in results only from the current provider popup. |
| Organization credentials change while a token refresh is in flight | Old tokens can overwrite new ones and the timer can use mixed organization data. | Hold the credential replacement lock and discard superseded refresh results. |
| A timer starts during an organization switch | Tracking can use the employee, token, or work context of the organization left. | Hold the switch and timer-start locks until the new tracker state is ready. |
| A required team is not selected for an organization that enforces teams | The timer can start with an incomplete work context or fail later at the server. | Apply the organization requirement during timer validation and mark the team selector. |
| A persistent queue job is not JSON-safe or safe to run again | Work can fail to persist or can be applied twice after recovery. | Store JSON-safe jobs and use repeat-safe processors. |
| Stored work is bypassed after a queue storage error | Timer duration, activity, and time-slot data can be applied out of order. | Drain stored work before using the in-memory fallback. |
| Network or server checks fail during sync | Local records remain pending and retry work does not reach the server. | Pause retry lanes and resume them after both checks pass. |
| Organization or employee capture permission is reduced after sign-in | A time slot can still create an image that policy does not allow. | Recompute the combined permission and gate both main-process and renderer capture. |
| Display IDs or display connections change | Active-only capture or the capture notice can target the wrong display. | Resolve the active display from current coordinates and use connected-display or primary-display fallback. |
| A selected notification display is disconnected or its layout changes | The notice appears on another monitor or outside the visible work area. | Resolve the display and position on each show and clamp it to current bounds. |
| A date picker applies an old UTC offset conversion to local picker fields | A selected day can move across midnight. | Rebuild picker values from wall-clock fields before forming the range. |
| A settings control sends its mutable value repeatedly | Duplicate writes and stacked notices can make state look inconsistent. | Compare against the last saved snapshot before sending IPC. |
| A stale selector response arrives after an organization or filter change | The user can pick an item from the old context. | Invalidate the request when the list resets and check the organization before applying the answer. |
| Last-log prefill overwrites a user choice or applies dependent fields at once | The timer starts with the wrong work context or loses a dependent selection. | Prefill only an empty form, apply choices in order, and stop when the user or timer takes control. |
| A custom screenshot sound points outside the app sound folder or is deleted | The app can play an unintended file or become silent. | Copy approved formats into app data and fall back to the bundled sound. |
| Timer sound handling treats a remote timer or midnight rollover as a user action | The user hears misleading start or stop cues. | Cue only local manual transitions and suppress internal quiet stretches. |
| The web portal derives a page from an arbitrary custom API host or accepts a non-HTTP destination | The app opens a wrong, unsafe, or unusable page. | Offer only a known local UI or a Cloud app whose API origin matches the active API, and accept HTTP(S) URLs only. |
| A request suppresses every 404 notification instead of only an API-shaped not-found response | A proxy or gateway failure can look like deleted tracking data. | Suppress a 404 only when the request opts in and the API response body confirms not-found. |
| A deleted time log is retried as if it still exists | Its pending time slots can retry forever and block later offline work. | Mark the deleted log's pending work as resolved and continue the sequence. |
| A 404 belongs to another employee after an organization switch | Pending work can be marked synced even though the current session cannot access its log. | Compare the employee at lookup time and now before discarding work. |
| A deleted time slot is cleared after a newer local capture arrives | The new capture can disappear from the timer panel. | Use a capture generation so an old lookup cannot clear newer local state. |
| Timer mutations reach the server at the same time | A stop can overwrite a newer start or alter adjacent time logs. | Serialize timer operations and release the chain after a bounded timeout. |
Key files
| File | Why to read it |
|---|---|
| packages/…/types.ts | Defines the local server, account, work-context, capture, display, window-position, sound, and sync state shared across packages. |
| packages/…/application-setting-store.service.ts | Shows the defaults for capture, sound, update, theme, and durable timer sync behavior. |
| packages/…/window.manager.ts | Shows the common identity and lifecycle model for desktop windows. |
| packages/…/kb-mouse-timer.ts | Explains how operating-system input becomes activity and flush signals. |
| packages/…/desktop-queue.ts and packages/…/persistent-queue.ts | Explain durable job storage, retry, ordering, pause and resume behavior, and restart recovery. |
| packages/…/desktop-window-timer.ts | Illustrates a reusable timer window, its route, lifecycle, and registration. |
| packages/…/navigation-guard.ts | Defines the navigation boundary for privileged Electron content. |
| packages/…/screen-capture-notification.ts | Shows capture-notice placement, display fallback, and close behavior. |
| packages/…/always-on.ts and packages/…/window-position-memory.ts | Show how the always-on widget remembers safe placements across display changes. |
| packages/…/desktop-ipc.ts | Maps renderer requests to main-process tracking, server, capture, authentication, display, network, sound, and sync actions. |
| packages/…/desktop-timer.ts | Combines timer state, activity sources, screenshots, local records, and queue choice. |
| packages/…/update-payload.ts | Defines safe partial updates for local database rows. |
| packages/…/desktop-listen-host.ts, packages/…/server-config.ts, and packages/…/ui-runtime-config.ts | Define local-only and LAN server reachability and how the served UI learns its API address. |
| packages/…/desktop-network-addresses.ts and packages/…/desktop-network-ipc.ts | Define network address discovery for server host selection. |
| packages/…/desktop-server.ts and packages/…/ui-service.ts | Show the local API and UI process lifecycle and runtime configuration handoff. |
| packages/…/desktop-secrets.ts and packages/…/desktop-seed-credentials.ts | Define per-install API secrets, seeded account passwords, environment handoff, and safe logging. |
| packages/…/screenshot-sound.service.ts and packages/…/sound-settings.ipc.ts | Show the local notification sound contracts across the main process and renderer. |
| packages/…/api-server-connectivity.ts and packages/…/desktop-offline-mode-handler.ts | Explain reachability checks and offline state changes. |
| packages/…/auth-strategy.service.ts and packages/…/refresh-token.interceptor.ts | Explain token refresh and credential replacement behavior. |
| packages/…/server-error.interceptor.ts and packages/…/skip-not-found-notification.token.ts | Define the shared error boundary and the safe contract for deleted server records. |
| packages/…/time-tracker.component.ts | Shows renderer-side timer state, capture permission, connectivity, sounds, and Electron event flow. |
| packages/…/time-tracker.service.ts | Defines timer API access, serialized timer mutations, and missing-record results. |
| packages/…/sequence-queue.ts | Shows how offline timer sequences handle deleted or out-of-reach time logs before sending dependent slots. |
| packages/…/timer-required-fields.ts and packages/…/timer-tracker-change-dialog.component.ts | Define the organization rules that gate timer start and active-timer context changes. |
| packages/…/organization-switch.service.ts | Defines the organization switch contract and its timer safety rules. |
| packages/…/time-tracker.component.deleted-slot.spec.ts and packages/…/time-tracker.service.not-found.spec.ts | Show how deleted captures and server records resolve without hiding real failures. |
| packages/…/sequence-queue.spec.ts and packages/…/server-error.interceptor.spec.ts | Show the contracts for deleted-log recovery and selective 404 notification suppression. |