Skip to content

Commit 6ec4e4e

Browse files
committed
feat: enhance thread parent ID resolution in thread actions
1 parent 65e5c16 commit 6ec4e4e

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

src-tauri/src/shared/codex_core.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,14 +424,24 @@ pub(crate) async fn list_threads_core(
424424
.get("directory")
425425
.and_then(|v| v.as_str())
426426
.unwrap_or_default();
427-
Some(json!({
427+
let parent_id = s
428+
.get("parentID")
429+
.or_else(|| s.get("parentId"))
430+
.or_else(|| s.get("parent_id"))
431+
.and_then(|v| v.as_str())
432+
.filter(|s| !s.is_empty());
433+
let mut entry = json!({
428434
"id": id,
429435
"cwd": directory,
430436
"name": title,
431437
"preview": title,
432438
"updatedAt": updated_at,
433439
"createdAt": updated_at
434-
}))
440+
});
441+
if let Some(pid) = parent_id {
442+
entry["parentId"] = json!(pid);
443+
}
444+
Some(entry)
435445
})
436446
.collect();
437447
Ok(json!({

src/features/threads/hooks/useThreadActions.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,10 @@ export function useThreadActions({
476476
return;
477477
}
478478
const sourceParentId = getParentThreadIdFromSource(thread.source);
479-
if (sourceParentId) {
480-
updateThreadParent(sourceParentId, [threadId]);
479+
const directParentId = asString(thread.parentId ?? thread.parent_id ?? "").trim() || null;
480+
const resolvedParentId = sourceParentId ?? directParentId;
481+
if (resolvedParentId) {
482+
updateThreadParent(resolvedParentId, [threadId]);
481483
}
482484
const timestamp = getThreadTimestamp(thread);
483485
if (timestamp > (nextActivityByThread[threadId] ?? 0)) {
@@ -662,8 +664,10 @@ export function useThreadActions({
662664
return;
663665
}
664666
const sourceParentId = getParentThreadIdFromSource(thread.source);
665-
if (sourceParentId) {
666-
updateThreadParent(sourceParentId, [id]);
667+
const directParentId = asString(thread.parentId ?? thread.parent_id ?? "").trim() || null;
668+
const resolvedParentId = sourceParentId ?? directParentId;
669+
if (resolvedParentId) {
670+
updateThreadParent(resolvedParentId, [id]);
667671
}
668672
const preview = asString(thread?.preview ?? "").trim();
669673
const explicitName = asString(thread?.name ?? thread?.title ?? "").trim();

0 commit comments

Comments
 (0)