Commit Graph

48 Commits

Author SHA1 Message Date
Gjermund Høsøien Wiggen
affbbdaa46 feat: add template delete — backend DELETE route, frontend trash button
- DELETE /templates/:id — backend route
- deleteTemplate() API client function
- Trash icon on each template list item (shows on hover)
- Confirms inline, no dialog needed
- Resets builder if the deleted template was being edited

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 12:49:45 +02:00
Gjermund Høsøien Wiggen
7be90684fb fix: replace broken add-filter button with stepped filter builder
- Fixed popover z-index: uses fixed positioning with z-50 above backdrop
- Stepped flow: select field → set operator (is/is_not) → choose/write value → Apply
- Removed old inline CF value inputs (handled inline in the new flow)
- Fixed filter persistence: clear filters when navigating away from saved view
- Fixed home redirect: check for default dashboard on load

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 11:30:17 +02:00
Gjermund Høsøien Wiggen
b70a133ea2 feat: add dashboards — tables, CRUD API, widget data endpoint
- New dashboards table (name, description, layout, is_default)
- New dashboard_widgets table (view_id, title, widget_type, position, config)
- GET/POST/PATCH/DELETE /dashboards
- GET/POST/PATCH/DELETE /dashboards/:id/widgets
- GET /dashboards/:id/widgets/:id/data — runs saved view filters,
  returns pre-aggregated data for count/ticket_list/status_chart/grouped_counts
- is_default uniqueness enforced on PATCH

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 11:26:22 +02:00
Gjermund Høsøien Wiggen
aa90b88991 feat: add saved views — database table, CRUD API, migration
- New views table (id, name, filters jsonb, sort_key, is_public, creator_id)
- GET/POST/PATCH/DELETE /views endpoints
- Register views router in server

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 11:10:25 +02:00
Gjermund Høsøien Wiggen
000e97e1bd feat: implement inline editing for custom fields in ticket sidebar
- Show CF values as read-only text with edit affordance (pencil icon on hover)
- Click to enter edit mode: inline input (free-text) or select (choice fields)
- Save on blur or Enter, cancel on Escape — reverts to original value
- Auto-save for select fields on change
- Loading spinner while saving
- Remove now-unused customFieldValue helper

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 10:55:45 +02:00
Gjermund Høsøien Wiggen
2501bcbad1 chore: add .codegraph to .gitignore, untrack daemon files
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 10:51:43 +02:00
Gjermund Høsøien Wiggen
aa808f1d3f feat: return scrip results on ticket create, update frontend types
- POST /tickets now returns { ticket, scrip_results } matching PATCH pattern
- createTicket API function returns UpdateResult instead of Ticket
- Update call site to use data.ticket.id

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 10:51:14 +02:00
Gjermund Høsøien Wiggen
60d2196e51 chore: exclude web and node_modules from tsconfig
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 10:43:52 +02:00
Gjermund Høsøien Wiggen
ade966ace7 docs: update CLAUDE.md with current project state and workflow
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 10:43:34 +02:00
Gjermund Høsøien Wiggen
06cc7c79a3 feat: enhance frontend UI — command palette, admin redesign, API coverage
Types + API:
- Add User, TemplatePreview, QueueCustomField types
- Add getUsers, getTemplates, createTemplate, updateTemplate,
  previewTemplate, updateQueue, updateLifecycle, updateCustomField API functions

UI:
- Command palette: keyboard-first navigation with fuzzy ticket search
- Admin: comprehensive redesign with tab-based layout (Queues, Lifecycles,
  Scrips, Custom Fields, Templates, Users)
- Ticket list: improved inbox-style rows with quick actions
- Ticket detail: enhanced conversation thread and properties sidebar
- App shell: sidebar visual refinement with active indicator bar
- Theme toggle: smoother transitions

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 10:43:28 +02:00
Gjermund Høsøien Wiggen
b96ba21e99 feat: add database seed script and utility scripts
- src/db/seed.ts: comprehensive seed data with idempotent upserts
  - 5 users (system, gjermund, operator, technician, analyst)
  - 5 queues (Support Desk, Operations, IT Infrastructure, Facilities, Field Ops)
  - 1 lifecycle (Demo service lifecycle with new→open→in_progress→resolved→closed)
  - 5 custom fields (impact, location, channel, urgency, outcome) with short keys
  - 10 realistic support tickets with varied statuses, custom fields, and history
  - 3 scrips (OnCreate email, OnResolve custom field, customer notification)
  - 2 templates (auto-response, resolve notification)
  - --reset flag to truncate all data before seeding
