Your own team of AI bots in one self-hosted binary: spaces, every account you have, handoffs, approvals and routines. Open-source, self-hosted alternative to Grok Bot, Claude Duet and OpenAI dots. Rust + React.
Rust ai-agentsai-assistantai-botautomationbotbots-teamchatbotclaude-duetgrokgrok-botgrok-bot-alternativeharnessllmmulti-agentopenai-dotsopenbotpersonal-agentrustself-hostedselfhosted-ai
29w: the Needs-you strip steps aside while its approval card is on screen (#861)
Oleksandr Ivanchenko440a5c23f908
diff --git a/frontend/src/App.tsx b/frontend/src/App.tsxindex 648750a0..5baf7aef 100644--- a/frontend/src/App.tsx+++ b/frontend/src/App.tsx@@ -161,7 +161,7 @@ import {turnsAwaitingAnswer,} from './questions';import { AwayError, AwayItem, affectsAway, awayApi, resolveBody } from './away';-import { asksHere, closedId, isHandOff, dismissKind, dropClosed, loadAskWindow, openTarget as askOpenTarget, resendTarget, retryRoute, switchFor, type AskAction, type Here } from './askHere';+import { asksHere, closedId, onlyLiveApproval, isHandOff, dismissKind, dropClosed, loadAskWindow, openTarget as askOpenTarget, resendTarget, retryRoute, switchFor, type AskAction, type Here } from './askHere';import { NeedsYouStrip } from './components/NeedsYouStrip';import { chainBudgetApi } from './chainBudget';import { needsYouRows, attentionRows } from './chatsTab';@@ -4632,6 +4632,7 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({}}needsYouStrip={needsYouStrip}needsYouOpen={asks.length > 0}+ stripOnlyApproval={onlyLiveApproval(asks)}subHeader={subHeader}threadLine={isPhone && threadBarProps ? <ThreadPicker {...threadBarProps} /> : undefined}notice={diff --git a/frontend/src/askHere.ts b/frontend/src/askHere.tsindex ddd82d00..bc133698 100644--- a/frontend/src/askHere.ts+++ b/frontend/src/askHere.ts@@ -332,3 +332,22 @@ export function resendTarget(messages: ChatMessage[], noticeId: string | null |}return null;}++/**+ * 29w (Mira's UX pass 0.9.26, fix #2): the strip's asks are exactly one live approval of this chat, so all it+ * says is the approval card's own ask ("Allow or Deny it on the card in the chat"). ChatView then lets the+ * strip step aside while that card's Allow / Deny row is fully on screen; it comes back when the buttons+ * scroll off, another ask joins, or the approval runs out (a stopped item, whose Ask again is the strip's).+ */+export const onlyLiveApproval = (asks: Parameters<typeof askAction>[0][]): boolean =>+ asks.length === 1 && asks[0].kind === 'approval' && askAction(asks[0]) === 'decide';++/**+ * 29w: whether the Needs-you strip steps aside. Its one ask is the live approval and either the card's Allow / Deny+ * row is fully on screen, or the chat still follows the bottom with the card in it. The second half keeps the strip+ * aside through the first 80 px of a slow scroll up: bringing it back there would shrink the chat, the follow pin+ * would snap to the bottom and hide it again, and the reader could not leave the bottom (Rigel, QA round 1).+ */+export const stripStepsAside = (s: { strip: boolean; onlyApproval: boolean; cardInView: boolean; followingCard: boolean }): boolean =>+ s.strip && s.onlyApproval && (s.cardInView || s.followingCard);+diff --git a/frontend/src/components/ChatView.tsx b/frontend/src/components/ChatView.tsxindex dcfe3a7e..4b89389e 100644--- a/frontend/src/components/ChatView.tsx+++ b/frontend/src/components/ChatView.tsx@@ -109,6 +109,7 @@ import { ideaBlockedLine, ideaLength } from '../ideaShell';import { JarIcon } from './JarIcon';import { consultedNames, hideStreamingDecisions, messageDecisions, parseWorkAhead } from '../decideFirst';import { approvalScrollAction, fullyVisible, isNearBottom, nextFollowing } from '../approvalVisibility';+import { stripStepsAside } from '../askHere';import { DecidingLine, DecisionChips, WorkAheadBody } from './Proactive';import { RouteChoiceMeta, parseRouteChoiceMeta, questionsOfReplies } from '../routeChoice';import { SmartActionsSlot } from './results/SmartActions';@@ -353,6 +354,8 @@ export interface ChatViewProps {needsYouStrip?: React.ReactNode;/** 22i: the strip shows an ask here, so the working line drops its own "Answer ↑". */needsYouOpen?: boolean;+ /** 29w: the strip's only ask is this chat's live approval, so it steps aside while that card's buttons are on screen. */+ stripOnlyApproval?: boolean;onHighlightDone?: () => void;/** Set while `messages` is an older window (a search hit beyond the latest page). */viewingHistory?: boolean;@@ -637,6 +640,7 @@ export const ChatView: React.FC<ChatViewProps> = ({highlightRing,needsYouStrip,needsYouOpen,+ stripOnlyApproval = false,onContinueFrom,threadKind,continuedFrom,@@ -956,18 +960,21 @@ export const ChatView: React.FC<ChatViewProps> = ({};// A waiting card whose buttons are off screen while the person reads further up.const [approvalOffscreen, setApprovalOffscreen] = useState(false);+ // 29w: some card's Allow / Deny row is fully on screen (the same measurement), so the strip need not repeat it.+ const [approvalCardInView, setApprovalCardInView] = useState(false);+ // ...or the chat follows the bottom with a card in it (the follow pin would undo the strip coming back there).+ const [followingCard, setFollowingCard] = useState(false);const approvalKey = pendingApprovals.map((a) => a.id).join(',');const checkApprovalVisible = () => {const el = scrollRef.current;if (!el) return;const view = el.getBoundingClientRect();const rows = Array.from(el.querySelectorAll<HTMLElement>('[data-approval-actions]'));- const action = approvalScrollAction({- waiting: rows.length,- following: stickRef.current,- buttonsVisible: rows.some((r) => fullyVisible(r.getBoundingClientRect(), view)),- });+ const buttonsVisible = rows.some((r) => fullyVisible(r.getBoundingClientRect(), view));+ const action = approvalScrollAction({ waiting: rows.length, following: stickRef.current, buttonsVisible });setApprovalOffscreen(action === 'notify');+ setApprovalCardInView(buttonsVisible);+ setFollowingCard(stickRef.current && rows.length > 0);};const onScroll = () => {const el = scrollRef.current;@@ -1014,6 +1021,18 @@ export const ChatView: React.FC<ChatViewProps> = ({card.scrollIntoView({ block: 'end', behavior: reduce ? 'auto' : 'smooth' });setApprovalOffscreen(false);};+ // 29w: the Needs-you strip steps aside while its one ask is the live approval whose buttons are on screen.+ const stripAside = stripStepsAside({ strip: !!needsYouStrip, onlyApproval: stripOnlyApproval, cardInView: approvalCardInView, followingCard });+ const stripSlotRef = useRef<HTMLDivElement | null>(null);+ const stripHadFocusRef = useRef(false);+ // Its "Go to the approval" brings the card into view and the strip goes: focus that was in it goes to the+ // composer (as when the strip leaves), never to the page body.+ useLayoutEffect(() => {+ if (!stripAside || !stripHadFocusRef.current) return;+ stripHadFocusRef.current = false;+ const a = document.activeElement;+ if (!a || a === document.body || stripSlotRef.current?.contains(a)) textareaRef.current?.focus({ preventScroll: true });+ }, [stripAside]);// The running turn's summary line (WorkingStrip): inside the composer section, right above the box.const { byBot: budgetsByBot } = useBudgets();const chatBudget = budgetBotId ? budgetsByBot[budgetBotId] : undefined;@@ -2827,7 +2846,10 @@ export const ChatView: React.FC<ChatViewProps> = ({{budgetBanner}{workingStrip}{/* 22i: below the working line, right above the box (design.md §2 order). */}- {needsYouStrip}+ {/* 29w: it steps aside (instantly, kept mounted) while it only repeats the approval card on screen. */}+ <div ref={stripSlotRef} className={stripAside ? 'hidden' : 'contents'} data-needs-you-slot={stripAside ? 'aside' : 'shown'} onFocus={(e) => (stripHadFocusRef.current = (e.target as HTMLElement).matches(':focus-visible'))} onBlur={() => (stripHadFocusRef.current = false)}>+ {needsYouStrip}+ </div><formonSubmit={handleSubmit}diff --git a/frontend/tests/askHere.test.mjs b/frontend/tests/askHere.test.mjsindex eaf7a6ed..901b538d 100644--- a/frontend/tests/askHere.test.mjs+++ b/frontend/tests/askHere.test.mjs@@ -603,3 +603,67 @@ test('pinned row tooltip: a Home Assistant lock ask says the card sentence too',const d = new DOMParser().parseFromString(`<body>${html}</body>`, 'text/html');assert.equal(d.querySelector('#pin-tip-house span:last-child').textContent, 'House wants to unlock Front door');});++// 29w (brief: autonomy/needs-you-strip-steps-aside/brief.md): while the chat's only ask is a live approval and its+// card's Allow / Deny row is fully on screen, the Needs-you strip steps aside (it would only repeat the card).+const live = { id: 'ap1', kind: 'approval', kwant_id: 'k1', kwant_name: 'Mia', title: 'Mia wants to run a command', timestamp: '2026-11-19T09:00:00Z' };+const asideWhen = ({ asks, cardInView }) => cardInView && m.onlyLiveApproval(asks);++test('29w: one live approval with its card in view: the strip steps aside; card scrolled off: it is back', () => {+ assert.equal(typeof m.onlyLiveApproval, 'function');+ assert.equal(m.onlyLiveApproval([live]), true);+ assert.equal(m.onlyLiveApproval([{ ...live, action: 'decide' }]), true);+ assert.equal(asideWhen({ asks: [live], cardInView: true }), true);+ assert.equal(asideWhen({ asks: [live], cardInView: false }), false);+});++test('29w: an approval plus a second ask, a run-out approval, or no asks: the strip is not hidden', () => {+ const q = { id: 'q1', kind: 'question', kwant_id: 'k1', title: 'Which folder?', timestamp: '2026-11-19T09:01:00Z' };+ const ranOut = { id: 's1', kind: 'stopped', kwant_id: 'k1', title: 'Approval ran out', retry: { type: 'approval', approval_id: 'ap0' }, timestamp: '2026-11-19T09:00:00Z' };+ assert.equal(m.onlyLiveApproval([live, q]), false);+ assert.equal(m.onlyLiveApproval([live, { ...live, id: 'ap2' }]), false);+ assert.equal(m.onlyLiveApproval([ranOut]), false);+ assert.equal(m.onlyLiveApproval([{ ...live, action: 'ask_again' }]), false);+ assert.equal(m.onlyLiveApproval([q]), false);+ assert.equal(m.onlyLiveApproval([]), false);+ assert.equal(asideWhen({ asks: [live, q], cardInView: true }), false);+ assert.equal(asideWhen({ asks: [ranOut], cardInView: true }), false);+});++test('29w: App passes stripOnlyApproval; ChatView keeps approvalCardInView from the same measurement and gates the strip', () => {+ const app = readFileSync(new URL('../src/App.tsx', import.meta.url), 'utf8');+ const chat = readFileSync(new URL('../src/components/ChatView.tsx', import.meta.url), 'utf8');+ assert.match(app, /stripOnlyApproval=\{onlyLiveApproval\(asks\)\}/);+ // Set in checkApprovalVisible from the same buttonsVisible the "Approval waiting" pill uses: no new listeners.+ const check = chat.slice(chat.indexOf('const checkApprovalVisible'), chat.indexOf('const onScroll'));+ assert.match(check, /const buttonsVisible = rows\.some\(\(r\) => fullyVisible\(/);+ assert.match(check, /setApprovalCardInView\(buttonsVisible\)/);+ assert.match(chat, /const stripAside = stripStepsAside\(\{ strip: !!needsYouStrip, onlyApproval: stripOnlyApproval, cardInView: approvalCardInView, followingCard \}\);/);+ // Round 3 (Rigel): followingCard comes from the same measurement, after onScroll has updated stickRef.+ assert.match(check, /setFollowingCard\(stickRef\.current && rows\.length > 0\)/);+ // Kept mounted (no re-enter animation, its state stays) and hidden at once: no new motion.+ assert.match(chat, /className=\{stripAside \? 'hidden' : 'contents'\}.*\n\s*\{needsYouStrip\}\n\s*<\/div>/);+ assert.doesNotMatch(chat, /\n\s*\{needsYouStrip\}\n\n\s*<form/);+ // Round 2 (Mira): only keyboard focus hands off to the composer; a tap (Android focuses the button) must not+ // raise the soft keyboard over Allow / Deny.+ assert.match(chat, /onFocus=\{\(e\) => \(stripHadFocusRef\.current = \(e\.target as HTMLElement\)\.matches\(':focus-visible'\)\)\}/);+ assert.doesNotMatch(chat, /stripHadFocusRef\.current = true/);+});++// Round 3 (Rigel's QA at 6168ce1b): bringing the strip back within the follow zone shrank the chat, the follow pin+// snapped to the bottom, the card was in view again and the strip hid: a slow scroll up could not leave the bottom.+test('29w: while the chat follows the bottom with the card in it, the strip stays aside; past the follow zone it is back', () => {+ const base = { strip: true, onlyApproval: true };+ assert.equal(typeof m.stripStepsAside, 'function');+ // At the bottom: card in view.+ assert.equal(m.stripStepsAside({ ...base, cardInView: true, followingCard: true }), true);+ // 32 px up: the buttons are clipped but the chat still follows: stays aside (was: back, then snapped down).+ assert.equal(m.stripStepsAside({ ...base, cardInView: false, followingCard: true }), true);+ // Past 80 px up: no longer following, buttons off screen: back.+ assert.equal(m.stripStepsAside({ ...base, cardInView: false, followingCard: false }), false);+ // Read up with the card still fully in view: aside, as before.+ assert.equal(m.stripStepsAside({ ...base, cardInView: true, followingCard: false }), true);+ // Never aside without a strip, or when the ask is not one live approval.+ assert.equal(m.stripStepsAside({ ...base, strip: false, cardInView: true, followingCard: true }), false);+ assert.equal(m.stripStepsAside({ ...base, onlyApproval: false, cardInView: true, followingCard: true }), false);+});diff --git a/frontend/tests/mobileCards.test.mjs b/frontend/tests/mobileCards.test.mjsindex 9be3898f..0ad7d597 100644--- a/frontend/tests/mobileCards.test.mjs+++ b/frontend/tests/mobileCards.test.mjs@@ -238,7 +238,8 @@ test('ChatView puts the strip inside the composer section, right above the box,assert.ok(src.indexOf('aria-label="Ask a member"', sectionAt) < at, 'below the Ask chips');// 22i (design.md §2): the Needs-you strip sits between the working line and the box, nothing elseconst between = src.slice(at + '{workingStrip}'.length, formAt).replace(/\{\/\*[\s\S]*?\*\/\}/g, '').trim();- assert.equal(between, '{needsYouStrip}', 'directly above the box, under the Needs-you strip');+ // 29w: inside its slot, which only hides it while it repeats the approval card on screen.+ assert.match(between, /^<div ref=\{stripSlotRef\}[^\n]*data-needs-you-slot[^\n]*>\s*\{needsYouStrip\}\s*<\/div>$/, 'directly above the box, under the Needs-you strip');assert.doesNotMatch(src, /\{!?phone && workingStrip\}/, 'no layout-specific place (Rigel: 390 sat outside the section)');assert.equal(src.split('{workingStrip}').length - 1, 1, 'rendered once');assert.equal(src.match(/<WorkingStrip\b/g).length, 1, 'one element');