Client:
- Add menuItem.Price; show prices in menu and compute totals from server ack
- Track and render recent “[order] …” broadcasts in right column
- Responsive layout with header/body/footer and window size handling
- Listen for server broadcasts after connect; keep last 10 orders
- Parse ORDER ack as “OK|<total>”; display “Total: $<amount>”
- Split view rendering into header/left/right/footer helpers
- Enhance form options to include “Name - $Price”
- Add width/height state; remove fixed 80-col assumption
Server:
- Extend defaultMenu with prices
- Compute total = qty × price; broadcast “[order] … ($xx.xx)”
- Acknowledge ORDER with “OK|<total>” instead of plain “OK”
Proto/UX:
- MENU returns items with price
- ORDER response now includes total for client display
Client (main.go):
- Replace chat viewport/textarea with a simple order console UI using Bubble Tea + Huh forms
- Add types and messages for connection, menu loading, order submission, and status
- Implement connectCmd with short greeting drain; status updates on connect
- Implement fetchMenuCmd: send "MENU", parse single-line JSON into []menuItem
- Implement submitOrderCmd: send "ORDER <json>", read single-line ack
- Build interactive form (name, menu select, quantity, confirm) with validation
- Add model state for host, status/loading/error, lastOrder, and form fields
- Keyboard controls: n (new order), r (reconnect), q/esc/ctrl+c (quit)
- Simplify program start (remove pre-connect path); alt-screen only
- Remove chat colorization/regex, viewport, and textarea logic
Server (server.go):
- Define menuItem and order structs; add a defaultMenu
- Extend protocol:
- "MENU" returns single-line JSON array of menu items
- "ORDER <json>" validates name/item/quantity (with lenient quantity parsing)
- Acknowledge with "OK" or send "[error] ..." lines
- Optionally broadcast "[order] ..." to chat for visibility
- Keep existing chat behavior; integrate new commands alongside it
Notes:
- Server logs ORDER parsing and continues to support chat commands
- Error handling surfaces server-side errors to the client status/messages
Client/main:
- Colorize display: hide raw IDs in rendered messages
- Chat lines now “Name: message” (ID omitted)
- [join]/[leave] now “[join] Name” / “[leave] Name”
- [rename] now “[rename] OldName -> NewName”
- Welcome now “Welcome Name”
- Init: if already connected, start reading immediately (textarea.Blink + readLineCmd)
- Pre-connect before TUI starts:
- Dial with 3s timeout, read up to two initial lines with 1s deadline
- Seed model with pre-read messages and existing conn
Server:
- IDs now lowercase hex; default username uses ID as-is
- Use strings.CutPrefix for “/name ” parsing
- Add structured logs for join/rename/leave with user, id, and remote addr
UI:
- Simplify chat line format for readability; keep color-coding based on ID-derived color
- Add go-nanoid to generate 6-char per-connection IDs; fallback to RemoteAddr
- Introduce sanitizeUsername with rules: [A-Za-z0-9_.-], spaces→_, trim ._-, max 12 chars
- Support /name <username> to change username with validation and broadcast [rename]
- Greet client with default username user_<id> and usage hint for /name
- Broadcast joins/leaves and messages including username and ID; exclude self on join
- Handle /quit to trigger unified leave flow; consistent leave announcement
- Comment/document broadcast struct, Hub, and startTCPServer
- Increase scanner buffer and add newline-delimited send in broadcaster
Client/main:
- Add flags: -host (default "localhost:9000") and -server (run only server)
- When -server is set, startTCPServer(host) and exit
- Use provided host for client connection
- Center header with width-aware lipgloss styling; adjust padding
Server:
- Introduce broadcast struct {text string, exclude net.Conn}
- Hub.msgCh now chan broadcast; send messages with optional exclusion
- On join: send “[join] …” to others (exclude the joiner)
- Broadcast chat lines without exclusion; newline-delimited as before
- Handle “/quit” by breaking loop (graceful disconnect)
- On leave: broadcast “[leave] …” to all
Refactor notes:
- Remove unconditional embedded server from client startup
- Scanner loop unchanged aside from quit handling and broadcast usage