Skip to content

Add frontend components for chat interface; implement message sending… - #2

Merged
codebyNorthsteep merged 3 commits into
mainfrom
feature/frontend-setup
May 5, 2026
Merged

Add frontend components for chat interface; implement message sending…#2
codebyNorthsteep merged 3 commits into
mainfrom
feature/frontend-setup

Conversation

@codebyNorthsteep

@codebyNorthsteep codebyNorthsteep commented May 5, 2026

Copy link
Copy Markdown
Owner

This pull request introduces a new mythological-themed web chat interface, allowing users to interact with various Norse gods through a modern, visually appealing UI. The main additions are a new HTML file (index.html), a JavaScript file for chat logic (app.js), and a comprehensive CSS stylesheet (style.css). Together, these changes implement the frontend for the "Asgard AI" chat application.

The most important changes are:

New Chat Application Frontend

  • Added index.html to provide the structure for the chat app, including a header, selectable Norse god personalities ("god chips"), a chat window, typing indicator, and message input area.
  • Added style.css to deliver a custom mythological visual theme, with responsive layout, rune-inspired colors, and distinct styles for user and AI (god) messages, as well as interactive god selection chips.

Interactive Chat Functionality

  • Added app.js to implement chat logic: manages session state, handles god chip selection, sends user messages to the backend (/api/v1/chat), displays responses, and shows a typing indicator while awaiting replies. Also, it ensures Heimdall is the default selected god.

User Experience Enhancements

  • Implemented keyboard support for sending messages (Enter key), error handling for failed requests, and automatic scrolling to the latest message in the chat window.
  • Improved accessibility and usability by hiding the raw personality select and using visually rich, clickable "god chips" for selection. [1] [2]… and personality selection

Summary by CodeRabbit

  • New Features
    • Added interactive chat interface with personality selector, enabling users to choose different conversation styles before messaging
    • Implemented real-time message sending and response display with visual loading indicators
    • Introduced dark-themed UI with gold and silver accents for enhanced visual experience

@coderabbitai

coderabbitai Bot commented May 5, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@codebyNorthsteep has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 13 minutes and 1 second before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 62530a34-7e0f-41d2-803d-ff95c001cd20

📥 Commits

Reviewing files that changed from the base of the PR and between 8aafdde and f3bf9c7.

📒 Files selected for processing (3)
  • src/main/resources/static/app.js
  • src/main/resources/static/index.html
  • src/main/resources/static/style.css
📝 Walkthrough

Walkthrough

This PR introduces a complete static web UI for a Norse-mythology-themed chat application. The changes include an HTML page structure, comprehensive dark-themed styling, and client-side JavaScript logic that handles personality selection via god-chips, message sending to an API endpoint, response rendering, and session management with a unique UUID per chat session.

Changes

Chat UI Foundation

Layer / File(s) Summary
HTML Structure
src/main/resources/static/index.html
Defines the complete page layout: header with "Asgard AI" branding, god-chip selector (ODIN, LOKI, THOR, FREYJA, HEIMDALL), chat window with initial message, typing indicator, textarea input, send button, and footer. All elements include semantic id and class attributes for CSS and JS targeting.
Visual Styling
src/main/resources/static/style.css
Applies a cohesive dark "abyss" theme with gold/silver accents (CSS custom properties). Styles header typography, god-chip hover/active states, message bubbles (user vs. assistant alignment and colors), scrollable chat window, fade-in animation for messages, input area with focus/disabled states, and utility classes.
Client Behavior & API Integration
src/main/resources/static/app.js
Initializes session state (UUID, waiting flag), caches DOM elements, and wires event handlers. Implements sendMessage() to POST { personality, message, sessionId } to /api/v1/chat, maps personality keys to display names, renders responses as assistant messages with god labels, handles errors as system messages, and manages loading state with a typing indicator. Send button and Enter-key events trigger messaging; multiline composition (Enter+Shift) is allowed.

Sequence Diagram

