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
4 changes: 2 additions & 2 deletions apps/fe/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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.

Expand Down
8 changes: 4 additions & 4 deletions apps/fe/src/modules/auth/components/SignInScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -147,9 +147,9 @@ export function SignInScreen() {
<Option
onClick={tryOut}
disabled={busy}
icon={demo.isPending ? <Spinner /> : <FlaskConicalIcon />}
title={emptyTryOut ? "Continue your try-out" : "Try without a wallet"}
note={emptyTryOut ? "Pick a Mind and start chatting." : "No sign-up. 20 messages and a shared test wallet. Deleted after 7 days."}
icon={demo.isPending ? <Spinner /> : <UserRoundIcon />}
title="Continue as guest"
note={emptyTryOut ? "Pick up where you left off." : "No sign-up. 20 messages with a shared test wallet."}
/>
</div>

Expand Down
14 changes: 7 additions & 7 deletions apps/fe/src/modules/auth/components/TryOutLockedDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ export type LockedAction = "add-funds" | "freeze" | "limits" | "wallet" | "keys"
export function lockedReason(action: LockedAction, name: string): string {
switch (action) {
case "freeze":
return `Freezing needs the owner's signature. In a try-out, ${name} uses a shared test wallet that only HelloNear can change.`
return `Freezing needs the owner's signature. As a guest, ${name} uses a shared test wallet that only HelloNear can change.`
case "add-funds":
return `Funds come from your own wallet. In a try-out, ${name} uses a shared test wallet that HelloNear fills.`
return `Funds come from your own wallet. As a guest, ${name} uses a shared test wallet that HelloNear fills.`
case "limits":
return `Changing limits needs the owner's signature. In a try-out, ${name} uses a shared test wallet with limits HelloNear sets.`
return `Changing limits needs the owner's signature. As a guest, ${name} uses a shared test wallet with limits HelloNear sets.`
case "wallet":
return `A wallet of ${name}'s own needs your signature for its limits. In a try-out, ${name} pays from a shared test wallet.`
return `A wallet of ${name}'s own needs your signature for its limits. As a guest, ${name} pays from a shared test wallet.`
case "keys":
return "Keys are kept for your account, and a try-out can't keep them. Connect a wallet to save keys for your own services."
return "Keys are kept for your account, and a guest session can't keep them. Connect a wallet to save keys for your own services."
case "autopilot":
return `Jobs that run on a schedule need your own account. In a try-out, you can still run ${name}'s jobs by hand with Run now.`
return `Jobs that run on a schedule need your own account. As a guest, you can still run ${name}'s jobs by hand with Run now.`
}
}

Expand Down Expand Up @@ -68,7 +68,7 @@ export function TryOutLockedDialog({ action, name, onClose }: { action: LockedAc
</div>
)}

<p className="text-[13px] text-tertiary-foreground">Connecting keeps nothing from this try-out. You start fresh with your own Mind and limits.</p>
<p className="text-[13px] text-tertiary-foreground">Connecting keeps nothing from this guest session. You start fresh with your own Mind and limits.</p>

<div className="flex flex-col-reverse gap-2 sm:flex-row sm:justify-end">
<Button
Expand Down
6 changes: 3 additions & 3 deletions apps/fe/src/modules/auth/data/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function walletError(err: unknown): string {

/** T1.2 and a backend without try-out mode. */
export function demoError(err: unknown): string {
if (isApiCode(err, "demo_rate_limited")) return "Too many try-outs from this network. Please try again later or connect a wallet."
if (err instanceof ApiError && err.status === 404) return "Try-out is not available at the moment. Please connect a wallet."
return "Could not start a try-out. Please try again later."
if (isApiCode(err, "demo_rate_limited")) return "Too many guest sessions from this network. Please try again later or connect a wallet."
if (err instanceof ApiError && err.status === 404) return "Guest access is not available at the moment. Please connect a wallet."
return "Could not start a guest session. Please try again later."
}
2 changes: 1 addition & 1 deletion apps/fe/src/modules/autopilot/components/Ideas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function IdeaCard({ mindId, name, demo, idea, onAdded, compact }: { mindId: stri
{busy && <Spinner />}
Use this
</Button>
{demo && <span className="text-xs text-muted-foreground">In a try-out it stays off; you can run it with Run now.</span>}
{demo && <span className="text-xs text-muted-foreground">As a guest it stays off; you can run it with Run now.</span>}
{(add.error || setSkills.error) && <span className="text-xs text-danger">Could not add it. Please try again later.</span>}
</>
)}
Expand Down
2 changes: 1 addition & 1 deletion apps/fe/src/modules/autopilot/components/JobDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function JobDetail({ mindId, name, workflowId }: { mindId: string; name:
isApiCode(err, "missing_tools")
? `${name} doesn't have a skill this job uses. Add it in Skills first.`
: isApiCode(err, "demo_run_limit")
? "That's all the messages this try-out has."
? "That's all the messages a guest gets."
: "The job did not start. Please try again later."
)
}
Expand Down
12 changes: 6 additions & 6 deletions apps/fe/src/modules/chat/components/ChatScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export function ChatScreen({ mindId, threadId }: { mindId: string; threadId: str
<p className="truncate text-xs text-muted-foreground">
{templateLabel(templateId)}
{/* Not "asks before every payment": an auto-approve rule (#167) can let small ones through. */}
{tryOut ? ", try-out with a shared test wallet" : limit ? `, payments up to ${limit} NEAR each` : ""}
{tryOut ? ", guest with a shared test wallet" : limit ? `, payments up to ${limit} NEAR each` : ""}
</p>
</div>
<Button variant="ghost" size="sm" onClick={toggleLive} aria-pressed={liveOpen} className="shrink-0 text-muted-foreground">
Expand All @@ -177,7 +177,7 @@ export function ChatScreen({ mindId, threadId }: { mindId: string; threadId: str
// sentence shows from 640 px.
<div role="status" className="mx-4 mt-3 flex items-center gap-3 rounded-md bg-brand-soft px-4 py-2 text-sm text-foreground md:mx-8">
<p className="min-w-0 flex-1">
Try-out{tryOutLeft !== null ? `: ${tryOutLeft} of ${TRY_OUT_MESSAGES} messages left` : ""}.
Guest{tryOutLeft !== null ? `: ${tryOutLeft} of ${TRY_OUT_MESSAGES} messages left` : ""}.
<span className="hidden sm:inline">
{" "}Payments come from a shared test wallet{limit ? `, up to ${limit} NEAR each,` : ""} to approved addresses only.
</span>
Expand Down Expand Up @@ -332,9 +332,9 @@ export function ChatScreen({ mindId, threadId }: { mindId: string; threadId: str
{outOfMessages && (
// T1.5: one clear way forward once the try-out's messages are used up.
<div className="mb-3 flex flex-col items-start gap-2 rounded-lg border border-border bg-surface p-4">
<p className="text-[15px] font-semibold text-foreground">That&apos;s the end of the try-out</p>
<p className="text-[15px] font-semibold text-foreground">That&apos;s the end of your guest session</p>
<p className="text-sm text-muted-foreground">
You&apos;ve used all {TRY_OUT_MESSAGES} messages. Connect a wallet to keep going with your own Mind, wallet and limits. This try-out is deleted after 7 days.
You&apos;ve used all {TRY_OUT_MESSAGES} messages. Connect a wallet to keep going with your own Mind, wallet and limits. This guest session is deleted after 7 days.
</p>
<Button size="sm" onClick={leaveTryOut}>
Connect Meteor
Expand All @@ -344,8 +344,8 @@ export function ChatScreen({ mindId, threadId }: { mindId: string; threadId: str
<Composer
name={name}
busy={busy}
note={outOfMessages ? "Connect a wallet to send more messages." : tryOut ? `Try-out payments: ${limit ? `up to ${limit} NEAR, ` : ""}approved addresses only.` : composerNote(name, frozen)}
locked={outOfMessages ? "Try-out finished" : undefined}
note={outOfMessages ? "Connect a wallet to send more messages." : tryOut ? `Guest payments: ${limit ? `up to ${limit} NEAR, ` : ""}approved addresses only.` : composerNote(name, frozen)}
locked={outOfMessages ? "Guest session finished" : undefined}
onSend={(text) => send(text, threadId)}
onStop={stop}
stopping={stopping}
Expand Down
2 changes: 1 addition & 1 deletion apps/fe/src/modules/chat/data/thread.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function longDay(iso: string, now: Date): string {

export function failureText(name: string, error: unknown): string {
if (error instanceof ApiError) {
if (error.code === "demo_run_limit") return `That's all the messages this try-out has. Connect a wallet to keep chatting with ${name}.`
if (error.code === "demo_run_limit") return `That's all the messages a guest gets. Connect a wallet to keep chatting with ${name}.`
if (error.code === "demo_rate_limited") return "Too many messages from this network. Please try again in a few minutes."
if (error.status === 401) return "Your session ended. Sign in again to keep chatting."
if (error.status >= 500) return `${name} could not answer. The AI service didn't respond, so nothing happened.`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export function ConnectionsScreen({ mindId }: { mindId: string }) {
<h2 id="apps" className="text-[15px] font-semibold text-foreground">
Apps
</h2>
{demo && <p className="text-[13px] text-muted-foreground">This try-out uses a sample inbox, calendar and Meet link, so the Google apps have nothing to connect. Telegram works with a bot of your own.</p>}
{demo && <p className="text-[13px] text-muted-foreground">Guests get a sample inbox, calendar and Meet link, so the Google apps have nothing to connect. Telegram works with a bot of your own.</p>}
{connections.isPending ? (
<Skeleton className="h-36 w-full" />
) : connections.isError ? (
Expand Down Expand Up @@ -177,7 +177,7 @@ export function ConnectionsScreen({ mindId }: { mindId: string }) {
<p className="text-[13px] text-muted-foreground">Could not load your keys.</p>
) : !secrets.data?.length ? (
<p className="py-2 text-[13px] text-muted-foreground">
{demo ? "A try-out can't keep keys." : `No keys yet. Add one when you want ${name} to call a service of your own.`}
{demo ? "A guest session can't keep keys." : `No keys yet. Add one when you want ${name} to call a service of your own.`}
</p>
) : (
<ul className="flex flex-col">
Expand Down
Loading
Loading