Detects non-interactive environments (CI, opencode run) and prevents session idle when: - Background tasks are still running - Incomplete todos remain in the queue Changes: - Add isNonInteractive() detector for CI/headless environment detection - Export detector from non-interactive-env hook module - Enhance todo-continuation-enforcer to inject prompts BEFORE session.idle - Pass BackgroundManager to todo-continuation-enforcer for task status checks This fix prevents `opencode run` from exiting prematurely when work is pending. 🤖 Generated with assistance of OhMyOpenCode (https://github.com/code-yeongyu/oh-my-opencode)
This commit is contained in:
19
src/hooks/non-interactive-env/detector.ts
Normal file
19
src/hooks/non-interactive-env/detector.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
export function isNonInteractive(): boolean {
|
||||
if (process.env.CI === "true" || process.env.CI === "1") {
|
||||
return true
|
||||
}
|
||||
|
||||
if (process.env.OPENCODE_RUN === "true" || process.env.OPENCODE_NON_INTERACTIVE === "true") {
|
||||
return true
|
||||
}
|
||||
|
||||
if (process.env.GITHUB_ACTIONS === "true") {
|
||||
return true
|
||||
}
|
||||
|
||||
if (!process.stdout.isTTY) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import { HOOK_NAME, NON_INTERACTIVE_ENV, SHELL_COMMAND_PATTERNS } from "./consta
|
||||
import { log } from "../../shared"
|
||||
|
||||
export * from "./constants"
|
||||
export * from "./detector"
|
||||
export * from "./types"
|
||||
|
||||
const BANNED_COMMAND_PATTERNS = SHELL_COMMAND_PATTERNS.banned
|
||||
|
||||
Reference in New Issue
Block a user