refactor(tui): make data sync owner-driven

This commit is contained in:
Dax Raad 2026-07-14 17:32:30 -04:00
commit 2508a74956
10 changed files with 519 additions and 407 deletions

View file

@ -467,11 +467,10 @@ async function connected(
toast: ReturnType<typeof useToast>,
onConnected?: OnIntegrationConnected,
) {
await Promise.all([
data.location.integration.refresh(),
data.location.model.refresh(),
data.location.provider.refresh(),
])
data.location.integration.invalidate()
data.location.model.invalidate()
data.location.provider.invalidate()
await Promise.all([data.location.integration.sync(), data.location.model.sync(), data.location.provider.sync()])
toast.show({ variant: "success", message: `Connected ${integration.name}` })
if (onConnected) {
onConnected(providerID(data, integration.id))
@ -498,11 +497,10 @@ async function disconnected(
dialog: ReturnType<typeof useDialog>,
toast: ReturnType<typeof useToast>,
) {
await Promise.all([
data.location.integration.refresh(),
data.location.model.refresh(),
data.location.provider.refresh(),
])
data.location.integration.invalidate()
data.location.model.invalidate()
data.location.provider.invalidate()
await Promise.all([data.location.integration.sync(), data.location.model.sync(), data.location.provider.sync()])
toast.show({ variant: "success", message: `Disconnected ${name}` })
dialog.clear()
}

View file

@ -25,7 +25,7 @@ export function DialogSkill(props: DialogSkillProps) {
.then(async () => {
const current = data.location.skill.list(props.location)
if (current) return current
await data.location.skill.refresh(props.location)
await data.location.skill.sync(props.location)
return data.location.skill.list(props.location) ?? []
})
// Catch so the rejected resource never reaches the memo below: reading

View file

@ -1055,7 +1055,7 @@ export function Prompt(props: PromptProps) {
} else {
move.startSubmit()
if (!session) {
await data.session.refresh(sessionID)
await data.session.sync(sessionID)
session = data.session.get(sessionID)
}
if (session?.agent !== agent.id) {

View file

@ -42,7 +42,7 @@ export function usePromptMove(input: { projectID: () => string | undefined; sess
const directory = result.directory
if (!directory) throw new Error("No project copy directory returned")
// Call a location-based route to make sure it's bootstrapped before moving on.
// Call a location-based route to initialize it before moving on.
await client.api.location.get({ location: { directory } })
setProgress("Creating session")
@ -139,7 +139,7 @@ export function usePromptMove(input: { projectID: () => string | undefined; sess
async function resolveSession(sessionID: string) {
const session = data.session.get(sessionID)
if (session) return session
await data.session.refresh(sessionID).catch(() => undefined)
await data.session.sync(sessionID).catch(() => undefined)
return data.session.get(sessionID)
}