diff --git a/site/src/pages/AgentsPage/AgentChatPage.stories.tsx b/site/src/pages/AgentsPage/AgentChatPage.stories.tsx index 50687411f8..be347cb264 100644 --- a/site/src/pages/AgentsPage/AgentChatPage.stories.tsx +++ b/site/src/pages/AgentsPage/AgentChatPage.stories.tsx @@ -351,7 +351,7 @@ export const WithMessageHistory: Story = { }, ], }, - // -- Turn 3: user follow-up -- + // -- Turn 3: user follow-up (long message) -- { id: 3, chat_id: CHAT_ID, @@ -360,7 +360,33 @@ export const WithMessageHistory: Story = { content: [ { type: "text", - text: "Can you show me the token validation code and a comparison of the old vs new approach?", + text: [ + "Can you show me the token validation code and a comparison of the old vs new approach?", + "", + "I have a lot of context I want to share so you can give me the best possible answer.", + "The current token validation is scattered across multiple files and it is really hard", + "to follow the flow from HTTP request to database lookup to response. The middleware in", + "coderd/httpmw/apikey.go does way too much - it parses the token, validates the signature,", + "checks expiration, looks up the user, checks if the user is suspended, and then sets up", + "the context. That is at least 6 different responsibilities in a single middleware function.", + "", + "Here are the specific files I have been looking at:", + "- coderd/httpmw/apikey.go (main middleware, ~400 lines)", + "- coderd/httpmw/oauth2.go (OAuth2 token handling)", + "- coderd/httpmw/session.go (session cookie management)", + "- coderd/userauth.go (login/logout handlers)", + "- coderd/apikey.go (API key CRUD operations)", + "- enterprise/coderd/proxyhealth.go (proxy authentication)", + "", + "The problem is that ExtractAPIKeyMW is doing too many things at once:", + "1. Extracting the token from the request (cookie or header)", + "2. Splitting the token into key ID and secret", + "3. Looking up the API key in the database", + "4. Hashing the secret and comparing it", + "5. Checking if the key is expired", + "", + "Can you incorporate all of this into your comparison of the old vs new approach?", + ].join("\n"), }, ], }, diff --git a/site/src/pages/AgentsPage/components/ChatConversation/ConversationTimeline.tsx b/site/src/pages/AgentsPage/components/ChatConversation/ConversationTimeline.tsx index 5e681106f7..f080e111a1 100644 --- a/site/src/pages/AgentsPage/components/ChatConversation/ConversationTimeline.tsx +++ b/site/src/pages/AgentsPage/components/ChatConversation/ConversationTimeline.tsx @@ -602,6 +602,7 @@ const ChatMessageItem = memo<{