toga-ai 1.0.748 → 1.0.749

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,106 @@
1
+ ---
2
+ type: session
3
+ slug: transfer-order-create-modal
4
+ title: Create Transfer Order modal — single-POST create + design-matched UI
5
+ author: apeterson
6
+ repos: [toga25-supply, _underscore, dbchanges2, api2]
7
+ framework: "2.0"
8
+ client: nychh
9
+ status: active
10
+ created: 2026-09-02
11
+ updated: 2026-09-02
12
+ ---
13
+
14
+ # Session: transfer-order-create-modal
15
+ **Date:** 2026-09-02
16
+ **Project/Repo:** toga25-supply (+ _underscore, dbchanges2, api2) — 2.0
17
+ **Task:** Build the Create Transfer Order modal for NYCHH end to end — one atomic POST, the three new `TransferOrders` columns behind it, and the picker/dropdown UI matched to the Claude Design mockup.
18
+
19
+ ---
20
+
21
+ ## What WORKED
22
+
23
+ - **Single POST create.** `useCreateTransferOrder.ts` now posts header + lines in one request to `/transfer-orders`, lines nested under `transferOrderItems`. Verified against the engine, not guessed: `api2/Component/Api/V2/V2.php:3248` converts the inherent child's `route` kebab→camel, and `:5241` uses the SAME lookup on the CREATE path (`$childrenToCreate[$key] = $val`). Jeff's nesting row exists — `InherentRecordChildren` id 152, parent record 312 → child 313, route `transfer-order-items` (confirmed by query).
24
+ - **Three new columns.** `_underscore/Model/Client/TransferOrder.php` has `contactId` (FK Contacts), `createdByUserId` (FK Users), `description` (varchar 255). Migrations written and guarded with `INFORMATION_SCHEMA` checks.
25
+ - **Core ids verified against production before use.** `Records` MAX(id) = 358; RecordFields 2561–2563 free. Handoff for the team: next `Records.id` = 359, next `RecordFields.id` = 2564.
26
+ - **TransferOrderNotes tables + metadata ran clean.** `Client/2026-09-01b` and `Core/2026-09-01c` are applied (Records 357/358, RecordFields 2550–2560). Both tables ship empty. NOTE: now unused — see Decisions.
27
+ - **Target Location picker.** `SelectTargetLocationModal.tsx` — flat list, 250 ms debounced search, breadcrumb path built from `parentLocation.uuid` with a cycle guard.
28
+ - **Contact scoping.** Contacts come from `Contacts` through the `Contacts_Locations` junction, scoped to the chosen location (`useLocationContacts.ts`).
29
+ - **One select control for the whole modal.** New app-local `PanelSelect.tsx` — 38px trigger, search box inside the panel, green check on the chosen row, optional pinned footer, optional clear (×). `ContactSelect.tsx` is now a thin mapping over it. The PO filter uses it at 200px with "All POs" as a row in the list. Matches the mockup's `window.FormSelect` / `FilterLockSelect`.
30
+ - **"Show more" on the item cell.** `TransferItemPickerTable.tsx`, rules copied from blox `PrimaryTableBodyCell`: offered only when text is really clipped (measured on hover), collapsed visibility is CSS `group-hover` not state, expanded wraps above a "Show less" toggle and grows the row (body cells align top), toggle `stopPropagation`s so it never checks the row. Cells cap at 300px so clipping can happen at all in an auto-layout table. Items table max height 355px.
31
+ - **Blank Item column fixed.** Label chain is `item.title || item.description || "(untitled item)"`, and `vendorItem.item.description` was added to the requested fields.
32
+ - **Verification each time:** `npx tsc --noEmit` exits 0; `npx eslint src/pages/TransferOrders/view/CreateTransferOrderModal` stays at the same 8 pre-existing errors (2 `set-state-in-effect`, 1 `react-hooks/refs`, 4 `no-explicit-any`, 1 `react-refresh/only-export-components`). Baseline was established with `git stash`, so "zero new errors" is measured, not assumed.
33
+
34
+ ## What did NOT work — DO NOT RETRY THESE
35
+
36
+ - **Three sequential POSTs to create a transfer.** Abandoned: it can leave a half-written transfer behind. The inherent-child single POST is one API transaction, which the front controller commits on success and rolls back on failure.
37
+ - **A scripted API endpoint for transfer create.** Not needed once the inherent child works. Developer decided no.
38
+ - **`useCallback` around the modal's `submit`.** React Compiler bailed with "Compilation Skipped: Existing memoization could not be preserved." Fixed by making `submit` a plain function. Do not wrap it again.
39
+ - **A `useEffect` that called `close()` when the select went disabled.** Tripped `react-hooks/set-state-in-effect`. Replaced with derived state: `const isPanelOpen = isOpen && !disabled;`.
40
+ - **Bare FK column names in the `fields` option.** I wrote `parentLocationId` and it returned nothing. This repo uses dotted paths — `parentLocation.uuid`, `vendorItem.item.title` — and FKs POST as nested `{ uuid }` objects.
41
+ - **A native `<select>` for the PO filter.** Looked like a different control next to the custom contact select. The mockup draws both with the same `FormSelect`.
42
+ - **Falling back to a part number for the item label.** Part Number already has its own column, so it duplicates a cell instead of naming the item.
43
+ - **`Locations.primaryContactId` as a default-contact FK.** Developer rejected it: `Contacts_Locations` is the right place.
44
+ - **A unique index on `Contacts_Locations (locationId, type)`.** Wrong — it is many-to-many, many contacts per location. Only `isPrimary` is viable.
45
+ - **My `_qty*` diagnosis "no ItemReceiptItems exist, it's data."** Wrong. The developer's query returned `216 | 80622 | 3270.00 | 27 | 3270.00` — receipts do exist. The seed-the-receipts plan built on that was also scrapped.
46
+ - **`AUTO_INCREMENT` / repo-derived ids for `Records` / `RecordFields`.** Never do this. They are the only two tables platform-wide with team-assigned ids; ask the developer, and the repo lags production.
47
+ - **Python heredoc edits that assume indentation depth.** Failed twice (`AssertionError: ('type', 0)`) — assumed 4 tabs where it was 3, and 10 where it was 11. Print `repr()` first or slice by index. The asserts fire before the write, so no file was corrupted.
48
+
49
+ ## Not tried yet (candidates for next session)
50
+
51
+ - A live POST of the create flow. **Nothing in this modal has been sent to a real API yet.** Blocked on the two pending migrations + the `_underscore` deploy.
52
+ - Setting `transferOrderStageId` on create — unknown which stage row NYCHH seeds as the opening one.
53
+ - Minting `TransferOrders.number`. Deliberately not done client-side: two concurrent creates would race. Needs a server-side owner.
54
+ - Stamping `createdByUserId` from the JWT server-side instead of from the browser's `user` localStorage key.
55
+ - Dropping the now-unused `TransferOrderNotes` / `TransferOrderNoteTypes` tables and their Core metadata (Records 357/358, RecordFields 2550–2560).
56
+ - Adding the ACL grant for NYCHH on records 357/358 — currently missing (only needed if the notes tables stay).
57
+ - Adding the magnifier icon inside the item search box (the mockup has one on the left; ours has none).
58
+ - Populating `Items.title` for NYCHH — the real fix behind the description fallback.
59
+
60
+ ## Current file state
61
+
62
+ | File | Status | Notes |
63
+ |------|--------|-------|
64
+ | `toga25-supply/.../CreateTransferOrderModal/hooks/useCreateTransferOrder.ts` | Modified | Single POST; exports `DESCRIPTION_MAX_LENGTH = 255`; omits `number` on purpose |
65
+ | `toga25-supply/.../hooks/usePurchaseOrderItemRows.ts` | Modified | `item.description` fallback; `VITE_TRANSFER_IGNORE_AVAILABILITY` escape hatch |
66
+ | `toga25-supply/.../hooks/useTargetLocationOptions.ts` | Modified | `parentLocation.uuid` dotted path; breadcrumb path + cycle guard |
67
+ | `toga25-supply/.../hooks/useLocationContacts.ts` | Modified | Contacts via `Contacts_Locations`, scoped to the location |
68
+ | `toga25-supply/.../hooks/useCreateLocationContact.ts` | Modified | Inline add-contact |
69
+ | `toga25-supply/.../view/SelectTargetLocationModal.tsx` | Created | Flat picker, debounced search, 720px card |
70
+ | `toga25-supply/.../view/PanelSelect.tsx` | Created | The one select control; `// TODO(blox): promote once stable` |
71
+ | `toga25-supply/.../view/ContactSelect.tsx` | Rewritten | Now a thin wrapper over `PanelSelect` |
72
+ | `toga25-supply/.../view/TransferItemPickerTable.tsx` | Modified | 355px max height, column lines, `ExpandableText` show-more, `align-top` cells |
73
+ | `toga25-supply/.../view/TransferNotesField.tsx` | Modified | Optional `maxLength`, wired to 255 |
74
+ | `toga25-supply/.../CreateTransferOrderModal.tsx` | Modified | `PanelSelect` for PO (200px, "All POs" row), plain `submit`, inline error |
75
+ | `_underscore/Model/Client/TransferOrder.php` | Modified | `contactId`, `createdByUserId`, `description` — **not deployed** |
76
+ | `_underscore/Model/Client/TransferOrderNote.php` | Created | Mirrors `PurchaseOrderNote` — currently unused |
77
+ | `_underscore/Model/Client/TransferOrderNoteType.php` | Created | Mirrors `PurchaseOrderNoteType` — currently unused |
78
+ | `dbchanges2/Client/2026-09-01b - TransferOrderNotesTables.sql` | Applied | Ran |
79
+ | `dbchanges2/Core/2026-09-01c - TransferOrderNotesRecords.sql` | Applied | Ran — Records 357/358, RecordFields 2550–2560 |
80
+ | `dbchanges2/Client/2026-09-01c - TransferOrderContactCreatedByAndDescription.sql` | **Not run** | 7 `INFORMATION_SCHEMA`-guarded sections; run on every client DB |
81
+ | `dbchanges2/Core/2026-09-01d - TransferOrderContactCreatedByAndDescriptionRecordFields.sql` | **Not run** | RecordFields 2561–2563 on record 312 + ACL roles 1 and 3 |
82
+
83
+ All application-repo changes sit uncommitted in the working tree on branch `features-talos-transferorders`. Nothing was committed or pushed.
84
+
85
+ ## Decisions made
86
+
87
+ - **One POST, not a scripted endpoint.** The inherent child gives the same all-or-nothing write, so a custom endpoint buys nothing. Rejected: three sequential POSTs (can half-write), a scripted API method.
88
+ - **The modal's Notes box writes `TransferOrders.description`, not a note row.** A transfer carries one free-text description, not a thread of typed notes from different authors. Consequence: `TransferOrderNotes` / `TransferOrderNoteTypes` are now unused even though they are already migrated. Rejected: posting a `TransferOrderNotes` row per create.
89
+ - **`createdByUserId` is client-supplied** (read from the `user` localStorage key), matching the SalesOrders precedent. It is only as trustworthy as this client — still open for Jeff. Rejected for now: JWT-stamped server-side.
90
+ - **`number` is left NULL.** Minting max+1 from the browser races two concurrent creates. Rejected: client-side minting.
91
+ - **The contact list lives in `Contacts_Locations`,** not a `Locations` FK — the developer's call. Many contacts per location, so only `isPrimary` can mark a default.
92
+ - **`PanelSelect` is app-local, not blox.** Front-end standard §21: build it here, promote after a second consumer. blox's `AdvancedSelect` has `renderOption` but no footer slot, and a sentinel row inside `data` gets filtered out by the very search that makes you need it.
93
+ - **Grid geometry stays in the front end.** Cell max width, table max height and column lines are presentation, not surface metadata.
94
+ - **`VITE_TRANSFER_IGNORE_AVAILABILITY` is local-only.** It disables the guard that stops a transfer asking for more than can be dispatched. **Never set it in a deployed environment.**
95
+
96
+ ## Blockers
97
+
98
+ - **`_qty*` returns 0 for every NYCHH PO line.** For PurchaseOrderItem `715ef031-003d-6742-871d-0d20de2fa40f` (PO 80622, line 21) the API gives `quantity: 3270` but `_qtyReceived` / `_qtyOnHand` / `_qtyAvailable` / `_qtyFulfilled` are all `0`, while SQL on `Client_Nychh` gives received 3270. A literal `0` (not absent) rules out field ACL and `calcDepth`. Physical shadowing columns also ruled out (the blank template has 7 columns on `PurchaseOrderItems`). The team KB already has the cause from 2026-09-01: the deployed `_Model_Nychh_PurchaseOrderItem` INNER JOINs `InventoryAdjustmentItems.itemFulfillmentItemId`, which is NULL on 100% of rows. Talk to Jeff as "this narrows the known blocker", not as a new bug. Worked around locally with `VITE_TRANSFER_IGNORE_AVAILABILITY=true`.
99
+ - **Two migrations + one deploy are pending,** so the create path cannot be tested live yet (see next step).
100
+
101
+ ## Exact next step
102
+
103
+ > Run the pending rollout, in this order: (1) deploy `_underscore` so `TransferOrder.php` carries `contactId` / `createdByUserId` / `description`; (2) run `dbchanges2/Client/2026-09-01c - TransferOrderContactCreatedByAndDescription.sql` on every client DB; (3) run `dbchanges2/Core/2026-09-01d - TransferOrderContactCreatedByAndDescriptionRecordFields.sql` on Core; (4) post `next Records.id = 359` / `next RecordFields.id = 2564` to the team; (5) create one test transfer in the modal with `VITE_TRANSFER_IGNORE_AVAILABILITY=true` and confirm the row has `contactId`, `createdByUserId`, `description`, and its `TransferOrderItems` rows written in the same request.
104
+
105
+ ---
106
+ _Saved by /session-save on 2026-09-02_
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toga-ai",
3
- "version": "1.0.748",
3
+ "version": "1.0.749",
4
4
  "description": "TOGA Technology Team Claude Knowledge System — shared AI coding harness with skills, knowledge base CLI, and project installer for Claude Code.",
5
5
  "keywords": [
6
6
  "claude",