From d00fe1dd6a56ec7e66d085568c8ab9d6c19983ca Mon Sep 17 00:00:00 2001 From: ancung Date: Thu, 12 Nov 2026 22:44:46 +0700 Subject: [PATCH] feat(fe): call the try-out a guest session on screen Axel asked for guest wording (12 Nov): "Try without a wallet" read technical, and its line "... Deleted after 7 days." was cut off. The sign-in button now reads "Continue as guest", "No sign-up. 20 messages with a shared test wallet.", with a person icon. Every other visible "try-out" follows (about 50 lines: the chat banner and lock, locked owner actions, skills, settings, connections, wallet, errors), e.g. "Guest: 18 of 20 messages left", "Guest session finished", "Not available to guests". The code keeps tryOut and demo, as the API does. Tests: typecheck, eslint, vitest 276/276 (expectations updated). Co-Authored-By: Claude Opus 5.5 --- apps/fe/CLAUDE.md | 4 ++-- .../modules/auth/components/SignInScreen.tsx | 8 +++---- .../auth/components/TryOutLockedDialog.tsx | 14 ++++++------ apps/fe/src/modules/auth/data/errors.ts | 6 ++--- .../modules/autopilot/components/Ideas.tsx | 2 +- .../autopilot/components/JobDetail.tsx | 2 +- .../modules/chat/components/ChatScreen.tsx | 12 +++++----- apps/fe/src/modules/chat/data/thread.ts | 2 +- .../components/ConnectionsScreen.tsx | 4 ++-- .../connections/components/KeyDialogs.tsx | 2 +- .../components/AutoApproveSection.tsx | 4 ++-- .../settings/components/DeleteMindDialog.tsx | 2 +- .../settings/components/GeneralSection.tsx | 2 +- .../settings/components/MemorySection.tsx | 6 ++--- apps/fe/src/modules/skills/data/skills.ts | 10 ++++----- .../fe/src/modules/skills/data/trackSkills.ts | 22 +++++++++---------- .../wallet/components/WalletScreen.tsx | 2 +- apps/fe/tests/meet.test.ts | 2 +- apps/fe/tests/sign-in.test.ts | 4 ++-- apps/fe/tests/skills.test.ts | 6 ++--- 20 files changed, 58 insertions(+), 58 deletions(-) diff --git a/apps/fe/CLAUDE.md b/apps/fe/CLAUDE.md index 13e4725d..72d91c8f 100644 --- a/apps/fe/CLAUDE.md +++ b/apps/fe/CLAUDE.md @@ -62,7 +62,7 @@ src/ tests/ unit tests ``` -Routes: `/` sign in (`SignInScreen`, design L1 and T1.1; once signed in it opens the newest Mind, or `/minds/new` when there is none, except a try-out with no Mind yet, which stays: Back from Choose a Mind returns to sign-in, and the try-out button reads "Continue your try-out" and reuses that session instead of making a new one; Ancung, 9 Nov), `/minds/new` Choose a Mind, and `/minds/[mindId]/{chat,chat/[threadId],wallet,skills,autopilot,connections,attack,settings}` inside `AppShell`; `/minds/[mindId]` redirects to chat and an unknown Mind is not found. The Builder (`/autopilot/new`, `/autopilot/{job}`) opens from Autopilot (no nav item) and has no app shell: Mind pages sit in route groups, `(shell)` with `AppShell` in its layout and `(focus)` for the Builder, while `[mindId]/layout.tsx` keeps `MindGate` and `ChatRunProvider` for both (Ancung, 9 Nov: a page without the sidebar to focus; the design's B1 is full screen too). URLs didn't change. +Routes: `/` sign in (`SignInScreen`, design L1 and T1.1; once signed in it opens the newest Mind, or `/minds/new` when there is none, except a try-out with no Mind yet, which stays: Back from Choose a Mind returns to sign-in, and the guest button reads "Pick up where you left off" under "Continue as guest" and reuses that session instead of making a new one; Ancung, 9 Nov), `/minds/new` Choose a Mind, and `/minds/[mindId]/{chat,chat/[threadId],wallet,skills,autopilot,connections,attack,settings}` inside `AppShell`; `/minds/[mindId]` redirects to chat and an unknown Mind is not found. The Builder (`/autopilot/new`, `/autopilot/{job}`) opens from Autopilot (no nav item) and has no app shell: Mind pages sit in route groups, `(shell)` with `AppShell` in its layout and `(focus)` for the Builder, while `[mindId]/layout.tsx` keeps `MindGate` and `ChatRunProvider` for both (Ancung, 9 Nov: a page without the sidebar to focus; the design's B1 is full screen too). URLs didn't change. App shell (`src/components/layout`, design N1): phone below 768 px (`md`) gets `MobileHeader` (menu with an amber dot while an approval waits, Mind switcher sheet) and a left drawer; tablet 768 to 1279 gets the 72 px rail whose top button opens the full sidebar over the page; desktop from 1280 (`xl`) gets the 256 px sidebar that folds into the rail (saved in `localStorage` as `hellonear.sidebar.folded`). `MindSwitcher` and `AccountMenu` (Appearance System/Light/Dark, Sign out) each have trigger variants for these places. Nav items live in `nav.ts`. In the full sidebar and the phone drawer the menu and Recent chats scroll together, with the scrollbar on the sidebar's edge (`SidebarScroll`, decided 9 Nov with Ancung, like Claude; before, only Recent chats scrolled); the logo, the Mind and the account stay put. Where more of the menu is hidden above or below, it fades into the sidebar's colour (24 px at the top, 32 px at the bottom), stopping short of the scrollbar, like the chat under its header (Ancung, 11 Nov); each fade shows only when there is something to scroll to on that side. @@ -201,7 +201,7 @@ Imports: `@/*` → `src/*`, `@app/*` → `app/*`. Keep route files in `app/` thi - **Hosting (#125):** `deploy/deploy.sh` builds this app on the deploying machine (`next build` with `NEXT_PUBLIC_API_URL`, the only build-time setting) and the demo box runs it with `next start` on port 3000 (`deploy/systemd/hellonear-fe.service`), behind the tunnel at `https://app.hellonear.xyz` (the old `hellonear.jameshub.fun` redirects there, `next.config.js`; the apex `hellonear.xyz` serves the landing page on its own port since 12 Nov, #266, so its redirect here was removed). A merge to `main` deploys it with the backend and engine (`deploy/README.md`). A new build-time env var must be added to `deploy.sh` too, or the hosted build won't have it. - Call the backend with `api()` from `src/lib/api.ts` (`credentials: "include"`, JSON). Failures throw `ApiError` with `status`, `code` (the backend's `error`) and `details`. - Sign-in (`src/modules/auth`, NEP-413, `docs/api-contract.md` §7): connect a wallet if none is connected, `POST /auth/challenge`, the wallet signs exactly `{ message, recipient, nonce }` (nonce decoded from base64 to 32 bytes; recipient comes from the challenge, `hellonear.app` on the hosted demo), then `POST /auth/login`. `useSignIn` signs through `connector.wallet()` / `connector.connect()` because the hook's own `signNEP413Message` reads wallet state from the previous render. `useSession` is the `["session"]` query (`GET /me`, `null` on 401); `useSignOut` logs out, disconnects the wallet and clears the query cache. The account shown in the app is the session's `nearAccountId`, not the wallet's. -- `SignInScreen` (`/`, design "3 · Start" L1, T1.1): the forest photo from the design (Unsplash, saved as `public/sign-in/forest.jpg` so the page doesn't load it from outside; desktop only) with the "Your limits stay yours." caption, then three choices. **Meteor Wallet** (with Meteor's own logo, `MeteorLogo` in `AppLogos.tsx`, the icon the official manifest lists, copied as is) opens Meteor straight away (`connector.connect({ walletId: "meteor-wallet" })`, the id in the official manifest `hot-dao/near-selector`, read 9 Nov); **Other NEAR wallets** opens the NEAR Connect list; after an "or" divider, **Try without a wallet** (`POST /auth/demo`). The chosen button shows "Waiting for Meteor"; a canceled signature says "Sign-in was canceled in the wallet. Nothing changed." (L1.3); `429 demo_rate_limited` and a backend without try-out mode (404) have their own lines (T1.2). "Welcome back." (L1.4) shows for the last wallet account that signed in on this browser (`hellonear.lastAccount` in localStorage, the account name only). "What is a Mind?" opens L1.5 as a dialog. +- `SignInScreen` (`/`, design "3 · Start" L1, T1.1): the forest photo from the design (Unsplash, saved as `public/sign-in/forest.jpg` so the page doesn't load it from outside; desktop only) with the "Your limits stay yours." caption, then three choices. **Meteor Wallet** (with Meteor's own logo, `MeteorLogo` in `AppLogos.tsx`, the icon the official manifest lists, copied as is) opens Meteor straight away (`connector.connect({ walletId: "meteor-wallet" })`, the id in the official manifest `hot-dao/near-selector`, read 9 Nov); **Other NEAR wallets** opens the NEAR Connect list; after an "or" divider, **Continue as guest** ("No sign-up. 20 messages with a shared test wallet.", a person icon; `POST /auth/demo`). On screen the try-out is called a guest session everywhere ("Guest: 18 of 20 messages left", "Guest session finished", "Not available to guests", "A guest Mind can't be deleted"; Axel, via Ancung, 12 Nov: "Try without a wallet" read technical, and its line was cut off); the code keeps `tryOut` and `demo`, as the API does. The chosen button shows "Waiting for Meteor"; a canceled signature says "Sign-in was canceled in the wallet. Nothing changed." (L1.3); `429 demo_rate_limited` and a backend without try-out mode (404) have their own lines (T1.2). "Welcome back." (L1.4) shows for the last wallet account that signed in on this browser (`hellonear.lastAccount` in localStorage, the account name only). "What is a Mind?" opens L1.5 as a dialog. - Try-out in the chat (T1.3, T1.5): a lime banner with the messages left and what the shared test wallet allows, and "Connect a wallet" (`useLeaveTryOut`: ends the try-out session and goes back to `/`). Messages left come from `useTryOutLeft`: the backend counts every run of the user's Minds against 20 (`assertDemoRunAllowed`), so the FE counts each Mind's `GET …/runs` the same way; no backend change. At 0 (or a `429 demo_run_limit`) the composer locks ("Try-out finished") and an end card offers Connect Meteor. Owner actions in a try-out (T1.4, `TryOutLockedDialog` in `src/modules/auth/components`): the buttons stay (Add funds, Freeze, Set limits, Set up a wallet on Wallet; Freeze on Approvals; Add key on Connections), and each opens "Connect a wallet to do this" with why that action needs one (`lockedReason`). The per-payment row shows "Locked" instead of Edit, as in the design. A centered dialog from `sm`, a sheet from the bottom on phones. "Connect Meteor" opens Meteor in the same click (`useSwitchToWallet`): a wallet login replaces the try-out's cookie (`POST /auth/login` sets a new one, `apps/be/src/server.ts`), then a full reload to `/` so nothing from the try-out stays cached. Checked by Ancung on 9 Nov with Meteor (testnet). - Proven 8 Nov: a Meteor (testnet) login from `http://localhost:3000` in Chrome against the hosted API (`HELLONEAR_API_URL=https://api-hellonear.jameshub.fun` in `.env.local`, after #71 was deployed); the session survives a reload. Not checked yet: Safari and other wallets. diff --git a/apps/fe/src/modules/auth/components/SignInScreen.tsx b/apps/fe/src/modules/auth/components/SignInScreen.tsx index 347e3ba5..c9043cf6 100644 --- a/apps/fe/src/modules/auth/components/SignInScreen.tsx +++ b/apps/fe/src/modules/auth/components/SignInScreen.tsx @@ -2,7 +2,7 @@ import Image from "next/image" import { useRouter } from "next/navigation" -import { ArrowRightIcon, CircleXIcon, FlaskConicalIcon, GlobeIcon, KeyRoundIcon, WalletMinimalIcon } from "lucide-react" +import { ArrowRightIcon, CircleXIcon, GlobeIcon, KeyRoundIcon, UserRoundIcon, WalletMinimalIcon } from "lucide-react" import { useEffect, useState, type ReactNode } from "react" import { cn } from "cn" import { ErrorRetry } from "@/components/elements/ErrorRetry" @@ -147,9 +147,9 @@ export function SignInScreen() {