(turns: readonly BrowserChatTurn[], scope: string)
| 54 | /** A question without its own context follows up on explicitly attached code or context |
| 55 | * in the same view. A selection or file that is gone leaves nothing to follow up on. */ |
| 56 | export function followedTopic(turns: readonly BrowserChatTurn[], scope: string): ChatTopic | undefined { |
| 57 | for (let index = turns.length - 1; index >= 0; index--) { |
| 58 | const topic = turns[index].topic; |
| 59 | if (!topic || turns[index].answeredFrom === 'local' || turns[index].answeredFrom === 'hint') continue; |
| 60 | // Stored history is data: a damaged key ends the follow-up instead of the send. |
| 61 | let turnScope: unknown; |
| 62 | try { [turnScope] = JSON.parse(topic.key) as unknown[]; } catch { return undefined; } |
| 63 | return turnScope === scope && (topic.kind === 'attachment' || topic.kind === 'context') ? topic : undefined; |
| 64 | } |
| 65 | return undefined; |
| 66 | } |
| 67 | |
| 68 | /** German when the question reads German; the chat's own replies follow the question. |
| 69 | * "was" and "die" are English words too and decide nothing on their own. Short questions |
no outgoing calls
no test coverage detected