Conversation
Greptile SummaryThis PR adds a new
Confidence Score: 3/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[InvestigationDetails Page] --> B{investigation loaded?}
B -->|No| C[Loading / Redirect]
B -->|Yes, has rootCause| D[Two-Column Layout]
D --> E[Left Column - 592px]
D --> F[Right Column - 340px]
E --> G[InvestigationDetailsVerdict]
F --> H[ChatWidget]
H --> I{isCollapsed?}
I -->|Yes| J[40x40 Logo Icon]
I -->|No| K[Expanded Chat Panel]
K --> L[Header: New Chat / History / Collapse]
K --> M[Message List]
K --> N[Input Area]
N -->|Enter / Click Send| O[Add message to local state]
A --> P[Full Width Below]
P --> Q[IntegrationDetailsEvidenceChain]
Prompt To Fix All With AIThis is a comment left during a code review.
Path: services/dashboard/src/pages/Investigation/components/ChatWidget.tsx
Line: 28-35
Comment:
**Stale timestamp on initial/reset messages**
`INITIAL_MESSAGES` is evaluated once at module load time, so the timestamp of the "How can I help you today?" message will always reflect when the page was first loaded — not when the chat was opened or reset. When a user clicks "New chat" (`handleNewChat`), the reset messages will also carry this stale timestamp.
Consider computing the initial messages lazily, e.g.:
```suggestion
const getInitialMessages = (): Message[] => [
{
id: "1",
role: "assistant",
content: "How can I help you today?",
timestamp: getFormattedTimestamp(),
},
];
```
Then use `getInitialMessages()` in both `useState` and `handleNewChat`:
```ts
const [messages, setMessages] = useState<Message[]>(getInitialMessages);
// ...
function handleNewChat() {
setMessages(getInitialMessages());
setInputValue("");
}
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: services/dashboard/src/pages/Investigation/components/ChatWidget.tsx
Line: 37-67
Comment:
**Chat is client-only with no backend integration**
Currently `handleSend` adds the user's message to local state but never sends it to any API or receives a response. Messages are never persisted and will be lost on navigation or refresh. Is this intentional scaffolding for a future backend integration, or should there be an API call here?
How can I resolve this? If you propose a fix, please make it concise.Last reviewed commit: 24fb410 |
| const INITIAL_MESSAGES: Message[] = [ | ||
| { | ||
| id: "1", | ||
| role: "assistant", | ||
| content: "How can I help you today?", | ||
| timestamp: getFormattedTimestamp(), | ||
| }, | ||
| ]; |
There was a problem hiding this comment.
Stale timestamp on initial/reset messages
INITIAL_MESSAGES is evaluated once at module load time, so the timestamp of the "How can I help you today?" message will always reflect when the page was first loaded — not when the chat was opened or reset. When a user clicks "New chat" (handleNewChat), the reset messages will also carry this stale timestamp.
Consider computing the initial messages lazily, e.g.:
| const INITIAL_MESSAGES: Message[] = [ | |
| { | |
| id: "1", | |
| role: "assistant", | |
| content: "How can I help you today?", | |
| timestamp: getFormattedTimestamp(), | |
| }, | |
| ]; | |
| const getInitialMessages = (): Message[] => [ | |
| { | |
| id: "1", | |
| role: "assistant", | |
| content: "How can I help you today?", | |
| timestamp: getFormattedTimestamp(), | |
| }, | |
| ]; |
Then use getInitialMessages() in both useState and handleNewChat:
const [messages, setMessages] = useState<Message[]>(getInitialMessages);
// ...
function handleNewChat() {
setMessages(getInitialMessages());
setInputValue("");
}Prompt To Fix With AI
This is a comment left during a code review.
Path: services/dashboard/src/pages/Investigation/components/ChatWidget.tsx
Line: 28-35
Comment:
**Stale timestamp on initial/reset messages**
`INITIAL_MESSAGES` is evaluated once at module load time, so the timestamp of the "How can I help you today?" message will always reflect when the page was first loaded — not when the chat was opened or reset. When a user clicks "New chat" (`handleNewChat`), the reset messages will also carry this stale timestamp.
Consider computing the initial messages lazily, e.g.:
```suggestion
const getInitialMessages = (): Message[] => [
{
id: "1",
role: "assistant",
content: "How can I help you today?",
timestamp: getFormattedTimestamp(),
},
];
```
Then use `getInitialMessages()` in both `useState` and `handleNewChat`:
```ts
const [messages, setMessages] = useState<Message[]>(getInitialMessages);
// ...
function handleNewChat() {
setMessages(getInitialMessages());
setInputValue("");
}
```
How can I resolve this? If you propose a fix, please make it concise.| export function ChatWidget() { | ||
| const [messages, setMessages] = useState<Message[]>(INITIAL_MESSAGES); | ||
| const [inputValue, setInputValue] = useState(""); | ||
| const [isCollapsed, setIsCollapsed] = useState(false); | ||
| const messagesEndRef = useRef<HTMLDivElement>(null); | ||
| const textareaRef = useRef<HTMLTextAreaElement>(null); | ||
|
|
||
| useEffect(() => { | ||
| if (!isCollapsed) { | ||
| messagesEndRef.current?.scrollIntoView({ behavior: "smooth" }); | ||
| } | ||
| }, [messages, isCollapsed]); | ||
|
|
||
| function handleSend() { | ||
| const trimmed = inputValue.trim(); | ||
| if (!trimmed) return; | ||
|
|
||
| setMessages((prev) => [ | ||
| ...prev, | ||
| { | ||
| id: Date.now().toString(), | ||
| role: "user", | ||
| content: trimmed, | ||
| timestamp: getFormattedTimestamp(), | ||
| }, | ||
| ]); | ||
| setInputValue(""); | ||
| if (textareaRef.current) { | ||
| textareaRef.current.style.height = "auto"; | ||
| } | ||
| } |
There was a problem hiding this comment.
Chat is client-only with no backend integration
Currently handleSend adds the user's message to local state but never sends it to any API or receives a response. Messages are never persisted and will be lost on navigation or refresh. Is this intentional scaffolding for a future backend integration, or should there be an API call here?
Prompt To Fix With AI
This is a comment left during a code review.
Path: services/dashboard/src/pages/Investigation/components/ChatWidget.tsx
Line: 37-67
Comment:
**Chat is client-only with no backend integration**
Currently `handleSend` adds the user's message to local state but never sends it to any API or receives a response. Messages are never persisted and will be lost on navigation or refresh. Is this intentional scaffolding for a future backend integration, or should there be an API call here?
How can I resolve this? If you propose a fix, please make it concise.
Added the front-end UI for the chat widget for Investigation details timeline approach.