Skip to content

feat: App chat — in-app nostr support DM entry point - #691

Merged
islandbitcoin merged 2 commits into
mainfrom
feat/app-chat-nostr-support
Aug 15, 2026
Merged

islandbitcoin merged 2 commits into
mainfrom
feat/app-chat-nostr-support

Conversation

@islandbitcoin

Copy link
Copy Markdown
Contributor

What

Adds an App chat row (first option) to Settings → Need help? Contact us. Tapping it opens a private NIP-17 encrypted DM thread with the Flash Support nostr identity (npub1qcesn86prsd9v4y48g4gzxg6gnsunlvhnnuq3kvdhftl7n2yrtyshlsgv9), reusing the chat stack the app already ships — every user already has a nostr key via NostrKeyEnsurer. If the Chat tab isn't enabled yet, it's enabled on first use and navigation is deferred one render so the route exists.

Support side: the identity is bridged into Chatwoot by nostr-dm-bridge (lnflash/flash-support-infra#8), so agents work conversations exactly like the website widget — this gives customers a working in-app support channel while WhatsApp is unavailable, and a first-class private channel after it returns.

The pubkey is overridable via Config.SUPPORT_CHAT_PUBKEY for staging.

Test-infra fixes (first spec to assert on rendered copy)

  • tsconfig.jest.json: jsx: react → react-jsx — app files rely on babel's automatic JSX runtime; several (e.g. group.tsx) have no React import and could never be rendered under ts-jest's classic transform.
  • jest moduleNameMapper + __mocks__/react-native-config.js — the package ships untranspiled and crashed any spec that imported @app/config.
  • New spec loads locales via loadAllLocales() mirroring app.tsx (TypesafeI18n renders nothing until locales load — why no prior spec asserted on copy).

Tests

  • New __tests__/screens/community-need-help.spec.tsx: renders all four contact options; App chat press is a safe no-op before the nostr key exists.
  • Full suite: 56 suites / 316 tests pass; yarn tsc:check clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_016MsAGwtS4sNodzWu2VMTKR

Dread and others added 2 commits August 14, 2026 10:18
Adds an "App chat" row (first option) to Settings → Need help? Contact us.
Tapping it opens a NIP-17 encrypted DM thread with the Flash Support nostr
identity (npub1qcesn86prsd9v4y48g4gzxg6gnsunlvhnnuq3kvdhftl7n2yrtyshlsgv9),
using the chat stack the app already ships. If the Chat tab isn't enabled
yet, it is enabled on first use and navigation is deferred one render.

The support key is bridged to Chatwoot by nostr-dm-bridge in
flash-support-infra, giving customers a private in-app support channel now
that WhatsApp support is unavailable. Overridable via Config.SUPPORT_CHAT_PUBKEY.

Test-infra fixes needed to cover this with a component test (first spec to
assert on rendered copy):
- tsconfig.jest.json: jsx react → react-jsx (app files rely on the automatic
  runtime; group.tsx etc. have no React import)
- jest moduleNameMapper + mock for react-native-config (untranspiled ESM)
- spec loads locales via loadAllLocales(), mirroring app.tsx startup

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016MsAGwtS4sNodzWu2VMTKR
- Surface a "Chat Unavailable" alert with an email fallback when the local
  nostr key is missing (restored-device cohort) instead of a silent no-op
- Replace the 300ms navigation timeout with a deterministic pending-navigation
  effect keyed on persistentState.chatEnabled, so enabling chat and navigating
  to the support DM no longer races the navigator re-render
- Validate the SUPPORT_CHAT_PUBKEY env override: accept 64-char hex or decode
  the npub form; reject anything else back to the baked-in default with a
  console warning (an npub groupId would make support DMs silently go nowhere)
- Replace the coverage-theater spec with behavioral tests: sorted-groupId
  navigation, missing-key alert + working email fallback (navigate not
  called), and one-shot deferred navigation after chatEnabled flips; add unit
  tests for the pubkey normalization
- Add the appChat + new support i18n keys to all 23 locale files, fixing the
  pre-existing translation-drift CI failure on this branch

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016MsAGwtS4sNodzWu2VMTKR
@islandbitcoin
islandbitcoin merged commit d5bd2c5 into main Aug 15, 2026
10 checks passed
islandbitcoin pushed a commit that referenced this pull request Aug 16, 2026
check:translation-drift requires each locale to contain every key in
en.json. Added with the English text as the placeholder, matching how
previous key-adding PRs (#689, #691, #693) seeded new keys before
translation.
islandbitcoin added a commit that referenced this pull request Aug 16, 2026
* fix(swap): stop reporting unsettled conversions as successful

A Cash->BTC conversion showed the success screen while no funds moved,
and the retry died on a generic error. Three defects in the swap flow,
all of which also affect production:

- swap() returned `true` for PENDING, so the confirmation screen
  navigated to "Conversion successful". A payment that is merely in
  flight — or one the API could not confirm at all — rendered as
  settled. It now returns a discriminated {status: "success"|"pending"},
  and the success screen shows an "in progress" state (payment-pending
  icon, its own copy, longer dwell) for the pending case.
- swap() read `status` before `errors`. The API reports a payment it
  could not confirm as PENDING *carrying* an error (see flash#483), so
  errors must win; they now throw.
- prepareUsdToBtc swallowed lnUsdInvoiceFeeProbe payload errors via
  `amount || 0`, sending the user to confirmation on a fee we never
  obtained — the real reason ("An error occurred. Contact support…")
  was discarded and resurfaced later as a vaguer send failure. Probe
  errors and a missing amount are now surfaced at the details screen.
- The Breez branch of swap() fell off the end returning undefined when
  the send failed, which the confirmation screen read as "nothing
  happened": no success, no error, no spinner reset. It now throws on
  failure and distinguishes Completed from Pending.

Also fixes the shared Breez SDK test mock, which exported PaymentStatus
as strings keyed "Complete" while the real SDK (and app code such as
app/types/transactions.ts) uses numeric `Completed` — any test touching
that comparison silently took the wrong branch.

Tests: 10 new covering each behaviour above. Full suite 67/471 green,
tsc clean, no ESLint errors on changed lines.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01NEoz7nBtdtsHyuYG5wNPQV

* chore(i18n): carry the three new keys into every translation file

check:translation-drift requires each locale to contain every key in
en.json. Added with the English text as the placeholder, matching how
previous key-adding PRs (#689, #691, #693) seeded new keys before
translation.

* fix(swap): address review on the pending/probe-error PR

- conversion-details-screen: submit-time errors go to a separate
  `submitErrorMsg` state instead of `errorMsg`. `ConversionAmountError`
  only clears `errorMsg` from an effect keyed on the amount, so a probe
  error parked there left Next permanently greyed out with no hint that
  nudging the amount was the only escape.
- conversion-details-screen: wrap `moveToNextScreen` in try/catch/finally.
  `receivePaymentBreez` has no try/catch and the Apollo fee probe rejects
  on network error, so a probe timeout left the spinner up forever plus an
  unhandled rejection.
- conversion-confirmation-screen: drop the `if (lnInvoice)` wrapper so the
  `!lnInvoice` guard added in useSwap is reachable. `prepareBtcToUsd` can
  produce `lnInvoice: ""`, and Convert was a silent dead tap for it.
- useSwap: switch on the generated `PaymentSendResult` const instead of raw
  string literals, with an explicit `FAILURE` case so `default:` means only
  "unrecognised". A codegen rename would otherwise break the app at runtime
  with every test green.
- useSwap: correct the errors-outrank-status comment — the server does not
  pair an error with a non-failed status today; the ordering is defensive.
- useSwap: `throw new Error("Invoice is already paid")` was hardcoded
  English toasted straight to the user; use the translated
  `ReceiveScreen.invoicePaid`.
- useSwap: delete the three remaining `console.log(">>>>>>>>")` lines; one
  dumped the full Breez receivePayment response into the retained log
  buffer on every USD->BTC conversion.
- i18n: drop all three new English keys. `common.somethingWentWrong` was
  byte-identical to the already-translated `errors.generic`, and the
  pending copy duplicates the fully-translated
  `SendBitcoinScreen.notConfirmed` the send flow already renders for an
  unconfirmed payment. They had shipped as English into all 23 locales;
  app/i18n/ is now byte-identical to main.
- tests: new conversion-success-screen, conversion-confirmation-screen and
  conversion-details-screen suites — the wiring that turns
  `{status: "pending"}` into a pending screen had no coverage at all.
  Verified by mutation: hardcoding `pending`, restoring the `if (lnInvoice)`
  guard, moving the submit error back into `errorMsg`, or removing the
  try/catch each turns them red.
- tests: useSwap's wholesale mock of @app/graphql/generated now takes
  `PaymentSendResult` from `jest.requireActual`, so a codegen change fails
  the test instead of passing against stale literals.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01NEoz7nBtdtsHyuYG5wNPQV

* fix(swap): report probe failures, clear stale submit errors, fix PaymentType mock

Follow-up review fixes on the pending/probe-error PR.

- __mocks__ PaymentType was still string-valued while the real SDK enum is
  numeric (Send = 0, Receive = 1) — the same trap that had already been fixed
  for PaymentStatus three lines below, left armed in the same object literal.
  Any test using a realistic Breez fixture (paymentType: 1) would have compared
  1 === "Receive", taken the send branch, and passed green while asserting the
  opposite of production behaviour. Both enums now carry the generated numbering
  and one comment covering the whole block.
- conversion-details-screen: the new catch swallowed the rejection into on-screen
  text and reported it nowhere, unlike its sibling in conversion-confirmation-screen.
  It now records the error to Crashlytics before setting the message, so the
  fee-probe failure rate is visible in the field.
- conversion-details-screen: submitErrorMsg was cleared only on submit, so a stale
  "An error occurred" stayed pinned under the inputs after a direction flip or an
  amount edit — describing a request that no longer matched the screen. It now
  clears on the same keys ConversionAmountError re-validates on.

Tests:
- app/types/__tests__/transactions.test.ts (new): isReceiveTransaction and
  getTransactionStatus against raw numeric SDK values; red with the string mock.
- conversion-details-screen tests: the amount-validation gate test now actually
  produces an error (was passing purely on "no amount entered", so deleting
  `|| Boolean(errorMsg)` left the suite green); a new test drives the USD→BTC
  direction and asserts prepareUsdToBtc is the one called; two new tests cover
  stale submit-error clearing; the reject tests now assert the Crashlytics report.

All five fixes verified by mutation: reverting each one turns its test red.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01NEoz7nBtdtsHyuYG5wNPQV

* fix(swap): record non-Error rejections to Crashlytics too

The catch branch added for non-Error rejections showed the generic copy
and recorded nothing, so the least diagnosable failure — an Apollo link
or Breez binding throwing a string — was also the only invisible one.
Wrap instead of branching: the report now carries the raw thrown value,
while the user still sees the generic message.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01NEoz7nBtdtsHyuYG5wNPQV

* style: prettier formatting on the crashlytics wrap

---------

Co-authored-by: Dread <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant