feat(tui): implement session export/import (JSON + Markdown) #1004

Closed
opened 2026-03-17 01:10:22 +00:00 by brent.edwards · 8 comments
Member

Session export/import in JSON and Markdown formats.

Dependencies

  • Parent: #868 (Epic: TUI Interface)
  • Tracked by: #926
Session export/import in JSON and Markdown formats. ## Dependencies - Parent: #868 (Epic: TUI Interface) - Tracked by: #926
brent.edwards added this to the v3.7.0 milestone 2026-03-17 01:11:48 +00:00
Author
Member

Implemented in PR #1244.

What changed:

  • Added TUI router support for /session:export and /session:import, including session:... colon aliases.
  • /session:export now supports JSON (default) and Markdown (--format md) output.
  • Added safe relative-path handling for export/import file paths.
  • Wired SessionService into run_tui() command router construction.
  • Updated slash catalog description for session:export to reflect JSON/Markdown support.
  • Expanded Behave coverage for session alias, export, import, and invalid JSON failure cases.
  • Added Robot smoke coverage for TUI session export/import command flow.

Validation run:

  • nox -s lint
  • nox -s typecheck unit_tests -- features/tui_commands_coverage.feature
  • PYTHONPATH=src NO_COLOR=1 .nox/integration_tests-3-13/bin/robot --outputdir build/reports/robot-smoke --variable PYTHON:/tmp/issue-1004/.nox/integration_tests-3-13/bin/python robot/tui_smoke.robot
  • nox -s coverage_report (COVERAGE OK: 98.6% >= 97% threshold)

Commit:

  • fc1c5b65 feat(tui): add session export/import command support
Implemented in PR #1244. What changed: - Added TUI router support for `/session:export` and `/session:import`, including `session:...` colon aliases. - `/session:export` now supports JSON (default) and Markdown (`--format md`) output. - Added safe relative-path handling for export/import file paths. - Wired `SessionService` into `run_tui()` command router construction. - Updated slash catalog description for `session:export` to reflect JSON/Markdown support. - Expanded Behave coverage for session alias, export, import, and invalid JSON failure cases. - Added Robot smoke coverage for TUI session export/import command flow. Validation run: - `nox -s lint` - `nox -s typecheck unit_tests -- features/tui_commands_coverage.feature` - `PYTHONPATH=src NO_COLOR=1 .nox/integration_tests-3-13/bin/robot --outputdir build/reports/robot-smoke --variable PYTHON:/tmp/issue-1004/.nox/integration_tests-3-13/bin/python robot/tui_smoke.robot` - `nox -s coverage_report` (COVERAGE OK: 98.6% >= 97% threshold) Commit: - `fc1c5b65` feat(tui): add session export/import command support
freemo self-assigned this 2026-04-02 06:14:02 +00:00
Owner

Implementation Complete — PR #1269 created

All subtasks implemented and quality gates passed.

What was implemented

New file: src/cleveragents/domain/models/core/session_markdown.py

  • render_session_markdown(session) — renders a Session as a Markdown document (metadata table, messages, token usage, linked plans)
  • build_session_from_export_dict(export_data) — reconstructs a Session from an export dict for Markdown rendering

Modified: src/cleveragents/domain/models/core/session.py

  • Added Session.as_markdown_export() method that delegates to render_session_markdown()

Modified: src/cleveragents/cli/commands/session.py

  • Extended agents session export with --format/-f option: json (default, re-importable) or markdown (human-readable)
  • Added _export_as_markdown() helper that hydrates a full Session from the export dict and renders Markdown

New file: features/session_export_markdown.feature + features/steps/session_export_markdown_steps.py

  • 10 Behave scenarios: Markdown export to stdout/file, --force overwrite, invalid format rejection, domain method structure, JSON round-trip

Quality gates

  • nox -s lint — all checks passed
  • nox -s typecheck — 0 errors, 0 warnings
  • nox -s unit_tests -- features/session_export_markdown.feature — 10/10 scenarios passed
  • Session CLI + service + persistence tests — 62 scenarios passed

PR: #1269

## Implementation Complete — PR #1269 created All subtasks implemented and quality gates passed. ### What was implemented **New file: `src/cleveragents/domain/models/core/session_markdown.py`** - `render_session_markdown(session)` — renders a Session as a Markdown document (metadata table, messages, token usage, linked plans) - `build_session_from_export_dict(export_data)` — reconstructs a Session from an export dict for Markdown rendering **Modified: `src/cleveragents/domain/models/core/session.py`** - Added `Session.as_markdown_export()` method that delegates to `render_session_markdown()` **Modified: `src/cleveragents/cli/commands/session.py`** - Extended `agents session export` with `--format`/`-f` option: `json` (default, re-importable) or `markdown` (human-readable) - Added `_export_as_markdown()` helper that hydrates a full Session from the export dict and renders Markdown **New file: `features/session_export_markdown.feature`** + **`features/steps/session_export_markdown_steps.py`** - 10 Behave scenarios: Markdown export to stdout/file, `--force` overwrite, invalid format rejection, domain method structure, JSON round-trip ### Quality gates - ✅ `nox -s lint` — all checks passed - ✅ `nox -s typecheck` — 0 errors, 0 warnings - ✅ `nox -s unit_tests -- features/session_export_markdown.feature` — 10/10 scenarios passed - ✅ Session CLI + service + persistence tests — 62 scenarios passed PR: https://git.cleverthis.com/cleveragents/cleveragents-core/pulls/1269
Owner

PR #1269 reviewed — changes requested.

Independent code review found a correctness bug: build_session_from_export_dict() in session_markdown.py does not pass created_at/updated_at from the export dict to the Session constructor, causing Markdown exports to show the current time instead of the original session timestamps. Also flagged missing argument validation per CONTRIBUTING.md §Argument Validation.

See PR #1269 review comment for full details and suggested fixes.

**PR #1269 reviewed — changes requested.** Independent code review found a correctness bug: `build_session_from_export_dict()` in `session_markdown.py` does not pass `created_at`/`updated_at` from the export dict to the Session constructor, causing Markdown exports to show the current time instead of the original session timestamps. Also flagged missing argument validation per CONTRIBUTING.md §Argument Validation. See [PR #1269 review comment](https://git.cleverthis.com/cleveragents/cleveragents-core/pulls/1269#issuecomment-76890) for full details and suggested fixes.
Owner

[Backlog Groomer - groomer-1] ⚠️ PR state inconsistency detected. PR #1244 (feat(tui): add session export/import command support) is open but this issue has State/In Review. Additionally, PR #1269 (feat(tui): implement session export/import (JSON + Markdown)) was closed without merging at 2026-04-02T16:22Z. Please verify which PR covers this issue and ensure it is properly linked.

**[Backlog Groomer - groomer-1]** ⚠️ **PR state inconsistency detected.** PR #1244 (`feat(tui): add session export/import command support`) is open but this issue has `State/In Review`. Additionally, PR #1269 (`feat(tui): implement session export/import (JSON + Markdown)`) was **closed without merging** at 2026-04-02T16:22Z. Please verify which PR covers this issue and ensure it is properly linked.
Owner

PR #1244 Review Outcome: Changes Requested

PR #1244 (feat(tui): add session export/import command support) has been reviewed. The code quality is good — well-structured implementation with proper type annotations, security-conscious path handling, and meaningful BDD + Robot test coverage.

However, two blocking issues prevent merge:

  1. Merge conflicts with master in CHANGELOG.md and robot/tui_smoke.robot — needs rebase
  2. Empty PR body — needs description with Closes #1004 per CONTRIBUTING.md

One minor code improvement was also requested (catching SessionExportError in the export handler).

Note: PR #1269 (the other PR for this issue) was closed without merge, so #1244 is the active implementation.

Full review details: #1244 (comment)

**PR #1244 Review Outcome: Changes Requested** PR #1244 (`feat(tui): add session export/import command support`) has been reviewed. The code quality is good — well-structured implementation with proper type annotations, security-conscious path handling, and meaningful BDD + Robot test coverage. However, two blocking issues prevent merge: 1. **Merge conflicts** with `master` in `CHANGELOG.md` and `robot/tui_smoke.robot` — needs rebase 2. **Empty PR body** — needs description with `Closes #1004` per CONTRIBUTING.md One minor code improvement was also requested (catching `SessionExportError` in the export handler). Note: PR #1269 (the other PR for this issue) was closed without merge, so #1244 is the active implementation. Full review details: https://git.cleverthis.com/cleveragents/cleveragents-core/pulls/1244#issuecomment-78051
Owner

PR #1392 reviewed, approved, and merged. Session export/import with JSON and Markdown formats is now implemented, including TUI slash command routing and 16 Behave test scenarios.

PR #1392 reviewed, approved, and merged. Session export/import with JSON and Markdown formats is now implemented, including TUI slash command routing and 16 Behave test scenarios.
Owner

PR #1244 Review Outcome: Changes Requested (Superseded)

PR #1244 (feat(tui): add session export/import command support) has been reviewed and marked as superseded. PR #1392 was already merged and resolved this issue. PR #1244 should be closed without merge to avoid duplicate/conflicting code.

The code quality in PR #1244 was good — well-structured, properly typed, with meaningful test coverage — but it is no longer needed.

**PR #1244 Review Outcome: Changes Requested (Superseded)** PR #1244 (`feat(tui): add session export/import command support`) has been reviewed and marked as superseded. PR #1392 was already merged and resolved this issue. PR #1244 should be closed without merge to avoid duplicate/conflicting code. The code quality in PR #1244 was good — well-structured, properly typed, with meaningful test coverage — but it is no longer needed.
Owner

PR #1244 has been reviewed and closed without merge — it is superseded by PR #1392, which was already merged and resolved this issue. No duplicate code was introduced.

PR #1244 has been reviewed and **closed without merge** — it is superseded by PR #1392, which was already merged and resolved this issue. No duplicate code was introduced.
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#1004
No description provided.