Skip to content

feat(live): incremental /save and NL curation for cleaner recordings#327

Open
chinmayajha wants to merge 3 commits into
mainfrom
feat/live-save-and-nl-curation
Open

feat(live): incremental /save and NL curation for cleaner recordings#327
chinmayajha wants to merge 3 commits into
mainfrom
feat/live-save-and-nl-curation

Conversation

@chinmayajha

@chinmayajha chinmayajha commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

Two complementary improvements to the optics live workflow:

  1. Incremental /save with fixed filenames: /save <test_case> <module_name> now writes to standard files (modules/modules.csv, test_cases/test_cases.csv, elements/elements.csv) that APPEND when they exist. This enables building a test suite one module at a time without name confusion. If a name conflicts, you're prompted to choose a different one or confirm the append. The recording buffer is cleared after each /save so the next actions form the next module.

  2. NL-mode curation on completion: When an AI instruction finishes successfully, an extra LLM pass prunes the recorded steps to a minimal replayable script—dropping dead-ends, backtracks, and no-op gestures. If curation fails or produces no usable result, it safely falls back to keeping all successful steps.

Together, these make it practical to interactively build a clean test suite from AI-driven recordings, one focused module per instruction.

Test Plan

  • 10 new tests for /save workflow (append, conflicts, dedup, buffer clear)
  • 13 new tests for NL curation (prune, normalize, all fallback paths, LLM errors, toggle-off, failed-step handling)
  • All 290 existing unit tests pass (common + helpers)
  • Pre-commit (ruff, bandit) clean

Follow-up Work

Two enhancements identified for future PRs:

These would make AI-generated tests even more robust for CI/automation.

…onflicts

The /save command now takes two arguments: /save <test_case> <module_name>
and writes to fixed-name CSVs (modules/modules.csv, test_cases/test_cases.csv,
elements/elements.csv) that are APPENDED to when they already exist, enabling
a 'one module at a time' pitch workflow. If a name conflicts, the save is
refused with a prompt; re-running the identical /save confirms the append.

The recording buffer is cleared after each /save, so the next keywords form
the next module. This prevents cross-module duplication and enforces a clean
separation of concerns.

A header-only elements.csv stub is created if missing, so the standard file
structure is always present for manual editing.

Implements the user's requested workflow: build a test suite interactively,
one module per /save, without accidental clobbering or name confusion.
When an AI instruction completes (status='done'), run an extra text-only LLM
pass that prunes the recorded steps to the minimal subset reproducing the goal.
This drops the agent's dead-ends, backtracks (e.g., navigate then press back),
and no-op gestures—all of which report ok=True mechanically but don't contribute
to the outcome. The result is a clean, replayable test module, not a transcript
of every attempt.

Curation is behind a curate_on_done flag (default=False on NaturalLanguageAgent
to keep it a pure primitive; enabled in LiveController so /save gets a clean
script). Safe fallback: any curation error or unusable response falls back to
keeping all successful steps, so a working recording is never lost.

Incomplete runs (failed/exhausted/aborted) record nothing, as before.

Includes:
- CURATION_SCHEMA: flat JSON schema (Gemini-safe, no anyOf).
- _curate_successful_steps: text-only LLM call; validates indices; safely falls
  back to "keep all" on any anomaly.
- _build_curation_prompt: candidate successful steps numbered 1-based (mapping
  to state.successful indices); failed steps as non-selectable context.
- Tests: 13 new cases covering prune, normalisation, all fallback paths,
  LLM errors, skip conditions, toggle-off, and failed-step exclusion.

The "kept N of M steps" note appears in the NLSummary message so the TUI
shows pruning happened.
Comment thread tests/units/helpers/test_live_save.py Fixed
…s in test

The _Controller test class intentionally bypasses LiveController.__init__
since we're unit-testing save() without a real session. Add a noqa comment
and docstring to clarify this is deliberate.
@sonarqubecloud

sonarqubecloud Bot commented Jul 1, 2026

Copy link
Copy Markdown

pytestmark = pytest.mark.white_box


class _Controller(LiveController):
@chinmayajha chinmayajha self-assigned this Jul 1, 2026
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.

1 participant