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
88 changes: 88 additions & 0 deletions .agent/context/20260913T065500Z-privy-browser-buffer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Session Context: Privy browser Buffer

## Date/time

- UTC: 2026-09-13T06:55:00Z

## User goal

Fix the Privy approval failure that displays `Buffer is not defined` after the
user approves an Arc Testnet USDC transfer.

## Original prompt/request

The user supplied screenshots of the Privy approval and failure dialogs and
asked to fix the issue.

## Assumptions

- The failure is in the browser bundle after approval; the backend settlement
and retry behavior must remain unchanged.
- Existing unrelated backend work in another worktree must remain untouched.

## Plan

1. Reproduce the missing browser-global dependency from the installed Privy
transaction path.
2. Install the existing `buffer` package as an explicit web dependency and
initialize it before Privy's lazy-loaded wallet code runs.
3. Build and run focused web checks.

## Key decisions

- Apply one entry-point polyfill because the installed Privy client contains
transaction paths that reference the global Node `Buffer` in the browser.
- Do not alter wallet selection, transaction parameters, settlement state, or
retry behavior.

## Files/components touched

- `apps/web/src/main.tsx`: initialize the browser `Buffer` global before Privy.
- `apps/web/package.json` and lockfile: make the polyfill a direct dependency.

## Commands/checks

- `pnpm --filter @oneshot/web typecheck` - PASS.
- `pnpm --filter @oneshot/web test` - PASS, 17 files / 93 tests.
- `pnpm --filter @oneshot/web build` - PASS; generated entry contains the
`globalThis.Buffer` initialization.
- `pnpm --filter @oneshot/web test:browser` - PASS, 8 Chromium tests; includes
an assertion that the browser global is installed.
- `pnpm lint` - PASS.
- `pnpm format:check` - PASS.
- `git diff --check` - PASS.
- Local Node is v22.23.2 while the repository requests v24.19.0.

## External-doc findings

- None; the installed dependency and observed runtime error establish the
compatibility issue.

## Unresolved questions

- A final live Privy approval requires the deployed frontend and the user's
wallet session; local checks cover bundle availability and existing wallet
behavior.

## Git and PR state

- Branch: `fix/privy-browser-buffer`
- Base: `origin/develop` at `5e1c9e9210ef22416ee8b62713e9a3e597bb4577`
- Implementation commit: `4721961d7e55047d120e2d4e51dc3a40b4d520bb`
- PR: [#126](https://github.com/SWOFART/OneShot/pull/126), draft
- CI: repository policy, Markdown/Mermaid, and Cloudflare Workers build passed;
frontend browser acceptance and ESLint/TypeScript were pending at this snapshot.
- Production frontend: Cloudflare Worker version
`935dfd2b-8fba-4875-964e-7f609c472378`; the public page returned HTTP 200 and
its entry bundle contained the `globalThis.Buffer` initialization.

## Review gates

- Gate A: NOT RUN under the user's standing explicit instruction to continue
without FreePi; no PASS is claimed.
- Gate B: NOT RUN

## Handoff/next steps

1. Wait for remaining PR checks and have the user retry one approved testnet
transfer; agents do not merge.
1 change: 1 addition & 0 deletions apps/web/browser/p5.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ async function unlockWorkspace(page: Page): Promise<void> {
test.describe('resumable job workspace', () => {
test('keeps the public landing separate from the authenticated cabinet', async ({ page }) => {
await page.goto('/');
expect(await page.evaluate(() => typeof globalThis.Buffer)).toBe('function');
await expect(
page.getByRole('heading', { name: 'Resume the job, not the payment.' }),
).toBeVisible();
Expand Down
1 change: 1 addition & 0 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@oneshot/recovery-ui": "workspace:*",
"@oneshot/settlement-ui": "workspace:*",
"@privy-io/react-auth": "3.6.1",
"buffer": "6.0.3",
"viem": "2.36.0",
"react": "19.2.8",
"react-dom": "19.2.8"
Expand Down
3 changes: 3 additions & 0 deletions apps/web/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { Buffer } from 'buffer';
import { lazy, StrictMode, Suspense } from 'react';
import { createRoot } from 'react-dom/client';
import { App } from './App.js';
import { WorkspaceLoading } from './components/WorkspaceLoading.js';

globalThis.Buffer ??= Buffer;

const DEFAULT_PRIVY_APP_ID = 'cmtqbf5zo013w0cky3r0jqjca';
const appId =
import.meta.env.MODE === 'test'
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading