Skip to content

Two follow-ups from #2227 v0.51.60 review: integration test gap + sidebar duplication after compression #2230

@nesquena-hermes

Description

@nesquena-hermes

Two follow-ups from the stage-353 / v0.51.60 Opus review of PR #2227 (compression-rotation data-loss fix for #2223). Neither blocked the release, but worth filing so they don't get lost.

1. Integration coverage gap on PR #2227

The 6 new tests in tests/test_issue2223_compression_no_rename.py are:

  • 3 static streaming_src grep checks (test_rename_call_removed, test_parent_session_id_stamped_on_continuation, test_old_session_preservation_logic_exists)
  • 3 unit tests targeting _merge_display_messages_after_agent_result() (a related but separate function)

There is no test that exercises the actual rotation block end-to-end — build a Session with N messages, stub agent.session_id = new_sid, invoke the rotation code, assert old_sid.json exists with N messages AND new_sid.json gets created on the subsequent s.save().

The grep tests catch removal-of-string but don't lock in behavior. Someone could re-introduce a different destructive op (e.g. os.unlink(old_path) or shutil.move) and all the grep checks would still pass.

Suggested fix: One integration test with tmp_path that:

  1. Creates a Session with N>1 messages and saves it as old_sid.json in the tmp SESSION_DIR
  2. Sets up s.session_id = old_sid then triggers the compression rotation block (or its extracted helper) with _agent_sid = new_sid
  3. Asserts old_sid.json still exists on disk after the rotation with all N messages intact
  4. Asserts new_sid.json is created and contains the post-compression state

Replace one of the static grep checks with this integration test. The other two grep checks still have value as "presence-of-fix" canaries.

2. Sidebar duplication after compression

After v0.51.60's fix, both old_sid.json and new_sid.json stay indexed in the sidebar. This matches /branch fork semantics (the old session becomes a permanent snapshot accessible via lineage traversal from the new one), but in a long-lived workspace with multiple compressions per session, the sidebar will accumulate snapshot entries.

_write_session_index fast path at api/models.py:158-160 keeps entries whose file exists on disk. The preservation block writes old_sid.json with skip_index=True, but the old entry was already in the index (it was the active session), so it stays.

Suggested fix path: Stamp s.archived = True on the preservation save so the snapshot stays out of the active sidebar but remains accessible via lineage traversal. The compression continuation new_sid would NOT inherit the archived flag (it's the new active session).

Alternative: add a new pre_compression_snapshot: True field on the snapshot and filter on it in the sidebar query, keeping archived semantics independent.

Worth discussing the right ownership model — for now this is just a future-proofing concern, not a user-reported problem.

Provenance

Metadata

Metadata

Assignees

No one assigned

    Labels

    trackingTracking issue for follow-up work

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions