Repository navigation
feat(web): mark and lock documents managed from a repository - #758
Conversation
There was a problem hiding this comment.
ℹ️ No critical issues — two low-stakes suggestions below.
Reviewed changes
- Managed-copy banner —
managed-copy-banner.tsx+ test: repository, file path and short commit, the locked/unlocked explanation, and a Lock/Unlock button only fordocs:write, disabled while a change is pending. - Lock handling —
doc-lock.ts+ route: a save answered with409 DOC_LOCKEDis dropped, the cached document is marked locked and refetched, and the page shows one "not saved" message. - Read-only editor —
editable = canWrite && !locked; the editor remounts when the lock flips, and a remote lock while dirty raises the single toast. - Doc tree —
app-sidebar.tsx: a managed-copy marker (icon + accessible label) and Rename disabled for locked copies, while move and delete stay available. - API surface —
DocSource/source_lockedonDocument,source_lockedon the update payload, andApiErrorCode.DocLocked. - Translations — 7
docs.managedCopy.*keys in all 9 locales. - e2e — new feature + spec covering the banner/marker, unlock, lock-while-open in two browsers, the 409 race, and rename/move.
- Realtime (stacked from #756,
118bc8a) — an empty post-grace collab room is dropped when the stored content changes, so the next editor re-seeds instead of being handed pre-write content. Reviewed; the drop is synchronous after the access-check await, the timers are cleared indestroy, and cluster leases simply stop being renewed.
ℹ️ Revert from the activity pane still writes to a locked copy
With docs:write, a locked managed copy still renders the activity pane's Revert action, and handleRevert PATCHes title/content. The API refuses that with 409 DOC_LOCKED, so the action always fails with the pane's generic "revert failed" message, while rename from the tree now explains why it is unavailable. Gating the revert on the lock (leaving comment editing enabled) would close the last content-write affordance this PR left open.
Technical details
# Gate the activity-pane revert on the document lock
## Affected sites
- `apps/web/src/components/projects/docs/doc-activity-pane.tsx:130-159` — `handleRevert` calls `updateDocument(projectId, docId, {title?, content?})`.
- `apps/web/src/components/projects/docs/doc-activity-pane.tsx:210-212` — `onRevert`/`isRevertable` are gated only on `canEdit` (= `canWrite`).
- `apps/web/src/routes/_authenticated/projects/$projectId/docs/$docId.tsx:364-369` — `DocActivityPane` receives `canEdit={canWrite}` with no lock information.
## Required outcome
- A locked managed copy does not offer an enabled Revert that the server will always reject; either hide it or disable it with the same reason the tree's Rename item uses (`docs.managedCopy.locked`).
- Comment add/edit/delete must stay available: the lock only covers content and title.
## Suggested approach (optional)
- Pass the lock state (or a `canRevert` boolean) from the doc page and combine it with `canEdit` for `onRevert`/`isRevertable` only, not for the comment props.deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
…s locked Clicking Lock blurs the editor, which starts a save. The button was disabled while a save was pending, so the click that caused the save was dropped. The lock request now waits for the save in flight instead. The activity pane offered Revert on a locked copy, which the API always refuses. It is offered only while the copy is unlocked; comments stay available.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Re-reviewed the delta since the last pullfrog review (1c50823 → 5a82ac8, 4 files). Both prior findings are addressed:
- Lock waits for the blur-save — the banner button is disabled only by
lockMutation.isPending, andlockMutation.mutationFnawaits the content save tracked insaveInFlightRefbefore sending the lock, so the save still reaches the server first without the click being dropped. The ordering holds in Chromium, Firefox and WebKit, where focus leaves the editor on mousedown and the save is dispatched beforeclick. - Revert gated on the lock —
DocActivityPanetakes acanRevertprop (defaulting tocanEdit) that gates onlyonRevert/isRevertable; the page passescanWrite && !locked, so a locked copy hides Revert while comments stay editable andView diffremains offered. - Coverage for both — two browser specs plus matching feature scenarios: locking with an unsaved edit takes one click and keeps the edit, and a locked copy offers no Revert until it is unlocked.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
pikann
left a comment
There was a problem hiding this comment.
LGTM! Thank you for the contribution! 🚀

Summary
Fourth part of #747 (docs pull / push / content check for coding agents), on top of #754. The web app shows which documents are managed copies of a repository file and stops people from editing a locked one by accident.
sourceshows where it comes from above the editor: repository, file path and, when recorded, the commit.docs:writecan lock or unlock a managed copy from the banner (PATCH /docs/{docId}withsource_locked). The button is disabled while a save is pending.source_lockedis true. Locking a document someone has open takes effect in their page without a reload: the existing rule that refetches a document ondoc.updatedalready covers it, so there is no new realtime code in the web app.409 DOC_LOCKEDis dropped and not retried, the page shows one message that the change was not saved, and the document is marked locked at once.Decisions, listed so they can be challenged
409that arrives after the person switched documents would mark the wrong one locked.docs:writecan unlock.Known gaps
source.commitraises no event (by design in feat(api): read and write documents by path, with managed-copy metadata and change notes #754), so an open page keeps showing the previous commit in the banner until the document is next fetched.409stays in the shared editing room for a short time. If someone unlocks the document within 30 seconds and nothing else is written in between, that edit can come back and be saved. It is the person's own edit, not someone else's content, but it contradicts the "not saved" message. Not covered by a test.If-Matchfor documents; that is unchanged here.Type of Change
Testing
apps/web:tscclean;biomereports no errors;vitest1673 of 1674 pass. The one failure,GitSettings.test.tsx("shows the platform's reason on error and keeps the form usable", 5 s timeout), fails 3 of 3 on unmodifiedmaster, and this PR does not touch that area. New unit tests:managed-copy-banner.test.tsx,doc-lock.test.ts.services/realtime(the fix(realtime): drop an empty collab room when the stored content changes #756 commit):bun run lint,bun run check,bun test(151 pass).apps/e2e, chromium,tests/docsandtests/realtime) on a stack built from this branch: 210 passed, 6 skipped, 2 failed, 1 passed on retry.tests/docs/managed-copies.spec.ts, all 5 pass:docs.spec.ts:350(rename from the sidebar) anddocs.spec.ts:640(edit own comment, usesControl+aon macOS) fail the same way onmaster.collaborative-editing.spec.ts:395failed once and passed on retry. The whole file run 4 times without retries failed 13 of 28 on this branch and 19 of 28 on unmodifiedmaster, so these specs are racy under parallel load today; run one at a time, spec 395 passed 15 of 15 on this branch.docs.spec.tsdoes not pass lint onmastertoday.Checklist