Skip to content

Commit 0105da1

Browse files
committed
fix: keep session ongoing when main file is stale but subagent is active
When a subagent does long-running work, the main session file stops being written to and becomes stale (>60s). Previously, chunks_ongoing gated on main file freshness and returned false even though a subagent was actively running. Now also checks any_subagent_ongoing when chunks are active but the main file is stale. Also checks pending background commands at the subagent level. Entire-Checkpoint: 3bcd1838f1b9
1 parent af945a9 commit 0105da1

1 file changed

Lines changed: 18 additions & 8 deletions

File tree

src-tauri/src/parser/ongoing.rs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -198,17 +198,27 @@ impl<'a> OngoingChecker<'a> {
198198

199199
/// Full ongoing check: chunks → subagents → background commands → file staleness.
200200
pub fn is_ongoing(&self) -> bool {
201-
// If the main session chunks are still in progress, gate on the main file freshness.
202-
if self.chunks_ongoing() {
203-
return self.is_file_fresh();
201+
let chunks_active = self.chunks_ongoing();
202+
let subagents_active = self.any_subagent_ongoing();
203+
204+
if chunks_active {
205+
// Main chunks show activity. If the main file is fresh, ongoing.
206+
// If the main file is stale but a subagent is still fresh, also
207+
// ongoing — the main file stops being written to while subagents
208+
// do the actual work.
209+
if self.is_file_fresh() || subagents_active {
210+
return true;
211+
}
204212
}
205-
// If any subagent is still running, the session is ongoing.
206-
// Subagent staleness is already checked per-file inside is_subagent_ongoing,
207-
// so we don't re-check the main session file here.
208-
if self.any_subagent_ongoing() {
213+
214+
// Subagent is active even though main chunks look done.
215+
if subagents_active {
209216
return true;
210217
}
211-
// Check for background Bash commands that haven't completed yet.
218+
219+
// Check for background Bash commands that haven't completed yet
220+
// (in main session or subagent chunks — subagent check is inside
221+
// is_subagent_ongoing above, this catches main-session-level ones).
212222
Self::has_pending_background_commands(self.chunks)
213223
}
214224

0 commit comments

Comments
 (0)