Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.
Rust acpagent-client-protocolai-agentsai-assistantclaudeclaude-codecodexcoding-agentscursorgeminigemini-cligrok-bot-alternativeiosiphonelinuxmacosmcpopen-sourcerustself-hosted
fix(desktop): keep avatars and animations sharp after the screen changes
leepokaia6b44551c54d
diff --git a/apps/desktop/src/renderer/components/Avatar.tsx b/apps/desktop/src/renderer/components/Avatar.tsxindex 458c3be6..a8515546 100644--- a/apps/desktop/src/renderer/components/Avatar.tsx+++ b/apps/desktop/src/renderer/components/Avatar.tsx@@ -1,6 +1,6 @@import { memo, useEffect, useRef, type CSSProperties } from 'react'import { isGroup, isWorking, needsInput, type Bot } from '@shared/models'-import { avatarColor, palette, useDark, useReduceMotion } from '../lib/theme'+import { avatarColor, palette, useDark, usePixelRatio, useReduceMotion } from '../lib/theme'import { Icon } from './Icon'import './avatar.css'@@ -118,12 +118,12 @@ export const CharacterAvatar = memo(function CharacterAvatar({ shape, color, tinconst canvas = useRef<HTMLCanvasElement>(null)const dark = useDark() || forceDark === trueconst reduce = useReduceMotion()+ const ratio = usePixelRatio()const fill = tint ?? avatarColor(color)useEffect(() => {const el = canvas.currentif (!el) return- const ratio = window.devicePixelRatio || 1el.width = Math.round(size * ratio)el.height = Math.round(size * ratio)const ctx = el.getContext('2d')!@@ -153,7 +153,7 @@ export const CharacterAvatar = memo(function CharacterAvatar({ shape, color, tinonScreen.disconnect()cancelAnimationFrame(frame)}- }, [shape, fill, size, mood, dark, reduce])+ }, [shape, fill, size, mood, dark, reduce, ratio])return <canvas ref={canvas} aria-hidden style={{ width: size, height: size, display: 'block', flex: 'none' }} />})diff --git a/apps/desktop/src/renderer/components/ThinkingOrb.tsx b/apps/desktop/src/renderer/components/ThinkingOrb.tsxindex 613771fb..8e5f212f 100644--- a/apps/desktop/src/renderer/components/ThinkingOrb.tsx+++ b/apps/desktop/src/renderer/components/ThinkingOrb.tsx@@ -1,5 +1,5 @@import { useEffect, useRef } from 'react'-import { useDark, useReduceMotion } from '../lib/theme'+import { useDark, usePixelRatio, useReduceMotion } from '../lib/theme'// thinking-orbs 0.3.1, commit de85557 (MIT, Jakub Antalik): src/engine/{core,orbits,lattice,web,morph}.ts// with the resolved 20/64 pt presets, as ported in kit's ThinkingOrbGeometry.@@ -219,10 +219,10 @@ export function ThinkingOrb({ state = 'working', size = 16, color = 'var(--text)const canvas = useRef<HTMLCanvasElement>(null)const reduce = useReduceMotion()const dark = useDark()+ const ratio = usePixelRatio()useEffect(() => {const el = canvas.currentif (!el) return- const ratio = window.devicePixelRatio || 1el.width = Math.round(size * ratio)el.height = Math.round(size * ratio)const ctx = el.getContext('2d')!@@ -262,6 +262,6 @@ export function ThinkingOrb({ state = 'working', size = 16, color = 'var(--text)}frame = requestAnimationFrame(draw)return () => cancelAnimationFrame(frame)- }, [state, size, animated, reduce, color, dark])+ }, [state, size, animated, reduce, color, dark, ratio])return <canvas ref={canvas} aria-hidden style={{ width: size, height: size, color, display: 'block', flex: 'none' }} />}diff --git a/apps/desktop/src/renderer/lib/theme.ts b/apps/desktop/src/renderer/lib/theme.tsindex 6a98a3e1..04777bce 100644--- a/apps/desktop/src/renderer/lib/theme.ts+++ b/apps/desktop/src/renderer/lib/theme.ts@@ -27,6 +27,35 @@ function mediaQuery(media: string) {const darkQuery = mediaQuery('(prefers-color-scheme: dark)')const motionQuery = mediaQuery('(prefers-reduced-motion: reduce)')+/**+ * The screen's pixel ratio, for canvases' backing size. It changes when the window moves to another+ * screen or the Mac sleeps with the lid closed; a canvas drawn meanwhile would stay blurry at 1x.+ * The query names the current ratio, so it is renewed on every change.+ */+const pixelRatio = {+ get: () => window.devicePixelRatio || 1,+ subscribe: (cb: () => void) => {+ let query: MediaQueryList | null = null+ const changed = () => {+ watch()+ cb()+ }+ const watch = () => {+ query?.removeEventListener('change', changed)+ query = window.matchMedia(`(resolution: ${pixelRatio.get()}dppx)`)+ query.addEventListener('change', changed)+ }+ watch()+ document.addEventListener('visibilitychange', changed)+ window.addEventListener('focus', changed)+ return () => {+ query?.removeEventListener('change', changed)+ document.removeEventListener('visibilitychange', changed)+ window.removeEventListener('focus', changed)+ }+ },+}+export function useDark() {return useSyncExternalStore(darkQuery.subscribe, darkQuery.get)}@@ -35,6 +64,10 @@ export function useReduceMotion() {return useSyncExternalStore(motionQuery.subscribe, motionQuery.get)}+export function usePixelRatio() {+ return useSyncExternalStore(pixelRatio.subscribe, pixelRatio.get)+}+export const isDark = darkQuery.getexport const reduceMotion = motionQuery.getdiff --git a/apps/desktop/src/renderer/views/call/CallView.tsx b/apps/desktop/src/renderer/views/call/CallView.tsxindex 562ad3ee..73fd4885 100644--- a/apps/desktop/src/renderer/views/call/CallView.tsx+++ b/apps/desktop/src/renderer/views/call/CallView.tsx@@ -5,7 +5,7 @@ import { Icon } from '../../components/Icon'import { Sheet } from '../../components/Overlay'import { Text } from '../../components/Text'import { useModel } from '../../lib/observable'-import { avatarColor, useDark, useReduceMotion, withAlpha } from '../../lib/theme'+import { avatarColor, useDark, usePixelRatio, useReduceMotion, withAlpha } from '../../lib/theme'import { useStore } from '../../store/context'import { VoiceChatSettingsView } from '../settings/VoiceChatSettingsView'import { CallOperator } from './call-operator'@@ -237,6 +237,7 @@ function CallLevelDots({ engine, working, color, label }: { engine: VoiceEngineconst canvas = useRef<HTMLCanvasElement>(null)const dark = useDark()const reduceMotion = useReduceMotion()+ const scale = usePixelRatio()const live = useRef({ engine, working, color, dark, reduceMotion })live.current = { engine, working, color, dark, reduceMotion }@@ -244,7 +245,6 @@ function CallLevelDots({ engine, working, color, label }: { engine: VoiceEngineconst el = canvas.currentconst ctx = el?.getContext('2d')if (!el || !ctx) return- const scale = window.devicePixelRatio || 1el.width = DOTS_WIDTH * scaleel.height = DOTS_HEIGHT * scalelet frame = 0@@ -273,7 +273,7 @@ function CallLevelDots({ engine, working, color, label }: { engine: VoiceEngine}frame = requestAnimationFrame(draw)return () => cancelAnimationFrame(frame)- }, [])+ }, [scale])return <canvas ref={canvas} role="img" aria-label={label} className="call-dots" style={{ width: DOTS_WIDTH, height: DOTS_HEIGHT }} />}