From bcf01d16fcd0896519df3114add05ef75a50c557 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Mon, 2 Nov 2026 17:52:17 -0600 Subject: [PATCH 1/3] fix(id): web-fmt 18 files, russh 0.65 auth_publickey signature, render_ansi_diff visibility (#1372) - biome format --write: 18 web files (matches nightly web-fmt-check 18 errors) - world_ssh.rs: auth_publickey takes VerifiedPublicKey (russh 0.65 trait change; E0053) - id-core world_presentation.rs: render_ansi_diff pub(crate) -> pub (E0624, called from id crate) --- .../crates/id-core/src/world_presentation.rs | 2 +- pkgs/id/src/world_ssh.rs | 10 +- pkgs/id/web/src/collab.test.ts | 66 ++---- pkgs/id/web/src/collab.ts | 13 +- pkgs/id/web/src/editor.ts | 6 +- pkgs/id/web/src/goto-line.test.ts | 119 +++------- pkgs/id/web/src/goto-line.ts | 4 +- pkgs/id/web/src/highlight-e2e.test.ts | 8 +- pkgs/id/web/src/highlight.test.ts | 10 +- pkgs/id/web/src/image-upload.test.ts | 11 +- pkgs/id/web/src/save-shortcut.test.ts | 18 +- pkgs/id/web/src/save-shortcut.ts | 6 +- pkgs/id/web/src/search-panel.ts | 33 +-- pkgs/id/web/src/shell-contract.ts | 5 +- pkgs/id/web/src/world-contract.test.ts | 11 +- pkgs/id/web/src/world-records.test.ts | 5 +- pkgs/id/web/src/world-rejoin.test.ts | 35 +-- pkgs/id/web/src/world-surface.test.ts | 29 ++- pkgs/id/web/src/world-surface.ts | 214 +++++++++++++++--- pkgs/id/web/src/world.ts | 7 +- 20 files changed, 340 insertions(+), 272 deletions(-) diff --git a/pkgs/id/crates/id-core/src/world_presentation.rs b/pkgs/id/crates/id-core/src/world_presentation.rs index f08d641742..4c614d8f19 100644 --- a/pkgs/id/crates/id-core/src/world_presentation.rs +++ b/pkgs/id/crates/id-core/src/world_presentation.rs @@ -454,7 +454,7 @@ impl ScreenSurface { /// leave a stale continuation cell behind. `None` means the caller must /// use a full repaint (invalid screen or changed dimensions/version). #[must_use] - pub(crate) fn render_ansi_diff(&self, previous: &Self) -> Option { + pub fn render_ansi_diff(&self, previous: &Self) -> Option { if !self.is_valid() || !previous.is_valid() || self.version != previous.version diff --git a/pkgs/id/src/world_ssh.rs b/pkgs/id/src/world_ssh.rs index ab35d719fe..c806b160b6 100644 --- a/pkgs/id/src/world_ssh.rs +++ b/pkgs/id/src/world_ssh.rs @@ -39,8 +39,10 @@ use std::{ use futures_lite::StreamExt; use russh::{ Channel, ChannelId, ChannelOpenFailure, MethodKind, MethodSet, Pty, - keys::{Algorithm, PrivateKey, PublicKey, ssh_key::HashAlg, ssh_key::LineEnding}, - server::{Auth, ChannelOpenHandle, Config, Handle, Handler, Msg, Server, Session}, + keys::{Algorithm, PrivateKey, ssh_key::HashAlg, ssh_key::LineEnding}, + server::{ + Auth, ChannelOpenHandle, Config, Handle, Handler, Msg, Server, Session, VerifiedPublicKey, + }, }; use serde_json::json; use tokio::{ @@ -305,12 +307,12 @@ impl Handler for SshClient { async fn auth_publickey( &mut self, user: &str, - public_key: &PublicKey, + public_key: VerifiedPublicKey<'_>, ) -> Result { let Some(world) = user.strip_prefix(EXPLORE_PREFIX) else { return Ok(Auth::reject()); }; - let Some(ed25519) = public_key.key_data().ed25519() else { + let Some(ed25519) = public_key.public_key.key_data().ed25519() else { return Ok(Auth::reject()); }; if self.permit.is_none() { diff --git a/pkgs/id/web/src/collab.test.ts b/pkgs/id/web/src/collab.test.ts index 4326898029..fdc3e36c23 100644 --- a/pkgs/id/web/src/collab.test.ts +++ b/pkgs/id/web/src/collab.test.ts @@ -52,10 +52,7 @@ class FakeWebSocket { deliver(msg: unknown): void { const packed = packr.pack(msg); - const buf = packed.buffer.slice( - packed.byteOffset, - packed.byteOffset + packed.byteLength, - ) as ArrayBuffer; + const buf = packed.buffer.slice(packed.byteOffset, packed.byteOffset + packed.byteLength) as ArrayBuffer; this.onmessage?.({ data: buf }); } @@ -84,16 +81,18 @@ function track void }>(conn: T): T { } function openCollab(onEditorReady = vi.fn()) { - const conn = track(initCollab( - "ws://example.test/collab", - makeContainer(), - "doc-1", - "notes.md", - null, - undefined, - undefined, - onEditorReady, - )); + const conn = track( + initCollab( + "ws://example.test/collab", + makeContainer(), + "doc-1", + "notes.md", + null, + undefined, + undefined, + onEditorReady, + ), + ); const socket = FakeWebSocket.instances.at(-1)!; socket.open(); return { conn, socket, onEditorReady }; @@ -119,14 +118,9 @@ describe("initCollab protocol handling (#1463, #2824)", () => { it("reconnect AUTH sends the AUTH_OK refreshed token, not the init token", () => { const onTokenRefresh = vi.fn(); - const conn = track(initCollab( - "ws://example.test/collab", - makeContainer(), - "doc-1", - "notes.md", - "OLD_TOKEN_A", - onTokenRefresh, - )); + const conn = track( + initCollab("ws://example.test/collab", makeContainer(), "doc-1", "notes.md", "OLD_TOKEN_A", onTokenRefresh), + ); const first = FakeWebSocket.instances[0]; first.open(); @@ -149,14 +143,9 @@ describe("initCollab protocol handling (#1463, #2824)", () => { }); it("reconnect without any refresh re-sends the init token", () => { - const conn = track(initCollab( - "ws://example.test/collab", - makeContainer(), - "doc-1", - "notes.md", - "ONLY_TOKEN", - undefined, - )); + const conn = track( + initCollab("ws://example.test/collab", makeContainer(), "doc-1", "notes.md", "ONLY_TOKEN", undefined), + ); const first = FakeWebSocket.instances[0]; first.open(); @@ -172,14 +161,7 @@ describe("initCollab protocol handling (#1463, #2824)", () => { }); it("anonymous connect sends no AUTH frame, before or after reconnect", () => { - const conn = track(initCollab( - "ws://example.test/collab", - makeContainer(), - "doc-1", - "notes.md", - null, - undefined, - )); + const conn = track(initCollab("ws://example.test/collab", makeContainer(), "doc-1", "notes.md", null, undefined)); const first = FakeWebSocket.instances[0]; first.open(); @@ -313,13 +295,7 @@ describe("buildCollabWsUrl (#2830)", () => { FakeWebSocket.instances = []; vi.stubGlobal("WebSocket", FakeWebSocket); const conn = track( - initCollab( - buildCollabWsUrl("ws:", "example.test", "a#b.md"), - makeContainer(), - "a#b.md", - "a#b.md", - null, - ), + initCollab(buildCollabWsUrl("ws:", "example.test", "a#b.md"), makeContainer(), "a#b.md", "a#b.md", null), ); const socket = FakeWebSocket.instances.at(-1)!; const url = new URL(socket.url); diff --git a/pkgs/id/web/src/collab.ts b/pkgs/id/web/src/collab.ts index 272908782b..27ea6a5794 100644 --- a/pkgs/id/web/src/collab.ts +++ b/pkgs/id/web/src/collab.ts @@ -288,14 +288,7 @@ export function initCollab( ); return; } - console.log( - "[collab] Sending", - batch.length, - "of", - sendable.steps.length, - "steps, version:", - sendable.version, - ); + console.log("[collab] Sending", batch.length, "of", sendable.steps.length, "steps, version:", sendable.version); send(MSG.STEPS, sendable.version, batch, sendable.clientID); } }; @@ -326,9 +319,7 @@ export function initCollab( const version = msg[1]; const doc = msg[2]; const docRecord = - doc !== null && typeof doc === "object" && !Array.isArray(doc) - ? (doc as Record) - : null; + doc !== null && typeof doc === "object" && !Array.isArray(doc) ? (doc as Record) : null; if (typeof version !== "number" || !Number.isSafeInteger(version) || version < 0) { console.error("[collab] Dropping malformed Init message: invalid version"); return; diff --git a/pkgs/id/web/src/editor.ts b/pkgs/id/web/src/editor.ts index 2caa724a86..efbf443b01 100644 --- a/pkgs/id/web/src/editor.ts +++ b/pkgs/id/web/src/editor.ts @@ -234,9 +234,11 @@ export const richSchema = new Schema({ // reflection admits fractional/negative/hex starts the u64 // markdown codec cannot represent). const el = dom as HTMLOListElement; - if (el.classList.contains("contains-task-list")) return { order: parseOrderedListStart(el.getAttribute("start")) }; + if (el.classList.contains("contains-task-list")) + return { order: parseOrderedListStart(el.getAttribute("start")) }; const firstLi = el.querySelector("li"); - if (firstLi?.querySelector('input[type="checkbox"]')) return { order: parseOrderedListStart(el.getAttribute("start")) }; + if (firstLi?.querySelector('input[type="checkbox"]')) + return { order: parseOrderedListStart(el.getAttribute("start")) }; return false; }, }, diff --git a/pkgs/id/web/src/goto-line.test.ts b/pkgs/id/web/src/goto-line.test.ts index 94021d9414..e74c933373 100644 --- a/pkgs/id/web/src/goto-line.test.ts +++ b/pkgs/id/web/src/goto-line.test.ts @@ -17,13 +17,7 @@ import { createGotoLinePlugin, destroyGotoLineDialog } from "./goto-line"; function createStateWithGotoLine(docContent?: string): EditorState { const plugin = createGotoLinePlugin(); const doc = docContent - ? rawSchema.node("doc", null, [ - rawSchema.node( - "code_block", - null, - docContent ? [rawSchema.text(docContent)] : [], - ), - ]) + ? rawSchema.node("doc", null, [rawSchema.node("code_block", null, docContent ? [rawSchema.text(docContent)] : [])]) : undefined; return EditorState.create({ schema: rawSchema, @@ -53,11 +47,7 @@ function triggerGotoLine(view: EditorView): boolean { // eslint-disable-next-line @typescript-eslint/no-explicit-any -- handleKeyDown this context workaround const handler = (plugin.props as any).handleKeyDown; if (!handler) return false; - return handler.call( - plugin, - view, - new KeyboardEvent("keydown", { key: "g", ctrlKey: true }), - ); + return handler.call(plugin, view, new KeyboardEvent("keydown", { key: "g", ctrlKey: true })); } // ── Tracked resources for cleanup ────────────────────────────────── @@ -206,9 +196,7 @@ describe("go-to-line command", () => { triggerGotoLine(view); - const input = container.querySelector( - ".goto-line-input", - ) as HTMLInputElement; + const input = container.querySelector(".goto-line-input") as HTMLInputElement; expect(input).not.toBeNull(); // 3 lines in doc → placeholder should contain "3" expect(input.placeholder).toContain("3"); @@ -241,13 +229,9 @@ describe("dialog input interaction", () => { const dialog = container.querySelector(".goto-line-dialog") as HTMLElement; expect(dialog).not.toBeNull(); - const input = container.querySelector( - ".goto-line-input", - ) as HTMLInputElement; + const input = container.querySelector(".goto-line-input") as HTMLInputElement; // Simulate pressing Escape on the input - input.dispatchEvent( - new KeyboardEvent("keydown", { key: "Escape", bubbles: true }), - ); + input.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true })); expect(dialog.style.display).toBe("none"); }); @@ -260,14 +244,10 @@ describe("dialog input interaction", () => { triggerGotoLine(view); const dialog = container.querySelector(".goto-line-dialog") as HTMLElement; - const input = container.querySelector( - ".goto-line-input", - ) as HTMLInputElement; + const input = container.querySelector(".goto-line-input") as HTMLInputElement; input.value = "1"; - input.dispatchEvent( - new KeyboardEvent("keydown", { key: "Enter", bubbles: true }), - ); + input.dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true })); expect(dialog.style.display).toBe("none"); }); @@ -278,17 +258,13 @@ describe("dialog input interaction", () => { triggerGotoLine(view); - const input = container.querySelector( - ".goto-line-input", - ) as HTMLInputElement; + const input = container.querySelector(".goto-line-input") as HTMLInputElement; input.value = "2"; // Before: cursor is at default position const _posBefore = view.state.selection.from; - input.dispatchEvent( - new KeyboardEvent("keydown", { key: "Enter", bubbles: true }), - ); + input.dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true })); // After: cursor should have moved (to line 2 start) // In rawSchema: doc > code_block > text "first\nsecond\nthird" @@ -313,36 +289,25 @@ describe("dialog input interaction", () => { ["+2", "signed line 2"], ["999", "out of range"], ["", "empty"], - ])( - "Enter with %s (%s) does not move the cursor and keeps the dialog open", - (value) => { - const { view, container } = createViewWithGotoLine( - "first\nsecond\nthird", - ); - views.push(view); - containers.push(container); - - triggerGotoLine(view); - - const dialog = container.querySelector( - ".goto-line-dialog", - ) as HTMLElement; - const input = container.querySelector( - ".goto-line-input", - ) as HTMLInputElement; - input.value = value; - const posBefore = view.state.selection.from; - - input.dispatchEvent( - new KeyboardEvent("keydown", { key: "Enter", bubbles: true }), - ); - - // #712: invalid input must not be silently reinterpreted (0 -> line 1, - // 2.9 -> line 2) or swallowed (999) — no move, dialog stays open. - expect(view.state.selection.from).toBe(posBefore); - expect(dialog.style.display).not.toBe("none"); - }, - ); + ])("Enter with %s (%s) does not move the cursor and keeps the dialog open", (value) => { + const { view, container } = createViewWithGotoLine("first\nsecond\nthird"); + views.push(view); + containers.push(container); + + triggerGotoLine(view); + + const dialog = container.querySelector(".goto-line-dialog") as HTMLElement; + const input = container.querySelector(".goto-line-input") as HTMLInputElement; + input.value = value; + const posBefore = view.state.selection.from; + + input.dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true })); + + // #712: invalid input must not be silently reinterpreted (0 -> line 1, + // 2.9 -> line 2) or swallowed (999) — no move, dialog stays open. + expect(view.state.selection.from).toBe(posBefore); + expect(dialog.style.display).not.toBe("none"); + }); it("Enter with line 1 moves cursor to the first line start", () => { const { view, container } = createViewWithGotoLine("first\nsecond"); @@ -351,14 +316,10 @@ describe("dialog input interaction", () => { triggerGotoLine(view); - const input = container.querySelector( - ".goto-line-input", - ) as HTMLInputElement; + const input = container.querySelector(".goto-line-input") as HTMLInputElement; input.value = "1"; - input.dispatchEvent( - new KeyboardEvent("keydown", { key: "Enter", bubbles: true }), - ); + input.dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true })); // Line 1 starts at the code_block's content start: the block sits // at pos 0, so its text starts at doc pos 1 (#745 doc-walk mapping). @@ -392,13 +353,9 @@ describe("go-to-line across textblocks (#745)", () => { } function gotoLine(container: HTMLElement, value: string): void { - const input = container.querySelector( - ".goto-line-input", - ) as HTMLInputElement; + const input = container.querySelector(".goto-line-input") as HTMLInputElement; input.value = value; - input.dispatchEvent( - new KeyboardEvent("keydown", { key: "Enter", bubbles: true }), - ); + input.dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true })); } it("rich doc of three paragraphs reports 3 lines and jumps to the second paragraph", () => { @@ -410,9 +367,7 @@ describe("go-to-line across textblocks (#745)", () => { const { view, container } = createViewFromDoc(richSchema, doc); triggerGotoLine(view); - const input = container.querySelector( - ".goto-line-input", - ) as HTMLInputElement; + const input = container.querySelector(".goto-line-input") as HTMLInputElement; // textContent is "alphabetagamma" (no separators) — the old count said 1. expect(input.placeholder).toContain("3"); expect(input.max).toBe("3"); @@ -430,9 +385,7 @@ describe("go-to-line across textblocks (#745)", () => { const { view, container } = createViewFromDoc(rawSchema, doc); triggerGotoLine(view); - const input = container.querySelector( - ".goto-line-input", - ) as HTMLInputElement; + const input = container.querySelector(".goto-line-input") as HTMLInputElement; expect(input.max).toBe("4"); gotoLine(container, "3"); @@ -454,9 +407,7 @@ describe("go-to-line across textblocks (#745)", () => { const { view, container } = createViewFromDoc(richSchema, doc); triggerGotoLine(view); - const input = container.querySelector( - ".goto-line-input", - ) as HTMLInputElement; + const input = container.querySelector(".goto-line-input") as HTMLInputElement; expect(input.max).toBe("4"); gotoLine(container, "3"); diff --git a/pkgs/id/web/src/goto-line.ts b/pkgs/id/web/src/goto-line.ts index e15afa693f..7d3212130c 100644 --- a/pkgs/id/web/src/goto-line.ts +++ b/pkgs/id/web/src/goto-line.ts @@ -127,9 +127,7 @@ function openGotoLine(view: EditorView): void { dialogInput?.select(); return; } - const tr = activeView.state.tr.setSelection( - TextSelection.create(activeView.state.doc, pos), - ); + const tr = activeView.state.tr.setSelection(TextSelection.create(activeView.state.doc, pos)); activeView.dispatch(tr); activeView.focus(); // Scroll the cursor into view diff --git a/pkgs/id/web/src/highlight-e2e.test.ts b/pkgs/id/web/src/highlight-e2e.test.ts index 2e6323f43f..2515746143 100644 --- a/pkgs/id/web/src/highlight-e2e.test.ts +++ b/pkgs/id/web/src/highlight-e2e.test.ts @@ -49,9 +49,7 @@ function decorationStyles(plugin: ReturnType | { decorations?: { find: () => { type: { attrs?: Record } }[] } } | undefined; const decorations = state?.decorations?.find() ?? []; - return decorations - .map((d) => d.type.attrs?.style) - .filter((s): s is string => typeof s === "string" && s.length > 0); + return decorations.map((d) => d.type.attrs?.style).filter((s): s is string => typeof s === "string" && s.length > 0); } describe("end-to-end highlighting for the #749 grammars", () => { @@ -60,9 +58,7 @@ describe("end-to-end highlighting for the #749 grammars", () => { expect(detectLanguage(filename)).toBe(lang); const plugin = createSyntaxHighlightPlugin({ filename, lineNumbers: false }); - const doc = rawSchema.node("doc", null, [ - rawSchema.node("code_block", null, [rawSchema.text(sample)]), - ]); + const doc = rawSchema.node("doc", null, [rawSchema.node("code_block", null, [rawSchema.text(sample)])]); const state = EditorState.create({ schema: rawSchema, doc, plugins: [plugin] }); const container = document.createElement("div"); document.body.appendChild(container); diff --git a/pkgs/id/web/src/highlight.test.ts b/pkgs/id/web/src/highlight.test.ts index dedeef18db..cc34a3a874 100644 --- a/pkgs/id/web/src/highlight.test.ts +++ b/pkgs/id/web/src/highlight.test.ts @@ -4,7 +4,15 @@ */ import { describe, expect, it } from "vitest"; -import { createSyntaxHighlightPlugin, detectLanguage, EXT_TO_LANG, FILENAME_TO_LANG, LANG_IMPORTS, languageFromInfoString, resolveCodeBlockLanguage } from "./highlight"; +import { + createSyntaxHighlightPlugin, + detectLanguage, + EXT_TO_LANG, + FILENAME_TO_LANG, + LANG_IMPORTS, + languageFromInfoString, + resolveCodeBlockLanguage, +} from "./highlight"; // ============================================================================ // Language Detection: Extension Mapping diff --git a/pkgs/id/web/src/image-upload.test.ts b/pkgs/id/web/src/image-upload.test.ts index 67b7695e79..08ddc71482 100644 --- a/pkgs/id/web/src/image-upload.test.ts +++ b/pkgs/id/web/src/image-upload.test.ts @@ -425,12 +425,7 @@ describe("handlePaste batch ordering (#1323)", () => { function paste(v: EditorView, files: File[]): void { const event = { clipboardData: { files }, preventDefault: vi.fn() }; - const result = handlePaste!.call( - plugin, - v, - event as unknown as ClipboardEvent, - undefined as unknown as Slice, - ); + const result = handlePaste!.call(plugin, v, event as unknown as ClipboardEvent, undefined as unknown as Slice); expect(result).toBe(true); } @@ -554,9 +549,7 @@ describe("upload completing after the document shrank (#1379)", () => { // upload is in flight: the captured insert position (25) is now // out of range and the placeholder decoration is deleted with // the replaced range. - const smallDoc = richSchema.node("doc", null, [ - richSchema.node("paragraph", null, [richSchema.text("x")]), - ]); + const smallDoc = richSchema.node("doc", null, [richSchema.node("paragraph", null, [richSchema.text("x")])]); view.dispatch(view.state.tr.replaceWith(0, view.state.doc.content.size, smallDoc.content)); resolveFetch({ diff --git a/pkgs/id/web/src/save-shortcut.test.ts b/pkgs/id/web/src/save-shortcut.test.ts index 1b1b034dca..e6b6cd04f5 100644 --- a/pkgs/id/web/src/save-shortcut.test.ts +++ b/pkgs/id/web/src/save-shortcut.test.ts @@ -5,11 +5,21 @@ import { describe, expect, it } from "vitest"; import { isSaveShortcut } from "./save-shortcut"; -function ev(partial: Partial<{ - ctrlKey: boolean; metaKey: boolean; shiftKey: boolean; code: string; key: string; -}>) { +function ev( + partial: Partial<{ + ctrlKey: boolean; + metaKey: boolean; + shiftKey: boolean; + code: string; + key: string; + }>, +) { return { - ctrlKey: false, metaKey: false, shiftKey: false, code: "", key: "", + ctrlKey: false, + metaKey: false, + shiftKey: false, + code: "", + key: "", ...partial, }; } diff --git a/pkgs/id/web/src/save-shortcut.ts b/pkgs/id/web/src/save-shortcut.ts index cb4a202a74..491c60a5b8 100644 --- a/pkgs/id/web/src/save-shortcut.ts +++ b/pkgs/id/web/src/save-shortcut.ts @@ -16,9 +16,5 @@ export interface SaveShortcutEvent { } export function isSaveShortcut(event: SaveShortcutEvent): boolean { - return ( - (event.ctrlKey || event.metaKey) && - !event.shiftKey && - event.code === "KeyS" - ); + return (event.ctrlKey || event.metaKey) && !event.shiftKey && event.code === "KeyS"; } diff --git a/pkgs/id/web/src/search-panel.ts b/pkgs/id/web/src/search-panel.ts index f1cee29a9a..87273f4442 100644 --- a/pkgs/id/web/src/search-panel.ts +++ b/pkgs/id/web/src/search-panel.ts @@ -70,8 +70,7 @@ function updateMatchCount(view: EditorView): void { return; } const total = countMatches(view); - panelState.matchCountEl.textContent = - total === 0 ? "No results" : `${total} match${total === 1 ? "" : "es"}`; + panelState.matchCountEl.textContent = total === 0 ? "No results" : `${total} match${total === 1 ? "" : "es"}`; } /** @@ -92,10 +91,8 @@ function searchStateChanged(prevState: EditorState, state: EditorState): boolean function syncQuery(view: EditorView): void { const searchText = panelState.searchInput?.value ?? ""; const replaceText = panelState.replaceInput?.value ?? ""; - const caseCheckbox = - panelState.panelEl?.querySelector("#search-case"); - const regexCheckbox = - panelState.panelEl?.querySelector("#search-regex"); + const caseCheckbox = panelState.panelEl?.querySelector("#search-case"); + const regexCheckbox = panelState.panelEl?.querySelector("#search-regex"); const query = new SearchQuery({ search: searchText, @@ -208,12 +205,8 @@ function setupPanelEvents(): void { }); // Case/regex toggles - panelEl - .querySelector("#search-case") - ?.addEventListener("change", () => syncQuery(view)); - panelEl - .querySelector("#search-regex") - ?.addEventListener("change", () => syncQuery(view)); + panelEl.querySelector("#search-case")?.addEventListener("change", () => syncQuery(view)); + panelEl.querySelector("#search-regex")?.addEventListener("change", () => syncQuery(view)); } /** Open find panel, optionally showing replace. */ @@ -226,24 +219,16 @@ function openPanel(view: EditorView, showReplace: boolean): void { // is detached with the old container and its handlers still point at the // destroyed view — and no production code calls destroySearchPanel() on // teardown. Rebind instead of "opening" a detached node (#718). - if ( - panelState.panelEl && - (panelState.view !== view || panelState.panelEl.parentElement !== container) - ) { + if (panelState.panelEl && (panelState.view !== view || panelState.panelEl.parentElement !== container)) { destroySearchPanel(); } if (!panelState.panelEl) { panelState.panelEl = createPanel(container); panelState.searchInput = panelState.panelEl.querySelector("#search-input"); - panelState.replaceInput = - panelState.panelEl.querySelector("#replace-input"); - panelState.matchCountEl = panelState.panelEl.querySelector( - "#search-match-count", - ); - panelState.replaceRow = panelState.panelEl.querySelector( - "#search-replace-row", - ); + panelState.replaceInput = panelState.panelEl.querySelector("#replace-input"); + panelState.matchCountEl = panelState.panelEl.querySelector("#search-match-count"); + panelState.replaceRow = panelState.panelEl.querySelector("#search-replace-row"); panelState.view = view; setupPanelEvents(); } diff --git a/pkgs/id/web/src/shell-contract.ts b/pkgs/id/web/src/shell-contract.ts index 0372fa911a..2ce02cd65c 100644 --- a/pkgs/id/web/src/shell-contract.ts +++ b/pkgs/id/web/src/shell-contract.ts @@ -89,10 +89,7 @@ function parseField(raw: unknown): Field { throw new Error(`${key} must be a finite number`); } } - if ( - raw.enum !== undefined && - (!Array.isArray(raw.enum) || raw.enum.some((item) => typeof item !== "string")) - ) { + if (raw.enum !== undefined && (!Array.isArray(raw.enum) || raw.enum.some((item) => typeof item !== "string"))) { throw new Error("enum must be an array of strings"); } return { diff --git a/pkgs/id/web/src/world-contract.test.ts b/pkgs/id/web/src/world-contract.test.ts index ac242c7d96..9449c73f6f 100644 --- a/pkgs/id/web/src/world-contract.test.ts +++ b/pkgs/id/web/src/world-contract.test.ts @@ -16,12 +16,7 @@ const contractDocument: unknown = JSON.parse( ); const contract = parseShellContract(contractDocument); -function withFieldType( - side: "client" | "server", - frameName: string, - fieldName: string, - type: string, -): ShellContract { +function withFieldType(side: "client" | "server", frameName: string, fieldName: string, type: string): ShellContract { const malformed = structuredClone(contract); const frames = side === "client" ? malformed.client_frames : malformed.server_frames; const frame = frames[frameName]; @@ -90,9 +85,7 @@ describe("shell contract validator", () => { session.client({ type: "join", capability: cap, after: null, world: null }); expect(session.phase).toBe("joined"); expect(() => session.client({ type: "chat", text: "hi" })).not.toThrow(); - expect(session.violations).toEqual([ - { index: 1, side: "client", message: expect.stringContaining("chat.text") }, - ]); + expect(session.violations).toEqual([{ index: 1, side: "client", message: expect.stringContaining("chat.text") }]); }); it("accepts the frames a joined shell sends", () => { diff --git a/pkgs/id/web/src/world-records.test.ts b/pkgs/id/web/src/world-records.test.ts index 6a9b0f6bf6..c102fe69ef 100644 --- a/pkgs/id/web/src/world-records.test.ts +++ b/pkgs/id/web/src/world-records.test.ts @@ -237,7 +237,10 @@ describe("world page records fetch (#1458)", () => { }, { type: "event", event: { sequence: 106, participant_id: "2", kind: { kind: "input", data: [27] } } }, { type: "event", event: { participant_id: 2, kind: { kind: "chat", data: "bad sequence" } } }, - { type: "event", event: { sequence: Number.NaN, participant_id: 2, kind: { kind: "chat", data: "bad sequence" } } }, + { + type: "event", + event: { sequence: Number.NaN, participant_id: 2, kind: { kind: "chat", data: "bad sequence" } }, + }, ]; for (const frame of malformedEvents) { diff --git a/pkgs/id/web/src/world-rejoin.test.ts b/pkgs/id/web/src/world-rejoin.test.ts index e2022c6ba3..eba15ebb54 100644 --- a/pkgs/id/web/src/world-rejoin.test.ts +++ b/pkgs/id/web/src/world-rejoin.test.ts @@ -171,23 +171,24 @@ describe("world page rejoin (ghost WebSocket, #1461)", () => { it("host view uses the admin header, shows an empty-program action, and blocks guest input", async () => { const realFetch = globalThis.fetch; - const fetchMock = vi.fn(async (_input: RequestInfo | URL, _init?: RequestInit) => - new Response( - JSON.stringify({ - snapshot: { - world_id: "lobby", - current_sequence: 0, - active_module_hash: null, - participants: [], - }, - view: null, - surface: null, - records_sequence: 0, - records: {}, - next_after: null, - }), - { status: 200, headers: { "content-type": "application/json" } }, - ), + const fetchMock = vi.fn( + async (_input: RequestInfo | URL, _init?: RequestInit) => + new Response( + JSON.stringify({ + snapshot: { + world_id: "lobby", + current_sequence: 0, + active_module_hash: null, + participants: [], + }, + view: null, + surface: null, + records_sequence: 0, + records: {}, + next_after: null, + }), + { status: 200, headers: { "content-type": "application/json" } }, + ), ); vi.stubGlobal("fetch", fetchMock); try { diff --git a/pkgs/id/web/src/world-surface.test.ts b/pkgs/id/web/src/world-surface.test.ts index 0a25411663..002d15cac6 100644 --- a/pkgs/id/web/src/world-surface.test.ts +++ b/pkgs/id/web/src/world-surface.test.ts @@ -24,11 +24,20 @@ describe("world screen presenter", () => { width: 4, height: 1, runs: [ - { start: 0, cells: [{ symbol: "界", fg: 0, bg: 0, bold: false, columns: 2 }, { symbol: "", fg: 0, bg: 0, bold: false, columns: 0 }] }, + { + start: 0, + cells: [ + { symbol: "界", fg: 0, bg: 0, bold: false, columns: 2 }, + { symbol: "", fg: 0, bg: 0, bold: false, columns: 0 }, + ], + }, { start: 3, cells: [{ symbol: "x", fg: 4, bg: 0, bold: true, columns: 1 }] }, ], }; - const full: ScreenSurface = { ...previous, cells: [...patch.runs[0].cells, previous.cells[2], ...patch.runs[1].cells] }; + const full: ScreenSurface = { + ...previous, + cells: [...patch.runs[0].cells, previous.cells[2], ...patch.runs[1].cells], + }; const applied = applyScreenPatch(previous, patch); expect(applied).toEqual(full); const root = document.createElement("div"); @@ -47,7 +56,15 @@ describe("world screen presenter", () => { height: 1, runs, }); - expect(applyScreenPatch(previous, patch([{ start: 1, cells: [previous.cells[1]] }, { start: 1, cells: [previous.cells[0]] }]))).toBeNull(); + expect( + applyScreenPatch( + previous, + patch([ + { start: 1, cells: [previous.cells[1]] }, + { start: 1, cells: [previous.cells[0]] }, + ]), + ), + ).toBeNull(); expect(applyScreenPatch(previous, patch([{ start: 2, cells: [previous.cells[0]] }]))).toBeNull(); expect( applyScreenPatch( @@ -247,9 +264,9 @@ describe("world screen presenter", () => { // validator. const longGrapheme = `e${"\u0301".repeat(17)}`; expect(longGrapheme.length).toBe(18); - expect(renderWorldSurface(root, makeScreen([{ symbol: longGrapheme, fg: 0, bg: 0, bold: false, columns: 1 }]))).toBe( - true, - ); + expect( + renderWorldSurface(root, makeScreen([{ symbol: longGrapheme, fg: 0, bg: 0, bold: false, columns: 1 }])), + ).toBe(true); }); it("measures U+FE0E text-presentation sequences as width 1, like Rust unicode-width 0.2.2 (#1581)", () => { diff --git a/pkgs/id/web/src/world-surface.ts b/pkgs/id/web/src/world-surface.ts index 928c911311..c97c5902de 100644 --- a/pkgs/id/web/src/world-surface.ts +++ b/pkgs/id/web/src/world-surface.ts @@ -325,37 +325,189 @@ function isTextPresentationCodePoint(codePoint: number): boolean { // whose U+FE0F immediately follows one of these measures 2; U+FE0F after // any other base measures 0 in the plain sum (#3265). const EMOJI_PRESENTATION_SEQ_RANGES: ReadonlyArray = [ - [0x23, 0x23], [0x2a, 0x2a], [0x30, 0x39], [0xa9, 0xa9], [0xae, 0xae], [0x203c, 0x203c], - [0x2049, 0x2049], [0x2122, 0x2122], [0x2139, 0x2139], [0x2194, 0x2199], [0x21a9, 0x21aa], [0x231a, 0x231b], - [0x2328, 0x2328], [0x23cf, 0x23cf], [0x23e9, 0x23f3], [0x23f8, 0x23fa], [0x24c2, 0x24c2], [0x25aa, 0x25ab], - [0x25b6, 0x25b6], [0x25c0, 0x25c0], [0x25fb, 0x25fe], [0x2600, 0x2604], [0x260e, 0x260e], [0x2611, 0x2611], - [0x2614, 0x2615], [0x2618, 0x2618], [0x261d, 0x261d], [0x2620, 0x2620], [0x2622, 0x2623], [0x2626, 0x2626], - [0x262a, 0x262a], [0x262e, 0x262f], [0x2638, 0x263a], [0x2640, 0x2640], [0x2642, 0x2642], [0x2648, 0x2653], - [0x265f, 0x2660], [0x2663, 0x2663], [0x2665, 0x2666], [0x2668, 0x2668], [0x267b, 0x267b], [0x267e, 0x267f], - [0x2692, 0x2697], [0x2699, 0x2699], [0x269b, 0x269c], [0x26a0, 0x26a1], [0x26a7, 0x26a7], [0x26aa, 0x26ab], - [0x26b0, 0x26b1], [0x26bd, 0x26be], [0x26c4, 0x26c5], [0x26c8, 0x26c8], [0x26ce, 0x26cf], [0x26d1, 0x26d1], - [0x26d3, 0x26d4], [0x26e9, 0x26ea], [0x26f0, 0x26f5], [0x26f7, 0x26fa], [0x26fd, 0x26fd], [0x2702, 0x2702], - [0x2705, 0x2705], [0x2708, 0x270d], [0x270f, 0x270f], [0x2712, 0x2712], [0x2714, 0x2714], [0x2716, 0x2716], - [0x271d, 0x271d], [0x2721, 0x2721], [0x2728, 0x2728], [0x2733, 0x2734], [0x2744, 0x2744], [0x2747, 0x2747], - [0x274c, 0x274c], [0x274e, 0x274e], [0x2753, 0x2755], [0x2757, 0x2757], [0x2763, 0x2764], [0x2795, 0x2797], - [0x27a1, 0x27a1], [0x27b0, 0x27b0], [0x27bf, 0x27bf], [0x2934, 0x2935], [0x2b05, 0x2b07], [0x2b1b, 0x2b1c], - [0x2b50, 0x2b50], [0x2b55, 0x2b55], [0x3030, 0x3030], [0x303d, 0x303d], [0x3297, 0x3297], [0x3299, 0x3299], - [0x1f004, 0x1f004], [0x1f170, 0x1f171], [0x1f17e, 0x1f17f], [0x1f202, 0x1f202], [0x1f21a, 0x1f21a], [0x1f22f, 0x1f22f], - [0x1f237, 0x1f237], [0x1f30d, 0x1f30f], [0x1f315, 0x1f315], [0x1f31c, 0x1f31c], [0x1f321, 0x1f321], [0x1f324, 0x1f32c], - [0x1f336, 0x1f336], [0x1f378, 0x1f378], [0x1f37d, 0x1f37d], [0x1f393, 0x1f393], [0x1f396, 0x1f397], [0x1f399, 0x1f39b], - [0x1f39e, 0x1f39f], [0x1f3a7, 0x1f3a7], [0x1f3ac, 0x1f3ae], [0x1f3c2, 0x1f3c2], [0x1f3c4, 0x1f3c4], [0x1f3c6, 0x1f3c6], - [0x1f3ca, 0x1f3ce], [0x1f3d4, 0x1f3e0], [0x1f3ed, 0x1f3ed], [0x1f3f3, 0x1f3f3], [0x1f3f5, 0x1f3f5], [0x1f3f7, 0x1f3f7], - [0x1f408, 0x1f408], [0x1f415, 0x1f415], [0x1f41f, 0x1f41f], [0x1f426, 0x1f426], [0x1f43f, 0x1f43f], [0x1f441, 0x1f442], - [0x1f446, 0x1f449], [0x1f44d, 0x1f44e], [0x1f453, 0x1f453], [0x1f46a, 0x1f46a], [0x1f47d, 0x1f47d], [0x1f4a3, 0x1f4a3], - [0x1f4b0, 0x1f4b0], [0x1f4b3, 0x1f4b3], [0x1f4bb, 0x1f4bb], [0x1f4bf, 0x1f4bf], [0x1f4cb, 0x1f4cb], [0x1f4da, 0x1f4da], - [0x1f4df, 0x1f4df], [0x1f4e4, 0x1f4e6], [0x1f4ea, 0x1f4ed], [0x1f4f7, 0x1f4f7], [0x1f4f9, 0x1f4fb], [0x1f4fd, 0x1f4fd], - [0x1f508, 0x1f508], [0x1f50d, 0x1f50d], [0x1f512, 0x1f513], [0x1f549, 0x1f54a], [0x1f550, 0x1f567], [0x1f56f, 0x1f570], - [0x1f573, 0x1f579], [0x1f587, 0x1f587], [0x1f58a, 0x1f58d], [0x1f590, 0x1f590], [0x1f5a5, 0x1f5a5], [0x1f5a8, 0x1f5a8], - [0x1f5b1, 0x1f5b2], [0x1f5bc, 0x1f5bc], [0x1f5c2, 0x1f5c4], [0x1f5d1, 0x1f5d3], [0x1f5dc, 0x1f5de], [0x1f5e1, 0x1f5e1], - [0x1f5e3, 0x1f5e3], [0x1f5e8, 0x1f5e8], [0x1f5ef, 0x1f5ef], [0x1f5f3, 0x1f5f3], [0x1f5fa, 0x1f5fa], [0x1f610, 0x1f610], - [0x1f687, 0x1f687], [0x1f68d, 0x1f68d], [0x1f691, 0x1f691], [0x1f694, 0x1f694], [0x1f698, 0x1f698], [0x1f6ad, 0x1f6ad], - [0x1f6b2, 0x1f6b2], [0x1f6b9, 0x1f6ba], [0x1f6bc, 0x1f6bc], [0x1f6cb, 0x1f6cb], [0x1f6cd, 0x1f6cf], [0x1f6e0, 0x1f6e5], - [0x1f6e9, 0x1f6e9], [0x1f6f0, 0x1f6f0], [0x1f6f3, 0x1f6f3], + [0x23, 0x23], + [0x2a, 0x2a], + [0x30, 0x39], + [0xa9, 0xa9], + [0xae, 0xae], + [0x203c, 0x203c], + [0x2049, 0x2049], + [0x2122, 0x2122], + [0x2139, 0x2139], + [0x2194, 0x2199], + [0x21a9, 0x21aa], + [0x231a, 0x231b], + [0x2328, 0x2328], + [0x23cf, 0x23cf], + [0x23e9, 0x23f3], + [0x23f8, 0x23fa], + [0x24c2, 0x24c2], + [0x25aa, 0x25ab], + [0x25b6, 0x25b6], + [0x25c0, 0x25c0], + [0x25fb, 0x25fe], + [0x2600, 0x2604], + [0x260e, 0x260e], + [0x2611, 0x2611], + [0x2614, 0x2615], + [0x2618, 0x2618], + [0x261d, 0x261d], + [0x2620, 0x2620], + [0x2622, 0x2623], + [0x2626, 0x2626], + [0x262a, 0x262a], + [0x262e, 0x262f], + [0x2638, 0x263a], + [0x2640, 0x2640], + [0x2642, 0x2642], + [0x2648, 0x2653], + [0x265f, 0x2660], + [0x2663, 0x2663], + [0x2665, 0x2666], + [0x2668, 0x2668], + [0x267b, 0x267b], + [0x267e, 0x267f], + [0x2692, 0x2697], + [0x2699, 0x2699], + [0x269b, 0x269c], + [0x26a0, 0x26a1], + [0x26a7, 0x26a7], + [0x26aa, 0x26ab], + [0x26b0, 0x26b1], + [0x26bd, 0x26be], + [0x26c4, 0x26c5], + [0x26c8, 0x26c8], + [0x26ce, 0x26cf], + [0x26d1, 0x26d1], + [0x26d3, 0x26d4], + [0x26e9, 0x26ea], + [0x26f0, 0x26f5], + [0x26f7, 0x26fa], + [0x26fd, 0x26fd], + [0x2702, 0x2702], + [0x2705, 0x2705], + [0x2708, 0x270d], + [0x270f, 0x270f], + [0x2712, 0x2712], + [0x2714, 0x2714], + [0x2716, 0x2716], + [0x271d, 0x271d], + [0x2721, 0x2721], + [0x2728, 0x2728], + [0x2733, 0x2734], + [0x2744, 0x2744], + [0x2747, 0x2747], + [0x274c, 0x274c], + [0x274e, 0x274e], + [0x2753, 0x2755], + [0x2757, 0x2757], + [0x2763, 0x2764], + [0x2795, 0x2797], + [0x27a1, 0x27a1], + [0x27b0, 0x27b0], + [0x27bf, 0x27bf], + [0x2934, 0x2935], + [0x2b05, 0x2b07], + [0x2b1b, 0x2b1c], + [0x2b50, 0x2b50], + [0x2b55, 0x2b55], + [0x3030, 0x3030], + [0x303d, 0x303d], + [0x3297, 0x3297], + [0x3299, 0x3299], + [0x1f004, 0x1f004], + [0x1f170, 0x1f171], + [0x1f17e, 0x1f17f], + [0x1f202, 0x1f202], + [0x1f21a, 0x1f21a], + [0x1f22f, 0x1f22f], + [0x1f237, 0x1f237], + [0x1f30d, 0x1f30f], + [0x1f315, 0x1f315], + [0x1f31c, 0x1f31c], + [0x1f321, 0x1f321], + [0x1f324, 0x1f32c], + [0x1f336, 0x1f336], + [0x1f378, 0x1f378], + [0x1f37d, 0x1f37d], + [0x1f393, 0x1f393], + [0x1f396, 0x1f397], + [0x1f399, 0x1f39b], + [0x1f39e, 0x1f39f], + [0x1f3a7, 0x1f3a7], + [0x1f3ac, 0x1f3ae], + [0x1f3c2, 0x1f3c2], + [0x1f3c4, 0x1f3c4], + [0x1f3c6, 0x1f3c6], + [0x1f3ca, 0x1f3ce], + [0x1f3d4, 0x1f3e0], + [0x1f3ed, 0x1f3ed], + [0x1f3f3, 0x1f3f3], + [0x1f3f5, 0x1f3f5], + [0x1f3f7, 0x1f3f7], + [0x1f408, 0x1f408], + [0x1f415, 0x1f415], + [0x1f41f, 0x1f41f], + [0x1f426, 0x1f426], + [0x1f43f, 0x1f43f], + [0x1f441, 0x1f442], + [0x1f446, 0x1f449], + [0x1f44d, 0x1f44e], + [0x1f453, 0x1f453], + [0x1f46a, 0x1f46a], + [0x1f47d, 0x1f47d], + [0x1f4a3, 0x1f4a3], + [0x1f4b0, 0x1f4b0], + [0x1f4b3, 0x1f4b3], + [0x1f4bb, 0x1f4bb], + [0x1f4bf, 0x1f4bf], + [0x1f4cb, 0x1f4cb], + [0x1f4da, 0x1f4da], + [0x1f4df, 0x1f4df], + [0x1f4e4, 0x1f4e6], + [0x1f4ea, 0x1f4ed], + [0x1f4f7, 0x1f4f7], + [0x1f4f9, 0x1f4fb], + [0x1f4fd, 0x1f4fd], + [0x1f508, 0x1f508], + [0x1f50d, 0x1f50d], + [0x1f512, 0x1f513], + [0x1f549, 0x1f54a], + [0x1f550, 0x1f567], + [0x1f56f, 0x1f570], + [0x1f573, 0x1f579], + [0x1f587, 0x1f587], + [0x1f58a, 0x1f58d], + [0x1f590, 0x1f590], + [0x1f5a5, 0x1f5a5], + [0x1f5a8, 0x1f5a8], + [0x1f5b1, 0x1f5b2], + [0x1f5bc, 0x1f5bc], + [0x1f5c2, 0x1f5c4], + [0x1f5d1, 0x1f5d3], + [0x1f5dc, 0x1f5de], + [0x1f5e1, 0x1f5e1], + [0x1f5e3, 0x1f5e3], + [0x1f5e8, 0x1f5e8], + [0x1f5ef, 0x1f5ef], + [0x1f5f3, 0x1f5f3], + [0x1f5fa, 0x1f5fa], + [0x1f610, 0x1f610], + [0x1f687, 0x1f687], + [0x1f68d, 0x1f68d], + [0x1f691, 0x1f691], + [0x1f694, 0x1f694], + [0x1f698, 0x1f698], + [0x1f6ad, 0x1f6ad], + [0x1f6b2, 0x1f6b2], + [0x1f6b9, 0x1f6ba], + [0x1f6bc, 0x1f6bc], + [0x1f6cb, 0x1f6cb], + [0x1f6cd, 0x1f6cf], + [0x1f6e0, 0x1f6e5], + [0x1f6e9, 0x1f6e9], + [0x1f6f0, 0x1f6f0], + [0x1f6f3, 0x1f6f3], ]; function isEmojiPresentationSeqBase(codePoint: number): boolean { diff --git a/pkgs/id/web/src/world.ts b/pkgs/id/web/src/world.ts index c531d90fc5..f9071afb1f 100644 --- a/pkgs/id/web/src/world.ts +++ b/pkgs/id/web/src/world.ts @@ -149,8 +149,7 @@ function initWorld(): void { const isRecord = (value: unknown): value is Record => typeof value === "object" && value !== null && !Array.isArray(value); - const isFiniteNumber = (value: unknown): value is number => - typeof value === "number" && Number.isFinite(value); + const isFiniteNumber = (value: unknown): value is number => typeof value === "number" && Number.isFinite(value); const isWorldSnapshot = (value: unknown): value is NonNullable => isRecord(value) && typeof value.world_id === "string" && @@ -423,9 +422,7 @@ function initWorld(): void { cache: "no-store", }); if (!response.ok) { - throw new Error( - response.status === 401 ? "Host authorization denied" : "Host view unavailable", - ); + throw new Error(response.status === 401 ? "Host authorization denied" : "Host view unavailable"); } if (generation !== hostViewGeneration || !hostMode) return; const result = (await response.json()) as { From 26c972e36facf144a0aae2c80881642edb6b947f Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Mon, 2 Nov 2026 19:08:21 -0600 Subject: [PATCH 2/3] style(id): fix shfmt drift in recipe checks --- pkgs/id/scripts/just-recipes-check-test.sh | 22 ++++++++++++++-------- pkgs/id/scripts/just-recipes-check.sh | 12 ++++++------ 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/pkgs/id/scripts/just-recipes-check-test.sh b/pkgs/id/scripts/just-recipes-check-test.sh index 755eb876c3..b749cb450f 100644 --- a/pkgs/id/scripts/just-recipes-check-test.sh +++ b/pkgs/id/scripts/just-recipes-check-test.sh @@ -5,20 +5,26 @@ script="$(cd "$(dirname "$0")" && pwd)/just-recipes-check.sh" tmp="$(mktemp -d)" trap 'rm -rf "$tmp"' EXIT mkdir "$tmp/bin" "$tmp/work" -printf '#!%s\n' "$(command -v bash)" > "$tmp/bin/just" -cat >> "$tmp/bin/just" <<'EOF' +printf '#!%s\n' "$(command -v bash)" >"$tmp/bin/just" +cat >>"$tmp/bin/just" <<'EOF' cat "$FRESH" EOF chmod +x "$tmp/bin/just" export PATH="$tmp/bin:$PATH" FRESH="$tmp/fresh.json" cd "$tmp/work" -cat > just-recipes.json <<'EOF' +cat >just-recipes.json <<'EOF' {"source":"old", "recipes":{"run":{"doc":"run", "private":false, "parameters":[{"name":"arg", "kind":"singular", "default":null, "export":false, "flag":false}], "dependencies":[{"recipe":"dep", "arguments":[["string", "a"]], "star":null}], "body":[["old"]]}}, "aliases":{"r":{"target":"run"}}} EOF cp just-recipes.json "$FRESH" -check_pass() { if ! bash "$script" > "$tmp/output" 2>&1; then cat "$tmp/output"; exit 1; fi; } -check_fail() { if bash "$script" > "$tmp/output" 2>&1; then echo "unexpected success: $1" >&2; exit 1; fi; } -change() { jq "$1" just-recipes.json > "$FRESH"; } +check_pass() { if ! bash "$script" >"$tmp/output" 2>&1; then + cat "$tmp/output" + exit 1 +fi; } +check_fail() { if bash "$script" >"$tmp/output" 2>&1; then + echo "unexpected success: $1" >&2 + exit 1 +fi; } +change() { jq "$1" just-recipes.json >"$FRESH"; } check_pass change '.source = "new" | .recipes.run.body = [["new"]]' @@ -33,9 +39,9 @@ change '.recipes.run.dependencies[0].star = true' check_fail 'dependency star' change '.aliases.r.target = "dep"' check_fail 'alias target' -printf '{' > "$FRESH" +printf '{' >"$FRESH" check_fail 'invalid fresh JSON' cp just-recipes.json "$FRESH" -printf '{' > just-recipes.json +printf '{' >just-recipes.json check_fail 'invalid committed JSON' echo 'just-recipes-check tests passed' diff --git a/pkgs/id/scripts/just-recipes-check.sh b/pkgs/id/scripts/just-recipes-check.sh index 8345b2b1b2..396060e07b 100644 --- a/pkgs/id/scripts/just-recipes-check.sh +++ b/pkgs/id/scripts/just-recipes-check.sh @@ -2,7 +2,7 @@ set -euo pipefail tmp="$(mktemp -d)" trap 'rm -rf "$tmp"' EXIT -just --dump --dump-format json > "$tmp/fresh.json" +just --dump --dump-format json >"$tmp/fresh.json" # Compare semantic fields only: recipe presence, doc, parameters, # dependencies and the private flag, plus alias targets. The top-level # `source` is an absolute path from the generating machine and recipe @@ -10,14 +10,14 @@ just --dump --dump-format json > "$tmp/fresh.json" # nesting, #2729), so both are projected out — a byte diff would # false-positive forever. project() { - jq -S '{recipes: (.recipes | to_entries | map({key, value: {doc: .value.doc, parameters: .value.parameters, dependencies: .value.dependencies, private: (.value.private // false)}}) | from_entries), aliases: ((.aliases // {}) | to_entries | map({key, value: .value.target}) | from_entries)}' "$1" + jq -S '{recipes: (.recipes | to_entries | map({key, value: {doc: .value.doc, parameters: .value.parameters, dependencies: .value.dependencies, private: (.value.private // false)}}) | from_entries), aliases: ((.aliases // {}) | to_entries | map({key, value: .value.target}) | from_entries)}' "$1" } # Project separately: failures inside process substitutions are otherwise hidden # by diff's exit status and can incorrectly report a match. -project just-recipes.json > "$tmp/committed.json" -project "$tmp/fresh.json" > "$tmp/projected.json" +project just-recipes.json >"$tmp/committed.json" +project "$tmp/fresh.json" >"$tmp/projected.json" if ! diff "$tmp/committed.json" "$tmp/projected.json"; then - echo "error: just-recipes.json has drifted from the justfile — run 'just lockfiles' and commit the result" >&2 - exit 1 + echo "error: just-recipes.json has drifted from the justfile — run 'just lockfiles' and commit the result" >&2 + exit 1 fi echo "✓ just-recipes.json matches the justfile" From 96d3cf8aed5424c0ab0f04e947dd4fc82718b957 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Mon, 2 Nov 2026 19:40:32 -0600 Subject: [PATCH 3/3] style(id): format world surface e2e assertion --- pkgs/id/e2e/tests/world-surface.spec.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pkgs/id/e2e/tests/world-surface.spec.ts b/pkgs/id/e2e/tests/world-surface.spec.ts index 65ed965397..59b67b7a59 100644 --- a/pkgs/id/e2e/tests/world-surface.spec.ts +++ b/pkgs/id/e2e/tests/world-surface.spec.ts @@ -60,10 +60,7 @@ test.describe("World surface", () => { // a role=img grid with a "columns by rows" label, not guest HTML text. const screen = view.locator(".id-world-screen"); await expect(screen).toBeVisible({ timeout: 15_000 }); - await expect(view.locator('[role="img"]')).toHaveAttribute( - "aria-label", - /World screen, \d+ columns by \d+ rows/, - ); + await expect(view.locator('[role="img"]')).toHaveAttribute("aria-label", /World screen, \d+ columns by \d+ rows/); await expect(view).not.toContainText("Waiting for a world view"); // The roc-screen fixture renders its counter through Screen cells. await expect(view).toContainText(/count=\d+/);