diff options
| author | Frank <[email protected]> | 2025-10-16 23:43:49 -0400 |
|---|---|---|
| committer | Frank <[email protected]> | 2025-10-16 23:43:49 -0400 |
| commit | 5f7bba11fddd24f01c7be81870320dfe54672a3b (patch) | |
| tree | 213839ae793552f6ecc0bed6d999058381533428 /packages/console/app/src/routes | |
| parent | 4663ea5faad41f8be9d16898f0d041630acf0c13 (diff) | |
| download | opencode-5f7bba11fddd24f01c7be81870320dfe54672a3b.tar.gz opencode-5f7bba11fddd24f01c7be81870320dfe54672a3b.zip | |
wip: zen
Diffstat (limited to 'packages/console/app/src/routes')
| -rw-r--r-- | packages/console/app/src/routes/auth/index.ts | 11 | ||||
| -rw-r--r-- | packages/console/app/src/routes/workspace-picker.tsx | 8 |
2 files changed, 14 insertions, 5 deletions
diff --git a/packages/console/app/src/routes/auth/index.ts b/packages/console/app/src/routes/auth/index.ts index f522e761d..63430b77f 100644 --- a/packages/console/app/src/routes/auth/index.ts +++ b/packages/console/app/src/routes/auth/index.ts @@ -1,5 +1,5 @@ import { Actor } from "@opencode-ai/console-core/actor.js" -import { and, Database, eq, isNull } from "@opencode-ai/console-core/drizzle/index.js" +import { and, Database, desc, eq, isNull } from "@opencode-ai/console-core/drizzle/index.js" import { UserTable } from "@opencode-ai/console-core/schema/user.sql.js" import { WorkspaceTable } from "@opencode-ai/console-core/schema/workspace.sql.js" import { redirect } from "@solidjs/router" @@ -8,7 +8,7 @@ import { withActor } from "~/context/auth.withActor" export async function GET(input: APIEvent) { try { - const workspaces = await withActor(async () => { + const workspaceID = await withActor(async () => { const actor = Actor.assert("account") return Database.transaction(async (tx) => tx @@ -21,10 +21,13 @@ export async function GET(input: APIEvent) { isNull(UserTable.timeDeleted), isNull(WorkspaceTable.timeDeleted), ), - ), + ) + .orderBy(desc(UserTable.timeSeen)) + .limit(1) + .then((x) => x[0]?.id), ) }) - return redirect(`/workspace/${workspaces[0].id}`) + return redirect(`/workspace/${workspaceID}`) } catch { return redirect("/auth/authorize") } diff --git a/packages/console/app/src/routes/workspace-picker.tsx b/packages/console/app/src/routes/workspace-picker.tsx index 934ec1688..fa8cf1d21 100644 --- a/packages/console/app/src/routes/workspace-picker.tsx +++ b/packages/console/app/src/routes/workspace-picker.tsx @@ -23,7 +23,13 @@ const getWorkspaces = query(async () => { }) .from(UserTable) .innerJoin(WorkspaceTable, eq(UserTable.workspaceID, WorkspaceTable.id)) - .where(and(eq(UserTable.accountID, Actor.account()), isNull(WorkspaceTable.timeDeleted))), + .where( + and( + eq(UserTable.accountID, Actor.account()), + isNull(WorkspaceTable.timeDeleted), + isNull(UserTable.timeDeleted), + ), + ), ) }) }, "workspaces") |
