mirror of
https://gitee.com/zhangsken/opencode.git
synced 2026-10-16 10:30:01 +08:00
fix(console): exclude migrated workspaces from selection (#49336)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { redirect } from "@solidjs/router"
|
||||
import { Resource } from "@opencode-ai/console-resource"
|
||||
import type { APIEvent } from "@solidjs/start/server"
|
||||
import { getLastSeenWorkspaceID } from "../workspace/common"
|
||||
import { localeFromRequest, route } from "~/lib/language"
|
||||
@@ -7,6 +8,11 @@ export async function GET(input: APIEvent) {
|
||||
const locale = localeFromRequest(input.request)
|
||||
try {
|
||||
const workspaceID = await getLastSeenWorkspaceID()
|
||||
if (!workspaceID) {
|
||||
const destination = Resource.ConsoleMigration.consoleUrl
|
||||
if (!destination) throw new Error("New Console URL is not configured")
|
||||
return redirect(`${destination}/login`, { headers: { "Cache-Control": "no-store" } })
|
||||
}
|
||||
return redirect(route(locale, `/workspace/${workspaceID}`))
|
||||
} catch {
|
||||
return redirect("/auth/authorize")
|
||||
|
||||
@@ -27,6 +27,7 @@ const getWorkspaces = query(async () => {
|
||||
and(
|
||||
eq(UserTable.accountID, Actor.account()),
|
||||
isNull(WorkspaceTable.timeDeleted),
|
||||
isNull(WorkspaceTable.migrated_at),
|
||||
isNull(UserTable.timeDeleted),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -53,6 +53,7 @@ export async function getLastSeenWorkspaceID() {
|
||||
eq(UserTable.accountID, actor.properties.accountID),
|
||||
isNull(UserTable.timeDeleted),
|
||||
isNull(WorkspaceTable.timeDeleted),
|
||||
isNull(WorkspaceTable.migrated_at),
|
||||
),
|
||||
)
|
||||
.orderBy(desc(UserTable.timeSeen))
|
||||
|
||||
Reference in New Issue
Block a user