Files
pig/apps/web/vite.config.ts
claude 99d165b5e5
CI / verify (push) Successful in 4m57s
CI / publish (push) Has been skipped
Rebuild Piggy's interface, and give the demo book a business to describe
Piggy answered in raw markdown, threw away every tool result it streamed,
and fought the reader's scroll on every token. The three surfaces that
made it worth having — what it read, how it reasoned, what it cost — were
all on the wire and none of them reached the screen.

The transcript is now composed of five parts under components/piggy:
answers render through streamdown, the container sticks to the bottom
without pinning the reader there, tool steps say what they read and link
to the record, and each turn carries its model and token count. Three
lifecycle bugs went with them: Stop left a permanent spinner, a truncated
stream was indistinguishable from thinking, and a failed send destroyed
the message it failed to send.

Underneath, the inference path grew timeouts, jittered retries on 429 and
5xx, tolerance of the malformed frames a 30B model emits, and an
agent_runs row per turn so chat spend is observable. The system prompt now
states that a field ending in Cents is cents — without it nemotron renders
costPerGpuHourCents: 189 as "$189 per GPU-hour", which is a 100x error on
the most scrutinised number in the room.

The demo book was arithmetically incoherent: every deal's value
contradicted its own allocation revenue by up to 3.6x, nothing had ever
closed, no customer had any paper, and the marketplace was empty. Deal
value is now derived from the allocation, the book clears 5.3% across five
blocks with one deliberately underwater, and the renewal, compliance and
agent-provenance machinery finally has rows to act on. A --clear that
deleted every obligation, SLA term and capacity request in the database
regardless of origin is scoped to the demo's own ids.

Around that: accounts have a detail page, ⌘K searches the book, Settings
can mint the API keys it always claimed to, and deploy.sh actually ships
the agent instead of silently skipping its compose profile.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-14 00:34:18 -07:00

52 lines
1.9 KiB
TypeScript

import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { fileURLToPath, URL } from 'node:url';
const apiTarget = process.env.PIG_API_TARGET ?? 'http://localhost:8920';
export default defineConfig({
plugins: [react()],
resolve: {
alias: { '@': fileURLToPath(new URL('./src', import.meta.url)) },
},
server: {
// Both are overridable so a second checkout (a worktree, a review branch)
// can run its own API and web server without colliding with the first.
port: Number(process.env.PIG_WEB_PORT ?? 5173),
// Proxy in development so the browser sees one origin, matching how
// production serves the API and the app together. Auth sessions are
// per-origin, so a split origin in dev but not prod hides real bugs.
/*
* `/media` is proxied as well as `/api`, because Learn videos PIG hosts
* itself are served from the API on a non-/api path. Without this entry
* Vite answers the <video> request with index.html and the player shows a
* black box with working controls and no error — the same silent
* 200-text/html failure the API guards against for its own routes.
*/
proxy: {
'/api': { target: apiTarget, changeOrigin: true },
'/media': { target: apiTarget, changeOrigin: true },
},
},
build: {
outDir: 'dist',
sourcemap: true,
rollupOptions: {
output: {
/*
* Split the vendor code that changes rarely from the app code that
* changes constantly, so a deploy invalidates only the small chunk.
* This matters on mobile: the auth client alone is a large download,
* and re-fetching it on every deploy over a cellular connection is
* exactly the cost worth avoiding.
*/
manualChunks: {
react: ['react', 'react-dom', 'react-router-dom'],
supabase: ['@supabase/supabase-js'],
query: ['@tanstack/react-query'],
},
},
},
},
});