- scripts/smoke-test.ts: API smoke tests
- scripts/watch-frontend.sh: frontend dev helper

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 10:43:18 +02:00
Gjermund Høsøien Wiggen
54ef6fcc5b feat: add users and templates routes, enhance existing API routes
New routes:
- GET /users — list all users
- GET/POST /templates — list and create templates
- PATCH /templates/:id — update template
- POST /templates/preview — render template with ticket/demo context

Enhanced routes:
- tickets: custom field support on create, status classification helper
- custom-fields: PATCH endpoint, auto-generate short key from name
- lifecycles: PATCH endpoint
- queues: PATCH endpoint

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 10:43:08 +02:00
Gjermund Høsøien Wiggen
e960df61ad feat: implement full scrip action engine with real executors
- SendEmail: real nodemailer transport with SMTP config, dynamic recipient resolution
  (static + ticket creator/owner lookup), Handlebars template support
- Webhook: HTTP POST/any method with configurable headers and JSON body
- FetchMetadata: external HTTP fetch, Handlebars URL/body templating,
  auto-adds result as comment/correspondence on ticket
- RunScript: arbitrary async JS execution with helpers (addComment,
  createTransaction, updateTicket, touchTicket), ticket context, and
  Drizzle ORM access
- SetCustomField: lookup by id/key/name, clear+insert value, record
  CustomFieldChange transaction
- CreateTransaction: insert arbitrary transaction record
- Add OnCustomFieldChange condition
- Pass condition_config to evaluator in engine

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 10:42:59 +02:00
Gjermund Høsøien Wiggen
9e884546f2 feat: add infrastructure foundation — scripts, schema key, new routes, model fields
- Add npm scripts for dev, migrate, seed, smoke
- Add key column to scrips table (unique short identifier)
- Register users and templates routes in server
- Set development: false in Bun.serve for production mode
- Add description and custom_fields to CreateTicketSchema
- Make owner_id nullable/optional for unassigned tickets
- Add migration for custom field key column

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 10:42:42 +02:00
Gjermund Høsøien Wiggen
599ca75fc4 Add RT architecture deep-dive analysis reference 2026-06-07 23:32:04 +02:00
Gjermund Høsøien Wiggen
087b8cdce7 Replace auto-generated CLAUDE.md with proper project documentation
- Architecture overview (backend + frontend)
- Stack details (Bun/Hono/Drizzle + Next.js/shadcn)
- How to run locally (backend, frontend, migrations)
- API endpoint reference
- Key design decisions (sequential IDs, transaction-centric, scrip engine)
- Git workflow and common issues
2026-06-07 23:31:28 +02:00
Gjermund Høsøien Wiggen
08b52426b0 Implement ticket reply functionality
Backend:
- POST /:id/comment endpoint accepting {body, internal?, creator_id?}
- internal=false → Correspond (public reply), internal=true → Comment
- Runs scrip engine on the new transaction so notifications fire
- CommentSchema zod validation

Frontend:
- sendComment() API function in lib/api.ts
- Send button wired with onClick, sending spinner, disabled state
- Error display below reply box, clears on new typing
- Refreshes transaction list after successful send
- Reply/Internal note mode passed as internal flag
2026-06-07 23:28:46 +02:00
Gjermund Høsøien Wiggen
04b4e28d21 Change ticket IDs from UUID to sequential integers
Backend:
- tickets.id: uuid → integer GENERATED ALWAYS AS IDENTITY
- transactions.ticket_id, custom_field_values.ticket_id: uuid → integer
- Routes convert string params to Number() for DB queries
- ScripEngine.prepare takes ticketId: number
- ActionPayload.ticketId: string → number

Frontend:
- Ticket.id: string → number, Transaction.ticket_id: string → number
- API functions accept number params
- formatTicketId() helper returns TKT-0001 format
- Ticket rows display TKT-XXXX, detail page uses formatTicketId

Migration: drops FKs, clears data, alters column types, re-adds FKs
2026-06-07 23:23:05 +02:00
Gjermund Høsøien Wiggen
7da52dfff6 Revert to single-column ticket list with inbox-style rows
- Remove three-column layout, inline detail panel, and properties sidebar
- Click a ticket navigates to /tickets/[id] via router.push
- Redesign TicketRow as inbox-style: status dot, bold subject on top line,
  muted ID/queue/owner meta on second line, time right-aligned
