Skip to content

Commit acfe782

Browse files
author
“nghyane”
committed
fix(PR#89): address review comments
- TmuxSessionManager: call startPolling() for fallback reliability - Remove redundant assignments before completeTask() in cancel() - Remove unused model parameter from LaunchOptions - Remove unused POLL_INTERVAL_BACKGROUND_MS import - Remove unused createSessionCreatedHandler/createSessionStatusHandler methods - Fix misplaced comment in schema.ts
1 parent 098209e commit acfe782

3 files changed

Lines changed: 7 additions & 35 deletions

File tree

src/background/background-manager.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
import type { PluginInput } from '@opencode-ai/plugin';
1717
import type { BackgroundTaskConfig, PluginConfig } from '../config';
18-
import { POLL_INTERVAL_BACKGROUND_MS } from '../config';
1918
import type { TmuxConfig } from '../config/schema';
2019
import { applyAgentVariant, resolveAgentVariant } from '../utils';
2120
import { log } from '../utils/logger';
@@ -66,7 +65,6 @@ export interface LaunchOptions {
6665
prompt: string; // Initial prompt to send to the agent
6766
description: string; // Human-readable task description
6867
parentSessionId: string; // Parent session ID for task hierarchy
69-
model?: string; // Optional model override
7068
notifyOnComplete?: boolean; // Whether to notify parent session on completion
7169
}
7270

@@ -225,10 +223,9 @@ export class BackgroundTaskManager {
225223
sessionId: session.data.id,
226224
});
227225
} catch (error) {
228-
task.status = 'failed';
229-
task.error = error instanceof Error ? error.message : String(error);
230-
task.completedAt = new Date();
231-
this.completeTask(task, 'failed', task.error);
226+
const errorMessage =
227+
error instanceof Error ? error.message : String(error);
228+
this.completeTask(task, 'failed', errorMessage);
232229
} finally {
233230
this.activeStarts--;
234231
this.processQueue();
@@ -435,9 +432,6 @@ export class BackgroundTaskManager {
435432
}
436433
}
437434

438-
task.status = 'cancelled';
439-
task.error = 'Cancelled by user';
440-
task.completedAt = new Date();
441435
this.completeTask(task, 'cancelled', 'Cancelled by user');
442436
return 1;
443437
}
@@ -459,9 +453,6 @@ export class BackgroundTaskManager {
459453
}
460454
}
461455

462-
task.status = 'cancelled';
463-
task.error = 'Cancelled by user';
464-
task.completedAt = new Date();
465456
this.completeTask(task, 'cancelled', 'Cancelled by user');
466457
count++;
467458
}

src/background/tmux-session-manager.ts

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ export class TmuxSessionManager {
116116
sessionId,
117117
paneId: paneResult.paneId,
118118
});
119+
120+
// Start polling for fallback reliability
121+
this.startPolling();
119122
}
120123
}
121124

@@ -226,28 +229,6 @@ export class TmuxSessionManager {
226229
}
227230
}
228231

229-
/**
230-
* Create the event handler for session.created events.
231-
*/
232-
createSessionCreatedHandler(): (input: {
233-
event: SessionEvent;
234-
}) => Promise<void> {
235-
return async (input) => {
236-
await this.onSessionCreated(input.event);
237-
};
238-
}
239-
240-
/**
241-
* Create the event handler for session.status events.
242-
*/
243-
createSessionStatusHandler(): (input: {
244-
event: SessionEvent;
245-
}) => Promise<void> {
246-
return async (input) => {
247-
await this.onSessionStatus(input.event);
248-
};
249-
}
250-
251232
/**
252233
* Clean up all tracked sessions.
253234
*/

src/config/schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ export type Preset = z.infer<typeof PresetSchema>;
3939
export const McpNameSchema = z.enum(['websearch', 'context7', 'grep_app']);
4040
export type McpName = z.infer<typeof McpNameSchema>;
4141

42-
// Main plugin config
4342
// Background task configuration
4443
export const BackgroundTaskConfigSchema = z.object({
4544
notifyOnComplete: z.boolean().default(false),
@@ -48,6 +47,7 @@ export const BackgroundTaskConfigSchema = z.object({
4847

4948
export type BackgroundTaskConfig = z.infer<typeof BackgroundTaskConfigSchema>;
5049

50+
// Main plugin config
5151
export const PluginConfigSchema = z.object({
5252
preset: z.string().optional(),
5353
presets: z.record(z.string(), PresetSchema).optional(),

0 commit comments

Comments
 (0)