[draft] Add early proposal for sort order for thread/list

To improve performance on connection/reconnection to a remote appserver, we want to allow for delta syncs of the thread list, so that you only get what updated since you last connected (in short reconnections, expected to be zero items).  This requires adding an ascending sort option to the thread search (both the sqlite DB query and the filesystem-based query), and then adding a slightly different sortkey for the ascending sort to efficiently support these delta syncs.

Note: This was codexed up, though iterated on a few times to make the implementation as clean as made sense to my untrained eye (not used to this codebase).  There's still models at a few layers for the sortdirection that feel ugly but seems consistent with other search parameters so may be fine.  The biggest ugliness is in the non-sqlite filesystem-backed query mode, where the ascending sort is pretty gross, but I don't think there's a better answer there, and it seems like that path is an edge case.
This commit is contained in:
David de Regt
2026-04-09 02:49:22 -04:00
parent 39cc85310f
commit ca7a98c5ea
26 changed files with 451 additions and 47 deletions

View File

@@ -13543,6 +13543,17 @@
"null"
]
},
"sortDirection": {
"anyOf": [
{
"$ref": "#/definitions/v2/ThreadSortDirection"
},
{
"type": "null"
}
],
"description": "Optional sort direction; defaults to descending (newest first)."
},
"sortKey": {
"anyOf": [
{
@@ -14222,6 +14233,13 @@
"title": "ThreadShellCommandResponse",
"type": "object"
},
"ThreadSortDirection": {
"enum": [
"asc",
"desc"
],
"type": "string"
},
"ThreadSortKey": {
"enum": [
"created_at",