Skip to content

feat: add reusable terminal helix visualizer module#21

Merged
jkbennitt merged 4 commits into
dev/phase-2from
feat/visualization
Mar 21, 2026
Merged

feat: add reusable terminal helix visualizer module#21
jkbennitt merged 4 commits into
dev/phase-2from
feat/visualization

Conversation

@jkbennitt
Copy link
Copy Markdown
Member

@jkbennitt jkbennitt commented Mar 21, 2026

Summary

  • Adds src/felix_agent_sdk/visualization/ module with HelixVisualizer for real-time ASCII rendering of agents progressing down the helix
  • Extracts and generalizes the 2D projection, ANSI rendering, and canvas patterns from examples/05_deep_research_live/ into a reusable SDK component
  • State-based API: register_agent()update()render() with live() context manager for terminal cleanup

What it does

Renders a terminal-based helix showing agent positions, phase boundaries (exploration/analysis/synthesis), animated backbone, per-agent sidebar with confidence bars, and team confidence footer. Works on Windows (pure ANSI, no curses). Respects NO_COLOR/FORCE_COLOR env vars.

Files

File Lines Purpose
visualization/__init__.py 18 Exports HelixVisualizer, AgentDisplayState
visualization/terminal.py 101 ANSI primitives: colors, cursor, progress bars
visualization/helix_visualizer.py 485 Core visualizer: canvas, projection, sidebar, animation
tests/unit/test_helix_visualizer.py 206 23 tests covering registration, rendering, NO_COLOR, dimensions
__init__.py +3 Added HelixVisualizer to top-level exports

Usage

from felix_agent_sdk import HelixVisualizer
from felix_agent_sdk.core.helix import HelixConfig

viz = HelixVisualizer(HelixConfig.default().to_geometry())
viz.register_agent("resource_mgr", label="RM", color="green")
viz.update("resource_mgr", progress=0.3, confidence=0.82)
viz.render(tick=47, day=12)

Test plan

  • pytest tests/unit/test_helix_visualizer.py -v — 23 tests pass
  • pytest tests/ -v — 686 total pass, no regressions
  • ruff check src/felix_agent_sdk/visualization/ — clean
  • Manual smoke test with multiple agents rendering in a loop
  • @CalebisGross review

🤖 Generated with Claude Code

@CalebisGross
Copy link
Copy Markdown
Contributor

Ran the gates locally -- couple small things before merging:

  • tests/unit/test_helix_visualizer.py has an unused import os (ruff F401)
  • helix_visualizer.py and the test file need a ruff format pass

mypy is clean, all 23 tests pass. Should be a quick fix.

@jkbennitt
Copy link
Copy Markdown
Member Author

Fixed both items — removed the unused import os and ran ruff format on both files. 23 tests pass, lint clean. Ready for re-review. (2680e73)

CalebisGross
CalebisGross previously approved these changes Mar 21, 2026
Copy link
Copy Markdown
Contributor

@CalebisGross CalebisGross left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gates pass, code is clean. Ship it.

@CalebisGross
Copy link
Copy Markdown
Contributor

Nit: _COLOR_MAP in helix_visualizer.py duplicates the ANSI constants from terminal.py. Could consolidate into a single lookup, but not a big deal.

@jkbennitt
Copy link
Copy Markdown
Member Author

Consolidated _COLOR_MAP into terminal.py as COLOR_MAP, built from the existing ANSI constants instead of re-hardcoding them. (65f5965)

@CalebisGross
Copy link
Copy Markdown
Contributor

CalebisGross commented Mar 21, 2026

Nice, that's the good stuff.

jkbennitt and others added 3 commits March 21, 2026 01:32
Extract and generalize the demo helix visualizer from
examples/05_deep_research_live/ into a proper SDK module at
src/felix_agent_sdk/visualization/. The new module provides:

- terminal.py: ANSI color primitives, cursor control, progress bars
- helix_visualizer.py: HelixVisualizer class with agent registration,
  live update, sidebar panel, phase boundaries, and team confidence
- AgentDisplayState dataclass for per-agent rendering state
- Exported via top-level __init__.py as HelixVisualizer

Includes 23 unit tests covering registration, update, rendering,
NO_COLOR support, context manager, and dimension customization.
All 686 tests pass, ruff clean.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Addresses review feedback from @CalebisGross:
- Remove unused `import os` in test file (ruff F401)
- Apply `ruff format` to helix_visualizer.py and test file

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Move the colour-name → ANSI-code mapping from helix_visualizer.py
into terminal.py as COLOR_MAP, eliminating duplicated constants.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jkbennitt jkbennitt force-pushed the feat/visualization branch from 65f5965 to 00e4501 Compare March 21, 2026 05:33
Wire the HelixVisualizer into all four features that landed on dev/phase-2:

- Event bus: attach_event_bus() auto-registers agents on AGENT_SPAWNED,
  updates progress on AGENT_POSITION_UPDATED, marks DONE/FAILED
- Streaming: VisualizerStreamHandler shows live token count in sidebar
- Spawning: set_monitor() displays confidence trend and spawn
  recommendation in the footer
- CLI: felix run --visualize / -V flag for live helix during workflows

31 visualizer tests pass (23 existing + 8 new). 823 total tests pass.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jkbennitt
Copy link
Copy Markdown
Member Author

Updated — visualizer now integrates with all four dev/phase-2 features:

  • Events: attach_event_bus() auto-registers agents on AGENT_SPAWNED, updates on AGENT_POSITION_UPDATED, marks DONE/FAILED
  • Streaming: VisualizerStreamHandler shows live token count in the sidebar
  • Spawning: set_monitor() adds confidence trend (↑↓→) and spawn recommendation to footer
  • CLI: felix run config.yaml --visualize for live helix during workflows

Rebased on latest dev/phase-2 (includes CLI, dynamic spawning, streaming, events). 823 tests pass, 31 visualizer-specific. (94b4189)

@jkbennitt jkbennitt changed the base branch from main to dev/phase-2 March 21, 2026 05:54
@jkbennitt jkbennitt merged commit 334315e into dev/phase-2 Mar 21, 2026
4 checks passed
@jkbennitt jkbennitt deleted the feat/visualization branch March 21, 2026 05:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants