Skip to content

How should my app keep a bulk export or review action stable while the gallery changes?

Capture an immutable selection snapshot when starting a bulk action and show what it includes. Newly completed results or changing filters should not silently join an export, deletion or review operation already approved. Selection state is your application's responsibility, separate from AISwapLab job completion.

PRESERVE API DATA ACCURATELYAISwapLab team · Editorial methodUpdated 2 min read
Open API documentationExplore 67 Image SkillsPrivate keys · Explicit credit approval
Article workflow: Define selection semantics; Freeze and validate the set; Test concurrent gallery changes.
Workflow diagram: Define selection semantics → Freeze and validate the set → Test concurrent gallery changes. Read the article for evidence and limits.

Select all can mean several sets

A gallery may show one page, all matching results or a live query whose membership changes. Users need a clear count and scope. Without a frozen set, background completion can change the operation after the user has made the decision.

What to do next

  1. 01

    Define selection semantics

    State whether Select all applies to visible items, a fixed filtered result set or a live query. For consequential bulk operations, resolve the selected immutable asset IDs and versions before presenting the final action summary.

  2. 02

    Freeze and validate the set

    Pass a server-validated selection snapshot or export job identity rather than rereading mutable frontend filters later. Recheck authorization and asset availability without silently substituting newer versions or including newly arrived results.

  3. 03

    Test concurrent gallery changes

    Start the bulk action, add a new completed item, change the filter and reorder cards. Verify the operation still targets the declared set, with missing or inaccessible items reported explicitly rather than replaced.

A concrete example

Illustrative example: a user exports seven reviewed images. An eighth result completes while the bundle builds. The export still contains the seven confirmed versions, and the eighth remains available for a later deliberate export.

Run the local counterexample

Local runtime fixture, executed November 16, 2026. No AISwapLab request, payment or model generation was made.

Recorded runtime: Python 3.12.10; SQLite 3.49.1. Run the complete script below using that runtime or record the version and changed behavior in your own environment. The script uses synthetic data and temporary resources only.

python
import sqlite3,tempfile,json
from pathlib import Path
with tempfile.TemporaryDirectory() as d:
    path=Path(d)/'gallery.db'
    a=sqlite3.connect(path,isolation_level=None);b=sqlite3.connect(path,isolation_level=None)
    mode=a.execute('PRAGMA journal_mode=WAL').fetchone()[0]
    a.execute('CREATE TABLE asset(id INTEGER PRIMARY KEY)');a.executemany('INSERT INTO asset VALUES(?)',[(1,),(2,)])
    a.execute('BEGIN');first=[r[0] for r in a.execute('SELECT id FROM asset ORDER BY id')]
    b.execute('INSERT INTO asset VALUES(3)')
    during=[r[0] for r in a.execute('SELECT id FROM asset ORDER BY id')]
    a.execute('COMMIT');after=[r[0] for r in a.execute('SELECT id FROM asset ORDER BY id')]
    print(json.dumps({'journalMode':mode,'firstRead':first,'sameReadTransaction':during,'afterReadCommit':after}))
    a.close();b.close()

Actual output from this run

json
{
  "journalMode": "wal",
  "firstRead": [
    1,
    2
  ],
  "sameReadTransaction": [
    1,
    2
  ],
  "afterReadCommit": [
    1,
    2,
    3
  ]
}

Use the result within its scope

The open read transaction continued to see two IDs while a second connection committed a third. After commit, a new read saw all three. Resolve and persist the approved ID/version set rather than assuming a database snapshot remains attached to a later export. Avoid keeping a transaction open for the whole media export; authorization and missing-asset checks still run at execution.

This is SQLite WAL isolation on a temporary file, not an AISwapLab export feature, a permanent selection token or a claim about every database's isolation defaults.

Before you call it ready

  • The action summary names count and scope.
  • New arrivals cannot join silently.
  • Version substitutions require explicit handling.

When to stop or choose another method

Stop evaluating a mutable gallery query at execution time when the user approved a specific set of assets.

Sources

One task. A recoverable workflow.

Check the contract, approve the quote and retain the job.

Open API documentation