mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
Feat: transcript retention (#123)
* feat(retention): prune old agent transcripts + panel-tunable setting
Agents write a {session-id}.jsonl per spawn under ~/.claude/projects; nothing
ever deleted them, so the operator's bind-mounted ~/.claude grew without bound.
Add a throttled orchestrator sweep that prunes agent-owned transcripts (the
shared -app dir + per-workspace dirs) older than a retention window — and ONLY
agent-owned dirs, never the operator's own Claude sessions (proven by the
temp-dir selection tests). The window is panel-tunable: a new system_settings
key-value table (migration 027) holds transcript_retention_days, read via
SettingsService with the roboco.config default (14d) as the fallback, exposed
through GET/PUT /api/settings. Panel wiring follows.
* feat(panel): add a panel-tunable transcript retention control
Wire the settings page to the /api/settings backend: a settings API client and
a self-contained Transcript Retention card (React Query) that loads
transcript_retention_days and saves it back, with client-side validation. The
existing settings controls are unchanged.
---------
Co-authored-by: Renn F <rennf93@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
"""Tests for SettingsService + setting validation."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
import pytest
|
||||
from roboco.services.settings import (
|
||||
SettingValidationError,
|
||||
get_settings_service,
|
||||
validate_setting,
|
||||
)
|
||||
|
||||
|
||||
def test_validate_setting_rejects_unknown_key() -> None:
|
||||
with pytest.raises(SettingValidationError):
|
||||
validate_setting("not_a_real_setting", "x")
|
||||
|
||||
|
||||
def test_validate_retention_requires_positive_int() -> None:
|
||||
validate_setting("transcript_retention_days", "7") # ok, no raise
|
||||
with pytest.raises(SettingValidationError):
|
||||
validate_setting("transcript_retention_days", "0")
|
||||
with pytest.raises(SettingValidationError):
|
||||
validate_setting("transcript_retention_days", "abc")
|
||||
|
||||
|
||||
_DEFAULT_RETENTION = 14
|
||||
_NEW_RETENTION = 30
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_int_returns_default_when_unset(db_session: Any) -> None:
|
||||
svc = get_settings_service(db_session)
|
||||
assert (
|
||||
await svc.get_int("transcript_retention_days", _DEFAULT_RETENTION)
|
||||
== _DEFAULT_RETENTION
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_set_then_get_roundtrips(db_session: Any) -> None:
|
||||
svc = get_settings_service(db_session)
|
||||
await svc.set("transcript_retention_days", str(_NEW_RETENTION))
|
||||
assert (
|
||||
await svc.get_int("transcript_retention_days", _DEFAULT_RETENTION)
|
||||
== _NEW_RETENTION
|
||||
)
|
||||
assert (await svc.all())["transcript_retention_days"] == str(_NEW_RETENTION)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_set_rejects_invalid_value(db_session: Any) -> None:
|
||||
svc = get_settings_service(db_session)
|
||||
with pytest.raises(SettingValidationError):
|
||||
await svc.set("transcript_retention_days", "-5")
|
||||
Reference in New Issue
Block a user