fix(pi): keep active runs alive during background sleep
This commit is contained in:
@@ -60,7 +60,10 @@ export interface CodingProjectConfigSnapshot {
|
||||
|
||||
export interface CodingProjectServiceOptions {
|
||||
onResourcesChanged?(project: CodingProject): Promise<void> | void;
|
||||
onProjectDeactivated?(project: CodingProject): Promise<void> | void;
|
||||
onProjectDeactivated?(
|
||||
project: CodingProject,
|
||||
reason: 'project_deactivated' | 'project_removed',
|
||||
): Promise<void> | void;
|
||||
createConversationStore?: typeof createCodingConversationStore;
|
||||
writeConfig?: typeof writeCodingProjectConfigV2;
|
||||
migration?: CodingProjectMigrationDependencies;
|
||||
@@ -198,7 +201,9 @@ export class CodingProjectService {
|
||||
async removeProject(projectId: string): Promise<void> {
|
||||
const project = await this.getProject(projectId);
|
||||
const active = await this.store.getActiveProject();
|
||||
if (active?.id === project.id) await this.options.onProjectDeactivated?.(project);
|
||||
if (active?.id === project.id) {
|
||||
await this.options.onProjectDeactivated?.(project, 'project_removed');
|
||||
}
|
||||
try {
|
||||
await this.store.removeProject(project.id);
|
||||
} catch (error) {
|
||||
@@ -373,7 +378,7 @@ export class CodingProjectService {
|
||||
const previous = await this.store.getActiveProject();
|
||||
const result = await operation();
|
||||
if (previous && previous.id !== result.project.id) {
|
||||
await this.options.onProjectDeactivated?.(previous);
|
||||
await this.options.onProjectDeactivated?.(previous, 'project_deactivated');
|
||||
}
|
||||
return result.value;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user