mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 06:17:23 +01:00
chatkit 0.14 carries the contract both ways; this is Loki's side of the
fleet chat-review loop (docs/architecture/chat-review.md).
- Thumbs under every Loki answer: chatkit's AnswerActions with onFeedback
replaces the hand-rolled "Bad answer" button and ReportAnswer form. The
thumb goes to POST /api/chat/feedback (new chat_feedback table, migration
0128); a thumb down is still filed as a report in Loki's own inbox through
the same plumbing the old button used (lib/loki/answer-report-file.ts).
The terminal's Loki rail and the prompt Run sheet pass onFeedback to
ChatThread.
- GET /api/chat/review-export: Loki's day of conversations as
ChatTranscript[] behind the shared CHAT_REVIEW_TOKEN (bearer, constant
time, 503 while unset), scope derived from Loki's own prompt
(lokiChatScope). Never a temporary chat; no names or user ids.
- src/config/chat-review.ts (SSOT): the four products, their export URLs
and repos, the night's budgets.
- Cron review-chats at 03:40: fetch each product's export, then start one
agent run on the product's Loki project (found by gitUrl, as its owner)
carrying chatkit's CHAT_REVIEW_INSTRUCTION + reviewPrompt for every
conversation and the door to file findings through (widget token + agent
pass, Origin = the product). The route calls no model: no box timer may
spend the free AI tier (no-free-background-ai), so the judge is the
project's agent, the way AI review reads a live page. Outcome per product
under debug_logs crons/review-chats.
- share-chat-review-token.yml: generate the token on the box into Loki's
env, copy it to heidi, orangecat, substrata when absent, redeploy all four;
the value is never printed.
- .env.example, docs/architecture/chat-review.md, link from the widget doc.
Verified: pnpm run verify green through test:unit (540 files) and the
remaining gates; test:ops fails only on .env ownership in the root sandbox.
Thumbs rendered at 390px in headless Chromium: 44px targets, no sideways
scroll, the app receives {messageId, verdict, reason} on Send.
Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE
Co-authored-by: Claude <noreply@anthropic.com>
13 lines
869 B
SQL
13 lines
869 B
SQL
CREATE TABLE "chat_feedback" (
|
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
"conversation_id" uuid NOT NULL,
|
|
"message_id" uuid NOT NULL,
|
|
"verdict" text NOT NULL,
|
|
"reason" text,
|
|
"text" text,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
ALTER TABLE "chat_feedback" ADD CONSTRAINT "chat_feedback_conversation_id_conversations_id_fk" FOREIGN KEY ("conversation_id") REFERENCES "public"."conversations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "chat_feedback" ADD CONSTRAINT "chat_feedback_message_id_conversation_messages_id_fk" FOREIGN KEY ("message_id") REFERENCES "public"."conversation_messages"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
CREATE INDEX "idx_chat_feedback_conversation_id" ON "chat_feedback" USING btree ("conversation_id"); |