Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion ui-tui/src/__tests__/appChromeStatusRule.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import { describe, expect, it, vi } from 'vitest'

import { StatusRule } from '../components/appChrome.js'
import { StatusRule, subagentPulseColor } from '../components/appChrome.js'
import { DEFAULT_THEME } from '../theme.js'

type ReactNodeLike = React.ReactNode
Expand Down Expand Up @@ -105,6 +105,12 @@ const baseProps = {
}

describe('StatusRule background-subagent indicator', () => {
it('alternates the pulse between muted and accent colors', () => {
expect(subagentPulseColor(0, DEFAULT_THEME)).toBe(DEFAULT_THEME.color.muted)
expect(subagentPulseColor(1, DEFAULT_THEME)).toBe(DEFAULT_THEME.color.accent)
expect(subagentPulseColor(2, DEFAULT_THEME)).toBe(DEFAULT_THEME.color.muted)
})

it('renders ⛓ N on a wide terminal when subagents are running', () => {
const element = StatusRule({
...baseProps,
Expand Down
18 changes: 17 additions & 1 deletion ui-tui/src/components/appChrome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ import type { Msg, Usage } from '../types.js'
import { scrollbarColors } from './overlayPrimitives.js'

const FACE_TICK_MS = 2500
const SUBAGENT_PULSE_MS = 700
const HEART_COLORS = ['#ff5fa2', '#ff4d6d']

export const subagentPulseColor = (tick: number, t: Theme) => (tick % 2 === 0 ? t.color.muted : t.color.accent)

// Keep verb segment width stable so status-bar content to the right doesn't
// jitter when the ticker rotates between short/long verbs.
export const VERB_PAD_LEN = VERBS.reduce((max, v) => Math.max(max, v.length), 0) + 1 // + ellipsis
Expand Down Expand Up @@ -432,6 +435,18 @@ export function GoodVibesHeart({ tick, t }: { tick: number; t: Theme }) {
return <Text color={color}>♥</Text>
}

function SubagentPulse({ children, t }: { children: ReactNode; t: Theme }) {
const [tick, setTick] = useState(0)

useEffect(() => {
const id = setInterval(() => setTick(n => n + 1), SUBAGENT_PULSE_MS)

return () => clearInterval(id)
}, [])

return <Text color={subagentPulseColor(tick, t)}>{children}</Text>
}

export function StatusRule({
battery,
focusView,
Expand Down Expand Up @@ -692,7 +707,8 @@ export function StatusRule({
) : null}
{showSubagents ? (
<Text color={t.color.muted} wrap="truncate-end">
{' │ '}⛓ {subagentCount}
{' │ '}
<SubagentPulse t={t}>⛓</SubagentPulse> {subagentCount}
</Text>
) : null}
{showResumeHint ? (
Expand Down
Loading