Skip to content

Commit d161c26

Browse files
committed
fixup! fix(web): file saves no longer overwrite newer disk changes (#1869)
1 parent db1dda6 commit d161c26

3 files changed

Lines changed: 11 additions & 22 deletions

File tree

‎apps/server/src/workspace/WorkspaceFileSystem.fork.ts‎

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
1-
// Fork-owned seam for the global external-workspace-symlink policy
2-
// (RSI-Software/t3code-hyprws#951, reshaping 565594bd75).
3-
//
4-
// Upstream's read resolver hard-blocks any path whose resolved target leaves
5-
// the workspace root. The fork adds a server-authoritative opt-in: when the
6-
// `followExternalWorkspaceSymlinks` server setting is enabled, reads may cross
7-
// symlinks whose targets are outside the root. The settings service is looked
8-
// up optionally so the seam adds no requirement to `WorkspaceFileSystem.layer`
9-
// — upstream files and test harnesses keep upstream text, and the production
10-
// wiring in `server.ts` provides the service through one marked hook. Without
11-
// the service (or on a settings error) the containment guard stays closed.
1+
// Fork seam: reads may cross symlinks whose targets leave the workspace root only when the
2+
// `followExternalWorkspaceSymlinks` server setting is on. The settings service is looked up
3+
// optionally so `WorkspaceFileSystem.layer` gains no requirement; `server.ts` provides it through
4+
// one marked hook. Without it, or on a settings error, the containment guard stays closed.
125
import { type ProjectWriteFileInput, projectFileRevision } from "@t3tools/contracts";
136
import * as Effect from "effect/Effect";
147
import * as FileSystem from "effect/FileSystem";

‎apps/web/src/components/files/fileSaveBase.fork.ts‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import { projectFileRevision } from "@t3tools/contracts";
22

3-
// Stale-write guard (RSI-Software/t3code-hyprws#1761): the disk revision each
4-
// unsaved draft started from, keyed by the file's optimistic atom. A save sends
5-
// it so the server refuses to replace a newer disk version. An entry without a
6-
// revision skips the check: the panel never showed disk contents, or the user
7-
// chose to overwrite. A saved or reloaded draft holds SETTLED until the next
8-
// edit, so an editor still holding it cannot resend it unchecked.
3+
// Stale-write guard: the disk revision each unsaved draft started from, sent on save
4+
// so the server refuses to replace a newer disk version. No revision skips the check
5+
// (disk contents never shown, or the user chose to overwrite). A saved or reloaded draft
6+
// holds SETTLED until the next edit, so a stale editor cannot resend it unchecked.
97
const SETTLED = Symbol("settled");
108
// Weak keys: a closed file's atom and its settled entry can be collected.
119
const draftBases = new WeakMap<object, string | undefined | typeof SETTLED>();

‎packages/contracts/src/projectFileRevision.fork.ts‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
// Fork-owned stale-write guard for workspace file saves
2-
// (RSI-Software/t3code-hyprws#1761). Client and server hash the same decoded
3-
// text, so a save names the disk version its draft started from without
4-
// resending that version's contents. Synchronous because `crypto.subtle` is
5-
// missing on plain-HTTP remote origins.
1+
// Fork-owned stale-write guard for workspace file saves. Client and server hash the same decoded
2+
// text, so a save names its draft's base disk version without resending it. Synchronous because
3+
// `crypto.subtle` is missing on plain-HTTP remote origins.
64
export function projectFileRevision(contents: string): string {
75
let hash = 2_166_136_261;
86
for (let index = 0; index < contents.length; index += 1) {

0 commit comments

Comments
 (0)