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(search): address Codex review round 3 (4 P2)

cyh74a80d50734a
diff --git a/ui/src/components/workbench/ChatPage.tsx b/ui/src/components/workbench/ChatPage.tsx
index 72f1ca988..983d8de9a 100644
--- a/ui/src/components/workbench/ChatPage.tsx
+++ b/ui/src/components/workbench/ChatPage.tsx
@@ -600,6 +600,15 @@ export const ChatPage: React.FC = () => {
onMessageNew: (msg) => {
if (msg.session_id !== sessionIdRef.current) return;
if (!isTranscriptMessage(msg)) return;
+ // Around-jump window active (a search jump landed away from the live
+ // tail): the transcript is a centered window with a deliberate gap to
+ // the tail. Appending a newly-arriving tail row here would graft a
+ // disjoint row below the historical window, so scrolling down would
+ // skip the intervening history. Skip the append — mirrors the reconcile
+ // guard above. The skipped rows are picked up when the user catches up
+ // to the tail (jump-to-latest reloads the tail; load-newer pages reach
+ // it), so nothing is lost (Codex P2).
+ if (newerCursorRef.current) return;
appendMessage(msg);
// Don't clear ``working`` from a result row here: with the queue, a
// result can belong to an EARLIER turn while a newer queued turn is
@@ -1086,6 +1095,17 @@ export const ChatPage: React.FC = () => {
};
}, [deepLinkMessageId, sessionId, loading, session, api, startHighlight, setSearchParams]);
+ // Re-arm the jump guard once ``?msg=`` is gone. ``clearParam`` (above) nulls
+ // the param after handling, so without this re-selecting the SAME search hit
+ // (which re-adds the same ``?msg=``) would be treated as already-handled and
+ // the jump effect would exit without scrolling/highlighting. The jump effect
+ // sets ``handledJumpRef`` BEFORE clearing the param, so this reset only
+ // re-enables the NEXT navigation to that id — it can't double-fire the
+ // current jump.
+ useEffect(() => {
+ if (!deepLinkMessageId) handledJumpRef.current = null;
+ }, [deepLinkMessageId]);
+
// Clear a pending highlight timer on unmount so it can't fire after teardown.
useEffect(() => {
return () => {
diff --git a/ui/src/components/workbench/search/SearchResultRow.tsx b/ui/src/components/workbench/search/SearchResultRow.tsx
index cccf5f94e..6c2ff3533 100644
--- a/ui/src/components/workbench/search/SearchResultRow.tsx
+++ b/ui/src/components/workbench/search/SearchResultRow.tsx
@@ -3,6 +3,7 @@ import clsx from 'clsx';
import type { MessageSearchMatch } from '../../../context/ApiContext';
import { formatRelativeTime } from '../../../lib/relativeTime';
+import { Button } from '../../ui/button';
import { Snippet } from './Snippet';
type SearchResultRowProps = {
@@ -17,19 +18,27 @@ type SearchResultRowProps = {
// a muted relative timestamp. Presentational + reusable by both the desktop
// palette and the mobile page — navigation is wired by the consumer via
// ``onSelect``.
+//
+// Built on the shared ``Button`` primitive (variant="ghost") per AGENTS.md —
+// the row is a button. Button's size variants impose a fixed height and centered
+// layout, so the className overrides them back to this row's auto-height,
+// full-width, left-aligned shape (twMerge lets className win over the variant
+// utilities). The selected state is marked with ``aria-current="true"`` — the
+// palette relies on that attribute to scroll the active row into view.
export const SearchResultRow: React.FC<SearchResultRowProps> = ({ match, selected, onSelect }) => {
const { t } = useTranslation();
const isUser = match.author === 'user';
return (
- <button
+ <Button
type="button"
+ variant="ghost"
onClick={onSelect}
aria-current={selected ? 'true' : undefined}
className={clsx(
- 'flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-left transition',
+ 'h-auto w-full justify-start gap-2.5 px-2.5 py-2 text-left font-normal',
selected
- ? 'bg-mint-soft ring-1 ring-inset ring-mint/40'
+ ? 'bg-mint-soft ring-1 ring-inset ring-mint/40 hover:bg-mint-soft'
: 'hover:bg-foreground/[0.04]',
)}
>
@@ -49,6 +58,6 @@ export const SearchResultRow: React.FC<SearchResultRowProps> = ({ match, selecte
<span className="shrink-0 font-mono text-[10px] text-muted">
{formatRelativeTime(match.created_at, t)}
</span>
- </button>
+ </Button>
);
};
diff --git a/ui/src/lib/useMessageSearch.ts b/ui/src/lib/useMessageSearch.ts
index 1eba8ad0f..bbd6c2c08 100644
--- a/ui/src/lib/useMessageSearch.ts
+++ b/ui/src/lib/useMessageSearch.ts
@@ -51,6 +51,12 @@ export function useMessageSearch(
return;
}
+ // Drop the PREVIOUS query's hits immediately (before the debounce/fetch) so
+ // the palette/page never render — and let the user select — stale rows under
+ // a changed query (Enter/tap could otherwise open a non-matching message).
+ // The loading spinner covers the gap until the new results resolve; the
+ // seq guard below still protects against out-of-order responses.
+ setResults(null);
setLoading(true);
setError(null);