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): address Codex search review (P2s)

cyh7e9f8865f935
diff --git a/ui/src/components/ui/input.tsx b/ui/src/components/ui/input.tsx
index 1de5a6e01..aa978f037 100644
--- a/ui/src/components/ui/input.tsx
+++ b/ui/src/components/ui/input.tsx
@@ -3,14 +3,29 @@ import * as React from 'react';
import { cn } from '@/lib/utils';
import { fieldBaseClass } from './field';
-export type InputProps = React.InputHTMLAttributes<HTMLInputElement>;
+export type InputProps = React.InputHTMLAttributes<HTMLInputElement> & {
+ // ``bare`` drops the inset-field chrome (border / fill / height) for inputs
+ // that sit inside a container which already owns the framing — e.g. a search
+ // field inside a bordered pill with its own glyph + clear/Esc affordances.
+ // Callers add only layout + text size on top. Keeps such fields on the shared
+ // primitive (focus behavior, future design-system fixes) instead of
+ // re-rolling a native <input>.
+ variant?: 'default' | 'bare';
+};
-export const Input = React.forwardRef<HTMLInputElement, InputProps>(({ className, type, ...props }, ref) => (
- <input
- ref={ref}
- type={type}
- className={cn(fieldBaseClass, 'flex h-9 px-3 py-1', className)}
- {...props}
- />
-));
+export const Input = React.forwardRef<HTMLInputElement, InputProps>(
+ ({ className, type, variant = 'default', ...props }, ref) => (
+ <input
+ ref={ref}
+ type={type}
+ className={cn(
+ variant === 'bare'
+ ? 'bg-transparent text-foreground outline-none placeholder:text-muted disabled:cursor-not-allowed disabled:opacity-50'
+ : cn(fieldBaseClass, 'flex h-9 px-3 py-1'),
+ className,
+ )}
+ {...props}
+ />
+ ),
+);
Input.displayName = 'Input';
diff --git a/ui/src/components/workbench/ChatPage.tsx b/ui/src/components/workbench/ChatPage.tsx
index b8246340e..71f442454 100644
--- a/ui/src/components/workbench/ChatPage.tsx
+++ b/ui/src/components/workbench/ChatPage.tsx
@@ -1921,12 +1921,19 @@ const Transcript: React.FC<TranscriptProps> = ({
if (!jumpTarget) return;
const el = scrollRef.current;
if (!el) return;
- // If the target is already the newest loaded row (a recent search hit, or a
- // just-sent message after an around-mode catch-up), pin to the bottom and keep
+ // If the target is the newest loaded row AND we're genuinely at the live tail
+ // (no around-window gap above the latest), pin to the bottom and keep
// following instead of centering+unpinning — otherwise the next agent reply
- // wouldn't auto-scroll into view (Codex P2). The mint highlight still applies
- // via ``highlightedId``, independent of the scroll.
- if (messages.length > 0 && messages[messages.length - 1]?.id === jumpTarget) {
+ // wouldn't auto-scroll into view. The mint highlight still applies via
+ // ``highlightedId``, independent of the scroll.
+ //
+ // The ``!hasNewer`` guard matters: in an around-window from a prior jump the
+ // last LOADED row is NOT the real tail (newer rows aren't fetched yet).
+ // Pinning here would hide the catch-up affordance while the around-mode
+ // onMessageNew guard still drops live rows, stranding the reader on history —
+ // so when hasNewer we fall through to the centering path, which keeps the
+ // jump-to-latest button visible.
+ if (!hasNewer && messages.length > 0 && messages[messages.length - 1]?.id === jumpTarget) {
const rafTail = requestAnimationFrame(() => {
scrollToBottom();
onJumpHandled();
@@ -1957,7 +1964,7 @@ const Transcript: React.FC<TranscriptProps> = ({
if (raf2) cancelAnimationFrame(raf2);
suppressAnchorRef.current = false;
};
- }, [jumpTarget, messages, captureAnchor, onJumpHandled, scrollToBottom]);
+ }, [jumpTarget, messages, hasNewer, captureAnchor, onJumpHandled, scrollToBottom]);
// The one place scroll position reacts to content size changes — two modes,
// never conflated. (Conflating them WAS the bug: any resize while "at bottom"
diff --git a/ui/src/components/workbench/SearchPage.tsx b/ui/src/components/workbench/SearchPage.tsx
index 6cc6a1cd2..dd15aeb3e 100644
--- a/ui/src/components/workbench/SearchPage.tsx
+++ b/ui/src/components/workbench/SearchPage.tsx
@@ -1,10 +1,11 @@
import { useEffect, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useLocation, useNavigate, useSearchParams } from 'react-router-dom';
-import { ChevronLeft, Loader2, Search, X } from 'lucide-react';
+import { AlertCircle, ChevronLeft, Loader2, Search, X } from 'lucide-react';
import { useMessageSearch } from '../../lib/useMessageSearch';
import { Button } from '../ui/button';
+import { Input } from '../ui/input';
import { SearchResultGroup } from './search/SearchResultGroup';
// Mobile full-screen message-content search (design.pen K7Bytg "M · Search
@@ -25,7 +26,7 @@ export const SearchPage: React.FC = () => {
// input from the param on mount and mirror every keystroke back into it.
const [searchParams, setSearchParams] = useSearchParams();
const [query, setQuery] = useState(() => searchParams.get('q') ?? '');
- const { results, loading } = useMessageSearch(query);
+ const { results, loading, error } = useMessageSearch(query);
const inputRef = useRef<HTMLInputElement | null>(null);
// Drive the query (state + URL together). ``replace: true`` so each keystroke
@@ -76,6 +77,7 @@ export const SearchPage: React.FC = () => {
const sessions = results?.sessions ?? [];
const hasResults = sessions.length > 0;
const showHint = trimmed.length === 0;
+ const showError = trimmed.length > 0 && !loading && !!error;
const showEmpty = trimmed.length > 0 && !loading && results !== null && !hasResults;
return (
@@ -97,13 +99,14 @@ export const SearchPage: React.FC = () => {
</Button>
<div className="flex min-w-0 flex-1 items-center gap-2.5 rounded-xl border border-border-strong bg-foreground/[0.04] px-3 py-2.5">
<Search className="size-4 shrink-0 text-mint" />
- <input
+ <Input
ref={inputRef}
+ variant="bare"
value={query}
onChange={(e) => updateQuery(e.target.value)}
placeholder={t('workbench.search.placeholder')}
aria-label={t('workbench.search.placeholder')}
- className="min-w-0 flex-1 bg-transparent text-[15px] text-foreground outline-none placeholder:text-muted"
+ className="min-w-0 flex-1 text-[15px]"
spellCheck={false}
autoComplete="off"
autoCorrect="off"
@@ -136,6 +139,14 @@ export const SearchPage: React.FC = () => {
{t('workbench.search.empty')}
</div>
)}
+ {showError && (
+ <div className="px-2.5 py-12">
+ <div className="mx-auto flex max-w-sm items-center gap-2 rounded-md border border-destructive/40 bg-destructive/[0.06] px-3 py-2 text-[13px] text-destructive">
+ <AlertCircle className="size-4 shrink-0" />
+ <span>{t('workbench.search.error')}</span>
+ </div>
+ </div>
+ )}
{hasResults && (
<div className="flex flex-col gap-1.5">
{sessions.map((session) => (
diff --git a/ui/src/components/workbench/search/SearchPalette.tsx b/ui/src/components/workbench/search/SearchPalette.tsx
index b033273c6..b63fc04fe 100644
--- a/ui/src/components/workbench/search/SearchPalette.tsx
+++ b/ui/src/components/workbench/search/SearchPalette.tsx
@@ -2,10 +2,11 @@ import { useEffect, useMemo, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useNavigate } from 'react-router-dom';
import * as DialogPrimitive from '@radix-ui/react-dialog';
-import { Loader2, Search } from 'lucide-react';
+import { AlertCircle, Loader2, Search } from 'lucide-react';
import { useMessageSearch } from '../../../lib/useMessageSearch';
import { Dialog, DialogOverlay, DialogPortal, DialogTitle } from '../../ui/dialog';
+import { Input } from '../../ui/input';
import { SearchResultGroup } from './SearchResultGroup';
type SearchPaletteProps = {
@@ -35,7 +36,7 @@ export const SearchPalette: React.FC<SearchPaletteProps> = ({ open, onClose }) =
const { t } = useTranslation();
const navigate = useNavigate();
const [query, setQuery] = useState('');
- const { results, loading } = useMessageSearch(query);
+ const { results, loading, error } = useMessageSearch(query);
const inputRef = useRef<HTMLInputElement | null>(null);
const listRef = useRef<HTMLDivElement | null>(null);
@@ -121,6 +122,7 @@ export const SearchPalette: React.FC<SearchPaletteProps> = ({ open, onClose }) =
const trimmed = query.trim();
const hasResults = (results?.sessions.length ?? 0) > 0;
+ const showError = trimmed.length > 0 && !loading && !!error;
const showEmpty = trimmed.length > 0 && !loading && results !== null && !hasResults;
const showHint = trimmed.length === 0;
@@ -144,12 +146,13 @@ export const SearchPalette: React.FC<SearchPaletteProps> = ({ open, onClose }) =
{/* Query row — mint search glyph + input + Esc pill. */}
<div className="flex shrink-0 items-center gap-3 border-b border-border px-[18px] py-4">
<Search className="size-[18px] shrink-0 text-mint" />
- <input
+ <Input
ref={inputRef}
+ variant="bare"
value={query}
onChange={(e) => setQuery(e.target.value)}
placeholder={t('workbench.search.placeholder')}
- className="min-w-0 flex-1 bg-transparent text-[17px] text-foreground outline-none placeholder:text-muted"
+ className="min-w-0 flex-1 text-[17px]"
aria-label={t('workbench.search.placeholder')}
spellCheck={false}
autoComplete="off"
@@ -172,6 +175,14 @@ export const SearchPalette: React.FC<SearchPaletteProps> = ({ open, onClose }) =
{t('workbench.search.empty')}
</div>
)}
+ {showError && (
+ <div className="px-2.5 py-10">
+ <div className="mx-auto flex max-w-sm items-center gap-2 rounded-md border border-destructive/40 bg-destructive/[0.06] px-3 py-2 text-[13px] text-destructive">
+ <AlertCircle className="size-4 shrink-0" />
+ <span>{t('workbench.search.error')}</span>
+ </div>
+ </div>
+ )}
{hasResults && (
<div className="flex flex-col gap-1.5">
{results!.sessions.map((session) => (
diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.json
index 1dcdaef63..ce7ff537e 100644
--- a/ui/src/i18n/en.json
+++ b/ui/src/i18n/en.json
@@ -638,6 +638,7 @@
"placeholder": "Search messages",
"hint": "Search your messages",
"empty": "No messages found",
+ "error": "Search failed — try again.",
"kbdEsc": "Esc",
"kbdNavigate": "Navigate",
"kbdOpen": "Open",
diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.json
index 807ff167a..e34d84b67 100644
--- a/ui/src/i18n/zh.json
+++ b/ui/src/i18n/zh.json
@@ -638,6 +638,7 @@
"placeholder": "搜索消息",
"hint": "搜索你的消息",
"empty": "未找到消息",
+ "error": "搜索失败,请重试。",
"kbdEsc": "Esc",
"kbdNavigate": "切换",
"kbdOpen": "打开",