* The candidates of an ambiguous name, as a list to choose from. * * Each entry carries what tells two symbols of the same name apart: the file and * the line. A list of three times `create` with nothing beside it would be the * same silence in a longer form.
(props: {
turn: ChatTurn;
onPick: (turn: ChatTurn, candidate: SubjectCandidate) => void;
})
| 196 | * same silence in a longer form. |
| 197 | */ |
| 198 | function ChoiceList(props: { |
| 199 | turn: ChatTurn; |
| 200 | onPick: (turn: ChatTurn, candidate: SubjectCandidate) => void; |
| 201 | }): JSX.Element | null { |
| 202 | const choice = props.turn.choice; |
| 203 | if (choice === undefined || choice.candidates.length === 0) { |
| 204 | return null; |
| 205 | } |
| 206 | return ( |
| 207 | <div |
| 208 | className="atlas-chat-choice" |
| 209 | data-testid="atlas-chat-choice" |
| 210 | data-count={choice.candidates.length} |
| 211 | data-name={choice.name} |
| 212 | > |
| 213 | <p className="atlas-chat-choice-head" data-testid="atlas-chat-choice-head"> |
| 214 | {chatChoiceHeadline(choice.name, choice.candidates.length)} |
| 215 | </p> |
| 216 | <ul className="atlas-chat-candidates" aria-label={messages.chat.candidatesLabel}> |
| 217 | {choice.candidates.map((candidate, index) => { |
| 218 | const qualified = candidate.qualifiedName ?? candidate.name; |
| 219 | return ( |
| 220 | <li className="atlas-chat-candidate-row" key={`${qualified}-${index}`}> |
| 221 | <Hint name="chat-candidate" text={chatCandidateTitle(qualified)}> |
| 222 | <button |
| 223 | type="button" |
| 224 | className="atlas-chat-candidate" |
| 225 | data-testid="atlas-chat-candidate" |
| 226 | data-qualified={qualified} |
| 227 | onClick={() => props.onPick(props.turn, candidate)} |
| 228 | > |
| 229 | {chatCandidateLabel(candidate.name, candidate.filePath, candidate.line)} |
| 230 | </button> |
| 231 | </Hint> |
| 232 | {candidate.isTest === true && ( |
| 233 | <span className="atlas-chat-candidate-mark"> |
| 234 | {CHAT_CANDIDATE_TEST_MARK} |
| 235 | </span> |
| 236 | )} |
| 237 | </li> |
| 238 | ); |
| 239 | })} |
| 240 | </ul> |
| 241 | </div> |
| 242 | ); |
| 243 | } |
| 244 | |
| 245 | /** One turn: the question, the answer with its citations, and the evidence. */ |
| 246 | function Turn(props: { |
nothing calls this directly
no test coverage detected