Skip to content

[codex] Add archived session controls to web UI#702

Merged
penso merged 5 commits intomainfrom
automatic-kookaburra
Apr 13, 2026
Merged

[codex] Add archived session controls to web UI#702
penso merged 5 commits intomainfrom
automatic-kookaburra

Conversation

@penso
Copy link
Copy Markdown
Collaborator

@penso penso commented Apr 13, 2026

Summary

Add session archiving for regular web chat sessions.

The root cause was that session metadata already had an archived field in storage, but the gateway list and patch paths did not expose or mutate it, and the web UI had no way to hide, reveal, archive, or unarchive sessions.

This PR wires archived through the gateway and sidebar flows, adds archive/unarchive controls in the chat session actions, hides archived sessions by default, adds a sidebar toggle to show them again, and keeps session search aligned with the current archived visibility filter. It also documents the new UI behavior and adds targeted Rust and E2E coverage.

Closes #701.

Validation

Completed

  • just format
  • cargo test -p moltis-sessions metadata::tests::
  • cargo test -p moltis-gateway patch_archived
  • just ui-e2e-install

Remaining

  • just lint
  • npx playwright test e2e/specs/sessions.spec.js -g "archived sessions are hidden by default and can be restored with the sidebar toggle"

The Playwright run was started, but the Rust web server boot path exceeded the repo's 5 minute command limit before the targeted test actually executed, so it was stopped rather than left hanging.

Manual QA

  1. Open the chat UI and create a regular non-channel session.
  2. Open More controls and click Archive.
  3. Confirm the UI switches back to main and the archived session disappears from the default sidebar list.
  4. Enable Show archived sessions in the sidebar and confirm the archived session reappears.
  5. Open the archived session, use Unarchive, then disable Show archived sessions and confirm the session remains visible.
  6. Confirm main, cron sessions, and channel-bound sessions do not offer archive controls.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 13, 2026

Greptile Summary

This PR wires the pre-existing archived field through the gateway patch/list/search paths and adds archive/unarchive controls to the web sidebar, including a "Show archived sessions" toggle and search alignment. The backend guard, metadata layer, and test coverage are solid.

  • P1 – session-list.js: The showArchived filter is only applied to the "sessions" tab; the "cron" tab branch has no corresponding guard, so archived cron sessions remain permanently visible and the "Show archived sessions" toggle (hidden while on that tab) offers no escape hatch.
  • P2 – default_channel_session_key: The helper is now duplicated verbatim in both service.rs and templates.rs — any future format change will need to be applied in two places.

Confidence Score: 4/5

Safe to merge after fixing the cron tab filter; the P1 means archiving a cron session produces no visible effect.

One P1 defect: archived cron sessions are not filtered from the cron tab, making the Archive button misleading for cron sessions. All other work — backend guard, metadata layer, search alignment, session-list filtering for the sessions tab, tests — is solid and well-covered.

crates/web/src/assets/js/components/session-list.js — missing archived filter in the cron tab branch

Important Files Changed

Filename Overview
crates/gateway/src/session/service.rs Adds archive guard to patch, exposes archived in list/get responses, and extracts is_current_channel_session/is_archivable_entry helpers; duplicates default_channel_session_key already in templates.rs.
crates/gateway/src/session/tests.rs Comprehensive tests for archive/unarchive guard, partial-mutation rejection, cron allowance, non-current channel allowance, search filtering, and orphaned-metadata fallback.
crates/web/src/assets/js/components/session-list.js Adds showArchived filter to the "sessions" tab only; the "cron" tab branch is missing the same filter, so archived cron sessions remain permanently visible there.
crates/web/src/assets/js/components/session-header.js Adds showArchive/onBeforeArchive props and onArchive callback with optimistic state update; correctly checks canArchive and isArchivableSession.
crates/web/src/templates.rs Adds archived to the gon snapshot; refactors active-channel detection to use default_channel_session_key — but that helper is a duplicate of the one in service.rs.

Reviews (5): Last reviewed commit: "fix(sessions): allow unarchiving active ..." | Re-trigger Greptile

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 13, 2026

Codecov Report

❌ Patch coverage is 88.09524% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/web/src/templates.rs 0.00% 7 Missing ⚠️
crates/gateway/src/session/service.rs 93.33% 2 Missing ⚠️
crates/gateway/src/session/maintenance.rs 94.73% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@codspeed-hq
Copy link
Copy Markdown
Contributor

codspeed-hq bot commented Apr 13, 2026

Merging this PR will not alter performance

✅ 39 untouched benchmarks
⏩ 5 skipped benchmarks1


Comparing automatic-kookaburra (b60d278) with main (34982a8)

Open in CodSpeed

Footnotes

  1. 5 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@penso
Copy link
Copy Markdown
Collaborator Author

penso commented Apr 13, 2026

Addressed the review feedback in cace18d5:

  • moved the archivability guard in sessions.patch ahead of any metadata writes, so a rejected archive request cannot partially mutate label or model
  • added a regression test for that failure mode in crates/gateway/src/session/tests.rs
  • added set_archived to the metadata version-increment test and a gateway search test that covers archived filtering in maintenance.rs
  • cleaned up the SQLite set_archived binding to use a separate val binding for consistency

Validation run after the fix:

  • just format
  • cargo test -p moltis-sessions test_version_increments_on_mutation
  • cargo test -p moltis-gateway patch_archived_
  • cargo test -p moltis-gateway search_excludes_archived_sessions_unless_requested
  • just lint

@penso penso marked this pull request as ready for review April 13, 2026 21:10
@penso
Copy link
Copy Markdown
Collaborator Author

penso commented Apr 13, 2026

Addressed the latest search review feedback in a82ae916:

  • sessions.search now preserves hits whose JSONL session exists but whose metadata row is missing
  • missing metadata falls back to label: null and archived: false, which restores the previous behavior while keeping archived filtering for real metadata rows
  • added a regression test for metadata-less search results

Validation run:

  • just format
  • cargo test -p moltis-gateway search_excludes_archived_sessions_unless_requested
  • cargo test -p moltis-gateway search_includes_results_without_metadata_rows

@penso
Copy link
Copy Markdown
Collaborator Author

penso commented Apr 13, 2026

Addressed the latest archive-guard feedback in b60d2784:

  • sessions.patch now blocks only archive operations (archived: true) for non-archivable sessions, not unarchive operations
  • this preserves the safety rule for active channel sessions while keeping recovery possible if one is already archived
  • the web helper now mirrors that behavior by allowing Unarchive for archived active-channel sessions
  • added a gateway regression test and focused browser coverage for the client-side gate

Validation run:

  • just format
  • cargo test -p moltis-gateway patch_archived_
  • biome check --write crates/web/src/assets/js/sessions.js crates/web/ui/e2e/specs/sessions.spec.js
  • npx playwright test e2e/specs/sessions.spec.js -g "current channel session is not archivable in the client helper|current archived channel session remains archivable for unarchive in the client helper"

@penso penso merged commit e2c6e2c into main Apr 13, 2026
25 of 34 checks passed
@penso penso deleted the automatic-kookaburra branch April 13, 2026 21:53
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.

[Feature]: Add ability to archive sessions/conversations

1 participant