Skip to content

Commit 59ff2bd

Browse files
committed
fix(bash): persist opt-out match frontier
1 parent 371331b commit 59ff2bd

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

src/node/services/backgroundProcessManager.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1841,6 +1841,8 @@ describe("BackgroundProcessManager", () => {
18411841
it("wake_on_exit=false still flushes pending matched lines without terminal metadata", async () => {
18421842
const matchEvents: MonitorMatchPayload[] = [];
18431843
manager.on("monitor:match", (_workspaceId, payload) => matchEvents.push(payload));
1844+
const stoppedEvents: MonitorStoppedPayload[] = [];
1845+
manager.on("monitor:stopped", (_workspaceId, payload) => stoppedEvents.push(payload));
18441846

18451847
const result = await manager.spawn(
18461848
runtime,
@@ -1869,6 +1871,10 @@ describe("BackgroundProcessManager", () => {
18691871
expect(matchEvents[0].lines).toEqual(["ERR boom"]);
18701872
expect(matchEvents[0].terminal).toBeUndefined();
18711873
expect(matchEvents[0].matchedThroughOffset).toBeDefined();
1874+
expect(stoppedEvents).toHaveLength(1);
1875+
expect(stoppedEvents[0].terminal?.matchedThroughOffset).toBe(
1876+
matchEvents[0].matchedThroughOffset
1877+
);
18721878
});
18731879

18741880
it("does not settle after maxEvents retirement", async () => {

src/node/services/backgroundProcessManager.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -875,14 +875,17 @@ export class BackgroundProcessManager extends EventEmitter<BackgroundProcessMana
875875
pendingLines.length > 0 && proc.shownThroughOffset < monitor.matchedThroughOffset;
876876

877877
const retainedMatch = monitor.retainedMatches[monitor.retainedMatches.length - 1];
878+
const retainedMatchedThroughOffset = includeMatched
879+
? monitor.matchedThroughOffset
880+
: retainedMatch?.matchedThroughOffset;
878881
monitor.settlementDisposition = {
879882
status: terminal.status,
880883
...(terminal.exitCode !== undefined ? { exitCode: terminal.exitCode } : {}),
881884
settledAt: new Date().toISOString(),
882885
wakeOnExit: monitor.wakeOnExit,
883886
terminalStatusShown: proc.terminalStatusShownToAgent,
884-
...(retainedMatch != null
885-
? { matchedThroughOffset: retainedMatch.matchedThroughOffset }
887+
...(retainedMatchedThroughOffset != null
888+
? { matchedThroughOffset: retainedMatchedThroughOffset }
886889
: {}),
887890
tailLines,
888891
};

0 commit comments

Comments
 (0)