sequenceDiagram
    participant User
    participant ChatUI as Chat UI<br/>(app.js)
    participant API as /api/v1/chat
    participant DOM as DOM & Display

    User->>ChatUI: 1. Select god chip (e.g., LOKI)
    ChatUI->>DOM: Set personality select value
    
    User->>ChatUI: 2. Type message & press Enter
    ChatUI->>ChatUI: Validate input, set isWaiting=true
    ChatUI->>DOM: Show typing indicator, disable send button
    
    ChatUI->>API: 3. POST { personality, message, sessionId }
    
    alt Success
        API-->>ChatUI: Response with assistant message
        ChatUI->>ChatUI: Map personality to god name (e.g., "Loki")
        ChatUI->>DOM: Append assistant message bubble with god label
    else Error
        API-->>ChatUI: Exception thrown
        ChatUI->>DOM: Append system error message
    end
    
    ChatUI->>DOM: 4. Hide typing indicator, enable send button
    ChatUI->>DOM: Scroll chat window to bottom
    ChatUI->>ChatUI: Clear waiting flag
    
    DOM-->>User: Display updated chat with message & response
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

Through the void where Asgard gleams, 🐰
A rabbit hops through digital dreams,
With god-chips clicking, so styled divine—
Static and dynamic now intertwine! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding frontend components for a chat interface with message sending functionality.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/frontend-setup

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/main/resources/static/app.js`:
- Around line 65-73: In appendMessage, avoid using innerHTML for assistant
output to prevent XSS: instead create a child element for the assistant label
(use the existing name string in a created element) and a separate content
element where you assign text to textContent (or create a text node) rather than
interpolating `text` into msgDiv.innerHTML; update the branch that checks `if
(role === 'assistant')` to append the label element and the text-content element
to msgDiv so the user/LLM-supplied `text` is never parsed as HTML.
- Around line 43-61: Wrap the fetch in an AbortController: create a controller
before the fetch, pass controller.signal into the fetch call, start a timeout
(e.g. 15s) that calls controller.abort(), and clear that timeout after the
response/when awaiting completes; in the catch block detect AbortError and call
appendMessage('assistant','System','Request timed out') (or similar) and ensure
chatState.isWaiting is set to false; keep the existing setLoading(false) in
finally so the UI is re-enabled. Reference: the fetch POST to '/api/v1/chat',
the controller.signal, the timeout handler, appendMessage, chatState.isWaiting,
and setLoading.

In `@src/main/resources/static/index.html`:
- Around line 45-57: Add accessible live-region semantics so screen readers
announce new messages and typing state: update the chat container(s) referenced
by IDs "chat-window" and "typing-indicator" to include appropriate ARIA
attributes (e.g., aria-live="polite" and role="status", and consider
aria-atomic="true" on "chat-window") so dynamically injected assistant messages
and the typing text are announced; ensure any code that appends new assistant
message nodes (the message element with class "assistant" inside "chat-window")
does not override or remove these attributes when updating DOM.
- Around line 37-42: The personality chips are non-semantic divs (elements with
class "god-chip" and data-god attributes) which prevents keyboard and AT
interaction—replace each <div class="god-chip" data-god="..."> with a semantic
<button type="button" class="god-chip" data-god="..."> and remove duplicate
attributes (e.g., Heimdall had two class attributes); then update the toggle
logic in src/main/resources/static/app.js (the code that adds/removes the
"active" class on .god-chip) to also set aria-pressed="true" when activating and
aria-pressed="false" when deactivating so the UI stays accessible and in sync.

In `@src/main/resources/static/style.css`:
- Line 19: Remove the quoted font-family names and the camelCase keyframe name
to satisfy Stylelint: unquote 'Georgia' (use Georgia) where it appears
(currently at the shown line and also at the other occurrences mentioned),
rename the keyframes rule named fadeIn to a kebab-case name (e.g., fade-in) and
update any animation or animation-name declarations that reference fadeIn to the
new kebab-case identifier (check the `@keyframes` block and all uses). Ensure
consistency across all occurrences (lines referenced: the shown line and the
other instances noted).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: aa1e6520-cd10-4ccc-95cd-5eea59d3bbe0

📥 Commits

Reviewing files that changed from the base of the PR and between 6d976c7 and 8aafdde.

📒 Files selected for processing (3)
  • src/main/resources/static/app.js
  • src/main/resources/static/index.html
  • src/main/resources/static/style.css

Comment thread src/main/resources/static/app.js
Comment thread src/main/resources/static/app.js
Comment thread src/main/resources/static/index.html Outdated
Comment thread src/main/resources/static/index.html
Comment thread src/main/resources/static/style.css Outdated
@codebyNorthsteep
codebyNorthsteep merged commit de876c3 into main May 5, 2026
1 check passed
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