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
5 changes: 5 additions & 0 deletions .changeset/address-fields.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"web": minor
---

The label's free-text details become a ship-to form: recipient, country, street with address suggestions from Photon in the chosen country, postcode and city, printed as three lines.
5 changes: 5 additions & 0 deletions .changeset/inspector-panel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"web": minor
---

The station's Cmd-K omnibox becomes the Inspector, a docked agent panel built on AI Elements: one thread per order, live tool steps, cited moments that play in place with the detector's boxes, suggestions per bench state, hold Space to talk with a live Canary transcript, and the after-seal check with Repack or Ship as short.
4 changes: 4 additions & 0 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@
"deploy": "vp run build && wrangler deploy"
},
"dependencies": {
"@ai-sdk/react": "catalog:",
"@base-ui/react": "^1.9.0",
"@dicebear/collection": "catalog:",
"@dicebear/core": "catalog:",
"@fontsource-variable/instrument-sans": "^5.2.0",
"@shadcn/react": "catalog:",
"@tailwindcss/vite": "^4",
"@workos-inc/authkit-react": "catalog:",
"ai": "catalog:",
"barcode-detector": "catalog:",
"class-variance-authority": "^0.7.1",
"cn": "^0.4.0",
Expand All @@ -25,6 +28,7 @@
"react-dom": "^19.3.0",
"react-error-boundary": "catalog:",
"shadcn": "^4.21.5",
"streamdown": "catalog:",
"tailwindcss": "^4",
"tw-animate-css": "^1.4.0",
"zxing-wasm": "catalog:"
Expand Down
187 changes: 187 additions & 0 deletions apps/web/src/components/address-fields.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
import { MapPinIcon } from "lucide-react";
import { useEffect, useState } from "react";

import {
Combobox,
ComboboxContent,
ComboboxInput,
ComboboxItem,
ComboboxList,
} from "@/components/ui/combobox";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import {
type Address,
type AddressSuggestion,
COUNTRIES,
countryName,
suggestAddresses,
} from "@/lib/address";

const SUGGEST_AFTER_CHARS = 3;
const SUGGEST_DEBOUNCE_MS = 250;
const COUNTRY_ITEMS = COUNTRIES.map((code) => ({ value: code, label: countryName(code) }));

function useAddressSuggestions(street: string, country: string) {
const [suggestions, setSuggestions] = useState<AddressSuggestion[]>([]);
useEffect(() => {
const query = street.trim();
if (query.length < SUGGEST_AFTER_CHARS) {
setSuggestions([]);
return;
}
const controller = new AbortController();
const timer = setTimeout(() => {
suggestAddresses(query, country, controller.signal)
.then(setSuggestions)
// suggestions only speed typing up; without them the fields still take any address
.catch(() => undefined);
}, SUGGEST_DEBOUNCE_MS);
return () => {
clearTimeout(timer);
controller.abort();
};
}, [street, country]);
return suggestions;
}

/** Recipient and address as separate fields; the street suggests real addresses in the chosen country. */
export function AddressFields({
address,
onChange,
}: {
address: Address;
onChange: (update: (current: Address) => Address) => void;
}) {
const suggestions = useAddressSuggestions(address.street, address.country);
const set = (field: keyof Address) => (value: string) =>
onChange((current) => ({ ...current, [field]: value }));

return (
<fieldset className="flex flex-col gap-3">
<legend className="mb-2 text-sm font-medium">Ship to</legend>
<div className="flex flex-col gap-1.5">
<Label htmlFor="recipient" className="text-xs text-muted-foreground">
Name or company
</Label>
<Input
id="recipient"
autoComplete="off"
placeholder="Acme GmbH"
maxLength={40}
value={address.recipient}
onChange={(event) => set("recipient")(event.target.value)}
/>
</div>
<div className="flex flex-col gap-1.5">
<Label htmlFor="country" className="text-xs text-muted-foreground">
Country
</Label>
<Select
items={COUNTRY_ITEMS}
value={address.country}
onValueChange={(code) => code && set("country")(code)}
>
<SelectTrigger id="country" className="w-full">
<SelectValue />
</SelectTrigger>
<SelectContent alignItemWithTrigger={false}>
{COUNTRY_ITEMS.map((country) => (
<SelectItem key={country.value} value={country.value}>
{country.label}
</SelectItem>
))}
</SelectContent>
</Select>
</div>
<div className="flex flex-col gap-1.5">
<Label htmlFor="street" className="text-xs text-muted-foreground">
Street and number
</Label>
<Combobox<AddressSuggestion>
items={suggestions}
filter={null}
autoHighlight
inputValue={address.street}
onInputValueChange={set("street")}
itemToStringLabel={(suggestion) => suggestion.street}
onValueChange={(picked) => {
if (!picked) return;
onChange((current) => ({
...current,
street: picked.street,
postcode: picked.postcode || current.postcode,
city: picked.city || current.city,
}));
}}
>
<ComboboxInput
id="street"
autoComplete="off"
placeholder={`Start typing a street in ${countryName(address.country)}`}
maxLength={40}
showTrigger={false}
className="w-full"
/>
<ComboboxContent className={suggestions.length === 0 ? "hidden" : undefined}>
<ComboboxList>
{(suggestion: AddressSuggestion) => (
<ComboboxItem
key={`${suggestion.street}|${suggestion.postcode}|${suggestion.city}`}
value={suggestion}
className="items-start py-1.5"
>
<MapPinIcon className="mt-0.5 text-muted-foreground" />
<span className="flex min-w-0 flex-col">
<span className="truncate font-medium">{suggestion.street}</span>
<span className="truncate text-xs text-muted-foreground">
{[suggestion.postcode, suggestion.city].filter(Boolean).join(" ")}
{suggestion.district && `, ${suggestion.district}`}
</span>
</span>
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>
</div>
<div className="grid grid-cols-[7rem_minmax(0,1fr)] gap-2">
<div className="flex flex-col gap-1.5">
<Label htmlFor="postcode" className="text-xs text-muted-foreground">
Postcode
</Label>
<Input
id="postcode"
autoComplete="off"
inputMode="text"
placeholder="10117"
maxLength={10}
className="tabular-nums"
value={address.postcode}
onChange={(event) => set("postcode")(event.target.value)}
/>
</div>
<div className="flex flex-col gap-1.5">
<Label htmlFor="city" className="text-xs text-muted-foreground">
City
</Label>
<Input
id="city"
autoComplete="off"
placeholder="Berlin"
maxLength={30}
value={address.city}
onChange={(event) => set("city")(event.target.value)}
/>
</div>
</div>
</fieldset>
);
}
7 changes: 4 additions & 3 deletions apps/web/src/components/app-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { notionists } from "@dicebear/collection";
import { createAvatar } from "@dicebear/core";
import { type User, useAuth } from "@workos-inc/authkit-react";
import { LogOutIcon } from "lucide-react";
import { useMemo } from "react";
import { type ReactNode, useMemo } from "react";

import { ThemeSwitch } from "@/components/theme-switch";
import { Avatar, AvatarImage } from "@/components/ui/avatar";
Expand Down Expand Up @@ -67,17 +67,18 @@ export function UserMenu({ user, onSignOut }: { user: Account; onSignOut: () =>
);
}

export function AppHeader() {
export function AppHeader({ children }: { children?: ReactNode }) {
const { user, signOut } = useAuth();
return (
<header className="sticky top-0 z-20 border-b bg-background/85 backdrop-blur-md">
<div className="mx-auto flex h-14 max-w-7xl items-center gap-3 px-4 sm:px-6">
<div className="mx-auto flex h-14 max-w-7xl items-center gap-3 px-4 sm:px-6 xl:group-has-data-[slot=inspector]/station:max-w-none">
<a href="/" className="shrink-0" aria-label="ProofBox home">
<img src="/proofbox-wordmark.svg" alt="ProofBox" className="h-7 dark:invert" />
</a>
<span aria-hidden className="hidden h-5 w-px bg-border sm:block" />
<span className="hidden text-sm text-muted-foreground sm:block">Packing station</span>
<div className="ml-auto flex items-center gap-3">
{children}
<ThemeSwitch />
{user && <UserMenu user={user} onSignOut={() => signOut()} />}
</div>
Expand Down
Loading
Loading