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
60 changes: 60 additions & 0 deletions web/app/not-found.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import type { Metadata } from 'next';
import Link from 'next/link';
import { ArrowLeft, BookOpen } from 'lucide-react';

import { LogoIcon, LogoWordmark } from '../components/SiteNav';
import { LostMessages } from './not-found/LostMessages';
import s from './not-found/not-found.module.css';

export const metadata: Metadata = {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The custom 404 title, description, and robots settings are not applied from a regular app/not-found.tsx; Next.js documents metadata support here only for global-not-found.js. This leaves the page with inherited metadata (and potentially indexable when no status-based noindex tag is injected), so the SEO behavior described by the PR is not guaranteed; using a supported global-not-found metadata path would make it reliable.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At web/app/not-found.tsx, line 9:

<comment>The custom 404 title, description, and robots settings are not applied from a regular `app/not-found.tsx`; Next.js documents metadata support here only for `global-not-found.js`. This leaves the page with inherited metadata (and potentially indexable when no status-based `noindex` tag is injected), so the SEO behavior described by the PR is not guaranteed; using a supported `global-not-found` metadata path would make it reliable.</comment>

<file context>
@@ -0,0 +1,60 @@
+import { LostMessages } from './not-found/LostMessages';
+import s from './not-found/not-found.module.css';
+
+export const metadata: Metadata = {
+  title: 'Message not delivered',
+  description: 'This Agent Relay route could not be found.',
</file context>

title: 'Message not delivered',
description: 'This Agent Relay route could not be found.',
robots: {
index: false,
follow: true,
},
};

export default function NotFound() {
return (
<main className={s.page}>
<header className={s.nav}>
<Link href="/" className={s.brand} aria-label="Agent Relay home">
<LogoIcon />
<LogoWordmark />
</Link>

<span className={s.routeCode}>ERR_ROUTE_NOT_FOUND</span>
</header>

<div className={s.layout}>
<section className={s.copy}>
<div className={s.errorCode} aria-hidden="true">
404
</div>
<p className={s.kicker}>Delivery failed</p>
<h1>Message sent. Page never joined.</h1>
<p className={s.lede}>A few agents are looking for it. They are not doing a great job.</p>

<div className={s.actions}>
<Link href="/" className={s.primaryAction}>
<ArrowLeft aria-hidden="true" size={18} strokeWidth={1.8} />
Back to safety
</Link>
<Link href="/docs" className={s.secondaryAction}>
<BookOpen aria-hidden="true" size={18} strokeWidth={1.8} />
Read the docs
</Link>
</div>
</section>

<LostMessages />
</div>

<footer className={s.footer}>
<span>Agent Relay</span>
<span>Undeliverable messages return to sender. Eventually.</span>
</footer>
</main>
);
}
98 changes: 98 additions & 0 deletions web/app/not-found/LostMessages.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
'use client';

import { useState } from 'react';
import { RotateCcw } from 'lucide-react';

import s from './not-found.module.css';

const attempts = [
{
status: 'No route to channel',
note: 'Builder sent /ship-it to a room that does not exist.',
messages: ['anyone here?', 'wrong channel', 'hello?'],
},
{
status: 'Recipient missing',
note: 'Reviewer asked 404 to approve the pull request.',
messages: ['please review', 'still there?', 'nudge'],
},
{
status: 'Context wandered off',
note: 'Scout found the page, then forgot where it put it.',
messages: ['found it!', 'wait', 'lost it'],
},
] as const;

export function LostMessages() {
const [attempt, setAttempt] = useState(0);
const current = attempts[attempt];

return (
<section className={s.network} aria-label="Failed message routing simulation">
<div className={s.networkHeader}>
<div>
<span className={s.liveLabel}>Live misrouting</span>
<p>{current.status}</p>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Activating “Misroute again” changes the routing scenario visually, but the updated status is not announced to screen readers because it is plain text rather than a live region. Mark the changing status as aria-live="polite" so the interactive state change is conveyed to assistive-technology users.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At web/app/not-found/LostMessages.tsx, line 35:

<comment>Activating “Misroute again” changes the routing scenario visually, but the updated status is not announced to screen readers because it is plain text rather than a live region. Mark the changing status as `aria-live="polite"` so the interactive state change is conveyed to assistive-technology users.</comment>

<file context>
@@ -0,0 +1,98 @@
+      <div className={s.networkHeader}>
+        <div>
+          <span className={s.liveLabel}>Live misrouting</span>
+          <p>{current.status}</p>
+        </div>
+        <span className={s.deliveryState}>undelivered</span>
</file context>

</div>
<span className={s.deliveryState}>undelivered</span>
</div>

<div className={s.stage} key={attempt}>
<div className={`${s.connection} ${s.connectionOne}`} />
<div className={`${s.connection} ${s.connectionTwo}`} />
<div className={`${s.connection} ${s.connectionThree}`} />

<AgentNode className={s.builder} initials="BU" name="Builder" status="sent" />
<AgentNode className={s.scout} initials="SC" name="Scout" status="searching" />
<AgentNode className={s.reviewer} initials="RV" name="Reviewer" status="confused" />

<div className={s.missingNode}>
<span>?</span>
<strong>missing-page</strong>
<small>never connected</small>
</div>

{current.messages.map((message, index) => (
<span key={message} className={`${s.packet} ${s[`packet${index + 1}`]}`}>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: Using the message string as a React key is fragile—if a future attempt ever contains duplicate message text, React will warn about duplicate keys and may render incorrectly. Since the parent <div className={s.stage} key={attempt}> already forces a full remount when the scenario changes, using the array index as key is safe and more robust here.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At web/app/not-found/LostMessages.tsx, line 56:

<comment>Using the message string as a React `key` is fragile—if a future attempt ever contains duplicate message text, React will warn about duplicate keys and may render incorrectly. Since the parent `<div className={s.stage} key={attempt}>` already forces a full remount when the scenario changes, using the array `index` as key is safe and more robust here.</comment>

<file context>
@@ -0,0 +1,98 @@
+        </div>
+
+        {current.messages.map((message, index) => (
+          <span key={message} className={`${s.packet} ${s[`packet${index + 1}`]}`}>
+            {message}
+          </span>
</file context>

{message}
</span>
))}
Comment on lines +55 to +59

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using the message string as a React key can lead to duplicate key warnings and rendering issues if duplicate messages are ever added to the attempts array in the future. Since the attempts array is static and the parent .stage container already uses key={attempt} (which forces a complete remount when the attempt changes), using the array index as the key is safe and robust here.

Suggested change
{current.messages.map((message, index) => (
<span key={message} className={`${s.packet} ${s[`packet${index + 1}`]}`}>
{message}
</span>
))}
{current.messages.map((message, index) => (
<span key={index} className={`${s.packet} ${s['packet' + (index + 1)]}`}>
{message}
</span>
))}


<div className={s.deadLetter}>
<span>DEAD LETTER</span>
<strong>404</strong>
</div>
</div>

<div className={s.networkFooter}>
<p>{current.note}</p>
<button type="button" onClick={() => setAttempt((attempt + 1) % attempts.length)}>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

When updating state based on the previous state, it is safer to use the functional state updater form (prev => ...) to avoid potential stale closure bugs, especially if the button is clicked rapidly.

Suggested change
<button type="button" onClick={() => setAttempt((attempt + 1) % attempts.length)}>
<button type="button" onClick={() => setAttempt((prev) => (prev + 1) % attempts.length)}>

<RotateCcw aria-hidden="true" size={15} strokeWidth={1.8} />
Misroute again
</button>
</div>
</section>
);
}

function AgentNode({
className,
initials,
name,
status,
}: {
className: string;
initials: string;
name: string;
status: string;
}) {
return (
<div className={`${s.agent} ${className}`}>
<span className={s.avatar}>{initials}</span>
<span>
<strong>{name}</strong>
<small>{status}</small>
</span>
</div>
);
}
Loading
Loading