Skip to content

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.

fix(desktop): keep bots still while a computer folds or unfolds

leepokai59c0c1fc7694
diff --git a/apps/desktop/src/renderer/lib/slide.ts b/apps/desktop/src/renderer/lib/slide.ts
index e8be4120..a26baa36 100644
--- a/apps/desktop/src/renderer/lib/slide.ts
+++ b/apps/desktop/src/renderer/lib/slide.ts
@@ -1,6 +1,16 @@
-import { useLayoutEffect, useRef, type RefObject } from 'react'
+import { useEffect, useLayoutEffect, useRef, type RefObject } from 'react'
import { reduceMotion } from './theme'
+/** Where an element sits inside its parent; relative to it, so a row doesn't slide again inside a section that is already sliding. */
+function topInParent(element: HTMLElement, parent: HTMLElement) {
+ return element.offsetTop - (parent.offsetParent === element.offsetParent ? parent.offsetTop : 0)
+}
+
+/** A fold or unfold is moving things around: that is not a reorder. */
+function folding(parent: HTMLElement) {
+ return parent.getAnimations({ subtree: true }).some((a) => a instanceof CSSTransition && a.transitionProperty === 'grid-template-rows')
+}
+
/** Slides an element from where it was to where it is now inside its parent (reordered rows and sections). */
export function useSlide(ref: RefObject<HTMLElement | null>) {
const lastTop = useRef<number | null>(null)
@@ -8,11 +18,21 @@ export function useSlide(ref: RefObject<HTMLElement | null>) {
const element = ref.current
const parent = element?.parentElement
if (!element || !parent) return
- // Relative to the parent, so a row doesn't slide again inside a section that is already sliding.
- const top = element.offsetTop - (parent.offsetParent === element.offsetParent ? parent.offsetTop : 0)
- if (lastTop.current !== null && top !== lastTop.current && !reduceMotion()) {
+ const top = topInParent(element, parent)
+ if (lastTop.current !== null && top !== lastTop.current && !folding(parent) && !reduceMotion()) {
element.animate([{ transform: `translateY(${lastTop.current - top}px)` }, { transform: 'translateY(0)' }], { duration: 300, easing: 'ease-out' })
}
lastTop.current = top
})
+ // A fold ends without a render: take where it left the element, so the next render doesn't slide from before it.
+ useEffect(() => {
+ const element = ref.current
+ const parent = element?.parentElement
+ if (!element || !parent) return
+ const settle = () => {
+ lastTop.current = topInParent(element, parent)
+ }
+ parent.addEventListener('transitionend', settle)
+ return () => parent.removeEventListener('transitionend', settle)
+ }, [ref])
}