Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(desktop): satisfy error display contract and close rebuilt test r…
…untimes
  • Loading branch information
SivanCola committed Nov 2, 2026
commit 2235b92580d6d5030781ab83edb97680075807d8
4 changes: 4 additions & 0 deletions desktop/frontend/src/__tests__/agent-presets-ui.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,10 @@ assert.ok(rootEl.querySelector("svg.lucide-search"), "failed image falls back to
assert.equal(rootEl.querySelector("img"), null);
await act(async () => root.render(<AgentPresetIcon image="https://example.com/icon.png" />));
assert.ok(rootEl.querySelector("svg.lucide-bot"), "untrusted image locations use the default without a network fetch");
for (const icon of ["unknown-glyph", "constructor"]) {
await act(async () => root.render(<AgentPresetIcon icon={icon} />));
assert.ok(rootEl.querySelector("svg.lucide-bot"), `unknown icon ${icon} uses the default glyph`);
}
await act(async () => root.unmount());
stub.uninstall();
dom.window.close();
Expand Down
2 changes: 1 addition & 1 deletion desktop/frontend/src/components/AgentPresetIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const AGENT_PRESET_ICONS: Record<string, LucideIcon> = {

export function AgentPresetIcon({ icon, image, color, size = 16 }: { icon?: string; image?: string; color?: string; size?: number }) {
const [failedImage, setFailedImage] = useState<string>();
const Glyph = (icon && AGENT_PRESET_ICONS[icon]) || Bot;
const Glyph = icon && Object.prototype.hasOwnProperty.call(AGENT_PRESET_ICONS, icon) ? AGENT_PRESET_ICONS[icon] : Bot;
if (image && image !== failedImage && isPresetIconImage(image)) return <img className="agent-preset-icon-image" src={image}
width={size} height={size} alt="" aria-hidden="true" draggable={false} onError={() => setFailedImage(image)} />;
return <Glyph size={size} aria-hidden="true" style={color && /^#[0-9a-f]{6}$/iu.test(color) ? { color } : undefined} />;
Expand Down
3 changes: 2 additions & 1 deletion desktop/frontend/src/components/AgentPresetIconPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Shuffle, Upload } from "lucide-react";
import { useT } from "../lib/i18n";
import { decodePresetIcon, drawPresetIcon, isPresetIconImage, PRESET_ICON_SIZE } from "../lib/agentPresetImage";
import { AGENT_PRESET_ICONS, AgentPresetIcon, DEFAULT_AGENT_PRESET_ICON } from "./AgentPresetIcon";
import { ErrorMessage } from "./ErrorMessage";

const COLORS = { default: "", red: "#fb7185", orange: "#fb923c", yellow: "#fbbf24", green: "#4ade80",
teal: "#2dd4bf", blue: "#60a5fa", purple: "#c084fc", pink: "#f472b6", gray: "#94a3b8" };
Expand Down Expand Up @@ -93,7 +94,7 @@ export function AgentPresetIconPicker({ icon, image, color, disabled, onChange,
</div>
<span className="set-hint">{t("agentPresets.uploadIconHint")}</span>
{loading && <span role="status">{t("agentPresets.iconLoading")}</span>}
{error && <span className="agent-preset-editor__error" role="alert">{error}</span>}
{error && <span className="agent-preset-editor__error" role="alert"><ErrorMessage error={error} /></span>}
{(source || loading) && <div className="agent-preset-icon-crop" role="group" aria-label={t("agentPresets.cropIcon")}>
{source && <>
<canvas ref={preview} width={192} height={192} role="img" aria-label={t("agentPresets.iconPreview")} />
Expand Down
19 changes: 19 additions & 0 deletions desktop/session_temp_rebuild_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,25 @@ func TestDesktopHotRebuildPathsKeepSessionTemp(t *testing.T) {
} {
t.Run(tc.name, func(t *testing.T) {
app, tab, oldAPI, _ := auditCurrentTab(t)
t.Cleanup(func() {
// The fixture closes the original controller; rebuilds install a
// new writer that must also finish before TempDir cleanup.
if current := app.controllerForTab(tab); current != nil {
current.Close()
if closed, ok := current.(interface{ Closed() <-chan struct{} }); ok {
<-closed.Closed()
}
}
oldAPI.Close()
<-oldAPI.Closed()
if err := app.sessionUI.Close(); err != nil {
t.Error(err)
}
if err := app.closeSessionServicesResult(); err != nil {
t.Error(err)
}
app.closeSharedSkillWatchService()
})
oldCtrl := oldAPI
if oldCtrl == nil {
t.Fatal("old controller is not *control.Controller")
Expand Down
Loading