Skip to content

Commit ec538d8

Browse files
authored
feat: queue files for auto-simplify with session isolation (#29)
* feat(simplify): queue files for auto-simplify with new session isolation * docs: update changelog
1 parent bff74a8 commit ec538d8

3 files changed

Lines changed: 31 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,13 @@ All notable changes to agent-stuff are documented here.
5454

5555

5656

57-
## docs/improve-task-breakdown-guidance
57+
58+
59+
## feat/auto-simplify-session-isolation
60+
61+
Implements session isolation for auto-triggered simplifications (#29), ensuring that files queued from the `agent_end` confirmation create a new isolated session before execution rather than running in the current context. This prevents simplification work from interfering with ongoing analysis and improves context management. The implementation queues files internally and defers their processing to the next `/simplify` invocation, which detects pending auto-simplify work and establishes a fresh session with appropriate naming before proceeding.
62+
63+
## [1.0.17](https://github.com/kostyay/agent-stuff/pull/28) - 2026-03-07
5864

5965
Enhanced task breakdown guidance in the ticket extension to provide agents with clearer constraints on task granularity (#28). The updated prompts now explicitly define "atomic tasks" as single, narrowly-scoped changes affecting 2-3 files or ~50 lines of code maximum, with concrete examples like individual functions, endpoints, or test files. This change addresses context window limitations by encouraging developers and AI agents to split larger tasks into smaller units, improving task completion rates and reducing incomplete work.
6066

pi-extensions/simplify.ts

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,14 @@ let hasProposedSimplify = false;
416416
*/
417417
let simplifyPending = false;
418418

419+
/**
420+
* Files queued by the `agent_end` auto-simplify confirmation.
421+
*
422+
* When set, the next `/simplify` invocation creates a new session
423+
* before running so the simplification work is isolated.
424+
*/
425+
let pendingAutoSimplifyFiles: string[] | null = null;
426+
419427
// ---------------------------------------------------------------------------
420428
// Extension entry point
421429
// ---------------------------------------------------------------------------
@@ -440,11 +448,23 @@ export default function simplifyExtension(pi: ExtensionAPI) {
440448
"Pass explicit file paths to target specific files. " +
441449
"Extra text that doesn't match a file extension is forwarded as additional instructions.",
442450
handler: async (args, ctx) => {
451+
const notify: Notify = (msg, level) => ctx.ui.notify(msg, level);
452+
const autoFiles = pendingAutoSimplifyFiles;
453+
pendingAutoSimplifyFiles = null;
454+
455+
if (autoFiles) {
456+
const result = await ctx.newSession();
457+
if (result.cancelled) return;
458+
pi.setSessionName("Code Simplification");
459+
await triggerSimplify(pi, { files: autoFiles }, notify);
460+
return;
461+
}
462+
443463
const { files, extraInstructions } = parseArgs(args);
444464
await triggerSimplify(
445465
pi,
446466
{ files: files.length > 0 ? files : undefined, extraInstructions },
447-
(msg, level) => ctx.ui.notify(msg, level),
467+
notify,
448468
);
449469
},
450470
});
@@ -488,10 +508,7 @@ export default function simplifyExtension(pi: ExtensionAPI) {
488508

489509
if (!confirmed) return;
490510

491-
await triggerSimplify(
492-
pi,
493-
{ files: sourceFiles },
494-
(msg, level) => ctx.ui.notify(msg, level),
495-
);
511+
pendingAutoSimplifyFiles = sourceFiles;
512+
pi.sendUserMessage("/simplify");
496513
});
497514
}

pi-extensions/status-bar.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ export default function statusBarExtension(pi: ExtensionAPI) {
239239

240240
// --- Line 1: badge + model + context meter (left), tokens + cost (right) ---
241241
const pct = ctx.getContextUsage()?.percent ?? 0;
242-
const filled = Math.round(pct / 10) || 1;
242+
const filled = Math.min(10, Math.round(pct / 10) || 1);
243243
const model = ctx.model?.id || "no-model";
244244

245245
const badge = buildProfileBadge(ctx);

0 commit comments

Comments
 (0)