Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

fix(workbench): trailing space after quote + stagger selection toolbar on touch

cyh43c533018f62
diff --git a/ui/src/components/workbench/ChatPage.tsx b/ui/src/components/workbench/ChatPage.tsx
index d1b5b1f09..babd6f93f 100644
--- a/ui/src/components/workbench/ChatPage.tsx
+++ b/ui/src/components/workbench/ChatPage.tsx
@@ -160,7 +160,8 @@ export const ChatPage: React.FC = () => {
// current composer; "Ask in a new session" forks this session and seeds the
// fork's draft with the same quote, then navigates to it.
const quoteSelectionToComposer = useCallback(
- (text: string) => composerRef.current?.appendText(quoteText(text)),
+ // Trailing space so the user's next typed text is separated from the quote.
+ (text: string) => composerRef.current?.appendText(quoteText(text) + ' '),
[],
);
const askInNewSession = useCallback(
@@ -172,7 +173,8 @@ export const ChatPage: React.FC = () => {
// setSessionDraft returns {ok:false} for a non-OK response (it doesn't
// throw), so check it before navigating — don't strand the user in a
// fork with an empty composer and a lost selection.
- const saved = await api.setSessionDraft(forked.id, quoteText(text));
+ // Trailing space so typing continues separated from the quote.
+ const saved = await api.setSessionDraft(forked.id, quoteText(text) + ' ');
if (!saved?.ok) {
showToast(t('chat.selection.askFailed'), 'error');
return;
@@ -2089,9 +2091,7 @@ const Transcript: React.FC<TranscriptProps> = ({
// omit the action otherwise so it isn't offered just to 409.
onAskInNew={session.native_session_id ? onAskInNewSession : undefined}
/>
- {/* [-webkit-touch-callout:none] suppresses the iOS selection callout so our
- toolbar is the selection UI on mobile (we re-offer Copy there). */}
- <div ref={scrollRef} onScroll={handleScroll} className="min-h-0 flex-1 overflow-y-auto px-4 py-5 [overflow-anchor:none] [-webkit-touch-callout:none] md:px-8">
+ <div ref={scrollRef} onScroll={handleScroll} className="min-h-0 flex-1 overflow-y-auto px-4 py-5 [overflow-anchor:none] md:px-8">
<div ref={contentRef} className="mx-auto flex w-full max-w-[1080px] flex-col gap-3">
{forkSourceBanner}
{loadingOlder && (
diff --git a/ui/src/components/workbench/SelectionQuoteToolbar.tsx b/ui/src/components/workbench/SelectionQuoteToolbar.tsx
index 01a987019..62dc65a81 100644
--- a/ui/src/components/workbench/SelectionQuoteToolbar.tsx
+++ b/ui/src/components/workbench/SelectionQuoteToolbar.tsx
@@ -15,8 +15,8 @@ const EDGE = 8;
// A floating toolbar that appears over a text selection inside the chat
// transcript. "Quote" appends the (quoted) selection to the current composer;
// "Ask in a new session" forks + prefills the fork's draft (only offered when
-// the session is forkable); "Copy" replaces the native callout that the
-// transcript suppresses on touch devices.
+// the session is forkable); "Copy" is a touch-only convenience — the OS
+// selection menu can't be suppressed, so on touch we stagger below it.
export const SelectionQuoteToolbar: React.FC<{
containerRef: React.RefObject<HTMLDivElement | null>;
onQuote: (text: string) => void;
@@ -29,9 +29,9 @@ export const SelectionQuoteToolbar: React.FC<{
const [copied, setCopied] = useState(false);
const toolbarRef = useRef<HTMLDivElement>(null);
const [width, setWidth] = useState(0);
- // Touch devices get a Copy action because the transcript suppresses the native
- // selection callout there (a coarse pointer covers phones AND tablets/iPads,
- // unlike a width breakpoint).
+ // Touch (coarse pointer — covers phones AND tablets/iPads, unlike a width
+ // breakpoint) gets a Copy convenience; the OS selection menu still shows, so
+ // we stagger our toolbar below it rather than try to fight it.
const [isTouch] = useState(
() => typeof window !== 'undefined' && !!window.matchMedia?.('(pointer: coarse)').matches,
);
@@ -125,8 +125,13 @@ export const SelectionQuoteToolbar: React.FC<{
},
});
- const above = sel.top > TOOLBAR_H + GAP + EDGE;
- const top = above ? sel.top - TOOLBAR_H - GAP : sel.bottom + GAP;
+ // The OS selection menu can't be queried or suppressed, but on touch it sits
+ // ABOVE the selection by default — so place ours BELOW to stagger (avoid the
+ // OS menu overlapping + covering ours). Desktop has no OS menu: prefer above.
+ const roomAbove = sel.top > TOOLBAR_H + GAP + EDGE;
+ const roomBelow = window.innerHeight - sel.bottom > TOOLBAR_H + GAP + EDGE;
+ const below = isTouch ? roomBelow || !roomAbove : !roomAbove;
+ const top = below ? sel.bottom + GAP : sel.top - TOOLBAR_H - GAP;
// Clamp by the on-screen (capped) width so a toolbar wider than the viewport
// centers + scrolls internally instead of pushing an edge off-screen.
const half = Math.min(width, window.innerWidth - 2 * EDGE) / 2;