Skip to content
Vocino edited this page Aug 20, 2026 · 6 revisions

Import

Location

  • Left rail $ import field (280px rail, not route, not overlay)
  • Top-right [ Sync / Import ] -> Import addon (wb1!)
  • Settings -> Import (same decoder)
  • Hotkey i anywhere. Opens rail tab if collapsed.

Flow

  1. Click Import or press i. Must be user gesture for navigator.clipboard.readText().
  2. If clipboard is wb1! length >10 -> auto-fill preview. Zero paste needed.
  3. Otherwise text area focused "Paste wb1! here Ctrl+V" -> debounce 150ms -> preview.
  4. Preview sentence (rail cannot hold 8 columns): "6 characters, 1 over 3 days, Enter to import" plus rows with dots, hover per-section.
  5. Enter confirms -> POST /api/addon/import { bundle:"wb1!..." } -> D1 character_addon_cache and warband_bank_cache upsert per user_id + char_key.
  6. Receipt: one line per character dot + gold printed in waves like $ output, held 6 seconds, decayed in 4 steps, removed. Block returns to original height.
  7. Nothing reloads. Only that line is stamped. Reload would discard receipt (what the overlay version did).

Validation

Client-side before D1 write:

  • Not wb1! -> if wb0! then "That is Camp DNA, not inventory, use Share tab" else "Does not look like wb1!, run /warband copy again"
  • Over 20 characters or over 1 MB decoded -> "Too large, try single-character"
  • Missing characters not deleted -> keeps old snapshot aging red. Staleness lowers confidence, never deletes.
  • One character 39 KB JSON 8.6 KB wire, 6 154 KB / 26 KB, 20 cap 474 KB / 73 KB. 4-7 KB figure is slim with no per-item lists.

Library

src/lib/warband-import.ts is pure, testable via Vitest, no DOM or D1:

  • WIRE_PREFIX='wb1!', DNA_PREFIX='wb0!', MAX_CHARACTERS=20, MAX_DECODED_BYTES=1_048_576
  • Base64url -> bytes -> DecompressionStream('deflate-raw') not deflate (zlib header addon does not emit, use raw or pako.inflateRaw)
  • Throws on invalid input.

Web tests src/__tests__/warband-import.test.ts. Addon vectors docs/contract/vectors/v1-min.wb1.

Parser Hazard

Any element whose raw text begins with // inside an Astro expression is deleted from output silently. Compiler reads // as line comment. No error.

Fix: never write literal // in .cmt text. Mark is .cmt::before CSS. Literal doubles when rendered and deletes when absent. Always a defect.

Clipboard

  • HTTPS and user gesture required. Warband.pro is HTTPS so Chrome and Edge work.
  • Never polling readText, only inside click.
  • Do not auto-submit. User confirms after seeing staleness.
  • Firefox and Safari are stricter -> fallback to text area Ctrl+V.

Tonight Plan

After confirm, scorer re-reads consumables rollup (tonight.ts, warband-import.ts types). Freshness changes block to grey text.

Warband.pro Companion

Home

Start

Integration

Internals

Clone this wiki locally