Skip to content

Commit 4496cd4

Browse files
committed
ignore: cloud solid fixes
1 parent 7f5e5fc commit 4496cd4

File tree

9 files changed

+206
-351
lines changed

9 files changed

+206
-351
lines changed

bun.lock

Lines changed: 155 additions & 308 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cloud/app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"@solidjs/meta": "^0.29.4",
1515
"@solidjs/router": "^0.15.0",
1616
"@solidjs/start": "^1.1.0",
17-
"solid-js": "^1.9.5",
17+
"solid-js": "catalog:",
1818
"vinxi": "^0.5.7",
1919
"@opencode/cloud-core": "workspace:*"
2020
},
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { useSession } from "vinxi/http"
2+
3+
export interface AuthSession {
4+
account: Record<
5+
string,
6+
{
7+
id: string
8+
email: string
9+
}
10+
>
11+
current?: string
12+
}
13+
14+
export function useAuthSession() {
15+
return useSession<AuthSession>({
16+
password: "0".repeat(32),
17+
name: "auth",
18+
cookie: {
19+
secure: false,
20+
httpOnly: true,
21+
},
22+
})
23+
}
Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { useSession } from "vinxi/http"
2-
import { createClient } from "@openauthjs/openauth/client"
31
import { getRequestEvent } from "solid-js/web"
42
import { and, Database, eq, inArray } from "@opencode/cloud-core/drizzle/index.js"
53
import { WorkspaceTable } from "@opencode/cloud-core/schema/workspace.sql.js"
@@ -8,18 +6,21 @@ import { query, redirect } from "@solidjs/router"
86
import { AccountTable } from "@opencode/cloud-core/schema/account.sql.js"
97
import { Actor } from "@opencode/cloud-core/actor.js"
108

11-
export async function withActor<T>(fn: () => T) {
12-
const actor = await getActor()
13-
return Actor.provide(actor.type, actor.properties, fn)
14-
}
9+
import { createClient } from "@openauthjs/openauth/client"
10+
import { useAuthSession } from "./auth.session"
11+
12+
export const AuthClient = createClient({
13+
clientID: "app",
14+
issuer: import.meta.env.VITE_AUTH_URL,
15+
})
1516

1617
export const getActor = query(async (): Promise<Actor.Info> => {
1718
"use server"
1819
const evt = getRequestEvent()
1920
const url = new URL(evt!.request.headers.get("referer") ?? evt!.request.url)
2021
const auth = await useAuthSession()
21-
const [, workspaceHint] = url.pathname.split("/").filter((x) => x.length > 0)
22-
if (!workspaceHint) {
22+
const splits = url.pathname.split("/").filter(Boolean)
23+
if (splits[0] !== "workspace") {
2324
if (auth.data.current) {
2425
const current = auth.data.account[auth.data.current]
2526
return {
@@ -49,6 +50,7 @@ export const getActor = query(async (): Promise<Actor.Info> => {
4950
properties: {},
5051
}
5152
}
53+
const workspaceHint = splits[1]
5254
const accounts = Object.keys(auth.data.account)
5355
const result = await Database.transaction(async (tx) => {
5456
return await tx
@@ -74,32 +76,3 @@ export const getActor = query(async (): Promise<Actor.Info> => {
7476
}
7577
throw redirect("/auth/authorize")
7678
}, "actor")
77-
78-
export const AuthClient = createClient({
79-
clientID: "app",
80-
issuer: import.meta.env.VITE_AUTH_URL,
81-
})
82-
83-
export interface AuthSession {
84-
account: Record<
85-
string,
86-
{
87-
id: string
88-
email: string
89-
}
90-
>
91-
current?: string
92-
}
93-
94-
export function useAuthSession() {
95-
return useSession<AuthSession>({
96-
password: "0".repeat(32),
97-
name: "auth",
98-
cookie: {
99-
secure: false,
100-
httpOnly: true,
101-
},
102-
})
103-
}
104-
105-
export function AuthProvider() { }
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { Actor } from "@opencode/cloud-core/actor.js"
2+
import { getActor } from "./auth"
3+
4+
export async function withActor<T>(fn: () => T) {
5+
const actor = await getActor()
6+
return Actor.provide(actor.type, actor.properties, fn)
7+
}

cloud/app/src/routes/workspace/[workspaceID].tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import { Billing } from "@opencode/cloud-core/billing.js"
22
import { Key } from "@opencode/cloud-core/key.js"
33
import { action, createAsync, revalidate, query, useAction, useSubmission } from "@solidjs/router"
44
import { createEffect, createSignal, For, onMount, Show } from "solid-js"
5-
import { getActor, withActor } from "~/context/auth"
5+
import { getActor } from "~/context/auth"
6+
import { withActor } from "~/context/auth.withActor"
67

78
/////////////////////////////////////
89
// Keys related queries and actions
@@ -47,8 +48,11 @@ const createPortalUrl = action(async (returnUrl: string) => {
4748
return withActor(() => Billing.generatePortalUrl({ returnUrl }))
4849
}, "portalUrl")
4950

50-
export default function() {
51+
export default function () {
5152
const actor = createAsync(() => getActor())
53+
onMount(() => {
54+
console.log("MOUNTED", actor())
55+
})
5256

5357
/////////////////
5458
// Keys section

cloud/web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"@solid-primitives/storage": "4.3.1",
2727
"@solidjs/meta": "0.29.4",
2828
"@solidjs/router": "0.15.3",
29-
"solid-js": "1.9.5",
29+
"solid-js": "catalog:",
3030
"solid-list": "0.3.0"
3131
}
3232
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"hono": "4.7.10",
2525
"typescript": "5.8.2",
2626
"zod": "3.25.76",
27-
"remeda": "2.26.0"
27+
"remeda": "2.26.0",
28+
"solid-js": "1.9.9"
2829
}
2930
},
3031
"dependencies": {

packages/web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"remeda": "2.26.0",
3131
"sharp": "0.32.5",
3232
"shiki": "3.4.2",
33-
"solid-js": "1.9.7",
33+
"solid-js": "catalog:",
3434
"toolbeam-docs-theme": "0.4.6"
3535
},
3636
"devDependencies": {

0 commit comments

Comments
 (0)