fix(tui): inject reminder after moving session (#31027)

This commit is contained in:
James Long 2026-06-05 17:33:50 -04:00 committed by GitHub
parent a645615a49
commit d5b205657f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 30 additions and 11 deletions

View File

@ -10,6 +10,10 @@ import { DialogMoveSession, type MoveSessionSelection } from "../dialog-move-ses
import { DialogWorkspaceFileChanges } from "../dialog-workspace-file-changes"
import { useHomeSessionDestination } from "../../routes/home/session-destination"
function moveReminderText(directory: string) {
return `<system-reminder>The user has changed the current working directory to "${directory}". This is still the same project but at a possibly new location; take this into account when working with any files from now on.</system-reminder>`
}
export function usePromptMove(input: { projectID: () => string | undefined; sessionID: () => string | undefined }) {
const dialog = useDialog()
const sdk = useSDK()
@ -110,8 +114,8 @@ export function usePromptMove(input: { projectID: () => string | undefined; sess
return
}
setProgress("Moving session")
await sdk.client.experimental.controlPlane
.moveSession(
try {
await sdk.client.experimental.controlPlane.moveSession(
{
sessionID,
destination: { directory },
@ -119,15 +123,28 @@ export function usePromptMove(input: { projectID: () => string | undefined; sess
},
{ throwOnError: true },
)
.then(() => dialog.clear())
.catch((error) => {
toast.error(error)
dialog.clear()
})
.finally(() => {
setProgress(undefined)
setCreating(false)
})
await sdk.client.session
.promptAsync({
sessionID,
directory,
noReply: true,
parts: [
{
type: "text",
text: moveReminderText(directory),
synthetic: true,
},
],
})
.catch(() => undefined)
dialog.clear()
} catch (error) {
toast.error(error)
dialog.clear()
} finally {
setProgress(undefined)
setCreating(false)
}
}
const pending = createMemo(() => Boolean(homeDestination?.destination()))

View File

@ -31,5 +31,7 @@ function message(error: MoveSession.Error) {
if (error instanceof SessionV2.NotFoundError) return `Session not found: ${error.sessionID}`
if (error instanceof MoveSession.DestinationProjectMismatchError)
return "Destination directory belongs to another project"
if (error instanceof MoveSession.ApplyChangesError)
return `Unable to apply your changes in the destination directory. The files may conflict with existing changes.`
return error.message
}