mirror of
https://github.com/openai/codex.git
synced 2026-11-22 23:00:42 +00:00
[codex] Add thread catalog subscriptions
This commit is contained in:
@@ -5268,6 +5268,29 @@
|
||||
"title": "Thread/listRequest",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"id": {
|
||||
"$ref": "#/definitions/RequestId"
|
||||
},
|
||||
"method": {
|
||||
"enum": [
|
||||
"threadCatalog/subscribe"
|
||||
],
|
||||
"title": "ThreadCatalog/subscribeRequestMethod",
|
||||
"type": "string"
|
||||
},
|
||||
"params": {
|
||||
"type": "null"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"method"
|
||||
],
|
||||
"title": "ThreadCatalog/subscribeRequest",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"id": {
|
||||
|
||||
@@ -3825,6 +3825,66 @@
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"ThreadCatalogChangedNotification": {
|
||||
"oneOf": [
|
||||
{
|
||||
"properties": {
|
||||
"thread": {
|
||||
"$ref": "#/definitions/ThreadSummary"
|
||||
},
|
||||
"type": {
|
||||
"enum": [
|
||||
"upsert"
|
||||
],
|
||||
"title": "UpsertThreadCatalogChangedNotificationType",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"thread",
|
||||
"type"
|
||||
],
|
||||
"title": "UpsertThreadCatalogChangedNotification",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"threadId": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"enum": [
|
||||
"delete"
|
||||
],
|
||||
"title": "DeleteThreadCatalogChangedNotificationType",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"threadId",
|
||||
"type"
|
||||
],
|
||||
"title": "DeleteThreadCatalogChangedNotification",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"type": {
|
||||
"enum": [
|
||||
"invalidate"
|
||||
],
|
||||
"title": "InvalidateThreadCatalogChangedNotificationType",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"type"
|
||||
],
|
||||
"title": "InvalidateThreadCatalogChangedNotification",
|
||||
"type": "object"
|
||||
}
|
||||
]
|
||||
},
|
||||
"ThreadClosedNotification": {
|
||||
"properties": {
|
||||
"threadId": {
|
||||
@@ -5090,6 +5150,125 @@
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"ThreadSummary": {
|
||||
"description": "Persisted metadata needed to render and order a thread catalog row.",
|
||||
"properties": {
|
||||
"agentNickname": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"agentRole": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"archivedAt": {
|
||||
"format": "int64",
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"createdAt": {
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
},
|
||||
"createdAtMs": {
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
},
|
||||
"cwd": {
|
||||
"$ref": "#/definitions/AbsolutePathBuf"
|
||||
},
|
||||
"forkedFromId": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"gitInfo": {
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/GitInfo"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"modelProvider": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"parentThreadId": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"preview": {
|
||||
"type": "string"
|
||||
},
|
||||
"recencyAt": {
|
||||
"format": "int64",
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"recencyAtMs": {
|
||||
"format": "int64",
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"source": {
|
||||
"$ref": "#/definitions/SessionSource"
|
||||
},
|
||||
"threadSource": {
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/ThreadSource"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"updatedAt": {
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
},
|
||||
"updatedAtMs": {
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"createdAt",
|
||||
"createdAtMs",
|
||||
"cwd",
|
||||
"id",
|
||||
"modelProvider",
|
||||
"preview",
|
||||
"source",
|
||||
"updatedAt",
|
||||
"updatedAtMs"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"ThreadTokenUsage": {
|
||||
"properties": {
|
||||
"last": {
|
||||
@@ -5860,6 +6039,26 @@
|
||||
"title": "Thread/unarchivedNotification",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"method": {
|
||||
"enum": [
|
||||
"threadCatalog/changed"
|
||||
],
|
||||
"title": "ThreadCatalog/changedNotificationMethod",
|
||||
"type": "string"
|
||||
},
|
||||
"params": {
|
||||
"$ref": "#/definitions/ThreadCatalogChangedNotification"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"method",
|
||||
"params"
|
||||
],
|
||||
"title": "ThreadCatalog/changedNotification",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"method": {
|
||||
|
||||
+229
@@ -636,6 +636,29 @@
|
||||
"title": "Thread/listRequest",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"id": {
|
||||
"$ref": "#/definitions/v2/RequestId"
|
||||
},
|
||||
"method": {
|
||||
"enum": [
|
||||
"threadCatalog/subscribe"
|
||||
],
|
||||
"title": "ThreadCatalog/subscribeRequestMethod",
|
||||
"type": "string"
|
||||
},
|
||||
"params": {
|
||||
"type": "null"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"method"
|
||||
],
|
||||
"title": "ThreadCatalog/subscribeRequest",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"id": {
|
||||
@@ -4228,6 +4251,26 @@
|
||||
"title": "Thread/unarchivedNotification",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"method": {
|
||||
"enum": [
|
||||
"threadCatalog/changed"
|
||||
],
|
||||
"title": "ThreadCatalog/changedNotificationMethod",
|
||||
"type": "string"
|
||||
},
|
||||
"params": {
|
||||
"$ref": "#/definitions/v2/ThreadCatalogChangedNotification"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"method",
|
||||
"params"
|
||||
],
|
||||
"title": "ThreadCatalog/changedNotification",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"method": {
|
||||
@@ -17317,6 +17360,73 @@
|
||||
"title": "ThreadArchivedNotification",
|
||||
"type": "object"
|
||||
},
|
||||
"ThreadCatalogChangedNotification": {
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"oneOf": [
|
||||
{
|
||||
"properties": {
|
||||
"thread": {
|
||||
"$ref": "#/definitions/v2/ThreadSummary"
|
||||
},
|
||||
"type": {
|
||||
"enum": [
|
||||
"upsert"
|
||||
],
|
||||
"title": "Upsertv2::ThreadCatalogChangedNotificationType",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"thread",
|
||||
"type"
|
||||
],
|
||||
"title": "Upsertv2::ThreadCatalogChangedNotification",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"threadId": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"enum": [
|
||||
"delete"
|
||||
],
|
||||
"title": "Deletev2::ThreadCatalogChangedNotificationType",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"threadId",
|
||||
"type"
|
||||
],
|
||||
"title": "Deletev2::ThreadCatalogChangedNotification",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"type": {
|
||||
"enum": [
|
||||
"invalidate"
|
||||
],
|
||||
"title": "Invalidatev2::ThreadCatalogChangedNotificationType",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"type"
|
||||
],
|
||||
"title": "Invalidatev2::ThreadCatalogChangedNotification",
|
||||
"type": "object"
|
||||
}
|
||||
],
|
||||
"title": "ThreadCatalogChangedNotification"
|
||||
},
|
||||
"ThreadCatalogSubscribeResponse": {
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "ThreadCatalogSubscribeResponse",
|
||||
"type": "object"
|
||||
},
|
||||
"ThreadClosedNotification": {
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"properties": {
|
||||
@@ -19816,6 +19926,125 @@
|
||||
"title": "ThreadStatusChangedNotification",
|
||||
"type": "object"
|
||||
},
|
||||
"ThreadSummary": {
|
||||
"description": "Persisted metadata needed to render and order a thread catalog row.",
|
||||
"properties": {
|
||||
"agentNickname": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"agentRole": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"archivedAt": {
|
||||
"format": "int64",
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"createdAt": {
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
},
|
||||
"createdAtMs": {
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
},
|
||||
"cwd": {
|
||||
"$ref": "#/definitions/v2/AbsolutePathBuf"
|
||||
},
|
||||
"forkedFromId": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"gitInfo": {
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/v2/GitInfo"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"modelProvider": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"parentThreadId": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"preview": {
|
||||
"type": "string"
|
||||
},
|
||||
"recencyAt": {
|
||||
"format": "int64",
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"recencyAtMs": {
|
||||
"format": "int64",
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"source": {
|
||||
"$ref": "#/definitions/v2/SessionSource"
|
||||
},
|
||||
"threadSource": {
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/v2/ThreadSource"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"updatedAt": {
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
},
|
||||
"updatedAtMs": {
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"createdAt",
|
||||
"createdAtMs",
|
||||
"cwd",
|
||||
"id",
|
||||
"modelProvider",
|
||||
"preview",
|
||||
"source",
|
||||
"updatedAt",
|
||||
"updatedAtMs"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"ThreadTokenUsage": {
|
||||
"properties": {
|
||||
"last": {
|
||||
|
||||
+229
@@ -1674,6 +1674,29 @@
|
||||
"title": "Thread/listRequest",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"id": {
|
||||
"$ref": "#/definitions/RequestId"
|
||||
},
|
||||
"method": {
|
||||
"enum": [
|
||||
"threadCatalog/subscribe"
|
||||
],
|
||||
"title": "ThreadCatalog/subscribeRequestMethod",
|
||||
"type": "string"
|
||||
},
|
||||
"params": {
|
||||
"type": "null"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"method"
|
||||
],
|
||||
"title": "ThreadCatalog/subscribeRequest",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"id": {
|
||||
@@ -12943,6 +12966,26 @@
|
||||
"title": "Thread/unarchivedNotification",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"method": {
|
||||
"enum": [
|
||||
"threadCatalog/changed"
|
||||
],
|
||||
"title": "ThreadCatalog/changedNotificationMethod",
|
||||
"type": "string"
|
||||
},
|
||||
"params": {
|
||||
"$ref": "#/definitions/ThreadCatalogChangedNotification"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"method",
|
||||
"params"
|
||||
],
|
||||
"title": "ThreadCatalog/changedNotification",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"method": {
|
||||
@@ -15096,6 +15139,73 @@
|
||||
"title": "ThreadArchivedNotification",
|
||||
"type": "object"
|
||||
},
|
||||
"ThreadCatalogChangedNotification": {
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"oneOf": [
|
||||
{
|
||||
"properties": {
|
||||
"thread": {
|
||||
"$ref": "#/definitions/ThreadSummary"
|
||||
},
|
||||
"type": {
|
||||
"enum": [
|
||||
"upsert"
|
||||
],
|
||||
"title": "Upsertv2::ThreadCatalogChangedNotificationType",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"thread",
|
||||
"type"
|
||||
],
|
||||
"title": "Upsertv2::ThreadCatalogChangedNotification",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"threadId": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"enum": [
|
||||
"delete"
|
||||
],
|
||||
"title": "Deletev2::ThreadCatalogChangedNotificationType",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"threadId",
|
||||
"type"
|
||||
],
|
||||
"title": "Deletev2::ThreadCatalogChangedNotification",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"type": {
|
||||
"enum": [
|
||||
"invalidate"
|
||||
],
|
||||
"title": "Invalidatev2::ThreadCatalogChangedNotificationType",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"type"
|
||||
],
|
||||
"title": "Invalidatev2::ThreadCatalogChangedNotification",
|
||||
"type": "object"
|
||||
}
|
||||
],
|
||||
"title": "ThreadCatalogChangedNotification"
|
||||
},
|
||||
"ThreadCatalogSubscribeResponse": {
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "ThreadCatalogSubscribeResponse",
|
||||
"type": "object"
|
||||
},
|
||||
"ThreadClosedNotification": {
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"properties": {
|
||||
@@ -17595,6 +17705,125 @@
|
||||
"title": "ThreadStatusChangedNotification",
|
||||
"type": "object"
|
||||
},
|
||||
"ThreadSummary": {
|
||||
"description": "Persisted metadata needed to render and order a thread catalog row.",
|
||||
"properties": {
|
||||
"agentNickname": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"agentRole": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"archivedAt": {
|
||||
"format": "int64",
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"createdAt": {
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
},
|
||||
"createdAtMs": {
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
},
|
||||
"cwd": {
|
||||
"$ref": "#/definitions/AbsolutePathBuf"
|
||||
},
|
||||
"forkedFromId": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"gitInfo": {
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/GitInfo"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"modelProvider": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"parentThreadId": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"preview": {
|
||||
"type": "string"
|
||||
},
|
||||
"recencyAt": {
|
||||
"format": "int64",
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"recencyAtMs": {
|
||||
"format": "int64",
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"source": {
|
||||
"$ref": "#/definitions/SessionSource"
|
||||
},
|
||||
"threadSource": {
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/ThreadSource"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"updatedAt": {
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
},
|
||||
"updatedAtMs": {
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"createdAt",
|
||||
"createdAtMs",
|
||||
"cwd",
|
||||
"id",
|
||||
"modelProvider",
|
||||
"preview",
|
||||
"source",
|
||||
"updatedAt",
|
||||
"updatedAtMs"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"ThreadTokenUsage": {
|
||||
"properties": {
|
||||
"last": {
|
||||
|
||||
+335
@@ -0,0 +1,335 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"definitions": {
|
||||
"AbsolutePathBuf": {
|
||||
"description": "A path that is guaranteed to be absolute and normalized (though it is not guaranteed to be canonicalized or exist on the filesystem).\n\nIMPORTANT: When deserializing an `AbsolutePathBuf`, a base path must be set using [AbsolutePathBufGuard::new]. If no base path is set, the deserialization will fail unless the path being deserialized is already absolute.",
|
||||
"type": "string"
|
||||
},
|
||||
"AgentPath": {
|
||||
"type": "string"
|
||||
},
|
||||
"GitInfo": {
|
||||
"properties": {
|
||||
"branch": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"originUrl": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"sha": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"SessionSource": {
|
||||
"oneOf": [
|
||||
{
|
||||
"enum": [
|
||||
"cli",
|
||||
"vscode",
|
||||
"exec",
|
||||
"appServer",
|
||||
"unknown"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"custom": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"custom"
|
||||
],
|
||||
"title": "CustomSessionSource",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"subAgent": {
|
||||
"$ref": "#/definitions/SubAgentSource"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"subAgent"
|
||||
],
|
||||
"title": "SubAgentSessionSource",
|
||||
"type": "object"
|
||||
}
|
||||
]
|
||||
},
|
||||
"SubAgentSource": {
|
||||
"oneOf": [
|
||||
{
|
||||
"enum": [
|
||||
"review",
|
||||
"compact",
|
||||
"memory_consolidation"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"thread_spawn": {
|
||||
"properties": {
|
||||
"agent_nickname": {
|
||||
"default": null,
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"agent_path": {
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/AgentPath"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"default": null
|
||||
},
|
||||
"agent_role": {
|
||||
"default": null,
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"depth": {
|
||||
"format": "int32",
|
||||
"type": "integer"
|
||||
},
|
||||
"parent_thread_id": {
|
||||
"$ref": "#/definitions/ThreadId"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"depth",
|
||||
"parent_thread_id"
|
||||
],
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"thread_spawn"
|
||||
],
|
||||
"title": "ThreadSpawnSubAgentSource",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"other": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"other"
|
||||
],
|
||||
"title": "OtherSubAgentSource",
|
||||
"type": "object"
|
||||
}
|
||||
]
|
||||
},
|
||||
"ThreadId": {
|
||||
"type": "string"
|
||||
},
|
||||
"ThreadSource": {
|
||||
"type": "string"
|
||||
},
|
||||
"ThreadSummary": {
|
||||
"description": "Persisted metadata needed to render and order a thread catalog row.",
|
||||
"properties": {
|
||||
"agentNickname": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"agentRole": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"archivedAt": {
|
||||
"format": "int64",
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"createdAt": {
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
},
|
||||
"createdAtMs": {
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
},
|
||||
"cwd": {
|
||||
"$ref": "#/definitions/AbsolutePathBuf"
|
||||
},
|
||||
"forkedFromId": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"gitInfo": {
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/GitInfo"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"modelProvider": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"parentThreadId": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"preview": {
|
||||
"type": "string"
|
||||
},
|
||||
"recencyAt": {
|
||||
"format": "int64",
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"recencyAtMs": {
|
||||
"format": "int64",
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"source": {
|
||||
"$ref": "#/definitions/SessionSource"
|
||||
},
|
||||
"threadSource": {
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/ThreadSource"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"updatedAt": {
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
},
|
||||
"updatedAtMs": {
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"createdAt",
|
||||
"createdAtMs",
|
||||
"cwd",
|
||||
"id",
|
||||
"modelProvider",
|
||||
"preview",
|
||||
"source",
|
||||
"updatedAt",
|
||||
"updatedAtMs"
|
||||
],
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"oneOf": [
|
||||
{
|
||||
"properties": {
|
||||
"thread": {
|
||||
"$ref": "#/definitions/ThreadSummary"
|
||||
},
|
||||
"type": {
|
||||
"enum": [
|
||||
"upsert"
|
||||
],
|
||||
"title": "Upsertv2::ThreadCatalogChangedNotificationType",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"thread",
|
||||
"type"
|
||||
],
|
||||
"title": "Upsertv2::ThreadCatalogChangedNotification",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"threadId": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"enum": [
|
||||
"delete"
|
||||
],
|
||||
"title": "Deletev2::ThreadCatalogChangedNotificationType",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"threadId",
|
||||
"type"
|
||||
],
|
||||
"title": "Deletev2::ThreadCatalogChangedNotification",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"type": {
|
||||
"enum": [
|
||||
"invalidate"
|
||||
],
|
||||
"title": "Invalidatev2::ThreadCatalogChangedNotificationType",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"type"
|
||||
],
|
||||
"title": "Invalidatev2::ThreadCatalogChangedNotification",
|
||||
"type": "object"
|
||||
}
|
||||
],
|
||||
"title": "ThreadCatalogChangedNotification"
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "ThreadCatalogSubscribeResponse",
|
||||
"type": "object"
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+6
@@ -0,0 +1,6 @@
|
||||
// GENERATED CODE! DO NOT MODIFY BY HAND!
|
||||
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { ThreadSummary } from "./ThreadSummary";
|
||||
|
||||
export type ThreadCatalogChangedNotification = { "type": "upsert", thread: ThreadSummary, } | { "type": "delete", threadId: string, } | { "type": "invalidate" };
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// GENERATED CODE! DO NOT MODIFY BY HAND!
|
||||
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export type ThreadCatalogSubscribeResponse = Record<string, never>;
|
||||
@@ -0,0 +1,12 @@
|
||||
// GENERATED CODE! DO NOT MODIFY BY HAND!
|
||||
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { AbsolutePathBuf } from "../AbsolutePathBuf";
|
||||
import type { GitInfo } from "./GitInfo";
|
||||
import type { SessionSource } from "./SessionSource";
|
||||
import type { ThreadSource } from "./ThreadSource";
|
||||
|
||||
/**
|
||||
* Persisted metadata needed to render and order a thread catalog row.
|
||||
*/
|
||||
export type ThreadSummary = { id: string, forkedFromId: string | null, parentThreadId: string | null, preview: string, modelProvider: string, createdAt: number, createdAtMs: number, updatedAt: number, updatedAtMs: number, recencyAt: number | null, recencyAtMs: number | null, archivedAt: number | null, cwd: AbsolutePathBuf, source: SessionSource, threadSource: ThreadSource | null, agentNickname: string | null, agentRole: string | null, gitInfo: GitInfo | null, name: string | null, };
|
||||
@@ -398,6 +398,8 @@ export type { ThreadApproveGuardianDeniedActionResponse } from "./ThreadApproveG
|
||||
export type { ThreadArchiveParams } from "./ThreadArchiveParams";
|
||||
export type { ThreadArchiveResponse } from "./ThreadArchiveResponse";
|
||||
export type { ThreadArchivedNotification } from "./ThreadArchivedNotification";
|
||||
export type { ThreadCatalogChangedNotification } from "./ThreadCatalogChangedNotification";
|
||||
export type { ThreadCatalogSubscribeResponse } from "./ThreadCatalogSubscribeResponse";
|
||||
export type { ThreadClosedNotification } from "./ThreadClosedNotification";
|
||||
export type { ThreadCompactStartParams } from "./ThreadCompactStartParams";
|
||||
export type { ThreadCompactStartResponse } from "./ThreadCompactStartResponse";
|
||||
@@ -462,6 +464,7 @@ export type { ThreadStartSource } from "./ThreadStartSource";
|
||||
export type { ThreadStartedNotification } from "./ThreadStartedNotification";
|
||||
export type { ThreadStatus } from "./ThreadStatus";
|
||||
export type { ThreadStatusChangedNotification } from "./ThreadStatusChangedNotification";
|
||||
export type { ThreadSummary } from "./ThreadSummary";
|
||||
export type { ThreadTokenUsage } from "./ThreadTokenUsage";
|
||||
export type { ThreadTokenUsageUpdatedNotification } from "./ThreadTokenUsageUpdatedNotification";
|
||||
export type { ThreadUnarchiveParams } from "./ThreadUnarchiveParams";
|
||||
|
||||
@@ -624,6 +624,11 @@ client_request_definitions! {
|
||||
serialization: None,
|
||||
response: v2::ThreadListResponse,
|
||||
},
|
||||
ThreadCatalogSubscribe => "threadCatalog/subscribe" {
|
||||
params: #[ts(type = "undefined")] #[serde(skip_serializing_if = "Option::is_none")] Option<()>,
|
||||
serialization: None,
|
||||
response: v2::ThreadCatalogSubscribeResponse,
|
||||
},
|
||||
#[experimental("thread/search")]
|
||||
ThreadSearch => "thread/search" {
|
||||
params: v2::ThreadSearchParams,
|
||||
@@ -1618,6 +1623,7 @@ server_notification_definitions! {
|
||||
ThreadArchived => "thread/archived" (v2::ThreadArchivedNotification),
|
||||
ThreadDeleted => "thread/deleted" (v2::ThreadDeletedNotification),
|
||||
ThreadUnarchived => "thread/unarchived" (v2::ThreadUnarchivedNotification),
|
||||
ThreadCatalogChanged => "threadCatalog/changed" (v2::ThreadCatalogChangedNotification),
|
||||
ThreadClosed => "thread/closed" (v2::ThreadClosedNotification),
|
||||
SkillsChanged => "skills/changed" (v2::SkillsChangedNotification),
|
||||
ThreadNameUpdated => "thread/name/updated" (v2::ThreadNameUpdatedNotification),
|
||||
|
||||
@@ -7,6 +7,7 @@ use super::Thread;
|
||||
use super::ThreadHistoryMode;
|
||||
use super::ThreadItem;
|
||||
use super::ThreadSource;
|
||||
use super::ThreadSummary;
|
||||
use super::Turn;
|
||||
use super::TurnEnvironmentParams;
|
||||
use super::TurnItemsView;
|
||||
@@ -1200,6 +1201,11 @@ pub struct ThreadListResponse {
|
||||
pub backwards_cursor: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadCatalogSubscribeResponse {}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
@@ -1461,6 +1467,22 @@ pub struct ThreadUnarchivedNotification {
|
||||
pub thread_id: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
#[ts(tag = "type", rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub enum ThreadCatalogChangedNotification {
|
||||
Upsert {
|
||||
thread: Box<ThreadSummary>,
|
||||
},
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(rename_all = "camelCase")]
|
||||
Delete {
|
||||
thread_id: String,
|
||||
},
|
||||
Invalidate,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
|
||||
@@ -225,6 +225,39 @@ pub struct Thread {
|
||||
pub turns: Vec<Turn>,
|
||||
}
|
||||
|
||||
/// Persisted metadata needed to render and order a thread catalog row.
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadSummary {
|
||||
pub id: String,
|
||||
pub forked_from_id: Option<String>,
|
||||
pub parent_thread_id: Option<String>,
|
||||
pub preview: String,
|
||||
pub model_provider: String,
|
||||
#[ts(type = "number")]
|
||||
pub created_at: i64,
|
||||
#[ts(type = "number")]
|
||||
pub created_at_ms: i64,
|
||||
#[ts(type = "number")]
|
||||
pub updated_at: i64,
|
||||
#[ts(type = "number")]
|
||||
pub updated_at_ms: i64,
|
||||
#[ts(type = "number | null")]
|
||||
pub recency_at: Option<i64>,
|
||||
#[ts(type = "number | null")]
|
||||
pub recency_at_ms: Option<i64>,
|
||||
#[ts(type = "number | null")]
|
||||
pub archived_at: Option<i64>,
|
||||
pub cwd: AbsolutePathBuf,
|
||||
pub source: SessionSource,
|
||||
pub thread_source: Option<ThreadSource>,
|
||||
pub agent_nickname: Option<String>,
|
||||
pub agent_role: Option<String>,
|
||||
pub git_info: Option<GitInfo>,
|
||||
pub name: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
|
||||
@@ -404,6 +404,17 @@ Example:
|
||||
|
||||
When `nextCursor` is `null`, you’ve reached the final page.
|
||||
|
||||
To keep a paginated catalog current, call `threadCatalog/subscribe` before the initial
|
||||
`thread/list`. The response only acknowledges future notifications; it does not replay existing
|
||||
threads. Registration completes before the response is sent, so clients should buffer catalog
|
||||
notifications until their list request completes and apply `threadCatalog/changed` summaries
|
||||
idempotently. Its `upsert` variant contains the complete row, `delete` removes a row, and
|
||||
`invalidate` means the client fell behind and must refetch its catalog view. Reconnects require
|
||||
another subscribe and list sequence.
|
||||
|
||||
`threadCatalog/changed` contains persisted sidebar metadata only. It never contains turns, items,
|
||||
messages, deltas, tool state, or loaded runtime status.
|
||||
|
||||
### Example: List descendant threads
|
||||
|
||||
Enable `capabilities.experimentalApi` during initialization, then use `thread/list` with `ancestorThreadId` to page through every spawned descendant of a thread from persisted spawn-edge state. The ancestor itself is excluded, and each result's `parentThreadId` remains its immediate parent. Use `parentThreadId` instead when only direct children are wanted; sending both filters is invalid. Review and Guardian threads are not included because they do not participate in the spawn-edge lifecycle. When `modelProviders` or `sourceKinds` is omitted, relationship-filtered requests include every provider or source kind, respectively. Explicit filters retain the ordinary `thread/list` behavior, including the interactive-only default for an empty `sourceKinds` list.
|
||||
|
||||
@@ -107,6 +107,7 @@ fn server_notification_requires_delivery(notification: &ServerNotification) -> b
|
||||
notification,
|
||||
ServerNotification::TurnCompleted(_)
|
||||
| ServerNotification::ThreadSettingsUpdated(_)
|
||||
| ServerNotification::ThreadCatalogChanged(_)
|
||||
| ServerNotification::ExternalAgentConfigImportCompleted(_)
|
||||
)
|
||||
}
|
||||
@@ -743,6 +744,7 @@ mod tests {
|
||||
use codex_app_server_protocol::ConfigRequirementsReadResponse;
|
||||
use codex_app_server_protocol::ExternalAgentConfigImportCompletedNotification;
|
||||
use codex_app_server_protocol::SessionSource as ApiSessionSource;
|
||||
use codex_app_server_protocol::ThreadCatalogChangedNotification;
|
||||
use codex_app_server_protocol::ThreadStartParams;
|
||||
use codex_app_server_protocol::ThreadStartResponse;
|
||||
use codex_app_server_protocol::Turn;
|
||||
@@ -914,5 +916,8 @@ mod tests {
|
||||
},
|
||||
)
|
||||
));
|
||||
assert!(server_notification_requires_delivery(
|
||||
&ServerNotification::ThreadCatalogChanged(ThreadCatalogChangedNotification::Invalidate,)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,6 +111,7 @@ mod request_processors;
|
||||
mod request_serialization;
|
||||
mod server_request_error;
|
||||
mod skills_watcher;
|
||||
mod thread_catalog;
|
||||
mod thread_state;
|
||||
mod thread_status;
|
||||
mod transport;
|
||||
|
||||
@@ -44,6 +44,7 @@ use crate::request_serialization::QueuedInitializedRequest;
|
||||
use crate::request_serialization::RequestSerializationQueueKey;
|
||||
use crate::request_serialization::RequestSerializationQueues;
|
||||
use crate::skills_watcher::SkillsWatcher;
|
||||
use crate::thread_catalog::ThreadCatalogSubscriptions;
|
||||
use crate::thread_state::ConnectionCapabilities;
|
||||
use crate::thread_state::ThreadStateManager;
|
||||
use crate::transport::AppServerTransport;
|
||||
@@ -60,6 +61,7 @@ use codex_app_server_protocol::JSONRPCErrorError;
|
||||
use codex_app_server_protocol::JSONRPCNotification;
|
||||
use codex_app_server_protocol::JSONRPCRequest;
|
||||
use codex_app_server_protocol::JSONRPCResponse;
|
||||
use codex_app_server_protocol::ThreadCatalogSubscribeResponse;
|
||||
use codex_app_server_protocol::experimental_required_message;
|
||||
use codex_arg0::Arg0DispatchPaths;
|
||||
use codex_chatgpt::workspace_settings;
|
||||
@@ -121,6 +123,7 @@ pub(crate) struct MessageProcessor {
|
||||
remote_control_processor: RemoteControlRequestProcessor,
|
||||
search_processor: SearchRequestProcessor,
|
||||
thread_goal_processor: ThreadGoalRequestProcessor,
|
||||
thread_catalog_subscriptions: ThreadCatalogSubscriptions,
|
||||
thread_processor: ThreadRequestProcessor,
|
||||
turn_processor: TurnRequestProcessor,
|
||||
windows_sandbox_processor: WindowsSandboxRequestProcessor,
|
||||
@@ -248,6 +251,12 @@ impl MessageProcessor {
|
||||
// affect per-thread behavior, but they must not move newly started,
|
||||
// resumed, or forked threads to a different persistence backend/root.
|
||||
let thread_store = codex_core::thread_store_from_config(config.as_ref(), state_db.clone());
|
||||
let thread_catalog_subscriptions = ThreadCatalogSubscriptions::new(
|
||||
outgoing.clone(),
|
||||
Arc::clone(&thread_store),
|
||||
config.model_provider_id.clone(),
|
||||
config.cwd.clone(),
|
||||
);
|
||||
let environment_manager_for_requests = Arc::clone(&environment_manager);
|
||||
let environment_manager_for_extensions = Arc::clone(&environment_manager);
|
||||
let restriction_product = session_source.restriction_product();
|
||||
@@ -488,6 +497,7 @@ impl MessageProcessor {
|
||||
remote_control_processor,
|
||||
search_processor,
|
||||
thread_goal_processor,
|
||||
thread_catalog_subscriptions,
|
||||
thread_processor,
|
||||
turn_processor,
|
||||
windows_sandbox_processor,
|
||||
@@ -718,6 +728,9 @@ impl MessageProcessor {
|
||||
.connection_closed(connection_id)
|
||||
.await;
|
||||
self.thread_processor.connection_closed(connection_id).await;
|
||||
self.thread_catalog_subscriptions
|
||||
.connection_closed(connection_id)
|
||||
.await;
|
||||
}
|
||||
|
||||
pub(crate) fn subscribe_running_assistant_turn_count(&self) -> watch::Receiver<usize> {
|
||||
@@ -1128,6 +1141,12 @@ impl MessageProcessor {
|
||||
ClientRequest::ThreadList { params, .. } => {
|
||||
self.thread_processor.thread_list(params).await
|
||||
}
|
||||
ClientRequest::ThreadCatalogSubscribe { .. } => {
|
||||
self.thread_catalog_subscriptions
|
||||
.subscribe(connection_id)
|
||||
.await;
|
||||
Ok(Some(ThreadCatalogSubscribeResponse {}.into()))
|
||||
}
|
||||
ClientRequest::ThreadSearch { params, .. } => {
|
||||
self.thread_processor.thread_search(params).await
|
||||
}
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
use std::collections::HashSet;
|
||||
use std::sync::Arc;
|
||||
use std::sync::Weak;
|
||||
|
||||
use codex_app_server_protocol::ServerNotification;
|
||||
use codex_app_server_protocol::ThreadCatalogChangedNotification;
|
||||
use codex_app_server_protocol::ThreadSummary;
|
||||
use codex_thread_store::ReadThreadParams;
|
||||
use codex_thread_store::ThreadCatalogChange;
|
||||
use codex_thread_store::ThreadStore;
|
||||
use codex_utils_absolute_path::AbsolutePathBuf;
|
||||
use tokio::sync::Mutex;
|
||||
use tokio::sync::broadcast::error::RecvError;
|
||||
use tracing::warn;
|
||||
|
||||
use crate::outgoing_message::ConnectionId;
|
||||
use crate::outgoing_message::OutgoingMessageSender;
|
||||
use crate::request_processors::thread_from_stored_thread;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub(crate) struct ThreadCatalogSubscriptions {
|
||||
connection_ids: Arc<Mutex<HashSet<ConnectionId>>>,
|
||||
}
|
||||
|
||||
impl ThreadCatalogSubscriptions {
|
||||
pub(crate) fn new(
|
||||
outgoing: Arc<OutgoingMessageSender>,
|
||||
thread_store: Arc<dyn ThreadStore>,
|
||||
fallback_provider: String,
|
||||
fallback_cwd: AbsolutePathBuf,
|
||||
) -> Self {
|
||||
let connection_ids = Arc::new(Mutex::new(HashSet::new()));
|
||||
let changes = thread_store.subscribe_catalog_changes();
|
||||
tokio::spawn(run_catalog_listener(
|
||||
changes,
|
||||
Arc::downgrade(&thread_store),
|
||||
Arc::clone(&outgoing),
|
||||
Arc::clone(&connection_ids),
|
||||
fallback_provider,
|
||||
fallback_cwd,
|
||||
));
|
||||
Self { connection_ids }
|
||||
}
|
||||
|
||||
pub(crate) async fn subscribe(&self, connection_id: ConnectionId) {
|
||||
self.connection_ids.lock().await.insert(connection_id);
|
||||
}
|
||||
|
||||
pub(crate) async fn connection_closed(&self, connection_id: ConnectionId) {
|
||||
self.connection_ids.lock().await.remove(&connection_id);
|
||||
}
|
||||
}
|
||||
|
||||
async fn run_catalog_listener(
|
||||
mut changes: tokio::sync::broadcast::Receiver<ThreadCatalogChange>,
|
||||
thread_store: Weak<dyn ThreadStore>,
|
||||
outgoing: Arc<OutgoingMessageSender>,
|
||||
connection_ids: Arc<Mutex<HashSet<ConnectionId>>>,
|
||||
fallback_provider: String,
|
||||
fallback_cwd: AbsolutePathBuf,
|
||||
) {
|
||||
loop {
|
||||
let change = match changes.recv().await {
|
||||
Ok(change) => Some(change),
|
||||
Err(RecvError::Lagged(skipped)) => {
|
||||
warn!("thread catalog listener lagged by {skipped} changes");
|
||||
None
|
||||
}
|
||||
Err(RecvError::Closed) => break,
|
||||
};
|
||||
let connection_ids = connection_ids
|
||||
.lock()
|
||||
.await
|
||||
.iter()
|
||||
.copied()
|
||||
.collect::<Vec<_>>();
|
||||
if connection_ids.is_empty() {
|
||||
continue;
|
||||
}
|
||||
|
||||
let notification = match change {
|
||||
Some(ThreadCatalogChange::Upsert { thread_id }) => {
|
||||
let Some(thread_store) = thread_store.upgrade() else {
|
||||
break;
|
||||
};
|
||||
match thread_store
|
||||
.read_thread(ReadThreadParams {
|
||||
thread_id,
|
||||
include_archived: true,
|
||||
include_history: false,
|
||||
})
|
||||
.await
|
||||
{
|
||||
Ok(thread) => ServerNotification::ThreadCatalogChanged(
|
||||
ThreadCatalogChangedNotification::Upsert {
|
||||
thread: Box::new(thread_summary_from_stored_thread(
|
||||
thread,
|
||||
&fallback_provider,
|
||||
&fallback_cwd,
|
||||
)),
|
||||
},
|
||||
),
|
||||
Err(err) => {
|
||||
warn!("failed to read thread {thread_id} after catalog change: {err}");
|
||||
ServerNotification::ThreadCatalogChanged(
|
||||
ThreadCatalogChangedNotification::Invalidate,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Some(ThreadCatalogChange::Delete { thread_id }) => {
|
||||
ServerNotification::ThreadCatalogChanged(ThreadCatalogChangedNotification::Delete {
|
||||
thread_id: thread_id.to_string(),
|
||||
})
|
||||
}
|
||||
None => ServerNotification::ThreadCatalogChanged(
|
||||
ThreadCatalogChangedNotification::Invalidate,
|
||||
),
|
||||
};
|
||||
outgoing
|
||||
.send_server_notification_to_connections(&connection_ids, notification)
|
||||
.await;
|
||||
}
|
||||
}
|
||||
|
||||
fn thread_summary_from_stored_thread(
|
||||
thread: codex_thread_store::StoredThread,
|
||||
fallback_provider: &str,
|
||||
fallback_cwd: &AbsolutePathBuf,
|
||||
) -> ThreadSummary {
|
||||
let created_at_ms = thread.created_at.timestamp_millis();
|
||||
let updated_at_ms = thread.updated_at.timestamp_millis();
|
||||
let recency_at_ms = thread.recency_at.timestamp_millis();
|
||||
let archived_at = thread.archived_at.as_ref().map(chrono::DateTime::timestamp);
|
||||
let (thread, _) = thread_from_stored_thread(thread, fallback_provider, fallback_cwd);
|
||||
ThreadSummary {
|
||||
id: thread.id,
|
||||
forked_from_id: thread.forked_from_id,
|
||||
parent_thread_id: thread.parent_thread_id,
|
||||
preview: thread.preview,
|
||||
model_provider: thread.model_provider,
|
||||
created_at: thread.created_at,
|
||||
created_at_ms,
|
||||
updated_at: thread.updated_at,
|
||||
updated_at_ms,
|
||||
recency_at: thread.recency_at,
|
||||
recency_at_ms: Some(recency_at_ms),
|
||||
archived_at,
|
||||
cwd: thread.cwd,
|
||||
source: thread.source,
|
||||
thread_source: thread.thread_source,
|
||||
agent_nickname: thread.agent_nickname,
|
||||
agent_role: thread.agent_role,
|
||||
git_info: thread.git_info,
|
||||
name: thread.name,
|
||||
}
|
||||
}
|
||||
@@ -64,6 +64,7 @@ mod selected_environment;
|
||||
mod skills_list;
|
||||
mod sleep;
|
||||
mod thread_archive;
|
||||
mod thread_catalog_subscription;
|
||||
mod thread_delete;
|
||||
mod thread_fork;
|
||||
mod thread_inject_items;
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
use anyhow::Result;
|
||||
use app_test_support::TestAppServer;
|
||||
use app_test_support::create_fake_rollout;
|
||||
use app_test_support::to_response;
|
||||
use app_test_support::write_mock_responses_config_toml;
|
||||
use codex_app_server_protocol::JSONRPCNotification;
|
||||
use codex_app_server_protocol::JSONRPCResponse;
|
||||
use codex_app_server_protocol::RequestId;
|
||||
use codex_app_server_protocol::ThreadCatalogChangedNotification;
|
||||
use codex_app_server_protocol::ThreadCatalogSubscribeResponse;
|
||||
use codex_app_server_protocol::ThreadDeleteParams;
|
||||
use codex_app_server_protocol::ThreadDeleteResponse;
|
||||
use codex_app_server_protocol::ThreadSetNameParams;
|
||||
use codex_app_server_protocol::ThreadSetNameResponse;
|
||||
use pretty_assertions::assert_eq;
|
||||
use serde::de::DeserializeOwned;
|
||||
use tempfile::TempDir;
|
||||
use tokio::time::Duration;
|
||||
use tokio::time::timeout;
|
||||
|
||||
const READ_TIMEOUT: Duration = Duration::from_secs(10);
|
||||
|
||||
#[tokio::test]
|
||||
async fn catalog_subscription_tracks_threads_the_client_never_listed() -> Result<()> {
|
||||
let codex_home = TempDir::new()?;
|
||||
let thread_id = create_fake_rollout(
|
||||
codex_home.path(),
|
||||
"2025-01-05T12-00-00",
|
||||
"2025-01-05T12:00:00Z",
|
||||
"Unlisted thread",
|
||||
Some("mock_provider"),
|
||||
/*git_info*/ None,
|
||||
)?;
|
||||
let mut app = start_app(&codex_home).await?;
|
||||
|
||||
let subscribe_id = app
|
||||
.send_raw_request("threadCatalog/subscribe", /*params*/ None)
|
||||
.await?;
|
||||
let _: ThreadCatalogSubscribeResponse = read_response(&mut app, subscribe_id).await?;
|
||||
|
||||
let rename_id = app
|
||||
.send_thread_set_name_request(ThreadSetNameParams {
|
||||
thread_id: thread_id.clone(),
|
||||
name: "Renamed without listing".to_string(),
|
||||
})
|
||||
.await?;
|
||||
let _: ThreadSetNameResponse = read_response(&mut app, rename_id).await?;
|
||||
let changed_raw: JSONRPCNotification = timeout(
|
||||
READ_TIMEOUT,
|
||||
app.read_stream_until_notification_message("threadCatalog/changed"),
|
||||
)
|
||||
.await??;
|
||||
let changed_params = changed_raw.params.expect("catalog change params");
|
||||
assert_eq!(changed_params["thread"].get("turns"), None);
|
||||
assert_eq!(changed_params["thread"].get("status"), None);
|
||||
let ThreadCatalogChangedNotification::Upsert { thread } =
|
||||
serde_json::from_value(changed_params)?
|
||||
else {
|
||||
panic!("expected catalog upsert");
|
||||
};
|
||||
assert_eq!(thread.id, thread_id);
|
||||
assert_eq!(thread.name.as_deref(), Some("Renamed without listing"));
|
||||
assert_eq!(
|
||||
thread.recency_at_ms.map(|value| value / 1_000),
|
||||
thread.recency_at
|
||||
);
|
||||
|
||||
let delete_id = app
|
||||
.send_thread_delete_request(ThreadDeleteParams {
|
||||
thread_id: thread_id.clone(),
|
||||
})
|
||||
.await?;
|
||||
let _: ThreadDeleteResponse = read_response(&mut app, delete_id).await?;
|
||||
let deleted_raw: JSONRPCNotification = timeout(
|
||||
READ_TIMEOUT,
|
||||
app.read_stream_until_notification_message("threadCatalog/changed"),
|
||||
)
|
||||
.await??;
|
||||
let deleted: ThreadCatalogChangedNotification =
|
||||
serde_json::from_value(deleted_raw.params.expect("catalog deletion params"))?;
|
||||
assert_eq!(
|
||||
deleted,
|
||||
ThreadCatalogChangedNotification::Delete { thread_id }
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn start_app(codex_home: &TempDir) -> Result<TestAppServer> {
|
||||
write_mock_responses_config_toml(
|
||||
codex_home.path(),
|
||||
"http://localhost:1",
|
||||
&Default::default(),
|
||||
i64::MAX,
|
||||
/*requires_openai_auth*/ None,
|
||||
"mock_provider",
|
||||
"",
|
||||
)?;
|
||||
let mut app = TestAppServer::new_with_auto_env(codex_home.path()).await?;
|
||||
timeout(READ_TIMEOUT, app.initialize()).await??;
|
||||
Ok(app)
|
||||
}
|
||||
|
||||
async fn read_response<T: DeserializeOwned>(app: &mut TestAppServer, id: i64) -> Result<T> {
|
||||
let response: JSONRPCResponse = timeout(
|
||||
READ_TIMEOUT,
|
||||
app.read_stream_until_response_message(RequestId::Integer(id)),
|
||||
)
|
||||
.await??;
|
||||
to_response(response)
|
||||
}
|
||||
Reference in New Issue
Block a user