()
| 138 | } |
| 139 | |
| 140 | function render(): void { |
| 141 | unmountPayload(); |
| 142 | |
| 143 | if (connectionError) { |
| 144 | renderEmpty(connectionError, "error"); |
| 145 | return; |
| 146 | } |
| 147 | |
| 148 | if (!connected) { |
| 149 | renderEmpty("Connecting to host..."); |
| 150 | return; |
| 151 | } |
| 152 | |
| 153 | if (!card) { |
| 154 | renderEmpty(errorMessage ?? "Waiting for a tool result.", errorMessage ? "error" : "muted"); |
| 155 | return; |
| 156 | } |
| 157 | |
| 158 | const display = getToolDisplay(card); |
| 159 | if (isReviewTool(card.tool)) { |
| 160 | renderReviewCard(card, display); |
| 161 | return; |
| 162 | } |
| 163 | |
| 164 | const expandable = isExpandableCard(card); |
| 165 | const main = element("main", { className: "shell" }); |
| 166 | const section = element("section", { className: `tool-card ${display.tone}` }); |
| 167 | const button = element("button", { |
| 168 | className: "tool-header", |
| 169 | type: "button", |
| 170 | ariaExpanded: String(expanded), |
| 171 | disabled: !expandable, |
| 172 | }); |
| 173 | |
| 174 | if (expandable) { |
| 175 | button.addEventListener("click", () => { |
| 176 | expanded = !expanded; |
| 177 | render(); |
| 178 | }); |
| 179 | } |
| 180 | |
| 181 | const icon = element("span", { className: "tool-icon", ariaHidden: "true" }); |
| 182 | icon.innerHTML = display.icon; |
| 183 | |
| 184 | const toolMain = element("span", { className: "tool-main" }); |
| 185 | const title = element("span", { className: "tool-title", text: display.title }); |
| 186 | const label = element("span", { |
| 187 | className: "tool-label", |
| 188 | text: display.label, |
| 189 | title: display.label, |
| 190 | }); |
| 191 | toolMain.append(title, label); |
| 192 | |
| 193 | button.append( |
| 194 | icon, |
| 195 | toolMain, |
| 196 | renderSummaryBadge(card), |
| 197 | renderChevron(expanded, expandable), |
no test coverage detected