summaryrefslogtreecommitdiffhomepage
path: root/cloud
diff options
context:
space:
mode:
authorDax Raad <[email protected]>2025-08-29 11:58:17 -0400
committerDax Raad <[email protected]>2025-08-29 11:58:17 -0400
commit4496cd4b64e51805b790728e67a018791e731cd6 (patch)
treee85cedfa322bd98e1f1443a725cb0dcd820891ac /cloud
parent7f5e5fccc8d9248871d59e5adbfe52a7d307d09a (diff)
downloadopencode-4496cd4b64e51805b790728e67a018791e731cd6.tar.gz
opencode-4496cd4b64e51805b790728e67a018791e731cd6.zip
ignore: cloud solid fixes
Diffstat (limited to 'cloud')
-rw-r--r--cloud/app/package.json2
-rw-r--r--cloud/app/src/context/auth.session.ts23
-rw-r--r--cloud/app/src/context/auth.ts (renamed from cloud/app/src/context/auth.tsx)47
-rw-r--r--cloud/app/src/context/auth.withActor.ts7
-rw-r--r--cloud/app/src/routes/workspace/[workspaceID].tsx8
-rw-r--r--cloud/web/package.json2
6 files changed, 48 insertions, 41 deletions
diff --git a/cloud/app/package.json b/cloud/app/package.json
index 0eb3ec6c2..3a236e09b 100644
--- a/cloud/app/package.json
+++ b/cloud/app/package.json
@@ -14,7 +14,7 @@
"@solidjs/meta": "^0.29.4",
"@solidjs/router": "^0.15.0",
"@solidjs/start": "^1.1.0",
- "solid-js": "^1.9.5",
+ "solid-js": "catalog:",
"vinxi": "^0.5.7",
"@opencode/cloud-core": "workspace:*"
},
diff --git a/cloud/app/src/context/auth.session.ts b/cloud/app/src/context/auth.session.ts
new file mode 100644
index 000000000..c4b3940aa
--- /dev/null
+++ b/cloud/app/src/context/auth.session.ts
@@ -0,0 +1,23 @@
+import { useSession } from "vinxi/http"
+
+export interface AuthSession {
+ account: Record<
+ string,
+ {
+ id: string
+ email: string
+ }
+ >
+ current?: string
+}
+
+export function useAuthSession() {
+ return useSession<AuthSession>({
+ password: "0".repeat(32),
+ name: "auth",
+ cookie: {
+ secure: false,
+ httpOnly: true,
+ },
+ })
+}
diff --git a/cloud/app/src/context/auth.tsx b/cloud/app/src/context/auth.ts
index 59fbff6e6..9a5606a44 100644
--- a/cloud/app/src/context/auth.tsx
+++ b/cloud/app/src/context/auth.ts
@@ -1,5 +1,3 @@
-import { useSession } from "vinxi/http"
-import { createClient } from "@openauthjs/openauth/client"
import { getRequestEvent } from "solid-js/web"
import { and, Database, eq, inArray } from "@opencode/cloud-core/drizzle/index.js"
import { WorkspaceTable } from "@opencode/cloud-core/schema/workspace.sql.js"
@@ -8,18 +6,21 @@ import { query, redirect } from "@solidjs/router"
import { AccountTable } from "@opencode/cloud-core/schema/account.sql.js"
import { Actor } from "@opencode/cloud-core/actor.js"
-export async function withActor<T>(fn: () => T) {
- const actor = await getActor()
- return Actor.provide(actor.type, actor.properties, fn)
-}
+import { createClient } from "@openauthjs/openauth/client"
+import { useAuthSession } from "./auth.session"
+
+export const AuthClient = createClient({
+ clientID: "app",
+ issuer: import.meta.env.VITE_AUTH_URL,
+})
export const getActor = query(async (): Promise<Actor.Info> => {
"use server"
const evt = getRequestEvent()
const url = new URL(evt!.request.headers.get("referer") ?? evt!.request.url)
const auth = await useAuthSession()
- const [, workspaceHint] = url.pathname.split("/").filter((x) => x.length > 0)
- if (!workspaceHint) {
+ const splits = url.pathname.split("/").filter(Boolean)
+ if (splits[0] !== "workspace") {
if (auth.data.current) {
const current = auth.data.account[auth.data.current]
return {
@@ -49,6 +50,7 @@ export const getActor = query(async (): Promise<Actor.Info> => {
properties: {},
}
}
+ const workspaceHint = splits[1]
const accounts = Object.keys(auth.data.account)
const result = await Database.transaction(async (tx) => {
return await tx
@@ -74,32 +76,3 @@ export const getActor = query(async (): Promise<Actor.Info> => {
}
throw redirect("/auth/authorize")
}, "actor")
-
-export const AuthClient = createClient({
- clientID: "app",
- issuer: import.meta.env.VITE_AUTH_URL,
-})
-
-export interface AuthSession {
- account: Record<
- string,
- {
- id: string
- email: string
- }
- >
- current?: string
-}
-
-export function useAuthSession() {
- return useSession<AuthSession>({
- password: "0".repeat(32),
- name: "auth",
- cookie: {
- secure: false,
- httpOnly: true,
- },
- })
-}
-
-export function AuthProvider() { }
diff --git a/cloud/app/src/context/auth.withActor.ts b/cloud/app/src/context/auth.withActor.ts
new file mode 100644
index 000000000..a61b728ef
--- /dev/null
+++ b/cloud/app/src/context/auth.withActor.ts
@@ -0,0 +1,7 @@
+import { Actor } from "@opencode/cloud-core/actor.js"
+import { getActor } from "./auth"
+
+export async function withActor<T>(fn: () => T) {
+ const actor = await getActor()
+ return Actor.provide(actor.type, actor.properties, fn)
+}
diff --git a/cloud/app/src/routes/workspace/[workspaceID].tsx b/cloud/app/src/routes/workspace/[workspaceID].tsx
index 00e61a0c7..f507b5152 100644
--- a/cloud/app/src/routes/workspace/[workspaceID].tsx
+++ b/cloud/app/src/routes/workspace/[workspaceID].tsx
@@ -2,7 +2,8 @@ import { Billing } from "@opencode/cloud-core/billing.js"
import { Key } from "@opencode/cloud-core/key.js"
import { action, createAsync, revalidate, query, useAction, useSubmission } from "@solidjs/router"
import { createEffect, createSignal, For, onMount, Show } from "solid-js"
-import { getActor, withActor } from "~/context/auth"
+import { getActor } from "~/context/auth"
+import { withActor } from "~/context/auth.withActor"
/////////////////////////////////////
// Keys related queries and actions
@@ -47,8 +48,11 @@ const createPortalUrl = action(async (returnUrl: string) => {
return withActor(() => Billing.generatePortalUrl({ returnUrl }))
}, "portalUrl")
-export default function() {
+export default function () {
const actor = createAsync(() => getActor())
+ onMount(() => {
+ console.log("MOUNTED", actor())
+ })
/////////////////
// Keys section
diff --git a/cloud/web/package.json b/cloud/web/package.json
index 1d0184131..95757e091 100644
--- a/cloud/web/package.json
+++ b/cloud/web/package.json
@@ -26,7 +26,7 @@
"@solid-primitives/storage": "4.3.1",
"@solidjs/meta": "0.29.4",
"@solidjs/router": "0.15.3",
- "solid-js": "1.9.5",
+ "solid-js": "catalog:",
"solid-list": "0.3.0"
}
}