From c676f12306b58a87006e0f2114f5c7f2cb25a49d Mon Sep 17 00:00:00 2001 From: Dax Raad Date: Sat, 30 Aug 2025 15:20:40 -0400 Subject: [PATCH] wip: cloud --- cloud/app/src/context/auth.withActor.ts | 9 +++++++++ cloud/app/src/routes/workspace.tsx | 2 +- cloud/app/src/routes/workspace/[id].tsx | 13 +++++++------ 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/cloud/app/src/context/auth.withActor.ts b/cloud/app/src/context/auth.withActor.ts index a61b728e..ca38be89 100644 --- a/cloud/app/src/context/auth.withActor.ts +++ b/cloud/app/src/context/auth.withActor.ts @@ -1,7 +1,16 @@ import { Actor } from "@opencode/cloud-core/actor.js" import { getActor } from "./auth" +import { query } from "@solidjs/router" export async function withActor(fn: () => T) { const actor = await getActor() return Actor.provide(actor.type, actor.properties, fn) } + +export function actorQuery(cb: () => T, name: string) { + "use server" + return query(async () => { + const actor = await getActor() + return withActor(cb) + }, name) +} diff --git a/cloud/app/src/routes/workspace.tsx b/cloud/app/src/routes/workspace.tsx index 920276e8..6876ae96 100644 --- a/cloud/app/src/routes/workspace.tsx +++ b/cloud/app/src/routes/workspace.tsx @@ -1,6 +1,6 @@ +import "./workspace.css" import { useAuthSession } from "~/context/auth.session" import { IconLogo } from "../component/icon" -import "./workspace.css" import { action, redirect, RouteSectionProps } from "@solidjs/router" const logout = action(async () => { diff --git a/cloud/app/src/routes/workspace/[id].tsx b/cloud/app/src/routes/workspace/[id].tsx index 41612886..ccdfe42f 100644 --- a/cloud/app/src/routes/workspace/[id].tsx +++ b/cloud/app/src/routes/workspace/[id].tsx @@ -13,26 +13,27 @@ import { Actor } from "@opencode/cloud-core/actor.js" // Keys related queries and actions ///////////////////////////////////// -const listKeys = query(async () => { + +const listKeys = query(() => { "use server" return withActor(() => Key.list()) -}, "keys") +}, "key.list") const createKey = action(async (name: string) => { "use server" return json( withActor(() => Key.create({ name })), - { revalidate: "keys" }, + { revalidate: listKeys.key }, ) -}, "createKey") +}, "key.create") const removeKey = action(async (id: string) => { "use server" return json( withActor(() => Key.remove({ id })), - { revalidate: "keys" }, + { revalidate: listKeys.key }, ) -}, "removeKey") +}, "key.remove") ///////////////////////////////////// // Billing related queries and actions