Repository navigation
feat(server): badge the live task queue from the SSE stream - #102
Merged
Merged
Conversation
The server announces its task queue on the event stream: `TaskQueueStatus` carries the queued total and the per-type split, and the first frame of every connection is that snapshot. iOS keeps it in `AppConfig.taskQueueStatus` and badges three surfaces with it (the settings server row, the server page's Server Info tile, the Server Info page's Tasks row). Android received the frame and threw it away. `SseService` counted it as the stream's keep-alive, `SseChangeParser` dropped every `Task*` name, and nothing listened for it, so the only queue number the app ever had was the one `ServerAdminViewModel.loadTasks` fetched from `/stats/server` — once, after the user had already opened Server → Tasks. A scan started from the web UI was invisible until then, and on stock Komga the per-type list stayed empty because the stats endpoint there carries no `queued`. `TaskQueueStore` now holds the announcement (count, per-type counts, and the time it arrived), `SseChangeParser.parseTaskQueue` decodes it, and `SseContentSync` routes it to the store instead of the change bus — it is the whole queue, not a content delta, so no row can be patched from it. The store is cleared wherever the socket stops, mirroring iOS's `disconnect`: the count belongs to that stream, and the next connection re-announces it. The `updatedAt` field is what keeps the UI honest: it separates "the server says zero" from "nothing has been announced yet", so a screen falls back to the fetched value (SSE off, non-admin session, an older server) instead of painting a zero it has no evidence for. Both the settings server row and the server page's 任务 row now read the live count, and the Tasks page prefers the snapshot — the same queue, but it moves on its own.
The settings hub showed the live queue as a bare trailing number. Against the other rows that read as a static fact — the server address, the account name all sit in the same slot — so a moving count was indistinguishable from a setting that simply happens to be a number. iOS has the same row in `SettingsBadgeRow`: an 8 pt `Circle` in the badge color (`.secondary` at the call site) followed by the count in `caption` semibold, with 4 pt of air between them. The dot is what makes the value read as a live badge and not a value. `SettingsRow` gains `valueDot`, `SettingsValueText` draws the dot and weights the label semibold when it is set, and only the server row passes it — every other `value` row keeps its regular-weight text.
dyphire
force-pushed
the
fix/task-queue-live-badge
branch
from
November 28, 2026 18:28
7e555fc to
bf9f6aa
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The server announces its task queue on the SSE stream:
TaskQueueStatuscarries the queued total plus a per-type split, and the first frame of every connection is that snapshot. iOS keeps it inAppConfig.taskQueueStatusand badges three surfaces with it (settings server row, server page's Server Info tile, Server Info page's Tasks row).Android received the frame and threw it away —
SseServicecounted it as the stream's keep-alive,SseChangeParserdropped everyTask*name, and no screen listened. The only queue number the app ever had was the oneServerAdminViewModel.loadTasksfetched from/stats/server, once, after the user had already opened Server → Tasks. A scan started from the web UI stayed invisible until then, and on stock Komga the per-type list stayed empty because the stats endpoint there carries noqueued.What changed
TaskQueueStore(new,core/sse): holds the last announcement —count,countByType,updatedAt.SseChangeParser.parseTaskQueue: decodes the frame (count/countByType, unknown keys ignored, missing fields default). It does not go throughparse(), because it is the whole queue and not a content delta — no row can be patched from it.SseContentSync: routes the frame to the store instead of the change bus. It is also the first frame of every connection, so a reconnect refills the badge without an extra request.SseService.stop(): clears the store, mirroring iOS'sdisconnect— the count belongs to that stream, and another instance must not inherit it.Why
updatedAtIt separates "the server says zero tasks" from "nothing has been announced yet". Without it, a screen can only paint a zero it has no evidence for — SSE disabled, a non-admin session, or an older server all look identical to an idle server. With it, those fall back to the value the page fetched.
Surfaces
SettingsBadgeRow:Circle+caption/semibold).SettingsRowgainedvalueDot,SettingsValueTextdraws the dot, andSettingsComponentskeeps a navigating row's chevron beside a value (iOS draws the badge before the disclosure indicator). Without the dot the count read as a static setting, indistinguishable from the server address in the same slot./stats/serverfetch said.queuedbutcountByTypedoes.Verification
:app:compileDebugKotlin,:app:testDebugUnitTest,:app:lintDebug(exit 0, no new findings) pass.TaskQueueTest(5 cases): payload mapping, empty queue, unknown/missing keys, unreadable payload discarded rather than guessed, store update/filter/clear semantics.