Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
95dd2b671c | ||
|
|
bbe5e14696 |
No files matched your search
@@ -99,24 +99,12 @@ const ReactorLayerLive = Layer.empty.pipe(
|
||||
Layer.provideMerge(RuntimeReceiptBusLive),
|
||||
);
|
||||
|
||||
const OrchestrationEventInfrastructureLayerLive = Layer.mergeAll(
|
||||
OrchestrationEventStoreLive,
|
||||
OrchestrationCommandReceiptRepositoryLive,
|
||||
);
|
||||
|
||||
const OrchestrationProjectionPipelineLayerLive = OrchestrationProjectionPipelineLive.pipe(
|
||||
Layer.provide(OrchestrationEventStoreLive),
|
||||
);
|
||||
|
||||
const OrchestrationInfrastructureLayerLive = Layer.mergeAll(
|
||||
OrchestrationProjectionSnapshotQueryLive,
|
||||
OrchestrationEventInfrastructureLayerLive,
|
||||
OrchestrationProjectionPipelineLayerLive,
|
||||
);
|
||||
|
||||
const OrchestrationLayerLive = Layer.mergeAll(
|
||||
OrchestrationInfrastructureLayerLive,
|
||||
OrchestrationEngineLive.pipe(Layer.provide(OrchestrationInfrastructureLayerLive)),
|
||||
const OrchestrationLayerLive = Layer.empty.pipe(
|
||||
Layer.provideMerge(OrchestrationProjectionSnapshotQueryLive),
|
||||
Layer.provideMerge(OrchestrationEngineLive),
|
||||
Layer.provideMerge(OrchestrationProjectionPipelineLive),
|
||||
Layer.provideMerge(OrchestrationEventStoreLive),
|
||||
Layer.provideMerge(OrchestrationCommandReceiptRepositoryLive),
|
||||
);
|
||||
|
||||
const CheckpointingLayerLive = Layer.empty.pipe(
|
||||
|
||||
@@ -18,7 +18,6 @@ import { useSettings } from "./useSettings";
|
||||
|
||||
export function useThreadActions() {
|
||||
const appSettings = useSettings();
|
||||
const syncServerReadModel = useStore((store) => store.syncServerReadModel);
|
||||
const clearComposerDraftForThread = useComposerDraftStore((store) => store.clearDraftThread);
|
||||
const clearProjectDraftThreadById = useComposerDraftStore(
|
||||
(store) => store.clearProjectDraftThreadById,
|
||||
@@ -33,13 +32,6 @@ export function useThreadActions() {
|
||||
const queryClient = useQueryClient();
|
||||
const removeWorktreeMutation = useMutation(gitRemoveWorktreeMutationOptions({ queryClient }));
|
||||
|
||||
const refreshActiveSnapshot = useCallback(async () => {
|
||||
const api = readNativeApi();
|
||||
if (!api) return;
|
||||
const snapshot = await api.orchestration.getActiveSnapshot();
|
||||
syncServerReadModel(snapshot);
|
||||
}, [syncServerReadModel]);
|
||||
|
||||
const archiveThread = useCallback(
|
||||
async (threadId: ThreadId) => {
|
||||
const api = readNativeApi();
|
||||
@@ -73,10 +65,9 @@ export function useThreadActions() {
|
||||
commandId: newCommandId(),
|
||||
threadId,
|
||||
});
|
||||
await refreshActiveSnapshot();
|
||||
void queryClient.invalidateQueries({ queryKey: orchestrationQueryKeys.archivedThreads() });
|
||||
},
|
||||
[queryClient, refreshActiveSnapshot],
|
||||
[queryClient],
|
||||
);
|
||||
|
||||
const deleteThread = useCallback(
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import type { OrchestrationListArchivedThreadsResult } from "@t3tools/contracts";
|
||||
import { queryOptions } from "@tanstack/react-query";
|
||||
import { ensureNativeApi } from "~/nativeApi";
|
||||
|
||||
@@ -8,7 +7,6 @@ export const orchestrationQueryKeys = {
|
||||
};
|
||||
|
||||
const DEFAULT_ARCHIVED_THREADS_STALE_TIME = 15_000;
|
||||
const EMPTY_ARCHIVED_THREADS: OrchestrationListArchivedThreadsResult = [];
|
||||
|
||||
export function archivedThreadsQueryOptions() {
|
||||
return queryOptions({
|
||||
@@ -18,6 +16,6 @@ export function archivedThreadsQueryOptions() {
|
||||
return api.orchestration.listArchivedThreads();
|
||||
},
|
||||
staleTime: DEFAULT_ARCHIVED_THREADS_STALE_TIME,
|
||||
placeholderData: (previous) => previous ?? EMPTY_ARCHIVED_THREADS,
|
||||
placeholderData: (previous) => previous,
|
||||
});
|
||||
}
|
||||
@@ -62,14 +62,10 @@ export function createOrchestrationRecoveryCoordinator() {
|
||||
return "apply";
|
||||
},
|
||||
|
||||
filterNewEvents<T extends SequencedEvent>(events: ReadonlyArray<T>): ReadonlyArray<T> {
|
||||
return events
|
||||
markEventBatchApplied<T extends SequencedEvent>(events: ReadonlyArray<T>): ReadonlyArray<T> {
|
||||
const nextEvents = events
|
||||
.filter((event) => event.sequence > state.latestSequence)
|
||||
.toSorted((left, right) => left.sequence - right.sequence);
|
||||
},
|
||||
|
||||
markEventBatchApplied<T extends SequencedEvent>(events: ReadonlyArray<T>): ReadonlyArray<T> {
|
||||
const nextEvents = this.filterNewEvents(events);
|
||||
if (nextEvents.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -313,7 +313,7 @@ function EventRouter() {
|
||||
const applyEventBatch = (
|
||||
events: ReadonlyArray<OrchestrationEvent>,
|
||||
): "applied" | "snapshot-recovery-needed" => {
|
||||
const nextEvents = recovery.filterNewEvents(events);
|
||||
const nextEvents = recovery.markEventBatchApplied(events);
|
||||
if (nextEvents.length === 0) {
|
||||
return "applied";
|
||||
}
|
||||
@@ -327,8 +327,6 @@ function EventRouter() {
|
||||
return "snapshot-recovery-needed";
|
||||
}
|
||||
|
||||
recovery.markEventBatchApplied(nextEvents);
|
||||
|
||||
const batchEffects = deriveOrchestrationBatchEffects(nextEvents);
|
||||
const needsProjectUiSync = nextEvents.some(
|
||||
(event) =>
|
||||
@@ -419,9 +417,6 @@ function EventRouter() {
|
||||
if (!disposed) {
|
||||
syncServerReadModel(snapshot);
|
||||
reconcileSnapshotDerivedState();
|
||||
void queryClient.invalidateQueries({
|
||||
queryKey: orchestrationQueryKeys.archivedThreads(),
|
||||
});
|
||||
if (recovery.completeSnapshotRecovery(snapshot.snapshotSequence)) {
|
||||
void recoverFromSequenceGap();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user