Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

1.3 KB
Raw Blame
/**
 * The fold every replay-family board slot (ADR-461) opens with: the page already draws the slot's rule, so the body is one
 * line and a button while it is closed (the page stays short), the full body once opened. Kept per slot id for the session.
 */
import type { RenderElement } from 'claude-code'

import { button, row, text, type Ctx } from './common'

const open = new Set<string>()

/** For tests. */
export const resetFolds = (): void => open.clear()

/** The closed line and its button, or the opened body under a "close" button. `redraw` runs after the flip. */
export function fold(ctx: Ctx, id: string, summary: string, body: () => RenderElement[]): RenderElement[] {
  const isOpen = open.has(id)
  const flip = (): void => {
    if (isOpen) open.delete(id)
    else open.add(id)
    ctx.act.workflows.setUi({})
  }

  return isOpen
    ? [row(ctx, [button(ctx, `wf-${id}-fold`, 'â–¾ close', flip), text(ctx, ` ${summary}`, { dimColor: true })], `wf-${id}-head`), ...body()]
    : [row(ctx, [button(ctx, `wf-${id}-fold`, 'â–¸ open', flip), text(ctx, ` ${summary}`, { dimColor: true })], `wf-${id}-head`)]
}

/** Asks the page to draw again (merging an empty change into the cursor invalidates the frame). */
export const redraw = (ctx: Ctx): void => ctx.act.workflows.setUi({})