mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
fix(session): unify prompt sends on prompt_async and suppress stale network banners
Remove the long-lived synchronous POST to /session/{id}/message that produced
spurious "Connection Failed" banners on transient network blips; route every
send (normal, streaming-queue follow-up, message refresh) through prompt_async,
whose failure genuinely means not-delivered. Suppress network-kind banners
while SSE is disconnected or reconnecting (the header already shows that state);
session-kind banners still appear and reconcile clears confirmed prompts after
reconnect.
This commit is contained in:
1 parent
80bca441ed
commit
59fd516b75
9 files changed
+156
-167
No files matched your search
@@ -8,7 +8,6 @@ type SessionListParams = NonNullable<paths['/session']['get']['parameters']['que
|
||||
}
|
||||
type CreateSessionRequest = NonNullable<paths['/session']['post']['requestBody']>['content']['application/json']
|
||||
type MessageListResponse = paths['/session/{sessionID}/message']['get']['responses']['200']['content']['application/json']
|
||||
type SendPromptRequest = NonNullable<paths['/session/{sessionID}/message']['post']['requestBody']>['content']['application/json']
|
||||
type SendPromptAsyncRequest = NonNullable<paths['/session/{sessionID}/prompt_async']['post']['requestBody']>['content']['application/json']
|
||||
type ConfigResponse = paths['/config']['get']['responses']['200']['content']['application/json']
|
||||
type CommandListResponse = paths['/command']['get']['responses']['200']['content']['application/json']
|
||||
@@ -18,7 +17,6 @@ type ShellRequest = NonNullable<paths['/session/{sessionID}/shell']['post']['req
|
||||
type AgentListResponse = paths['/agent']['get']['responses']['200']['content']['application/json']
|
||||
type PermissionListResponse = paths['/permission']['get']['responses']['200']['content']['application/json']
|
||||
type QuestionListResponse = paths['/question']['get']['responses']['200']['content']['application/json']
|
||||
type SendPromptResponse = paths['/session/{sessionID}/message']['post']['responses']['200']['content']['application/json']
|
||||
type LspStatusResponse = paths['/lsp']['get']['responses']['200']['content']['application/json']
|
||||
type LspStatus = LspStatusResponse[number]
|
||||
|
||||
@@ -91,7 +89,7 @@ function toLegacySession(session: SessionV2Info, directory?: string): LegacySess
|
||||
} as LegacySession
|
||||
}
|
||||
|
||||
export type { SendPromptResponse, SendCommandResponse, LspStatus }
|
||||
export type { SendCommandResponse, LspStatus }
|
||||
|
||||
export class OpenCodeClient {
|
||||
private baseURL: string
|
||||
@@ -196,19 +194,6 @@ export class OpenCodeClient {
|
||||
})
|
||||
}
|
||||
|
||||
async sendPrompt(sessionID: string, data: SendPromptRequest): Promise<SendPromptResponse> {
|
||||
return fetchWrapper<SendPromptResponse>(
|
||||
`${this.baseURL}/session/${sessionID}/message`,
|
||||
{
|
||||
method: 'POST',
|
||||
params: this.getParams(),
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data),
|
||||
timeout: 0,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async sendPromptAsync(sessionID: string, data: SendPromptAsyncRequest): Promise<void> {
|
||||
return fetchWrapperVoid(
|
||||
`${this.baseURL}/session/${sessionID}/prompt_async`,
|
||||
|
||||
Reference in new issue
Block a user