Skip to content

feat(companion): open the asset from an audit row - #2989

Open
carlosvirreira wants to merge 1 commit into
mainfrom
feat/companion-audit-row-opens-asset
Open

carlosvirreira wants to merge 1 commit into
mainfrom
feat/companion-audit-row-opens-asset

Conversation

@carlosvirreira

@carlosvirreira carlosvirreira commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Why

A field worker who finds a missing or unexpected asset during an audit needs to open that asset and update it right there. On the web audit detail page the asset row already links its title to the asset page (audit-asset-list-item.tsx). On the phone the row was inert unless it had evidence, in which case the whole card opened the evidence viewer.

The row was made inert because an earlier router.push("/(tabs)/assets/...") from the Audits stack polluted the Assets tab's stack. pushIntoTab (lib/navigation.ts) has since solved that for bookings, home and the scanner: it navigates with withAnchor, so the Assets list sits beneath the asset detail and "back" has a target. The audit row now uses the same helper.

Change

  • apps/companion/app/(tabs)/audits/[id].tsx
    • DisplayAsset gains assetId: string | null. Expected rows carry the asset id; unexpected scans carry scan.assetId, or null when the asset was deleted. The existing id field (the FlatList key) is unchanged.
    • Card tap: a row with a non-null assetId is a TouchableOpacity that calls pushIntoTab("/(tabs)/assets", "/(tabs)/assets/<assetId>"). A deleted-asset row stays an inert View (accessibilityRole="summary").
    • Evidence chip: the note/photo count chip is now its own TouchableOpacity (with hitSlop 8 on each side) that opens the evidence viewer exactly as the card did before. Evidence stays reachable on every row that has it, including a deleted-asset row, where the chip is the only tappable element.
    • Accessibility: the card keeps accessible and a composed label; a card that opens the asset ends with "tap to open asset" and has role button. The chip gets its own label (for example 2 notes, 1 photo, tap to view) and role button. Because accessible folds the chip into the card for screen readers, rows with evidence also expose a View evidence custom accessibility action (VoiceOver rotor / TalkBack actions menu) that opens the viewer.
    • The JSX comment describing the removed cross-tab push is replaced with comments that describe the current behaviour.
    • useCallback dependencies are unchanged; pushIntoTab is a module import.
  • apps/companion/.maestro/flows/audits/06-row-opens-asset.yaml (new)
    • Opens SHELF_TEST_AUDIT_NAME from the Audits list, taps the first row whose label ends in "tap to open asset", asserts the asset detail ("Created" is always rendered there), presses back and asserts the Assets list is shown (the anchor pushIntoTab places beneath the detail), then reopens the audit from Home and asserts the audit detail is intact.

Not changed: components/audit/scanned-items-list.tsx (row tap opens the evidence modal on the scan screen) and components/audit/remaining-assets-list.tsx (image tap opens an image preview). Neither opens the asset; that is out of scope here.

Note on back navigation: the Audits group is hidden from the tab bar (href: null), so after "back" lands on the Assets list the audit is reopened from Home. The audit's own stack stays mounted throughout.

Testing

Run in apps/companion:

  • npx tsc --noEmit: 0 errors.
  • pnpm lint (expo lint + scripts/check-version-sync.mjs): clean; version sync OK.
  • pnpm test (node test runner, lib/**/*.test.ts): 80 passed, 0 failed. The companion has no vitest setup.
  • npx prettier --check on both changed files: clean.

The Maestro flow 06-row-opens-asset.yaml has NOT been run on a device or simulator yet. It follows the selectors and fixtures the other audit flows use (SHELF_TEST_AUDIT_NAME, "Created" on the asset detail, Filter: All on the audit detail, "Search assets" on the Assets list).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Tapping a live asset row in an audit now opens that asset’s detail page.
    • Evidence can be opened from a dedicated evidence control within the audit row.
    • Back navigation from asset details returns to the audit’s Assets list.
  • Bug Fixes

    • Deleted assets remain non-interactive summaries instead of attempting to open unavailable details.
    • Audit details remain intact after navigating to an asset and returning.
  • Tests

    • Added an end-to-end flow covering asset navigation, back navigation, and audit state preservation.

