( threadId: string, offset = 0, limit = 8, )
| 970 | } |
| 971 | |
| 972 | export async function listWebCodexThreadMessages( |
| 973 | threadId: string, |
| 974 | offset = 0, |
| 975 | limit = 8, |
| 976 | ): Promise<{ |
| 977 | items: WebCodexThreadMessage[]; |
| 978 | hasMore: boolean; |
| 979 | }> { |
| 980 | const filePath = getStoredCodexSessionFileMap().get(threadId); |
| 981 | if (!filePath || !fs.existsSync(filePath)) { |
| 982 | return { |
| 983 | items: [], |
| 984 | hasMore: false, |
| 985 | }; |
| 986 | } |
| 987 | |
| 988 | const messages = getCachedThreadMessages(threadId, filePath); |
| 989 | const end = Math.max(0, messages.length - offset); |
| 990 | const start = Math.max(0, end - limit); |
| 991 | const slice = messages.slice(start, end); |
| 992 | return { |
| 993 | items: slice, |
| 994 | hasMore: start > 0, |
| 995 | }; |
| 996 | } |
| 997 | |
| 998 | export async function getWebCodexThreadRecentMessages( |
| 999 | threadId: string, |
no test coverage detected