"Keep This Window Open" Is a Bug Report
Our backfill flow once told users to keep the window open. That copy admitted the server didn't own the job, and fixing it made dedup the real problem.
"Please keep this window open until complete." That sentence sat in small gray text under a progress bar on KittyLog's dashboard for about four months. The commit that added it described it as a helpful note. I have come around to a less flattering reading: it was a bug report, written by the app, about itself, and we shipped it to users instead of filing it.
The feature behind it is backfill. When you connect a repository that already has history, KittyLog offers to generate changelog entries for the releases you shipped before it existed. The first version of that flow worked like this: the browser opened a server-sent-events stream, and the server generated entries one at a time while the connection stayed up. The progress bar was real, the entries were real, and the whole thing was welded to the lifetime of one HTTP request. Navigate away and generation stopped wherever it happened to be. For a fresh connect with fifty-plus historical releases, that is a long time to keep a tab pinned like it owes you money.
Hence the note, which went in with a commit on December 17, 2025. Any instruction of the form "don't close this tab" means the same thing everywhere you see it: the server is not treating the work as a job, it is treating the work as a request. Requests die with their connection; jobs have their own lifecycle, stored somewhere a browser can't reach. The copy is the app admitting which of the two it built. Once I read our own note that way, it became an architecture ticket: issue #1087, "move to background job (drop 'keep this window open')."
The fix landed in April 2026. The frontend now calls a queue endpoint that inserts one row per item into a backlog_jobs table and returns immediately. A background worker drains the table and does the actual generation server-side. The browser's only remaining role is to poll a status endpoint and draw the progress bar. Close the tab mid-backfill and nothing stops, because nothing was ever running in the tab. The gray note is gone from the codebase; I grepped for it to make sure.
What I underestimated was the second half of the trade. While the browser owned the job, exactly one thing could run it: that connection. The moment the server owns the job, anything can request it, as many times as it likes. Two tabs open on the same repo both auto-trigger backfill on mount, and a reload asks all over again. We had filed this as issue #1090 before the background move even shipped, and the honest note in that issue says the old duplication was "probably benign" because each item checked the database before generating. Wasteful, but roughly self-limiting.
With a job table, dedup has to be deliberate, and it ended up as three layers. A partial unique index on (repo_id, item_id) where status is pending or running, so concurrent enqueues of the same item collapse into one row and the loser is treated as a no-op. A per-repo advisory lock, so two worker passes don't drain the same repo at once. And FOR UPDATE SKIP LOCKED on the claim query, so individual jobs can't be picked up twice. None of this is exotic; it's standard Postgres. The point is that every layer became necessary only after we did the right thing. Moving the work server-side relocated the coordination problem rather than removing it, though at least it landed somewhere Postgres can referee.
Even then a gap survived. The old SSE endpoint still existed for manual clicks, and it didn't consult the job table at all. Click "backfill now" while the queue was already processing the same items and you'd pay for duplicate LLM calls. Issue #1112 closed that with a defensive filter (items already pending or running get skipped, and the stream reports them as skipped so the progress numbers still add up) plus an integration test that races two real enqueues and asserts one surviving row.
The small stuff got swept too. The success banner used to re-show on every reload because it trusted hook-local state (#1089, fixed with a flag that only sets when generation actually started this session). The last manual click in the flow, "Load Full History," now happens automatically on a fresh connect (#1091). And by July the server-side fetch code had grown to a 659-line file that we split into three modules, which I take as a decent sign of where the weight of this feature now lives.
One piece of this remains unfinished. That SSE streaming endpoint still exists. The onboarding modal still calls it for manual generation, so KittyLog currently has two backfill execution models: the queue, and the filtered stream. Issue #1112 named retiring the stream as the eventual right answer and explicitly scoped it out, and as of this writing no open issue tracks it. I should probably go file one.
Source records
- Issue #1087, backfill moved to a background job (closed April 2026).
- Issues #1089, #1090, #1091, #1112, the follow-up dedup and polish items (all closed).
- Commit 6eb1afab, the December 2025 commit that added the "keep this window open" note.
- Commits a193f1a0, 037e228d, 7d8fb60d, 3de6a299, and 63c63668.
api/services/backlog_queue_service.py,api/services/backlog_worker_service.py,api/routers/repositories/backlog/.