Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/components/layout/areas/MlEphantConversationPaneWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ function MlEphantConversationPaneInner(props: AreaTypeComponentProps) {

const {
beginPendingZookeeperHistoryWrite,
cancelPendingZookeeperHistoryWrite,
completePendingZookeeperHistoryWrite,
} = useZookeeperEditPatchHistory({
kclManager,
Expand Down Expand Up @@ -230,6 +231,11 @@ function MlEphantConversationPaneInner(props: AreaTypeComponentProps) {
})
}
},
onFileSystemError: () => {
if (shouldRecordZookeeperHistory) {
cancelPendingZookeeperHistoryWrite(exchangeId)
}
},
...(shouldRefreshActiveEditorAfterPlainOutput && activeFileOutput
? {
onSuccess: () => {
Expand Down Expand Up @@ -483,6 +489,16 @@ function useZookeeperEditPatchHistory({
[tryFlushPendingZookeeperHistory]
)

const cancelPendingZookeeperHistoryWrite = useCallback(
(exchangeId: number) => {
pendingZookeeperHistoryByExchange.current.delete(exchangeId)
if (pendingZookeeperHistoryByExchange.current.size === 0) {
kclManager.zookeeperHistoryRecordingInProgress = false
}
},
[kclManager]
)

useFlushZookeeperHistoryOnResponseEnd(
mlEphantManagerActor,
pendingZookeeperHistoryByExchange,
Expand All @@ -491,6 +507,7 @@ function useZookeeperEditPatchHistory({

return {
beginPendingZookeeperHistoryWrite,
cancelPendingZookeeperHistoryWrite,
completePendingZookeeperHistoryWrite,
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/machines/systemIO/systemIOMachine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export const systemIOMachine = setup({
override?: boolean
requestedSubRoute?: string
onFileSystemSuccess?: () => void
onFileSystemError?: () => void
onSuccess?: () => void
}
}
Expand Down Expand Up @@ -669,6 +670,7 @@ export const systemIOMachine = setup({
override?: boolean
requestedSubRoute?: string
onFileSystemSuccess?: () => void
onFileSystemError?: () => void
onSuccess?: () => void
}
}): Promise<{
Expand Down Expand Up @@ -1708,6 +1710,7 @@ export const systemIOMachine = setup({
event.data.requestedFileNameWithExtension,
requestedSubRoute: event.data.requestedSubRoute,
onFileSystemSuccess: event.data.onFileSystemSuccess,
onFileSystemError: event.data.onFileSystemError,
onSuccess: event.data.onSuccess,
}
},
Expand Down
54 changes: 33 additions & 21 deletions src/machines/systemIO/systemIOMachineImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,15 @@ const sharedBulkDeleteWorkflow = async ({
wasmInstance: ModuleType
}
}) => {
const requestedFilesToDelete = new Set(
(input.filesToDelete ?? []).map((file) =>
normalizeKCLFileDeletePath(file.requestedFileName)
)
)
if (requestedFilesToDelete.size === 0) {
return 0
}

if (!input.context.folders) {
console.warn('no folders')
return
Expand All @@ -396,12 +405,6 @@ const sharedBulkDeleteWorkflow = async ({
projectContext: project,
})

const requestedFilesToDelete = new Set(
(input.filesToDelete ?? []).map((file) =>
normalizeKCLFileDeletePath(file.requestedFileName)
)
)

// requestedFileName is the relative path too.
const filesToDelete = filesInProject.filter(
(file) =>
Expand Down Expand Up @@ -874,24 +877,33 @@ export const systemIOMachineImpl = systemIOMachine.provide({
requestedFileNameWithExtension: string
requestedSubRoute?: string
onFileSystemSuccess?: () => void
onFileSystemError?: () => void
onSuccess?: () => void
}
}) => {
const wasmInstance = await input.context.wasmInstancePromise
const message = await sharedBulkCreateWorkflow({
input: {
...input,
wasmInstance,
override: input.override,
},
})
// We won't delete until everything's created / updated first.
const totalDeleted = await sharedBulkDeleteWorkflow({
input: {
...input,
wasmInstance,
},
})
let message: Awaited<ReturnType<typeof sharedBulkCreateWorkflow>>
let totalDeleted = 0
try {
const wasmInstance = await input.context.wasmInstancePromise
message = await sharedBulkCreateWorkflow({
input: {
...input,
wasmInstance,
override: input.override,
},
})
// We won't delete until everything's created / updated first.
totalDeleted =
(await sharedBulkDeleteWorkflow({
input: {
...input,
wasmInstance,
},
})) ?? 0
} catch (error) {
input.onFileSystemError?.()
return Promise.reject(error)
}

message.message += `, ${totalDeleted} deleted`
input.onFileSystemSuccess?.()
Expand Down
Loading