Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .github/extensions/replica-prototype/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
"name": "replica-prototype",
"description": "Wrap a running prototype with Replica publish controls and repository status.",
"version": "1.10.0",
"version": "1.10.1",
"author": {
"name": "GitHub"
},
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -420,3 +420,92 @@ it("keeps startup binding discovery pending while a mount effect registers its A
},
})
})

it("clears saved settings before Reset all lets the app navigate", async () => {
let page = "Enterprise"
const routes: Record<string, string> = { Organization: "/org", Enterprise: "/enterprise" }
vi.stubGlobal("pageNavigation", {
readPage: () => page,
writePage: (next: string) => {
if (next === page) return
page = next
window.history.pushState({ router: next }, "", routes[next])
},
})
window.history.replaceState(null, "", '/enterprise?rc=1&rc.navigation.page="Enterprise"')
vi.stubGlobal(
"fetch",
vi.fn().mockResolvedValue(
Response.json({
version: 1,
scope: "navigation",
controls: [
{
id: "page",
label: "Page",
type: "select",
default: "Organization",
options: ["Organization", "Enterprise"],
binding: {
type: "api",
object: "pageNavigation",
read: "readPage",
write: "writePage",
pollMs: 250,
},
},
],
}),
),
)
vi.spyOn(document, "readyState", "get").mockReturnValue("complete")
const post = vi.spyOn(window.parent, "postMessage").mockImplementation(() => {})
dispose = installControlsBridge(origin)
hello({ controlQuery: 'rc.navigation.page="Enterprise"' })
await vi.waitFor(() => expect(post.mock.calls.at(-1)?.[0]).toMatchObject({ type: "reply" }))
const controller = getControlsRuntime().list()[0]!
message({
protocol: "replica:controls",
version: 1,
epoch: "canvas-epoch",
requestId: "restore",
type: "command",
command: {
operation: "restore",
scope: "navigation",
fingerprint: JSON.stringify(controller.declaration),
revision: controller.getSnapshot().revision,
values: { page: "Enterprise" },
},
})
await vi.waitFor(() =>
expect(post.mock.calls.at(-1)?.[0]).toMatchObject({ type: "reply", requestId: "restore" }),
)
expect(window.location.pathname).toBe("/enterprise")
expect(new URLSearchParams(window.location.search).get("rc.navigation.page")).toBe('"Enterprise"')
message({
protocol: "replica:controls",
version: 1,
epoch: "canvas-epoch",
requestId: "reset",
type: "command",
command: {
operation: "reset-all",
contexts: [
{
scope: "navigation",
fingerprint: JSON.stringify(controller.declaration),
revision: controller.getSnapshot().revision,
},
],
},
})
await vi.waitFor(() =>
expect(post.mock.calls.at(-1)?.[0]).toMatchObject({ type: "reply", requestId: "reset" }),
)
expect(post.mock.calls.at(-1)?.[0]).not.toHaveProperty("error")
expect(window.location.pathname).toBe("/org")
expect(new URLSearchParams(window.location.search).has("rc.navigation.page")).toBe(false)
window.dispatchEvent(new PopStateEvent("popstate"))
expect(post.mock.calls.at(-1)?.[0]).toMatchObject({ type: "snapshot", controlQuery: "" })
})
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@ export function installControlsBridge(parentOrigin: string) {
)
throw new Error("Controls changed. The stale reset was not applied.")
restoredScopes.clear()
// Clear saved settings first so app navigation during reset cannot carry them forward.
controlsUrl.set("")
await bindings?.reset(undefined, guard)
} else {
const controller = runtime
Expand Down

Large diffs are not rendered by default.

Loading