Skip to content

chat widget#36

Open
farhinhusain0 wants to merge 1 commit intoasteroncall:mainfrom
farhinhusain0:feat/chat-ui
Open

chat widget#36
farhinhusain0 wants to merge 1 commit intoasteroncall:mainfrom
farhinhusain0:feat/chat-ui

Conversation

@farhinhusain0
Copy link
Contributor

@farhinhusain0 farhinhusain0 commented Mar 16, 2026

Added the front-end UI for the chat widget for Investigation details timeline approach.

image

@greptile-apps
Copy link

greptile-apps bot commented Mar 16, 2026

Greptile Summary

This PR adds a new ChatWidget component to the Investigation Details page, placed alongside the existing verdict card in a side-by-side layout. The widget features a collapsible/expandable UI with smooth spring animations, a message input with auto-resize, and keyboard shortcuts (Enter to send).

  • New ChatWidget component with collapse/expand animation, message rendering, and input handling — currently client-only with no backend integration (messages are not persisted or sent to an API)
  • Investigation details layout restructured from a single-column to a two-column layout (verdict 592px + chat 340px = 952px container) with the evidence chain remaining full-width below
  • ContentContainerCard Root now accepts an optional className prop for layout flexibility
  • InvestigationDetailsVerdict updated with h-full styling to stretch to match the adjacent chat widget height
  • Bug: INITIAL_MESSAGES timestamp is computed once at module load, causing stale timestamps on "New chat" reset

Confidence Score: 3/5

  • This PR is safe to merge as UI scaffolding, but the chat widget has no backend integration and contains a stale timestamp bug.
  • Score of 3 reflects that the layout changes are well-structured and the component is self-contained, but the ChatWidget is purely cosmetic (no API calls, messages lost on navigation) and has a timestamp bug. No risk of breaking existing functionality.
  • Pay close attention to services/dashboard/src/pages/Investigation/components/ChatWidget.tsx — stale timestamp bug and missing backend integration.

Important Files Changed

Filename Overview
services/dashboard/src/pages/Investigation/components/ChatWidget.tsx New chat widget component with collapse/expand animation. Has a stale timestamp bug on initial messages and no backend integration yet.
services/dashboard/src/pages/Investigation/InvestigationDetails.tsx Layout restructured to place ChatWidget alongside InvestigationDetailsVerdict in a flex row. Layout math (592px + 340px + 20px gap = 952px) is correct.
services/dashboard/src/components/common/ContentContainerCard.tsx Added optional className prop to Root component, merged via cx. Clean, backward-compatible change.
services/dashboard/src/pages/Investigation/components/InvestigationDetailsVerdict.tsx Added className prop and h-full styling to stretch the verdict card to match the adjacent chat widget height. Trailing whitespace on lines 29/32.
services/dashboard/src/pages/Investigation/components/index.ts Added ChatWidget re-export from barrel file. Straightforward change.

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]
Loading
Prompt To Fix All 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.

---

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

Comment on lines +28 to +35
const INITIAL_MESSAGES: Message[] = [
{
id: "1",
role: "assistant",
content: "How can I help you today?",
timestamp: getFormattedTimestamp(),
},
];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.:

Suggested change
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.

Comment on lines +37 to +67
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";
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant