Manually deleting phases left their parent changeset as "applied", causing the Plan tab to show a stale "Created N phases" banner with no phases visible. - deletePhase now checks if all phases from a changeset are gone and marks it reverted - PlanSection filters out dismissed agents so dismissed banners stay hidden - revertChangeSet marks reverted before entity deletion to prevent ghost state on partial failure - deletePhase invalidation now includes listChangeSets
43 lines
1.4 KiB
TypeScript
43 lines
1.4 KiB
TypeScript
/**
|
|
* Change Set Repository Port Interface
|
|
*
|
|
* Port for ChangeSet aggregate operations.
|
|
* Implementations (Drizzle, etc.) are adapters.
|
|
*/
|
|
|
|
import type { ChangeSet, ChangeSetEntry } from '../schema.js';
|
|
|
|
export type CreateChangeSetData = {
|
|
agentId: string | null;
|
|
agentName: string;
|
|
initiativeId: string;
|
|
mode: 'plan' | 'detail' | 'refine' | 'chat';
|
|
summary?: string | null;
|
|
};
|
|
|
|
export type CreateChangeSetEntryData = {
|
|
entityType: 'page' | 'phase' | 'task' | 'phase_dependency' | 'task_dependency';
|
|
entityId: string;
|
|
action: 'create' | 'update' | 'delete';
|
|
previousState?: string | null;
|
|
newState?: string | null;
|
|
sortOrder?: number;
|
|
};
|
|
|
|
export type ChangeSetWithEntries = ChangeSet & { entries: ChangeSetEntry[] };
|
|
|
|
export interface ChangeSetRepository {
|
|
createWithEntries(data: CreateChangeSetData, entries: CreateChangeSetEntryData[]): Promise<ChangeSet>;
|
|
findById(id: string): Promise<ChangeSet | null>;
|
|
findByIdWithEntries(id: string): Promise<ChangeSetWithEntries | null>;
|
|
findByInitiativeId(initiativeId: string): Promise<ChangeSet[]>;
|
|
findByAgentId(agentId: string): Promise<ChangeSet[]>;
|
|
markReverted(id: string): Promise<ChangeSet>;
|
|
|
|
/**
|
|
* Find applied changesets that have a 'create' entry for the given entity.
|
|
* Used to reconcile changeset status when entities are manually deleted.
|
|
*/
|
|
findAppliedByCreatedEntity(entityType: string, entityId: string): Promise<ChangeSetWithEntries[]>;
|
|
}
|