You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Before: a bulk import (a folder scan, an archive's files, a list of links, a source's chosen files) left its assets mixed in with everything else, so undoing a wrong one meant finding and deleting each asset by hand.
After: each bulk import is one import run, and every asset it makes carries the run's id (import_run). GET /api/v1/import/runs lists recent runs with how many assets each made and how many are left, and POST /api/v1/import/runs/{id}/undo deletes them all through the normal delete. That needs owner rights on each asset (nothing goes when any isn't yours to delete) and is audited per asset and for the run. The toast after a link or source import has Undo, the Import screen lists recent runs with Undo on each, and the assistant has import_runs and undo_import, which always waits for the person's yes. Assets imported before keep no run, and nothing changes for them.
How: import_runs.py records a run and stamps its assets from ingest, convert, links and sources; imports.py adds the two routes; ops_tools.py adds the two assistant tools, with undo_import in ASK_TOOLS.
Two fixes the new tests found:
deletion.py and moving.py now use array::complement(field ?? [], …). On a SurrealDB 3.2.4 server, UPDATE chat SET scope.recordings = array::complement(scope.recordings, [$r]) WHERE scope.recordings CONTAINS $r fails with "Argument 1 … found NONE" when any row lacks the field, even though the WHERE excludes it (reproduced with curl against surrealdb/surrealdb:v3.2.4). That means deleting an asset failed in server mode whenever a chat without a recording scope existed.
Item from the personal feature plan sheet (undo a whole import).
Screenshots (if appropriate):
n/a
Steps to reproduce (if appropriate):
Paste two links on the Import screen, then press Undo in the toast: both assets are deleted, and the run shows as undone under recent imports.
Types of changes
Bug fix (non-breaking change which fixes an issue)
New feature (non-breaking change which adds functionality)
Breaking change (fix or feature that would cause existing functionality to change; ! in the title)
Checklist:
The title is a Conventional Commit.
My code follows the code style of this project (make hooks checks it on commit).
I added or updated tests (tests/api/test_import_runs.py, __tests__/import-runs.test.tsx).
My change requires documentation updates, and I have updated docs/ accordingly (docs/api.md, Import runs; docs/assistant.md; docs/processing.md; docs/database.md).
Goal: delivers what the user wanted, merged on green CI.
Agents: usable through the API, MCP or an assistant tool. Two routes and the import_runs / undo_import tools.
Zero setup: no new prerequisite, .env edit or manual step.
Fewest clicks and keystrokes. One Undo in the toast, or one per run on the Import screen; no confirm dialog.
Configurable: new settings in the web app with defaults; wizard asks only what is required. n/a: no settings.
Light: default install still runs on a Raspberry Pi with cloud models.
Private and secure: data local and encrypted, passkeys, threat model updated. New row for the routes and tools; runs are seen only by whoever started them, namespace owners and admins.
Cost: cheapest path, model calls in the activity ledger, budgets respected. n/a: no model calls.
User decides: consequential or new actions wait for the user; defaults unchanged. The assistant's undo always waits for a yes.
Upgrades: existing installs upgrade safely (upgrade step for stored-data changes). import_run is a new optional field and a new table; older assets have none (docs/database.md).
Honest: sources cited; labelled built, in progress or planned. README built list and docs/requirements.md name test_import_runs.py.
Tests, docs and generated files updated (make openapi).
Open standards; dependencies keep Lens MIT. n/a: no dependencies.
Result reported with evidence; "refine later" items written down.
Reuse: existing Lens code and permissive libraries reused, nothing reinvented. Undo goes through the existing delete.
Local CI (ci/local-ci.sh): Next.js, pre-commit and PR title passed. The two FastAPI jobs failed on the two tests above. After the fixes, test_setup_assistant.py and test_import_runs.py pass embedded (14 passed), and test_import_runs.py and test_delete.py pass against a SurrealDB 3.2.4 server (10 passed).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Adeel · project thread
Description
Before: a bulk import (a folder scan, an archive's files, a list of links, a source's chosen files) left its assets mixed in with everything else, so undoing a wrong one meant finding and deleting each asset by hand.
After: each bulk import is one import run, and every asset it makes carries the run's id (
import_run).GET /api/v1/import/runslists recent runs with how many assets each made and how many are left, andPOST /api/v1/import/runs/{id}/undodeletes them all through the normal delete. That needs owner rights on each asset (nothing goes when any isn't yours to delete) and is audited per asset and for the run. The toast after a link or source import has Undo, the Import screen lists recent runs with Undo on each, and the assistant hasimport_runsandundo_import, which always waits for the person's yes. Assets imported before keep no run, and nothing changes for them.How:
import_runs.pyrecords a run and stamps its assets fromingest,convert,linksandsources;imports.pyadds the two routes;ops_tools.pyadds the two assistant tools, withundo_importinASK_TOOLS.Two fixes the new tests found:
deletion.pyandmoving.pynow usearray::complement(field ?? [], …). On a SurrealDB 3.2.4 server,UPDATE chat SET scope.recordings = array::complement(scope.recordings, [$r]) WHERE scope.recordings CONTAINS $rfails with "Argument 1 … foundNONE" when any row lacks the field, even though the WHERE excludes it (reproduced with curl againstsurrealdb/surrealdb:v3.2.4). That means deleting an asset failed in server mode whenever a chat without a recording scope existed.test_the_assistant_manages_people_with_approvalraiseschat.CONTEXT_TOKENSthe waytest_a_setup_conversation_sets_the_server_upalready does, because two more admin tools pushed its people list past what fits (Admin assistant toolbox leaves almost no room in the default 16k context window #677).Motivation and Context
Item from the personal feature plan sheet (undo a whole import).
Screenshots (if appropriate):
n/a
Steps to reproduce (if appropriate):
Paste two links on the Import screen, then press Undo in the toast: both assets are deleted, and the run shows as undone under recent imports.
Types of changes
!in the title)Checklist:
make hookschecks it on commit).tests/api/test_import_runs.py,__tests__/import-runs.test.tsx).docs/accordingly (docs/api.md, Import runs;docs/assistant.md;docs/processing.md;docs/database.md).## UnreleasedinCHANGELOG.md. Written aschangelog.d/import-runs.md, per build(release): changelog fragments in changelog.d/ instead of one Unreleased section #581.Done questions (AGENTS.md)
import_runs/undo_importtools..envedit or manual step.import_runis a new optional field and a new table; older assets have none (docs/database.md).docs/requirements.mdnametest_import_runs.py.make openapi).Local CI (
ci/local-ci.sh): Next.js, pre-commit and PR title passed. The two FastAPI jobs failed on the two tests above. After the fixes,test_setup_assistant.pyandtest_import_runs.pypass embedded (14 passed), andtest_import_runs.pyandtest_delete.pypass against a SurrealDB 3.2.4 server (10 passed).Generated by Claude Code