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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user