Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions docs/upgrading.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ Version notes that change behavior, newest first. Installing or updating through
database migrations for you: every one is additive, and an older database upgrades in place on first
open. Take a copy of `inventory.db` before a big jump anyway.

## 0.17.0

- **The camera shows what it read.** In Put away, a **Scanned** list sits right under the video, newest
first, so you can see each piece go in without scrolling. Check a bin shows what it has found the same
way.
- **A clearer read.** A quick shutter flash and a green snap of the frame, with the name in a pill on the
video (and a short buzz on phones that support it). Already scanned is amber, a QR code that isn't an
Inventory label is red. Before, the success flash also borrowed a Stock-list style and briefly
re-laid-out the viewfinder.
- **The drawer holds still.** Repainting an open drawer updates it in place. Before, every label read
replayed the bottom sheet's slide-in, so the sheet dropped and rose again on each scan.
- **The viewfinder fits a phone.** 4:3 and at most a third of the screen, with the instruction on the video,
so the camera, the Scanned list and the buttons all fit in the bottom sheet.

## 0.16.4

- **Price the sell pile needs a comps source.** Without the ebay plugin enabled, it no longer starts an
Expand Down
6 changes: 4 additions & 2 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,10 @@ price changes and the sticker doesn't.
Label first, then bin by scanning:

1. **Bins → Put away**, then **Scan with camera** (or **Take a photo**).
2. Point at a piece's label. It's added to the list with a short beep. Do the same for as many pieces as are
going in the same bin.
2. Point at a piece's label. The screen flashes, the frame turns green, a beep sounds, and the piece's name
shows at the top of the camera and at the top of the **Scanned** list right under it (the newest three,
with a count). A label already in the list turns the frame amber ("Already scanned"); a QR code that
isn't one of your labels turns it red. Do the same for as many pieces as are going in the same bin.
3. Point at the bin's label and confirm "Put 3 items in B01?". They move into that bin, and a planned piece
becomes available.

Expand Down
2 changes: 1 addition & 1 deletion protoagent.plugin.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
id: inventory
name: Inventory (resale source of truth)
version: 0.16.4
version: 0.17.0
description: >-
Inventory for resellers who buy in lots and sell piece by piece. Tracks what you bought, what each
box split into, which bin every piece is in, what it's worth (eBay sold comps, each price with its
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "inventory-plugin"
version = "0.16.4"
version = "0.17.0"
description = "Resale inventory as a source of truth for protoAgent — lots, items, listings, sales, price evidence, audit"
requires-python = ">=3.11"
license = "MIT"
Expand Down
62 changes: 62 additions & 0 deletions tests/test_live_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,65 @@ def test_every_third_tick_reads_the_whole_frame_so_an_off_centre_label_still_rea
)
got = _node(script, str(ROOT / "vendor" / "jsqr" / "jsQR.js"), stdin=json.dumps(frame))
assert got == [None, {"kind": "item", "id": "NH-SH-Harrows"}] # the centre crop misses it; the full frame reads it


# ── 0.17.0: the viewfinder shows what it read ────────────────────────────────────────────


def _feed_fn() -> str:
page = _page()
return page[page.index(" const CAM_FEED_ROWS") : page.index(" function camFeed(head, names)")]


def test_the_feed_lists_the_newest_reads_first_capped_with_a_more_line_and_escaped():
esc = "const esc = (s) => String(s).replace(/&/g,'&amp;').replace(/</g,'&lt;');"
got = _node(
esc
+ _feed_fn()
+ "console.log(JSON.stringify({"
+ " empty: camFeedHtml('Scanned · 0', [], []),"
+ " one: camFeedHtml('Scanned · 1', ['Ork <Boyz>'], []),"
+ " six: camFeedHtml('Scanned · 6', ['a','b','c','d','e','f'], ['b','c','d']),"
+ " again: camFeedHtml('Scanned · 6', ['a','b','c','d','e','f'], ['d','e','f']) }));"
)
assert got["empty"] == ""
assert "Ork &lt;Boyz>" in got["one"] and '<li class="cf-row new">' in got["one"]
six = got["six"]
order = [six.index(x) for x in ("<span>f<", "<span>e<", "<span>d<")]
assert order == sorted(order) # newest first
assert "<span>c<" not in six and "+ 3 more below" in six # three rows, then a count
assert six.count(" new") == 1 and six.count(" old") == 2 # only the fresh read slides in
assert " new" not in got["again"] # nothing new: no row animates


def test_a_read_never_borrows_the_stock_lists_hit_class_and_every_outcome_shows():
page = _page()
cam = page[page.index(" const CAM = {") : page.index(" function openPutAway()")]
assert '"hit"' not in cam and ".cam.hit" not in page # .hit is the Stock row's tap target
hit = page[page.index("async function camHit") :][:2200]
for kind in ('camSignal("ok"', 'camSignal("dup"', 'camSignal("bad"'):
assert kind in hit
assert "void el.offsetWidth" in page # back-to-back reads each replay the animation
# The running list is painted onto the video by every drawer that owns the camera.
assert page.count("camMount(); camFeed(") == 3
style = page[page.index("<style>") : page.index("</style>")]
assert "@keyframes cam-shutter" in style and "prefers-reduced-motion" in style


def test_a_repaint_updates_the_open_drawer_in_place_instead_of_replaying_its_slide_in():
page = _page()
fn = page[page.index(" function paintDrawer(") : page.index(" let drawerSeq = 0;")]
in_place, rebuild = (
fn.index('open.classList.contains("pl-drawer--" + side)'),
fn.index('$("#overlay-root").innerHTML ='),
)
assert in_place < rebuild and "return;" in fn[in_place:rebuild]


def test_holding_the_piece_just_read_in_view_stays_quiet():
page = _page()
hit = page[page.index("async function camHit") :][:2400]
item = hit[hit.index('if (lab.kind === "item")') :]
item = item[: item.index("return;")]
assert 'else if (!had) camSignal("bad"' in item # never "Not added" for a piece already in
assert "else camSignal(" not in item
5 changes: 3 additions & 2 deletions tests/test_scan_in_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ def test_the_scanner_opens_items_and_bins_and_never_navigates():
assert "openItem(it.id)" in fn and "openBin(lab.id)" in fn
assert "location" not in fn and "window.open" not in fn
assert "parseLabel(text)" in PAGE[PAGE.index("async function slScan") :][:600]
hit = PAGE[PAGE.index("async function camHit") :][:700]
assert 'CAM.ctx === "scanlabel"' in hit and "slApply(parseLabel(text))" in hit
hit = PAGE[PAGE.index("async function camHit") :][:1400]
assert "const lab = parseLabel(text);" in hit # parsed once, before any context sees it
assert 'CAM.ctx === "scanlabel"' in hit and "slApply(lab)" in hit
assert 'data-cap === "sl" ? slScan(f)' in PAGE.replace("t.dataset.cap", "data-cap")
Loading
Loading