- Cleaner visual hierarchy with increased padding and gap
2026-06-07 23:14:59 +02:00
Gjermund Høsøien Wiggen
86e00b076a Add properties sidebar to inline ticket detail panel
- Two-column layout inside TicketDetailPanel: conversation (left) + sidebar (right)
- Status section: Select dropdown with all statuses, previewTicket + updateTicket flow with Apply/Cancel
- Assignment section: read-only assignee display with avatar initial
- Details section: queue name, created/updated/resolved dates
- Custom fields section: name:value pairs when present
- Sidebar skeleton during loading
- Fetches queue info alongside ticket data for display
2026-06-07 23:13:00 +02:00
Gjermund Høsøien Wiggen
88ab30a7fd Fix transaction_type case mismatch in both ticket pages
Backend returns PascalCase (Create, StatusChange, SetOwner, Comment, Correspond).
Frontend was checking lowercase, causing transaction rendering to fall through to raw type strings.
2026-06-07 23:06:25 +02:00
Gjermund Høsøien Wiggen
737e8942f6 Redesign ticket list to three-column layout with proportional widths
- Replace Sheet slide-over with inline peer detail column
- List column: 40% width (min 360px) when ticket selected, flex-1 otherwise
- Detail column: 60% width (min 480px), slides in from right (300ms)
- Mobile: list hidden when ticket selected, detail becomes full-width
- Subtle border-r divider on list column
- Taller ticket rows (py-4) with smooth hover transitions
- width transition on list column resize
2026-06-07 23:00:45 +02:00
Gjermund Høsøien Wiggen
10962f795f feat: three-column ticket list layout (list + detail as peers, no Sheet)
- Replace Sheet slide-over with persistent right-column detail panel
- Ticket list shrinks to w-80 when ticket selected, detail takes flex-1
- Animated transition (300ms ease-out) when selecting/deselecting
- Kept existing conversation thread, properties sidebar, reply box inline
2026-06-07 22:58:50 +02:00
Gjermund Høsøien Wiggen
784d30acbd fix: wrap TicketListPage in Suspense boundary for useSearchParams 2026-06-07 22:46:34 +02:00
Gjermund Høsøien Wiggen
6f2b0f39f7 feat: breadcrumb nav, grouped properties sidebar, larger status selector, transitions 2026-06-07 22:34:31 +02:00
Gjermund Høsøien Wiggen
8175b05b23 feat: fuzzy ticket search in command palette, improved styling 2026-06-07 22:34:28 +02:00
Gjermund Høsøien Wiggen
b2423f2821 feat: inbox-style ticket rows, Sheet detail slide-over, gradient New Ticket button 2026-06-07 22:34:27 +02:00
Gjermund Høsøien Wiggen
b05eb8b2d4 feat: add sidebar collapse/expand, theme-toggle, theme-aware colors 2026-06-07 22:34:26 +02:00
Gjermund Høsøien Wiggen
10005799fb feat: add theme-toggle component with next-themes sun/moon icons 2026-06-07 22:34:26 +02:00
Gjermund Høsøien Wiggen
87bd6997e3 Add light mode support (next-themes), JetBrains Mono font, OpenType features
- layout.tsx: ThemeProvider from next-themes, light mode DEFAULT, JetBrains_Mono font
- globals.css: font-mono pointing to correct variable, font-feature-settings cv01+ss03 on body
- next-themes package installed
- Build passes with zero errors
2026-06-07 22:29:52 +02:00
Gjermund Høsøien Wiggen
77860eb6c4 Redesign: Linear-inspired dark mode frontend
Complete rewrite of all pages:
- layout.tsx: App shell with 240px sidebar (saved views, queue list, admin link)
- app-shell.tsx: Client sidebar component with route highlighting + counts
- page.tsx: Sleek ticket list with filter chips (All/Open/In progress/Resolved), search bar, status dots, assignee avatars, skeleton loading
- tickets/[id]/page.tsx: Two-panel conversation layout — message thread (left) + properties sidebar (right) with status change, scrip preview, reply box
- admin/page.tsx: Suspense-wrapped admin with tabs in sheet panels
- command-palette.tsx: Cmd+K search with keyboard navigation

