fix(mcp): refresh prompt slash commands
This commit is contained in:
parent
dbbe67f066
commit
594eddb288
9 changed files with 172 additions and 17 deletions
|
|
@ -134,6 +134,25 @@ describe("applyGlobalEvent", () => {
|
|||
})
|
||||
|
||||
describe("applyDirectoryEvent", () => {
|
||||
test("refreshes commands when command catalog changes", () => {
|
||||
const [store, setStore] = createStore(baseState())
|
||||
let refreshCount = 0
|
||||
|
||||
applyDirectoryEvent({
|
||||
event: { type: "command.changed" },
|
||||
store,
|
||||
setStore,
|
||||
push() {},
|
||||
directory: "/tmp",
|
||||
loadCommand() {
|
||||
refreshCount += 1
|
||||
},
|
||||
loadLsp() {},
|
||||
})
|
||||
|
||||
expect(refreshCount).toBe(1)
|
||||
})
|
||||
|
||||
test("preserves a Home-specific retained session limit", () => {
|
||||
const [store, setStore] = createStore(
|
||||
baseState({
|
||||
|
|
|
|||
|
|
@ -96,6 +96,7 @@ export function applyDirectoryEvent(input: {
|
|||
setStore: SetStoreFunction<State>
|
||||
push: (directory: string) => void
|
||||
directory: string
|
||||
loadCommand?: () => void
|
||||
loadLsp: () => void
|
||||
vcsCache?: VcsCache
|
||||
setSessionTodo?: (sessionID: string, todos: Todo[] | undefined) => void
|
||||
|
|
@ -108,6 +109,10 @@ export function applyDirectoryEvent(input: {
|
|||
input.push(input.directory)
|
||||
return
|
||||
}
|
||||
case "command.changed": {
|
||||
input.loadCommand?.()
|
||||
return
|
||||
}
|
||||
case "session.created": {
|
||||
const info = (event.properties as { info: Session }).info
|
||||
const result = Binary.search(input.store.session, info.id, (s) => s.id)
|
||||
|
|
|
|||
|
|
@ -407,6 +407,13 @@ export function createServerSyncContextInner(_serverSDK?: ServerSDK) {
|
|||
setSessionTodo,
|
||||
retainedLimit: sessionMeta.get(key)?.limit,
|
||||
vcsCache: children.vcsCache.get(key),
|
||||
loadCommand: () => {
|
||||
void retry(() =>
|
||||
sdkFor(directory)
|
||||
.command.list()
|
||||
.then((x) => setStore("command", x.data ?? [])),
|
||||
)
|
||||
},
|
||||
loadLsp: () => {
|
||||
void queryClient.fetchQuery(queryOptionsApi.lsp(key))
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue