fix: invoke skills selected from the slash command menu (#1607)
Selecting a user-installed skill from the slash menu inserted "/name" as a plain text message instead of running the skill (#1605). routeMessage only dispatched a "/name" via session.command when the name was found in the synced command list (hydrated once at bootstrap) or the commands store (which filters skills out), so skills installed after startup fell through to a plain prompt. Consult the live skills store when classifying a slash token. OpenCode registers every skill as a command (source: "skill"), so a known skill is dispatched via session.command and its content is injected, matching the existing behavior of skills that happened to be in the bootstrap snapshot. Signed-off-by: Bohdan Triapitsyn <artmore@protonmail.com> Co-authored-by: Ibrahim Khan <ibrakhxn@amazon.com> Co-authored-by: Bohdan Triapitsyn <artmore@protonmail.com>
This commit is contained in:
committed by
GitHub
co-authored by
Ibrahim Khan
Bohdan Triapitsyn
parent
ec69dcc28b
commit
f1c9776fde
@@ -24,6 +24,7 @@ import { useGlobalSessionsStore, resolveGlobalSessionDirectory } from "@/stores/
|
||||
import { useDirectoryStore } from "@/stores/useDirectoryStore"
|
||||
import { useSessionFoldersStore } from "@/stores/useSessionFoldersStore"
|
||||
import { useCommandsStore } from "@/stores/useCommandsStore"
|
||||
import { useSkillsStore } from "@/stores/useSkillsStore"
|
||||
import { getSafeStorage } from "@/stores/utils/safeStorage"
|
||||
import { markPendingUserSendAnimation } from "@/lib/userSendAnimation"
|
||||
import { flattenAssistantTextParts } from "@/lib/messages/messageText"
|
||||
@@ -101,8 +102,14 @@ export function routeMessage(params: {
|
||||
const syncCommands = dirState?.command ?? []
|
||||
const storeCommands = useCommandsStore.getState().commands
|
||||
|
||||
// OpenCode registers every skill as a command (source: "skill"), but the
|
||||
// commands store filters skills out and the synced command list is only
|
||||
// hydrated at bootstrap. Consult the live skills store so a skill selected
|
||||
// from the slash menu is invoked via session.command (injecting its
|
||||
// content) instead of being sent as a literal "/name" message (#1605).
|
||||
const isCommand = syncCommands.find((c) => c.name === cmdName)
|
||||
|| storeCommands.find((c) => c.name === cmdName)
|
||||
|| useSkillsStore.getState().skills.some((s) => s.name === cmdName)
|
||||
|
||||
if (isCommand) {
|
||||
return optimisticSend({
|
||||
|
||||
Reference in New Issue
Block a user