@cocorograph/hub-agent 0.8.115 → 0.8.116
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/main.mjs +24 -7
package/package.json
CHANGED
package/src/main.mjs
CHANGED
|
@@ -1574,14 +1574,31 @@ export function withSortAffectingAt(snapshot, getSortAt = getSortAffectingAt) {
|
|
|
1574
1574
|
const live = Array.isArray(snapshot?.live) ? snapshot.live : []
|
|
1575
1575
|
return {
|
|
1576
1576
|
...snapshot,
|
|
1577
|
-
live: live.map((item) =>
|
|
1578
|
-
const name = typeof item?.session_name === "string" ? item.session_name : ""
|
|
1579
|
-
const at = name ? getSortAt(name) : undefined
|
|
1580
|
-
return typeof at === "number" && at > 0 ? { ...item, sort_affecting_at: at } : item
|
|
1581
|
-
}),
|
|
1577
|
+
live: live.map((item) => attachSortAffectingAt(item, getSortAt)),
|
|
1582
1578
|
}
|
|
1583
1579
|
}
|
|
1584
1580
|
|
|
1581
|
+
/** 1 行 (`session_name` を持つ) に送信時刻を載せる。chat.sessions と sidebar_snapshot で共有する。 */
|
|
1582
|
+
function attachSortAffectingAt(item, getSortAt) {
|
|
1583
|
+
const name = typeof item?.session_name === "string" ? item.session_name : ""
|
|
1584
|
+
const at = name ? getSortAt(name) : undefined
|
|
1585
|
+
return typeof at === "number" && at > 0 ? { ...item, sort_affecting_at: at } : item
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1588
|
+
/**
|
|
1589
|
+
* `chat.sidebar_snapshot.response` の各行に、その行の「最後にユーザーが送信した時刻」
|
|
1590
|
+
* (`sort_affecting_at`) を載せる。
|
|
1591
|
+
*
|
|
1592
|
+
* `chat.sessions` は live な会話にしか送信時刻を載せない。サイドバーは、ユーザーが×で閉じて
|
|
1593
|
+
* いないのにプロセスが落ちて一覧から消えた会話も「起きている」段に残して送信時刻順に並べる
|
|
1594
|
+
* ため、再読み込み後はここでしか送信時刻を復元できない (2026-10-24)。
|
|
1595
|
+
* 値は withSortAffectingAt と同じ (sidecar で永続化済みのもの)。送信履歴の無い行は
|
|
1596
|
+
* キーごと付けない。
|
|
1597
|
+
*/
|
|
1598
|
+
export function withSnapshotSortAt(messages, getSortAt = getSortAffectingAt) {
|
|
1599
|
+
return (Array.isArray(messages) ? messages : []).map((item) => attachSortAffectingAt(item, getSortAt))
|
|
1600
|
+
}
|
|
1601
|
+
|
|
1585
1602
|
// sort 時刻 sidecar の接尾辞。`.json` にしない (readAllSessionEvents / pushFile が
|
|
1586
1603
|
// `.endsWith(".json")` で event ファイルと誤認しないように)。
|
|
1587
1604
|
const SORT_AT_SUFFIX = ".sortat"
|
|
@@ -5066,10 +5083,10 @@ export async function dispatch(msg, ctx) {
|
|
|
5066
5083
|
}
|
|
5067
5084
|
case "chat.sidebar_snapshot.request": {
|
|
5068
5085
|
try {
|
|
5069
|
-
const messages = await readSidebarMessageSnapshot(msg.targets, {
|
|
5086
|
+
const messages = withSnapshotSortAt(await readSidebarMessageSnapshot(msg.targets, {
|
|
5070
5087
|
claudeBridge: ctx.claudeBridge,
|
|
5071
5088
|
codexBridge: ctx.codexBridge,
|
|
5072
|
-
})
|
|
5089
|
+
}))
|
|
5073
5090
|
ctx.client.send({
|
|
5074
5091
|
type: "chat.sidebar_snapshot.response",
|
|
5075
5092
|
request_id: msg.request_id,
|