Design tokens from Linear:
- bg-[#08090a] canvas, bg-[#0f1011] panels, bg-[#191a1b] cards
- text-[#f7f8f8] primary, text-[#d0d6e0] secondary, text-[#8a8f98] tertiary
- borders: rgba(255,255,255,0.08) standard, rgba(255,255,255,0.05) subtle
- accent: #5e6ad2 primary, #7170ff interactive
- status colors: new=gray, open=indigo, in_progress=amber, resolved=green
- Inter font, weights 400/510/590, no pure white

Fixed: Suspense boundaries for useSearchParams in layout and admin pages
Build: passes with zero errors
2026-06-07 22:16:18 +02:00
Gjermund Høsøien Wiggen
df677cb37f Add web redesign spec: Linear-inspired UX, conversation-centric, two-panel layout 2026-06-07 22:07:03 +02:00
Gjermund Høsøien Wiggen
49834f5215 fix: API proxy — strip /api prefix in rewrite (backend routes don't use /api) 2026-06-07 22:05:30 +02:00
Gjermund Høsøien Wiggen
73cf283f06 Add admin page with 4 tabs for managing queues, lifecycles, scrips, and custom fields 2026-06-07 22:02:11 +02:00
Gjermund Høsøien Wiggen
1029176873 Add ticket detail page with transaction timeline and status change 2026-06-07 22:02:08 +02:00
Gjermund Høsøien Wiggen
a49e888011 Add ticket list page with filters, status badges, create dialog 2026-06-07 22:02:06 +02:00
Gjermund Høsøien Wiggen
f69678db4b Add dark theme root layout with Inter font and nav bar 2026-06-07 22:02:03 +02:00
Gjermund Høsøien Wiggen
00dd21f4dd Add typed fetch API client with 15 endpoint functions 2026-06-07 22:02:01 +02:00
Gjermund Høsøien Wiggen
59d66b3392 Add TypeScript interfaces for Tessera domain types 2026-06-07 22:01:58 +02:00
Gjermund Høsøien Wiggen
6b7d8c4aba Fix next.config.ts API proxy, add web pages spec 2026-06-07 21:56:36 +02:00
Gjermund Høsøien Wiggen
9b1af0b7b3 Add Next.js + shadcn/ui scaffold with deps
- Next.js 15 App Router, TypeScript, Tailwind CSS
- shadcn/ui components: button, input, select, textarea, dialog, tabs, table, card, badge, label, separator, dropdown-menu, form, sheet, tooltip
- Runtime deps: @tanstack/react-table, zod, react-hook-form, @hookform/resolvers, lucide-react, date-fns
2026-06-07 21:55:54 +02:00
Gjermund Høsøien Wiggen
974df8a9f1 Add React/Next.js + shadcn/ui frontend spec 2026-06-07 21:53:16 +02:00
Gjermund Høsøien Wiggen
3a98027f5e fix: scrip engine condition matching and ticket GET endpoint
- engine.ts: remove transaction_type-based scrip filtering. Now uses condition evaluator
  exclusively (matching by scrip.condition_type against transaction types was incorrect —
  'OnResolve' ≠ 'StatusChange'). All non-disabled, queue-matching scrips are evaluated.
- tickets.ts: fix GET /:id — replace broken Drizzle 'with' relation with manual CF join.
  Set up Drizzle relations needed for proper schema typing (customFieldValues → customFields).
2026-06-07 21:48:04 +02:00
Gjermund Høsøien Wiggen
1f238330c7 feat: scrip engine implementation — real SMTP, webhooks, DB actions
- config.ts: add SMTP_HOST, SMTP_PORT, SMTP_USER, SMTP_PASS, SMTP_FROM
- engine.ts: prepare() queries real scrips from DB, matches by queue_id + condition_type, loads lifecycle for OnResolve context, renders Handlebars templates, builds PreparedScrip. commit() dispatches to real action executors.
- actions.ts: SendEmail via nodemailer SMTP, Webhook via fetch POST, SetCustomField writes to custom_field_values table
- conditions.ts: OnResolve uses LifecycleValidator.isResolvedStatus()
- tickets.ts: updated to pass lifecycleDef context to scrip engine
- nodemailer installed
- Port changed to 9876 (8080 occupied by Apache)

Verification: bun run src/index.ts starts server, GET /health returns {"status":"ok","version":"0.1.0"}
2026-06-07 21:38:56 +02:00
Gjermund Høsøien Wiggen
1136227510 TypeScript/Bun project scaffold
- Stack: Bun, Hono, Drizzle ORM, Zod, Handlebars, Pino
- Models: ticket, queue, transaction, scrip, template, custom_field, user, lifecycle
- Scrip engine: prepare/commit two-phase dispatch, template rendering, mock actions
- Lifecycle validator: state machine transition validation with wildcard support
- Routes: health, tickets (full CRUD + preview + transactions), queues, scrips, custom-fields, lifecycles
- Middleware: Pino logging, error handler
- Database: Drizzle ORM schema + initial migration (10 tables)
- Type-check: passes (tsc --noEmit, zero errors)
2026-06-07 21:21:50 +02:00
Gjermund Høsøien Wiggen
7be1810162 Add TypeScript/Bun scaffold specification 2026-06-07 21:12:14 +02:00
Gjermund Høsøien Wiggen
3611fa97d7 Add architecture document and RT analysis reference 2026-06-07 21:09:26 +02:00
Gjermund Høsøien Wiggen
af359fca15 Initial commit: project scaffold 2026-06-07 21:07:25 +02:00