anthropics / anthropics/claude-code

[BUG] Artifact db capability — live sync doesn't deliver updates to the page on reload

未关闭
#94,426 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
area:claude-code-web bug platform:web
主要语言
Python
星标
145k
派生
23.1k
PR 合并指标
PR 指标待抓取

描述

### Preflight Checklist

- [x] I have searched [existing issues](https://github.com/anthropics/claude-code/issues?q=is%3Aissue%20state%3Aopen%20label%3Abug) and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code

### What's Wrong?

Title: Artifact db capability — live sync doesn't deliver updates to the page on reload

Artifact: https://claude.ai/code/artifact/e79c7ec3-3686-4b07-bf32-6369bfff00ed (private, runtime contract 0.2.49 — latest)

Summary: Writes to the artifact's db collection persist correctly and durably (verified repeatedly via read_db, including at as_level: interact matching a normal viewer's access). The published page's own hydrateFromDb() — a one-time collection("jobs").get() followed by onSnapshot(), matching the documented db capability contract exactly — does not reliably reflect those writes on a fresh page load.

Reproduction:

Edit a document via the page's own UI (adds/changes a field), confirm the write succeeded via read_db.
Fully reload the page (not just close/reopen a panel within the same tab).
The reload shows the pre-edit state, not the current database state.

Confirmed NOT the cause:

Not browser cache — reproduced in a fresh incognito window.
Not local to one machine — reproduced on a separate device (mobile) on a separate network.
Not a stale runtime — upgraded from contract 0.2.43 to the latest (0.2.49); no change.
Not a code defect — hydrateFromDb()/onSnapshot() usage was audited against the platform's own db.d.ts for contract 0.2.49 and matches the documented pattern (subscribed once, not per-render, no filters).
Not an access-rule issue — identical stale result at both owner-level and interact-level reads.
No error surfaces to the page — hydrateFromDb()'s .catch path (which would show a "couldn't load the latest data" notice) never fires.

Current workaround: manually re-fetch the collection and republish the page with a freshly baked-in seed. Not sustainable as a standing fix.

### What Should Happen?

What should happen: On a fresh page load, hydrateFromDb()'s initial collection("jobs").get() should resolve with the current state of every document in the collection — including any writes made before the reload, regardless of who made them or how recently. Per the db capability's own documentation: "Read once. Absence is NOT an error" — a one-time get() is documented as authoritative, not eventually-consistent or cached. The subsequent onSnapshot() subscription should then keep that state live for as long as the page stays open, per its documented contract: "next fires with the current state soon after registration, then on every change — including other viewers' writes, live."

In practice: reload the page, and it should show exactly what's in the database at that moment — not a snapshot from whenever the artifact was last republished.

### Error Messages/Logs

```shell

```

### Steps to Reproduce

Steps to Reproduce

Publish an artifact declaring capabilities: {db: {}}, with a page that on load calls a one-time read followed by a live subscription:
const db = await claude.use("db");
db.collection("jobs").get().then(snap => {
// render initial state from snap.docs
db.collection("jobs").onSnapshot(snap => {
// re-render on every change
});
});

(This is the exact pattern used in artifact e79c7ec3-3686-4b07-bf32-6369bfff00ed, contract 0.2.49 — subscribed once at page load, not per-render, no filters/limits on the query.)

Open the published page as the owner (or any granted viewer) and edit a document through the page's own UI — e.g. change a text field on one job record — triggering a set()/update() write.
Confirm the write actually persisted by reading the same document directly via the platform's read_db (bypassing the page entirely) — it shows the new value, with an incremented version and a fresh updatedAt.
Fully reload the page (not a same-tab panel close/reopen — an actual navigation/reload) and view that same document.
Expected: the page shows the value confirmed in step 3.
Actual: the page shows the value from before step 2 — the state as of whenever the artifact was last republished, not the current database state.
Repeat step 4 in: a private/incognito window, and on a separate physical device on a separate network. Same stale result every time — rules out browser cache, cookies, or anything local to one machine.
Repeat the whole test after upgrading the artifact's contract to latest (0.2.43 → 0.2.49) and republishing. No change in behavior.

Concrete instance: job PHX-1014 in the artifact above — a second unit/vehicle was added via the page's edit form and saved; read_db confirmed the write (both vehicles present, version incremented); the page, reloaded fresh on desktop, incognito, and mobile, continued showing only the original single vehicle until the artifact was manually republished with the current data force-baked into its seed.

### Claude Model

Sonnet (default)

### Is this a regression?

No, this never worked

### Last Working Version

_No response_

### Claude Code Version

2.1.272 (Claude Code)

### Platform

Anthropic API

### Operating System

Windows

### Terminal/Shell

Windows Terminal

### Additional Information

_No response_

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。