fix(core,tui): resolve stuck compacting status with terminal compaction events

This commit is contained in:
Kit Langton 2026-07-02 08:48:25 -04:00
commit 4f4cb8cb36
10 changed files with 297 additions and 6 deletions

View file

@ -399,6 +399,8 @@ import type {
V2SessionSwitchAgentResponses,
V2SessionSwitchModelErrors,
V2SessionSwitchModelResponses,
V2SessionSyntheticErrors,
V2SessionSyntheticResponses,
V2SessionWaitErrors,
V2SessionWaitResponses,
V2ShellCreateErrors,
@ -5816,6 +5818,47 @@ export class Session3 extends HeyApiClient {
})
}
/**
* Add synthetic message
*
* Append a synthetic message to a session and resume execution.
*/
public synthetic<ThrowOnError extends boolean = false>(
parameters: {
sessionID: string
text?: string
description?: string
metadata?: {
[key: string]: unknown
}
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams(
[parameters],
[
{
args: [
{ in: "path", key: "sessionID" },
{ in: "body", key: "text" },
{ in: "body", key: "description" },
{ in: "body", key: "metadata" },
],
},
],
)
return (options?.client ?? this.client).post<V2SessionSyntheticResponses, V2SessionSyntheticErrors, ThrowOnError>({
url: "/api/session/{sessionID}/synthetic",
...options,
...params,
headers: {
"Content-Type": "application/json",
...options?.headers,
...params.headers,
},
})
}
/**
* Compact session
*

View file

@ -49,6 +49,7 @@ export type Event =
| EventSessionNextCompactionStarted
| EventSessionNextCompactionDelta
| EventSessionNextCompactionEnded
| EventSessionNextCompactionFailed
| EventSessionNextRevertStaged
| EventSessionNextRevertCleared
| EventSessionNextRevertCommitted
@ -942,6 +943,9 @@ export type GlobalEvent = {
messageID: string
text: string
description?: string
metadata?: {
[key: string]: unknown
}
}
}
| {
@ -1229,6 +1233,16 @@ export type GlobalEvent = {
recent: string
}
}
| {
id: string
type: "session.next.compaction.failed"
properties: {
timestamp: number
sessionID: string
messageID: string
reason: "auto" | "manual"
}
}
| {
id: string
type: "session.next.revert.staged"
@ -3032,6 +3046,7 @@ export type V2Event =
| SessionNextCompactionStarted
| SessionNextCompactionDelta
| SessionNextCompactionEnded
| SessionNextCompactionFailed
| SessionNextRevertStaged
| SessionNextRevertCleared
| SessionNextRevertCommitted
@ -3618,6 +3633,9 @@ export type SyncEventSessionNextSynthetic = {
messageID: string
text: string
description?: string
metadata?: {
[key: string]: unknown
}
}
}
}
@ -4583,6 +4601,9 @@ export type SessionNextSynthetic = {
messageID: string
text: string
description?: string
metadata?: {
[key: string]: unknown
}
}
}
@ -5664,6 +5685,26 @@ export type SessionNextCompactionDelta = {
}
}
export type SessionNextCompactionFailed = {
id: string
metadata?: {
[key: string]: unknown
}
type: "session.next.compaction.failed"
durable?: {
aggregateID: string
seq: number
version: number
}
location?: LocationRef
data: {
timestamp: number
sessionID: string
messageID: string
reason: "auto" | "manual"
}
}
export type MessagePartDelta = {
id: string
metadata?: {
@ -6806,6 +6847,9 @@ export type EventSessionNextSynthetic = {
messageID: string
text: string
description?: string
metadata?: {
[key: string]: unknown
}
}
}
@ -7117,6 +7161,17 @@ export type EventSessionNextCompactionEnded = {
}
}
export type EventSessionNextCompactionFailed = {
id: string
type: "session.next.compaction.failed"
properties: {
timestamp: number
sessionID: string
messageID: string
reason: "auto" | "manual"
}
}
export type EventSessionNextRevertStaged = {
id: string
type: "session.next.revert.staged"
@ -12284,6 +12339,47 @@ export type V2SessionSkillResponses = {
export type V2SessionSkillResponse = V2SessionSkillResponses[keyof V2SessionSkillResponses]
export type V2SessionSyntheticData = {
body: {
text: string
description?: string
metadata?: {
[key: string]: unknown
}
}
path: {
sessionID: string
}
query?: never
url: "/api/session/{sessionID}/synthetic"
}
export type V2SessionSyntheticErrors = {
/**
* InvalidRequestError
*/
400: InvalidRequestError
/**
* UnauthorizedError
*/
401: UnauthorizedError
/**
* SessionNotFoundError
*/
404: SessionNotFoundError
}
export type V2SessionSyntheticError = V2SessionSyntheticErrors[keyof V2SessionSyntheticErrors]
export type V2SessionSyntheticResponses = {
/**
* <No Content>
*/
204: void
}
export type V2SessionSyntheticResponse = V2SessionSyntheticResponses[keyof V2SessionSyntheticResponses]
export type V2SessionCompactData = {
body?: never
path: {