From 20242f177982e000ef26d73d2acdf2d37b1ffc3f Mon Sep 17 00:00:00 2001 From: yoji export Date: Tue, 1 Dec 2026 02:24:17 +0000 Subject: [PATCH] Export yoji from 97cf4c418c75 --- package.json | 2 +- src/renderer/src/AgentButton.tsx | 17 +++++++++++++---- src/renderer/src/agentButton.test.ts | 27 ++++++++++++++++++++++++++- 3 files changed, 40 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index a8ebd52..8df577c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "yoji", "productName": "yoji", - "version": "0.1.3", + "version": "0.1.4", "private": true, "description": "A desktop app for your tasks, calendar, inbox and AI agents, on a Convex backend you own.", "license": "Apache-2.0", diff --git a/src/renderer/src/AgentButton.tsx b/src/renderer/src/AgentButton.tsx index 1817b8d..ab64b68 100644 --- a/src/renderer/src/AgentButton.tsx +++ b/src/renderer/src/AgentButton.tsx @@ -5,10 +5,11 @@ // narrow composer, chips leave from the oldest end instead of shrinking. Like an inbox item, a chip clears with // the × that opens a slot of its own after the title on hover or focus, a middle-click, ⌫, or Clear, Clear others and // Clear all on a right-click, with Undo in a toast; the chat itself stays (agentChips.ts). After a clear by the × or a -// middle-click, an empty gap holds the chip's place until the pointer leaves the row, as Chrome holds its tabs, so the -// next chip never slides under the pointer; ⌫ and the menu let the row settle at once. While this row is on screen the +// middle-click, an empty gap holds the chip's place until the pointer leaves the row or rests on it for HOLD_REST, as +// Chrome holds its tabs, so a quick second click never lands on the next chip; a pointer that stays still (or a Mac that +// stops sending it moves, as under a screenshot) never leaves a hole in the row. ⌫ and the menu let the row settle at once. While this row is on screen the // minimized dock (AgentPill) stays hidden, so the chats sit here instead of above the composer. -import { useLayoutEffect, useRef, useState, type ReactElement } from 'react'; +import { useEffect, useLayoutEffect, useRef, useState, type ReactElement } from 'react'; import { AgentMark, Mark } from './AgentMark'; import { clearChips, restoreChips, useClearedChips } from './agentChips'; import { agentPanelShown, agentToggled } from './agentDismiss'; @@ -37,6 +38,9 @@ export function chipChats(chats: r return recentChats(chats).filter((c) => !cleared.includes(c._id)).reverse(); } +/** How long the pointer may rest on the row after a clear by the pointer before its gaps close anyway, in ms. */ +export const HOLD_REST = 1000; + /** The width a chip gains on hover or focus to open the slot for its × (AgentPanel.css). */ export const X_SLOT = 18; @@ -67,9 +71,14 @@ export function AgentButton(): ReactElement { const row = useRef(null), cleared = useClearedChips(), chips = chipChats(chats, cleared); const [menu, setMenu] = useState<{ x: number; y: number; id: string } | null>(null); const [held, setHeld] = useState>({}); + const rest = useRef>(undefined); + const settle = () => (clearTimeout(rest.current), setHeld({})); + const settleAtRest = () => (clearTimeout(rest.current), (rest.current = setTimeout(settle, HOLD_REST))); + useEffect(() => () => clearTimeout(rest.current), []); const clearByPointer = (chip: HTMLElement, id: string) => { const x = chip.querySelector('.x')!.getBoundingClientRect().width; setHeld((h) => ({ ...h, [id]: chip.getBoundingClientRect().width - x })); + settleAtRest(); clearWithUndo([id]); }; useLayoutEffect(() => { @@ -80,7 +89,7 @@ export function AgentButton(): ReactElement { useLayoutEffect(() => fitChips(row.current!)); const others = (id: string) => chips.filter((c) => c._id !== id).map((c) => c._id); return ( -
setHeld({})}> +
{recentChats(chats).reverse().map((c) => { if (cleared.includes(c._id)) return held[c._id] !== undefined ?