feat(core): allow passing workspaceID into session create endpoint (#16798)
This commit is contained in:
@@ -402,9 +402,12 @@ function App() {
|
|||||||
const current = promptRef.current
|
const current = promptRef.current
|
||||||
// Don't require focus - if there's any text, preserve it
|
// Don't require focus - if there's any text, preserve it
|
||||||
const currentPrompt = current?.current?.input ? current.current : undefined
|
const currentPrompt = current?.current?.input ? current.current : undefined
|
||||||
|
const workspaceID =
|
||||||
|
route.data.type === "session" ? sync.session.get(route.data.sessionID)?.workspaceID : undefined
|
||||||
route.navigate({
|
route.navigate({
|
||||||
type: "home",
|
type: "home",
|
||||||
initialPrompt: currentPrompt,
|
initialPrompt: currentPrompt,
|
||||||
|
workspaceID,
|
||||||
})
|
})
|
||||||
dialog.clear()
|
dialog.clear()
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ async function openWorkspace(input: {
|
|||||||
}
|
}
|
||||||
let created: Session | undefined
|
let created: Session | undefined
|
||||||
while (!created) {
|
while (!created) {
|
||||||
const result = await client.session.create({}).catch(() => undefined)
|
const result = await client.session.create({ workspaceID: input.workspaceID }).catch(() => undefined)
|
||||||
if (!result) {
|
if (!result) {
|
||||||
input.toast.show({
|
input.toast.show({
|
||||||
message: "Failed to open workspace",
|
message: "Failed to open workspace",
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import { DialogSkill } from "../dialog-skill"
|
|||||||
|
|
||||||
export type PromptProps = {
|
export type PromptProps = {
|
||||||
sessionID?: string
|
sessionID?: string
|
||||||
|
workspaceID?: string
|
||||||
visible?: boolean
|
visible?: boolean
|
||||||
disabled?: boolean
|
disabled?: boolean
|
||||||
onSubmit?: () => void
|
onSubmit?: () => void
|
||||||
@@ -542,7 +543,9 @@ export function Prompt(props: PromptProps) {
|
|||||||
|
|
||||||
let sessionID = props.sessionID
|
let sessionID = props.sessionID
|
||||||
if (sessionID == null) {
|
if (sessionID == null) {
|
||||||
const res = await sdk.client.session.create({})
|
const res = await sdk.client.session.create({
|
||||||
|
workspaceID: props.workspaceID,
|
||||||
|
})
|
||||||
|
|
||||||
if (res.error) {
|
if (res.error) {
|
||||||
console.log("Creating a session failed:", res.error)
|
console.log("Creating a session failed:", res.error)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import type { PromptInfo } from "../component/prompt/history"
|
|||||||
export type HomeRoute = {
|
export type HomeRoute = {
|
||||||
type: "home"
|
type: "home"
|
||||||
initialPrompt?: PromptInfo
|
initialPrompt?: PromptInfo
|
||||||
|
workspaceID?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export type SessionRoute = {
|
export type SessionRoute = {
|
||||||
|
|||||||
@@ -121,6 +121,7 @@ export function Home() {
|
|||||||
promptRef.set(r)
|
promptRef.set(r)
|
||||||
}}
|
}}
|
||||||
hint={Hint}
|
hint={Hint}
|
||||||
|
workspaceID={route.workspaceID}
|
||||||
/>
|
/>
|
||||||
</box>
|
</box>
|
||||||
<box height={4} minHeight={0} width="100%" maxWidth={75} alignItems="center" paddingTop={3} flexShrink={1}>
|
<box height={4} minHeight={0} width="100%" maxWidth={75} alignItems="center" paddingTop={3} flexShrink={1}>
|
||||||
|
|||||||
@@ -219,6 +219,7 @@ export namespace Session {
|
|||||||
parentID: Identifier.schema("session").optional(),
|
parentID: Identifier.schema("session").optional(),
|
||||||
title: z.string().optional(),
|
title: z.string().optional(),
|
||||||
permission: Info.shape.permission,
|
permission: Info.shape.permission,
|
||||||
|
workspaceID: Identifier.schema("workspace").optional(),
|
||||||
})
|
})
|
||||||
.optional(),
|
.optional(),
|
||||||
async (input) => {
|
async (input) => {
|
||||||
@@ -227,6 +228,7 @@ export namespace Session {
|
|||||||
directory: Instance.directory,
|
directory: Instance.directory,
|
||||||
title: input?.title,
|
title: input?.title,
|
||||||
permission: input?.permission,
|
permission: input?.permission,
|
||||||
|
workspaceID: input?.workspaceID,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -242,6 +244,7 @@ export namespace Session {
|
|||||||
const title = getForkedTitle(original.title)
|
const title = getForkedTitle(original.title)
|
||||||
const session = await createNext({
|
const session = await createNext({
|
||||||
directory: Instance.directory,
|
directory: Instance.directory,
|
||||||
|
workspaceID: original.workspaceID,
|
||||||
title,
|
title,
|
||||||
})
|
})
|
||||||
const msgs = await messages({ sessionID: input.sessionID })
|
const msgs = await messages({ sessionID: input.sessionID })
|
||||||
@@ -292,6 +295,7 @@ export namespace Session {
|
|||||||
id?: string
|
id?: string
|
||||||
title?: string
|
title?: string
|
||||||
parentID?: string
|
parentID?: string
|
||||||
|
workspaceID?: string
|
||||||
directory: string
|
directory: string
|
||||||
permission?: PermissionNext.Ruleset
|
permission?: PermissionNext.Ruleset
|
||||||
}) {
|
}) {
|
||||||
@@ -301,7 +305,7 @@ export namespace Session {
|
|||||||
version: Installation.VERSION,
|
version: Installation.VERSION,
|
||||||
projectID: Instance.project.id,
|
projectID: Instance.project.id,
|
||||||
directory: input.directory,
|
directory: input.directory,
|
||||||
workspaceID: WorkspaceContext.workspaceID,
|
workspaceID: input.workspaceID,
|
||||||
parentID: input.parentID,
|
parentID: input.parentID,
|
||||||
title: input.title ?? createDefaultTitle(!!input.parentID),
|
title: input.title ?? createDefaultTitle(!!input.parentID),
|
||||||
permission: input.permission,
|
permission: input.permission,
|
||||||
|
|||||||
@@ -1295,6 +1295,7 @@ export class Session2 extends HeyApiClient {
|
|||||||
parentID?: string
|
parentID?: string
|
||||||
title?: string
|
title?: string
|
||||||
permission?: PermissionRuleset
|
permission?: PermissionRuleset
|
||||||
|
workspaceID?: string
|
||||||
},
|
},
|
||||||
options?: Options<never, ThrowOnError>,
|
options?: Options<never, ThrowOnError>,
|
||||||
) {
|
) {
|
||||||
@@ -1308,6 +1309,7 @@ export class Session2 extends HeyApiClient {
|
|||||||
{ in: "body", key: "parentID" },
|
{ in: "body", key: "parentID" },
|
||||||
{ in: "body", key: "title" },
|
{ in: "body", key: "title" },
|
||||||
{ in: "body", key: "permission" },
|
{ in: "body", key: "permission" },
|
||||||
|
{ in: "body", key: "workspaceID" },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -2764,6 +2764,7 @@ export type SessionCreateData = {
|
|||||||
parentID?: string
|
parentID?: string
|
||||||
title?: string
|
title?: string
|
||||||
permission?: PermissionRuleset
|
permission?: PermissionRuleset
|
||||||
|
workspaceID?: string
|
||||||
}
|
}
|
||||||
path?: never
|
path?: never
|
||||||
query?: {
|
query?: {
|
||||||
|
|||||||
Reference in New Issue
Block a user