Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:AIScientists Dev WorldSeed stream store

From Leeroopedia
Knowledge Sources
Domains Frontend, State_Management
Last Updated 2026-10-26 18:00 GMT

Overview

Concrete Zustand store for live event stream records with view-mode filtering, sub-filter presets, and agent text merging, provided by the WorldSeed frontend.

Description

The useStreamStore holds `streamRecords`, connection status, view mode (`chapters`/`all`), sub-filter (`digest`/`story`/`all`), kind filter, hidden kinds, agent filter, and agent texts. `pushRecord` appends to the stream. `computeStreamFilteredRecords` is the derived-data function: it applies sub-filter hidden kinds, exclusive kind filtering, admin scope filtering, failed-action hiding (story/digest), user-toggled hidden kinds, agent filtering, agent text merging (interleaving agent text responses by timestamp), and system agent hiding. `computeStreamGroups` groups records by tick. View mode and sub-filter are persisted to localStorage.

Usage

Import `useStreamStore`, `computeStreamFilteredRecords`, and `computeStreamGroups` from StreamPanel and other stream display components. Use `pushRecord` from the SSE handler.

Code Reference

Source Location

  • Repository: WorldSeed
  • File: frontend/src/stores/stream.ts

Signature

export const useStreamStore = create<StreamState & StreamActions>((set, get) => ({
  streamRecords: StreamRecord[];
  streamConnected: boolean;
  streamViewMode: StreamViewMode;
  streamSubFilter: StreamSubFilter;
  pushRecord: (rec: any) => void;
  setSubFilter: (filter: StreamSubFilter) => void;
  // ...
}));

export function computeStreamFilteredRecords(
  streamRecords: StreamRecord[], streamKindFilter: string,
  agentTexts: AgentText[], viewMode?: StreamViewMode,
  agentFilter?: string, hiddenKinds?: string[],
  subFilter?: StreamSubFilter, systemAgents?: string[],
): StreamRecord[];

export function computeStreamGroups(records: StreamRecord[]): { tick: number; records: StreamRecord[] }[];

Import

import { useStreamStore, computeStreamFilteredRecords, computeStreamGroups } from '@/stores/stream';

I/O Contract

Inputs

Name Type Required Description
rec any Yes (pushRecord) │ Stream record from SSE
streamRecords StreamRecord[] Yes (compute) │ Raw records array
subFilter StreamSubFilter No │ View preset (digest/story/all)

Outputs

Name Type Description
computeStreamFilteredRecords returns StreamRecord[] │ Filtered + merged records
computeStreamGroups returns { tick, records }[] │ Records grouped by tick

Usage Examples

import { useStreamStore, computeStreamFilteredRecords, computeStreamGroups } from '@/stores/stream';

// In a component
const records = useStreamStore(s => s.streamRecords);
const subFilter = useStreamStore(s => s.streamSubFilter);
const filtered = useMemo(
  () => computeStreamFilteredRecords(records, '', agentTexts, 'all', '', [], subFilter, systemAgents),
  [records, subFilter],
);
const groups = computeStreamGroups(filtered);

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment