(threads: Array<ThreadMeta>)
| 132 | } |
| 133 | |
| 134 | function writeIndex(threads: Array<ThreadMeta>): void { |
| 135 | if (!hasWindow()) return |
| 136 | try { |
| 137 | window.localStorage.setItem(INDEX_KEY, JSON.stringify(threads)) |
| 138 | } catch { |
| 139 | // Best-effort, mirroring the persistence adapter: a full or unavailable |
| 140 | // store should never break the chat. |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | const byRecency = (a: ThreadMeta, b: ThreadMeta) => b.updatedAt - a.updatedAt |
| 145 |