diff options
Diffstat (limited to 'packages/console/app/src/routes/auth')
| -rw-r--r-- | packages/console/app/src/routes/auth/index.ts | 11 |
1 files changed, 7 insertions, 4 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") } |
