Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
feat(workbench): project archive-recovery by path + session pagination (#375)
Call Whitefbfe4a6bf6bf
diff --git a/docs/plans/workbench-project-reuse-session-paging.md b/docs/plans/workbench-project-reuse-session-paging.mdnew file mode 100644index 000000000..17a996ab6--- /dev/null+++ b/docs/plans/workbench-project-reuse-session-paging.md@@ -0,0 +1,144 @@+# Workbench: project archive-recovery by path + session pagination++Branch: `feat/workbench-project-reuse-session-paging`++## Background++Today (verified against code):++- A "project" is a `scopes` row (`platform='avibe'`, `scope_type='project'`) + a+ `scope_settings` row. The folder path lives in `scope_settings.workdir`+ (already stored resolved/absolute via `Path(...).expanduser().resolve()`).+- "Archived" == `scope_settings.enabled = 0`. `create_project` always mints a+ **new** random `proj_<hex>` scope, so the same folder can spawn duplicate+ projects, and there is **no unarchive path** anywhere (no service method, no+ route). `archive_project` only flips `enabled=0`.+- The sidebar loads sessions for a project with a hardcoded `limit: 50`,+ `status='active'`, and **ignores** the server cursor (`next_before_id`). The+ API client (`listSessions`) already supports `beforeId -> before_id` and the+ service already does cursor pagination (clamped 1..200). So pagination is a+ pure frontend wiring job.++## Goals (this change)++1. **Project archive recovery without a new endpoint.** On create/open+ (`POST /api/projects`, the only project-creation entry — `NewProjectDialog`),+ find-or-create by resolved folder path:+ - same-path project exists → **reuse** it (no duplicate);+ - if it was archived (`enabled=0`) → **un-archive** (`enabled=1`).+ Recovery UX = user clicks "open project", picks the same folder, it comes back+ with its sessions intact.+2. **Session pagination in the sidebar.** Load the most recent **10** active+ sessions per project; show a **"Load more"** button when more exist; each+ click appends the next 10 via the existing cursor.++## Non-goals++- **Session archiving stays untouched** (per request). `archive_session` ++ `DELETE /api/sessions/:id` + the unused `archiveSession` client method remain+ exactly as-is. We add no session-archive UI.+- No DB migration, no new uniqueness constraint, no merging of pre-existing+ duplicate-path projects.++## Design++### 1. Backend — `storage/projects_service.py::create_project` becomes find-or-create++```+folder = _resolve_folder(folder_path) # existing; resolves ~ and symlinks+existing = _find_project_by_workdir(conn, str(folder))+if existing:+ if not existing.enabled: # archived -> revive+ scope_settings.enabled = 1+ scopes.last_seen_at = now; scopes.updated_at = now # "opened" => recent+ # display_name: keep existing by default (see decision Q1)+ return _project_payload(conn, existing.scope_id)+# else: current insert path (new scope + scope_settings, enabled=1)+```++`_find_project_by_workdir(conn, workdir)`: join `scopes` (avibe/project) ⨝+`scope_settings` where `workdir = :workdir`, order by `enabled DESC,+last_seen_at DESC`, limit 1 (deterministic pick if legacy duplicates exist —+prefer an active one, else most recently active). `workdir` is indexed+(`ix_scope_settings_workdir`).++- Route `projects_create` already wraps the call in `engine.begin()` (single+ transaction) → the lookup+revive is atomic. Keep returning the project payload+ (status code: keep `201`, or `200` on reuse — decision Q5/low-stakes).+- This makes create idempotent-by-path and removes the need for any unarchive+ endpoint.++### 2. Frontend — pagination (`WorkbenchSidebar.tsx` + `SessionList`)++- Add `const SESSIONS_PAGE_SIZE = 10` (named constant; replaces the `50` magic+ number at line 446).+- Extend per-project state:+ - keep `sessionsByProject: Record<string, WorkbenchSession[]>` (now appended);+ - add `sessionCursorByProject: Record<string, string | null>` (server+ `next_before_id`; `null` = no more, absent = not loaded);+ - add a per-project "loading more" flag (reuse/extend `sessionsLoading`).+- `fetchSessions(projectId, { append })`:+ - first load: `listSessions({ projectId, status:'active', limit: 10 })`, replace;+ - load more: `listSessions({ ..., beforeId: cursor })`, **append**;+ - store `next_before_id` as the cursor both times.+- `SessionList`: render a "Load more" row/button when+ `cursor !== null && cursor !== undefined`; onClick → `fetchSessions(id, {append:true})`.+ Show a small spinner while loading more. (i18n key `workbench.sessionsLoadMore`.)+- New-session optimistic prepend (`createSessionForProject`) is unchanged and+ still correct with paging.++### 3. Frontend — open/restore UX (`NewProjectDialog` + sidebar `onCreated`)++- The dialog already posts `folder_path` (+ optional `display_name`). After the+ backend change, picking an archived path just restores it — **no dialog logic+ change required** for the core flow.+- Harden `onCreated`: dedupe by `id` (or refetch projects) so a reused/restored+ project shows up exactly once and is selected/expanded. (A restored project+ was absent from the list, so it must be added; an already-active reuse must not+ duplicate.)+- Copy: consider relabeling the entry + dialog title to "Open / Add project"+ (打开 / 添加项目) since it now opens-or-creates (decision Q4, low-stakes).++## Edge cases / open decisions (need product confirmation)++- **Q1 — display name on reuse.** Recommend: on reuse, **keep the existing+ project's name**; ignore the dialog's `display_name` unless the user explicitly+ typed a different one (rename stays a separate explicit action). Avoids the+ re-open auto-filling folder-basename and clobbering a custom name.+- **Q2 — reuse when path is already ACTIVE.** Recommend: **yes**, reuse (return+ existing) — makes create idempotent and fixes the current duplicate-project+ bug. (Matches "find same scope → reuse directly".)+- **Q3 — path equality.** Match on resolved absolute path (current storage+ shape). `~`, trailing slash, and symlinks converge. Known minor limit: macOS+ case-insensitive FS — different-case spellings won't dedupe. Accept for now.+- **Q4 — legacy duplicate paths.** Deterministic pick (active first, then most+ recent); no auto-merge.+- **Q5 — HTTP status on reuse.** `201` vs `200`. Low-stakes; default keep `201`.++## Changes (files)++- `storage/projects_service.py` — `_find_project_by_workdir` + find-or-create in+ `create_project` (+ revive/last_seen bump).+- `tests/test_projects_service.py` (new) — find-or-create returns same id;+ re-create of archived path re-enables it; different path makes a new project;+ duplicate-path deterministic pick.+- `ui/src/components/workbench/WorkbenchSidebar.tsx` — page size constant,+ cursor state, append, Load-more wiring; `onCreated` dedupe.+- `ui/src/i18n/en.json` + `zh.json` — `workbench.sessionsLoadMore` (+ any copy+ tweak for open/add project).+- Possibly `NewProjectDialog.tsx` — only if we change copy.++## Testing / evidence++- Unit: `tests/test_projects_service.py` (new) for find-or-create + revive.+ Run the storage test group, not just the new file.+- `ruff check` on changed Python before push.+- UI: `npm run build` in `ui/`.+- Manual / regression: archive a project, "open" same folder → it returns with+ sessions; project with >10 sessions shows Load-more and appends correctly.+- No scenario catalog applies to this surface (not an auth/setup flow).++## Out of scope / follow-ups++- Session archive UI (explicitly deferred).+- Real path-uniqueness constraint + duplicate-merge migration (future, if needed).diff --git a/storage/projects_service.py b/storage/projects_service.pyindex 9d10dc9ac..3bedaef64 100644--- a/storage/projects_service.py+++ b/storage/projects_service.py@@ -53,6 +53,46 @@ def _resolve_folder(folder_path: str) -> Path:return folder+def _find_project_by_workdir(conn: Connection, workdir: str) -> Optional[dict[str, Any]]:+ """Find an existing avibe *project* scope whose folder matches ``workdir``.++ Only avibe project scopes are considered: IM channel scopes can carry+ their own ``scope_settings.workdir``, so matching across all scopes would+ wrongly collide a project with a chat channel that happens to share a cwd.+ ``workdir`` must already be a resolved absolute path (see ``_resolve_folder``)+ so it lines up with how projects are stored. When legacy duplicates share a+ path, prefer an active row, then the most recently seen, so the pick is+ deterministic.+ """++ row = (+ conn.execute(+ select(+ scopes.c.id.label("scope_id"),+ scopes.c.native_id,+ scope_settings.c.enabled,+ )+ .select_from(scopes.join(scope_settings, scope_settings.c.scope_id == scopes.c.id))+ .where(+ scopes.c.platform == PROJECT_PLATFORM,+ scopes.c.scope_type == PROJECT_SCOPE_TYPE,+ scope_settings.c.workdir == workdir,+ )+ .order_by(+ scope_settings.c.enabled.desc(),+ scopes.c.last_seen_at.desc(),+ scopes.c.id.asc(),+ )+ .limit(1)+ )+ .mappings()+ .first()+ )+ if row is None:+ return None+ return {"scope_id": row["scope_id"], "native_id": row["native_id"], "enabled": row["enabled"]}++def list_projects(conn: Connection, *, include_archived: bool = False) -> list[dict[str, Any]]:"""Return all avibe projects sorted by recency, optionally including archived ones."""@@ -105,11 +145,39 @@ def create_project(folder_path: str,display_name: Optional[str] = None,) -> dict[str, Any]:+ """Create an avibe project, or reuse the existing one for this folder.++ Projects are keyed by their resolved absolute folder path. Opening or+ creating a project that points at a folder we already track returns the+ existing project instead of minting a duplicate scope, and an archived+ match is revived (``enabled = 1``) — this is how a project is restored+ after archiving, without a dedicated unarchive endpoint. The caller's+ ``display_name`` is intentionally ignored on reuse so re-opening a folder+ never clobbers a name the user set earlier; renaming stays explicit.+ """+folder = _resolve_folder(folder_path)+ now = _utc_now_iso()++ existing = _find_project_by_workdir(conn, str(folder))+ if existing is not None:+ scope_id = existing["scope_id"]+ if not existing["enabled"]:+ conn.execute(+ update(scope_settings)+ .where(scope_settings.c.scope_id == scope_id)+ .values(enabled=1, updated_at=now)+ )+ # Treat (re)opening as recent activity so the project sorts to the top.+ conn.execute(+ update(scopes)+ .where(scopes.c.id == scope_id)+ .values(last_seen_at=now, updated_at=now)+ )+ return _project_payload(conn, scope_id)project_id = _new_project_id()scope_id = _make_scope_id(project_id)- now = _utc_now_iso()name = (display_name or folder.name).strip() or project_idconn.execute(diff --git a/tests/test_projects_service.py b/tests/test_projects_service.pynew file mode 100644index 000000000..b82654b35--- /dev/null+++ b/tests/test_projects_service.py@@ -0,0 +1,192 @@+"""Tests for avibe project find-or-create / archive-recovery semantics.++Projects are keyed by their resolved absolute folder path. Creating or+"opening" a project for a folder we already track must reuse the existing+scope (no duplicates) and revive it if it was archived — that is how a+project is restored after archiving, without a dedicated unarchive endpoint.+"""++from __future__ import annotations++import pytest++from storage import projects_service+from storage.db import create_sqlite_engine+from storage.importer import ensure_sqlite_state+from storage.models import scope_settings, scopes+++def engine():+ # conftest's autouse fixture points VIBE_REMOTE_HOME at a per-test tmp dir,+ # so this initialises and connects to an isolated SQLite state file.+ ensure_sqlite_state()+ return create_sqlite_engine()+++def test_create_project_is_idempotent_by_path(engine, tmp_path):+ folder = tmp_path / "proj"+ folder.mkdir()+ resolved = str(folder.resolve())++ with engine.begin() as conn:+ first = projects_service.create_project(conn, str(folder), display_name="My Project")+ with engine.begin() as conn:+ second = projects_service.create_project(conn, str(folder), display_name="Different Name")+ projects = projects_service.list_projects(conn, include_archived=True)++ # Same scope reused, not a fresh duplicate.+ assert first["id"] == second["id"]+ assert first["scope_id"] == second["scope_id"]+ # Reuse keeps the original name; the second call's display_name is ignored.+ assert second["display_name"] == "My Project"+ # Exactly one project tracks this path.+ same_path = [p for p in projects if p["folder_path"] == resolved]+ assert len(same_path) == 1+++def test_reopening_archived_path_revives_it(engine, tmp_path):+ folder = tmp_path / "proj"+ folder.mkdir()++ with engine.begin() as conn:+ created = projects_service.create_project(conn, str(folder), display_name="Kept Name")+ projects_service.archive_project(conn, created["id"])++ # Archived projects drop out of the default list.+ with engine.connect() as conn:+ assert all(p["id"] != created["id"] for p in projects_service.list_projects(conn))++ # Re-opening the same folder restores the same project (revived, name kept).+ with engine.begin() as conn:+ revived = projects_service.create_project(conn, str(folder), display_name="Ignored On Reuse")++ assert revived["id"] == created["id"]+ assert revived["archived"] is False+ assert revived["display_name"] == "Kept Name"+ with engine.connect() as conn:+ assert any(p["id"] == created["id"] for p in projects_service.list_projects(conn))+++def test_different_paths_make_distinct_projects(engine, tmp_path):+ a_dir = tmp_path / "a"+ b_dir = tmp_path / "b"+ a_dir.mkdir()+ b_dir.mkdir()++ with engine.begin() as conn:+ a = projects_service.create_project(conn, str(a_dir))+ b = projects_service.create_project(conn, str(b_dir))++ assert a["id"] != b["id"]+ assert a["scope_id"] != b["scope_id"]+++def test_path_lookup_ignores_non_project_scopes(engine, tmp_path):+ """An IM-channel scope sharing the same workdir must never be matched."""+ folder = tmp_path / "shared"+ folder.mkdir()+ workdir = str(folder.resolve())++ # Seed a Slack channel scope pointing at the same directory.+ with engine.begin() as conn:+ ts = "2026-01-01T00:00:00Z"+ conn.execute(+ scopes.insert().values(+ id="slack::channel::C1",+ platform="slack",+ scope_type="channel",+ native_id="C1",+ parent_scope_id=None,+ display_name="chan",+ native_type="channel",+ is_private=0,+ supports_threads=1,+ metadata_json="{}",+ first_seen_at=ts,+ last_seen_at=ts,+ updated_at=ts,+ )+ )+ conn.execute(+ scope_settings.insert().values(+ scope_id="slack::channel::C1",+ enabled=1,+ role=None,+ workdir=workdir,+ agent_name=None,+ agent_backend=None,+ agent_variant=None,+ model=None,+ reasoning_effort=None,+ require_mention=None,+ settings_version=1,+ settings_json="{}",+ created_at=ts,+ updated_at=ts,+ )+ )++ with engine.begin() as conn:+ # The channel sharing the path is not a project match...+ assert projects_service._find_project_by_workdir(conn, workdir) is None+ # ...so creating a project for it mints a real avibe project scope.+ proj = projects_service.create_project(conn, workdir)++ assert proj["scope_id"].startswith("avibe::project::")+++def test_duplicate_path_pick_prefers_active_then_recent(engine, tmp_path):+ """Legacy duplicates for one path resolve deterministically: active first."""+ folder = tmp_path / "dup"+ folder.mkdir()+ workdir = str(folder.resolve())++ def _insert_project(scope_id: str, *, enabled: int, last_seen: str) -> None:+ with engine.begin() as conn:+ conn.execute(+ scopes.insert().values(+ id=scope_id,+ platform="avibe",+ scope_type="project",+ native_id=scope_id.split("::")[-1],+ parent_scope_id=None,+ display_name="dup",+ native_type="project",+ is_private=1,+ supports_threads=1,+ metadata_json="{}",+ first_seen_at="2026-01-01T00:00:00Z",+ last_seen_at=last_seen,+ updated_at=last_seen,+ )+ )+ conn.execute(+ scope_settings.insert().values(+ scope_id=scope_id,+ enabled=enabled,+ role=None,+ workdir=workdir,+ agent_name=None,+ agent_backend=None,+ agent_variant=None,+ model=None,+ reasoning_effort=None,+ require_mention=None,+ settings_version=1,+ settings_json="{}",+ created_at="2026-01-01T00:00:00Z",+ updated_at=last_seen,+ )+ )++ # An archived row seen more recently, and an active row seen earlier.+ _insert_project("avibe::project::proj_archived", enabled=0, last_seen="2026-05-02T00:00:00Z")+ _insert_project("avibe::project::proj_active", enabled=1, last_seen="2026-05-01T00:00:00Z")++ with engine.begin() as conn:+ found = projects_service._find_project_by_workdir(conn, workdir)++ # Active wins over the more-recent archived row.+ assert found is not None+ assert found["scope_id"] == "avibe::project::proj_active"diff --git a/ui/src/components/Workbench.tsx b/ui/src/components/Workbench.tsxindex f439dfe7a..19e29b42d 100644--- a/ui/src/components/Workbench.tsx+++ b/ui/src/components/Workbench.tsx@@ -189,7 +189,14 @@ export const Workbench: React.FC = () => {onClose={() => setNewProjectOpen(false)}onCreated={(project) => {setNewProjectOpen(false);- setProjects((prev) => (prev ? [project, ...prev] : [project]));+ // create_project is find-or-create by path: this may return an+ // already-tracked project, refreshed (revived / last_active_at+ // bumped). Drop any stale copy and hoist the fresh one to the top so+ // the canvas "most recent" target reflects the folder just opened.+ setProjects((prev) => {+ if (!prev) return [project];+ return [project, ...prev.filter((p) => p.id !== project.id)];+ });}}/>)}diff --git a/ui/src/components/workbench/WorkbenchSidebar.tsx b/ui/src/components/workbench/WorkbenchSidebar.tsxindex 1dfe8dc60..a36d5f01e 100644--- a/ui/src/components/workbench/WorkbenchSidebar.tsx+++ b/ui/src/components/workbench/WorkbenchSidebar.tsx@@ -44,6 +44,11 @@ const CAPABILITY_NAV: CapabilityNavItem[] = [{ to: '/vaults', i18nKey: 'workbench.nav.vaults', icon: KeyRound },];+// How many sessions to load per page under a project. The server caps the page+// size and returns a cursor (next_before_id); the sidebar appends the next page+// via the "Load more" control rather than loading every session up front.+const SESSIONS_PAGE_SIZE = 10;+// 360px floating popover that opens when the user hovers the Inbox entry.// Mirrors design.pen KmQ1L — header + a few session cards + footer "open full// inbox" link. Pure presentational; data comes from <WorkbenchInboxProvider>.@@ -172,6 +177,9 @@ const ProjectRow: React.FC<{expanded: boolean;sessions: WorkbenchSession[] | null;loading: boolean;+ loadingMore: boolean;+ hasMore: boolean;+ onLoadMore: () => void;onToggle: () => void;onCreateSession: () => void;creatingSession: boolean;@@ -184,6 +192,9 @@ const ProjectRow: React.FC<{expanded,sessions,loading,+ loadingMore,+ hasMore,+ onLoadMore,onToggle,onCreateSession,creatingSession,@@ -374,6 +385,17 @@ const ProjectRow: React.FC<{</button>);})}+ {hasMore && (+ <button+ type="button"+ onClick={onLoadMore}+ disabled={loadingMore}+ className="flex items-center gap-1.5 rounded-md py-1.5 pl-[30px] pr-2.5 text-left text-[11px] font-medium text-muted transition hover:bg-foreground/[0.04] hover:text-foreground disabled:cursor-default disabled:opacity-60"+ >+ {loadingMore ? <Loader2 className="size-3 animate-spin" /> : <ChevronDown className="size-3" />}+ {t('workbench.sessionsLoadMore')}+ </button>+ )}</div>)}</div>@@ -394,6 +416,16 @@ export const WorkbenchSidebar: React.FC = () => {const [expanded, setExpanded] = useState<Set<string>>(new Set());const [sessionsByProject, setSessionsByProject] = useState<Record<string, WorkbenchSession[]>>({});const [sessionsLoading, setSessionsLoading] = useState<Record<string, boolean>>({});+ const [sessionsLoadingMore, setSessionsLoadingMore] = useState<Record<string, boolean>>({});+ // Cursor (server next_before_id) per project: a string means "more pages+ // exist", null means "fully loaded", absent means "not loaded yet". The ref+ // mirror lets fetchSessions read the latest cursor without going stale inside+ // its memoised closure.+ const [sessionCursor, setSessionCursor] = useState<Record<string, string | null>>({});+ const sessionCursorRef = useRef<Record<string, string | null>>({});+ // Projects with an in-flight session fetch — serialises first-page and+ // load-more calls per project so a refetch can't race or truncate an append.+ const sessionsInFlightRef = useRef<Set<string>>(new Set());const [creatingSession, setCreatingSession] = useState<Set<string>>(new Set());const [showNewProject, setShowNewProject] = useState(false);@@ -441,16 +473,50 @@ export const WorkbenchSidebar: React.FC = () => {}, [api]);const fetchSessions = useCallback(- async (projectId: string) => {- setSessionsLoading((prev) => ({ ...prev, [projectId]: true }));+ async (projectId: string, opts?: { append?: boolean }) => {+ const append = opts?.append ?? false;+ if (append && !sessionCursorRef.current[projectId]) return; // nothing more to load+ if (sessionsInFlightRef.current.has(projectId)) return; // serialise per project+ sessionsInFlightRef.current.add(projectId);+ if (append) {+ setSessionsLoadingMore((prev) => ({ ...prev, [projectId]: true }));+ } else {+ setSessionsLoading((prev) => ({ ...prev, [projectId]: true }));+ }try {- const result = await api.listSessions({ projectId, status: 'active', limit: 50 });- setSessionsByProject((prev) => ({ ...prev, [projectId]: result.sessions }));+ const result = await api.listSessions({+ projectId,+ status: 'active',+ limit: SESSIONS_PAGE_SIZE,+ beforeId: append ? sessionCursorRef.current[projectId] ?? undefined : undefined,+ });+ // Mutate the ref in place so a concurrent load for another project+ // can't drop this cursor via a stale read-modify-write snapshot.+ sessionCursorRef.current[projectId] = result.next_before_id;+ setSessionCursor((prev) => ({ ...prev, [projectId]: result.next_before_id }));+ setSessionsByProject((prev) => {+ if (!append) return { ...prev, [projectId]: result.sessions };+ // Cursor pages can overlap if a row's last_active_at shifts between+ // fetches (the cursor is just a row id resolved against current+ // activity); drop ids we already hold so rows never duplicate.+ const existing = prev[projectId] ?? [];+ const seen = new Set(existing.map((s) => s.id));+ return { ...prev, [projectId]: [...existing, ...result.sessions.filter((s) => !seen.has(s.id))] };+ });} catch (err) {- // Surface as empty list; user can collapse + re-expand to retry.- setSessionsByProject((prev) => ({ ...prev, [projectId]: prev[projectId] ?? [] }));+ // First-page failure: surface as empty so the user can collapse ++ // re-expand to retry. On a "load more" failure, keep the existing list+ // and cursor so the button stays available for another attempt.+ if (!append) {+ setSessionsByProject((prev) => ({ ...prev, [projectId]: prev[projectId] ?? [] }));+ }} finally {- setSessionsLoading((prev) => ({ ...prev, [projectId]: false }));+ sessionsInFlightRef.current.delete(projectId);+ if (append) {+ setSessionsLoadingMore((prev) => ({ ...prev, [projectId]: false }));+ } else {+ setSessionsLoading((prev) => ({ ...prev, [projectId]: false }));+ }}},[api],@@ -734,6 +800,9 @@ export const WorkbenchSidebar: React.FC = () => {expanded={expanded.has(project.id)}sessions={sessionsByProject[project.id] ?? null}loading={!!sessionsLoading[project.id]}+ loadingMore={!!sessionsLoadingMore[project.id]}+ hasMore={!!sessionCursor[project.id]}+ onLoadMore={() => fetchSessions(project.id, { append: true })}onToggle={() => toggleExpanded(project.id)}onCreateSession={() => createSessionForProject(project.id)}creatingSession={creatingSession.has(project.id)}@@ -751,15 +820,26 @@ export const WorkbenchSidebar: React.FC = () => {onClose={() => setShowNewProject(false)}onCreated={(project) => {setShowNewProject(false);- setProjects((prev) => (prev ? [project, ...prev] : [project]));+ // Opening a folder we already track returns the existing project+ // (idempotent by path), refreshed (revived / last_active_at bumped).+ // Drop any stale copy and hoist the fresh one to the top instead of+ // adding a duplicate row.+ setProjects((prev) => {+ if (!prev) return [project];+ return [project, ...prev.filter((p) => p.id !== project.id)];+ });setExpanded((prev) => {const next = new Set(prev);next.add(project.id);return next;});- // Pre-seed empty sessions list so the expand shows the empty state- // immediately instead of a flash of "Loading…"- setSessionsByProject((prev) => ({ ...prev, [project.id]: [] }));+ // Load sessions only if we don't already have them cached. A new or+ // restored project has no cache yet, so this fetches its real list;+ // an already-open project keeps the pages the user already paged in+ // instead of being truncated back to the first page.+ if (sessionsByProject[project.id] === undefined) {+ fetchSessions(project.id);+ }}}/>)}diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.jsonindex e3dabc981..612765cfb 100644--- a/ui/src/i18n/en.json+++ b/ui/src/i18n/en.json@@ -445,7 +445,7 @@"heroBody": "Describe what you want and an agent will run it. Or start with one of the suggestions below.","v1Hint": "v1 placeholder · canvas-anchored iteration lands next","suggestions": {- "newProject": "New project",+ "newProject": "Open project","newProjectHint": "Pick a folder; sessions default to it","openAgents": "Manage agents","openAgentsHint": "Add or tweak available agents",@@ -460,7 +460,7 @@"openControlPanel": "Open Control Panel","capabilitiesLabel": "Capabilities","projectsLabel": "Projects",- "addProject": "Add project",+ "addProject": "Open project","addSession": "New session in this project","projectActions": "Project actions","projectRename": "Rename",@@ -472,16 +472,17 @@"projectsLoadError": "Couldn't load projects.","sessionsLoading": "Loading sessions…","sessionsEmpty": "No sessions in this project.",+ "sessionsLoadMore": "Load more","untitledSession": "Untitled session","newProjectDialog": {- "title": "New project",- "description": "Pick a working directory. An avibe project gives every session in it a shared cwd and inbox.",+ "title": "Open project",+ "description": "Pick a working directory. Opening a folder you've used before reopens that project — restoring it if it was archived.","pickFolder": "Choose folder","displayName": "Display name","displayNamePlaceholder": "Auto from folder name","folderLabel": "Folder",- "create": "Create project",- "creating": "Creating…",+ "create": "Open project",+ "creating": "Opening…","cancel": "Cancel"},"nav": {diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.jsonindex 60ddf8475..c510bfe6c 100644--- a/ui/src/i18n/zh.json+++ b/ui/src/i18n/zh.json@@ -445,7 +445,7 @@"heroBody": "在下面输入想做的事,Agent 会按你的描述执行。你也可以从下面的建议开始。","v1Hint": "v1 占位 · 后续会做画布标注 + 多轮迭代","suggestions": {- "newProject": "新建项目",+ "newProject": "打开项目","newProjectHint": "选个目录开个项目,会话默认会落在里面","openAgents": "管理 Agents","openAgentsHint": "添加或调整可选的 Agent",@@ -460,7 +460,7 @@"openControlPanel": "进入控制面板","capabilitiesLabel": "能力模块","projectsLabel": "项目",- "addProject": "添加项目",+ "addProject": "打开项目","addSession": "在该项目新建会话","projectActions": "项目操作","projectRename": "重命名",@@ -472,16 +472,17 @@"projectsLoadError": "项目加载失败。","sessionsLoading": "加载会话中…","sessionsEmpty": "项目里还没有会话。",+ "sessionsLoadMore": "加载更多","untitledSession": "未命名会话","newProjectDialog": {- "title": "新建项目",- "description": "选一个工作目录。avibe 项目里的每个会话共用同一个 cwd 和收件箱。",+ "title": "打开项目",+ "description": "选一个工作目录。打开你之前用过的文件夹会重新打开那个项目 —— 如果它被归档过,会一并恢复。","pickFolder": "选择文件夹","displayName": "显示名","displayNamePlaceholder": "默认使用文件夹名","folderLabel": "目录",- "create": "创建项目",- "creating": "创建中…",+ "create": "打开项目",+ "creating": "打开中…","cancel": "取消"},"nav": {