Repository navigation
feat(imports): make each bulk import one run you can undo whole - #679
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QFUNzy1QZy5HhKAyJxTAYJ
adeelahmad
force-pushed
the
claude/project-thread-xfmkzn
branch
from
October 19, 2026 07:53
c097491 to
c159244
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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