fix(plugin): handle raw /ulw-loop commands appearing after injected messages

Fix parseRawLoopSlashCommand to correctly extract and parse loop commands
that appear after injected background task messages (e.g., "[BACKGROUND
TASK COMPLETED]"). Previously, the function only checked if the entire
message started with a slash command, failing when injected content
preceded the command.

🤖 Generated with assistance of OhMyOpenCode (https://github.com/code-yeongyu/oh-my-opencode)
This commit is contained in:
YeonGyu-Kim
2026-04-03 22:13:02 +09:00
parent df7dc2f716
commit 6624803a52
2 changed files with 55 additions and 3 deletions
+10 -3
View File
@@ -90,17 +90,24 @@ function getStoredMainSessionModel(
function parseRawLoopSlashCommand(promptText: string): RawLoopCommand | null {
const trimmed = promptText.trim()
const commandText = trimmed.startsWith("/")
? trimmed
: trimmed
.split("\n")
.map((line) => line.trim())
.filter((line) => /^\/(?:ralph-loop|ulw-loop|cancel-ralph)\b/i.test(line))
.at(-1)
if (!trimmed.startsWith("/")) {
if (!commandText) {
return null
}
const cancelMatch = trimmed.match(/^\/cancel-ralph(?:\s+.*)?$/i)
const cancelMatch = commandText.match(/^\/cancel-ralph(?:\s+.*)?$/i)
if (cancelMatch) {
return { command: "cancel-ralph", args: "" }
}
const loopMatch = trimmed.match(/^\/(ralph-loop|ulw-loop)\s*([\s\S]*)$/i)
const loopMatch = commandText.match(/^\/(ralph-loop|ulw-loop)\s*([\s\S]*)$/i)
if (!loopMatch) {
return null
}