An asset row on the audit detail screen now opens the asset detail, matching
the web audit row where the title links to the asset page. A field worker who
finds a missing or unexpected asset can open it and update it from the audit.

The row was inert because an earlier cross-tab router.push polluted the Assets
tab's stack. pushIntoTab already solves that for bookings, home and the
scanner by anchoring the Assets list beneath the detail, so the row uses it.

DisplayAsset gains assetId (null for a deleted asset, whose row stays inert).
The evidence chip becomes its own touchable with hitSlop so evidence stays
reachable on every row, including a deleted-asset row. The card keeps a
composed accessibility label ending in "tap to open asset"; the chip gets its
own "tap to view" label, and rows with evidence expose a "View evidence"
custom accessibility action because the accessible card folds the chip in.

Adds a Maestro regression flow (audits/06-row-opens-asset.yaml). It has not
been run on a device yet.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@carlosvirreira carlosvirreira added the companion Companion (mobile) app — tag every companion-related PR label Sep 2, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-02T12:14:35.211382Z e9903fa PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

🩺 React Doctor — companion

Findings on the files changed by this PR:

  • 0 errors
  • 5 warnings — advisory
⚠️ 5 warnings (click to expand)
  • react-doctor/rn-prefer-reanimated (1)
    • apps/companion/app/(tabs)/audits/[id].tsx:11
  • react-doctor/rn-no-legacy-expo-packages (1)
    • apps/companion/app/(tabs)/audits/[id].tsx:18
  • react-doctor/prefer-useReducer (1)
    • apps/companion/app/(tabs)/audits/[id].tsx:158
  • react-doctor/no-giant-component (1)
    • apps/companion/app/(tabs)/audits/[id].tsx:158
  • react-doctor/no-cascading-set-state (1)
    • apps/companion/app/(tabs)/audits/[id].tsx:226

Run locally with pnpm companion:doctor for a full scan, or cd apps/companion && pnpm exec react-doctor . --diff for the same diff-only view.

@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 96ab53dc-1909-4844-a58d-fe2c9654b31a

📥 Commits

Reviewing files that changed from the base of the PR and between 6d7af8a and e9903fa.

📒 Files selected for processing (2)
  • apps/companion/.maestro/flows/audits/06-row-opens-asset.yaml
  • apps/companion/app/(tabs)/audits/[id].tsx

Included review availability: Your plan provides up to 8 included reviews per hour; 4 remain after this review.


Walkthrough

Changes

Audit asset navigation

Layer / File(s) Summary
Audit row navigation and evidence actions
apps/companion/app/(tabs)/audits/[id].tsx
Audit rows now carry nullable asset IDs. Live asset rows open the asset detail through the Assets tab. Deleted asset rows remain inert. Evidence opening uses a separate tappable chip and accessibility action.
End-to-end navigation validation
apps/companion/.maestro/flows/audits/06-row-opens-asset.yaml
The Maestro flow verifies asset opening, back navigation to the Assets list, and audit re-entry.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to e9903

This localized change adds asset navigation while preserving evidence access and deleted-asset handling. No actionable merge-blocking risk remains beyond normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant AuditDetail
  participant Navigation
  participant AssetDetail
  participant AssetsList
  AuditDetail->>Navigation: Tap live asset row
  Navigation->>AssetDetail: Open asset detail in Assets tab
  AssetDetail->>AssetsList: Press back
  AssetsList-->>AuditDetail: Show Assets list
Loading

Suggested reviewers: donkoko

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: opening an asset from an audit row in the Companion app.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/companion-audit-row-opens-asset

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

companion Companion (mobile) app — tag every companion-related PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant