fix(ui): preserve slash command message ids (#1031)
This commit is contained in:
@@ -70,9 +70,8 @@ function routeMessage(params: {
|
|||||||
files?: Array<{ type: "file"; mime: string; url: string; filename: string }>
|
files?: Array<{ type: "file"; mime: string; url: string; filename: string }>
|
||||||
additionalParts?: Array<{ text: string; synthetic?: boolean; files?: Array<{ type: "file"; mime: string; url: string; filename: string }> }>
|
additionalParts?: Array<{ text: string; synthetic?: boolean; files?: Array<{ type: "file"; mime: string; url: string; filename: string }> }>
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
const sdk = opencodeClient.getSdkClient()
|
|
||||||
|
|
||||||
if (params.inputMode === "shell") {
|
if (params.inputMode === "shell") {
|
||||||
|
const sdk = opencodeClient.getSdkClient()
|
||||||
const dir = opencodeClient.getDirectory() || undefined
|
const dir = opencodeClient.getDirectory() || undefined
|
||||||
return sdk.session.shell({
|
return sdk.session.shell({
|
||||||
sessionID: params.sessionId,
|
sessionID: params.sessionId,
|
||||||
@@ -96,17 +95,25 @@ function routeMessage(params: {
|
|||||||
|| storeCommands.find((c) => c.name === cmdName)
|
|| storeCommands.find((c) => c.name === cmdName)
|
||||||
|
|
||||||
if (isCommand) {
|
if (isCommand) {
|
||||||
const dir = opencodeClient.getDirectory() || undefined
|
return optimisticSend({
|
||||||
return sdk.session.command({
|
sessionId: params.sessionId,
|
||||||
sessionID: params.sessionId,
|
content: params.content,
|
||||||
directory: dir,
|
providerID: params.providerID,
|
||||||
command: cmdName,
|
modelID: params.modelID,
|
||||||
arguments: tail.join(" "),
|
|
||||||
agent: params.agent,
|
agent: params.agent,
|
||||||
model: `${params.providerID}/${params.modelID}`,
|
files: params.files,
|
||||||
variant: params.variant,
|
send: (messageID) => opencodeClient.sendCommand({
|
||||||
parts: params.files,
|
id: params.sessionId,
|
||||||
}).then(() => {})
|
providerID: params.providerID,
|
||||||
|
modelID: params.modelID,
|
||||||
|
command: cmdName,
|
||||||
|
arguments: tail.join(" "),
|
||||||
|
agent: params.agent,
|
||||||
|
variant: params.variant,
|
||||||
|
files: params.files,
|
||||||
|
messageId: messageID,
|
||||||
|
}).then(() => {}),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,6 +139,11 @@ function routeMessage(params: {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function notifyMessageSent(sessionId: string): void {
|
||||||
|
fetch(`/api/sessions/${sessionId}/message-sent`, { method: "POST" })
|
||||||
|
.catch(() => { /* ignore */ })
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Types
|
// Types
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@@ -754,6 +766,8 @@ export const useSessionUIStore = create<SessionUIState>()((set, get) => ({
|
|||||||
await waitForWorktreeBootstrap(createdDirectory)
|
await waitForWorktreeBootstrap(createdDirectory)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
notifyMessageSent(created.id)
|
||||||
|
|
||||||
markPendingUserSendAnimation(created.id)
|
markPendingUserSendAnimation(created.id)
|
||||||
|
|
||||||
const files = attachments?.map((a) => ({
|
const files = attachments?.map((a) => ({
|
||||||
@@ -823,8 +837,7 @@ export const useSessionUIStore = create<SessionUIState>()((set, get) => ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (currentSessionId) {
|
if (currentSessionId) {
|
||||||
fetch(`/api/sessions/${currentSessionId}/message-sent`, { method: "POST" })
|
notifyMessageSent(currentSessionId)
|
||||||
.catch(() => { /* ignore */ })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentSessionId) {
|
if (currentSessionId) {
|
||||||
|
|||||||
Reference in New Issue
Block a user