Commit Graph

126 Commits

Author SHA1 Message Date
Nicolas Varrot
c596bdd99a feat: line numbers in code blocks with toggle button
- Show line numbers for code blocks with more than 3 lines
- Toggle button (# icon + line count) in the language header bar
- Preference persisted in localStorage
- Line numbers are non-selectable (won't copy with code)
- Hidden for short snippets to reduce visual noise
2026-02-13 19:53:04 +00:00
Nicolas Varrot
1927fce788 fix: restore textarea border, only remove accent focus ring 2026-02-13 18:14:46 +00:00
Nicolas Varrot
51de6984b6 feat: message grouping — hide avatar and reduce spacing for consecutive same-role messages
Consecutive messages from the same role within 2 minutes are visually
grouped: subsequent messages hide the avatar (keeping alignment) and
use tighter vertical spacing. Date separators and role changes break
groups. This matches modern chat UX patterns (Discord, Telegram).
2026-02-13 18:12:44 +00:00
Nicolas Varrot
2f25c45942 fix: remove textarea inner border, keep only container border 2026-02-13 17:57:03 +00:00
Nicolas Varrot
0329fa48bf fix: replace ugly focus ring with subtle border color change on textarea 2026-02-13 17:55:19 +00:00
Nicolas Varrot
ac29646dc8 fix: hide non-essential header buttons on mobile (sound, export, theme, language) 2026-02-13 17:50:49 +00:00
Nicolas Varrot
219d487c43 fix: hide preview and syntax highlight buttons on mobile to give textarea more space 2026-02-13 17:50:00 +00:00
Nicolas Varrot
153d165457 fix: navigator not defined in test environment 2026-02-13 15:51:07 +00:00
Nicolas Varrot
622aa107f8 feat: show response generation time on assistant messages
Track how long each assistant response took to generate and display
it subtly next to the timestamp (e.g. '· 12.3s'). The timing is
measured from the first streaming delta to the final state, and
preserved across the history reload that follows stream completion.

Only visible for messages generated during the current session.
2026-02-13 15:46:29 +00:00
Nicolas Varrot
d3e8f3143a fix: sync html lang attribute with i18n locale selection
- Set document.documentElement.lang on initial load and locale change
- Ensures screen readers and browser features respect the active language
- Removes duplicate aria-label on MessageSearch input
2026-02-13 15:11:39 +00:00
Nicolas Varrot
a44b6db77d style: add global focus-visible outline for keyboard navigation accessibility
Adds a consistent focus ring (accent-dim color, 2px) on all focusable
elements when navigated via keyboard (:focus-visible). Mouse/touch clicks
no longer show the default browser outline (:focus:not(:focus-visible)).

Elements with existing Tailwind focus:ring-* classes are unaffected since
they already handle their own focus styling.
2026-02-13 14:57:39 +00:00
Nicolas Varrot
1942ba18c7 feat: semantic <time> elements with full-date tooltip on message timestamps
- Replace raw text timestamps with <time> HTML elements
- Add dateTime attribute (ISO 8601) for accessibility and machine readability
- Add title attribute showing full date+time on hover (weekday, date, time with seconds)
- Localized tooltip using the user's language preference
- Helps users see exact timestamps for older messages shown as abbreviated times
2026-02-13 14:43:05 +00:00
Nicolas Varrot
3d707dbd90 perf: lazy-load ReactMarkdown and plugins for faster initial render
Move react-markdown, remark-gfm, remark-breaks, and rehype-highlight
imports from eager to dynamic via a LazyMarkdown wrapper component.
The ~336KB markdown bundle is now loaded on-demand after initial paint
instead of blocking the critical rendering path.

- Create LazyMarkdown component with Suspense fallback
- Pre-load plugins in parallel on module init
- Replace all ReactMarkdown usage in ChatMessage with LazyMarkdown
2026-02-13 14:26:14 +00:00
Nicolas Varrot
388879e14e style: add print stylesheet for conversation export
- Hide sidebar, header, chat input, and scroll button when printing
- Reset backgrounds to white, text to black for readability
- Code blocks get light background with borders
- Tool calls styled for print (compact, bordered)
- External links show their URL in parentheses
- Chat scroll area becomes fully visible (no overflow)
- Messages avoid page-break-inside for clean pagination
- Remove shadows and backdrop filters in print
2026-02-13 14:12:41 +00:00
Nicolas Varrot
52458b6171 test: add GatewayClient WebSocket unit tests (12 tests)
Cover core networking: connect/disconnect, challenge handshake,
event routing, request/response, error handling, timeout,
reconnect behavior, and credential updates.

Adds __APP_VERSION__ define to vitest.config.ts for test env.
Total test count: 95 → 107.
2026-02-13 14:03:16 +00:00
Nicolas Varrot
e230f9791f feat: improve accessibility — semantic HTML landmarks, skip-to-content link, ARIA attributes
- Replace div with <main> for primary chat pane (screen reader landmark)
- Replace div with <section> for split pane
- Add skip-to-content link for keyboard navigation (Tab → jump to chat input)
- Add aria-expanded and aria-label to tool call badge buttons
- Add id='chat-input' to textarea for skip link target
- Add i18n keys for new ARIA labels (EN + FR)
2026-02-13 13:28:02 +00:00
Nicolas Varrot
72e9bce4c5 fix: bust service worker cache on each build with version+timestamp
The SW cache name was hardcoded to 'pinchchat-v1', meaning PWA users
would get stale cached assets forever. Now the cache name includes
the package version and build timestamp, so each build creates a new
cache and old ones are cleaned up on activation.

Also adds:
- Periodic SW update check (every 30 min)
- Auto-reload when new SW version is detected
2026-02-13 11:57:32 +00:00
Nicolas Varrot
13f5c4ac0c fix: textarea overflow and width in highlighted input container 2026-02-13 11:52:39 +00:00
Nicolas Varrot
beced29c91 fix: textarea not expanding in flex layout with syntax highlight enabled 2026-02-13 11:51:55 +00:00
Nicolas Varrot
f8324b760c feat: add C, C++, and Java syntax highlighting support
Add c, cpp, and java to the highlight.js language bundle for code block
rendering. These are among the most commonly used languages in AI coding
conversations and were previously unsupported, falling back to plain text.

Also adds aliases: h (C headers), cc/cxx/c++/hpp/hxx (C++ variants).
2026-02-13 11:30:18 +00:00
Nicolas Varrot
ccabb8699f perf: memoize ChatMessage component and hoist ReactMarkdown plugin arrays
- Wrap ChatMessageComponent with React.memo to skip re-renders when props unchanged
- Hoist remarkPlugins and rehypePlugins arrays to module scope to avoid
  creating new array references on every render (prevents unnecessary
  ReactMarkdown re-processing)
- Use proper PluggableList type from unified instead of any
2026-02-13 10:58:11 +00:00
Nicolas Varrot
1c09ccde22 fix: improve accessibility — add ARIA attributes to ThemeSwitcher, ThinkingBlock, ThinkingIndicator, ErrorBoundary, SessionIcon
- ThemeSwitcher: aria-expanded, aria-haspopup, aria-pressed on theme/accent buttons, Escape to close, dialog role
- ThinkingBlock: aria-expanded on toggle, region role on content
- ThinkingIndicator: role=status, aria-label, decorative icon aria-hidden
- ErrorBoundary: role=alert on error state
- SessionIcon: aria-hidden on decorative SVG brand icons
2026-02-13 10:42:10 +00:00
Nicolas Varrot
cbb46115a0 fix: render markdown lists with proper bullet/number styles
Tailwind's preflight resets list-style to none on ul/ol elements.
Add explicit list-style-type rules for markdown-body: disc for ul,
decimal for ol, with circle/square for nested levels.
Also add li margin for spacing.

Closes feedback #61
2026-02-13 09:40:22 +00:00
Nicolas Varrot
5acc5a820d fix: improve light theme readability for tool badges and user bubbles
- Expose resolvedTheme in ThemeContext for theme-aware rendering
- Tool call badges: darker text colors and higher bg opacity in light theme
- User message bubbles: increased bg opacity and border strength in light theme
- Progress bars and send button already use accent CSS variables (no change needed)

Closes feedback #60
2026-02-13 09:27:42 +00:00
Nicolas Varrot
b783ae181b feat: optimistic message rendering with send status indicators
- User messages appear instantly with 'sending' state (dimmed, clock icon)
- Transitions to 'sent' (checkmark) when server acknowledges
- Shows error state (alert icon, retry visible) if send fails
- Applied to both primary and secondary sessions
2026-02-13 09:12:09 +00:00
Nicolas Varrot
85a14224ad fix: theme switcher portal — max z-index, remove backdrop-blur to fix compositing 2026-02-13 08:46:13 +00:00
Nicolas Varrot
885cd0ea22 fix: render theme switcher via portal to escape overflow/stacking context 2026-02-13 08:44:26 +00:00
Nicolas Varrot
f2162c6731 test: add i18n and highlight.js test suites (18 cases, 95 total) 2026-02-13 08:42:59 +00:00
Nicolas Varrot
317096499c fix: theme switcher click handling — prevent click-outside from swallowing button clicks 2026-02-13 08:36:12 +00:00
Nicolas Varrot
3fcaa1eef8 fix: replace remaining hardcoded zinc color classes with theme variables in App.tsx 2026-02-13 08:26:54 +00:00
Nicolas Varrot
e698e64bc8 test: add unit tests for image, utils, and credentials modules (22 cases) 2026-02-13 08:11:17 +00:00
Nicolas Varrot
3fad7b1e0a test: expand exportChat coverage with tool_result and edge case tests 2026-02-13 07:56:54 +00:00
Nicolas Varrot
bb9393c138 test: add systemEvent utility tests (21 cases) 2026-02-13 07:40:45 +00:00
Nicolas Varrot
c4725e65c2 feat: add Vitest unit tests for utility functions
- Set up Vitest with 27 tests across 3 test suites
- relativeTime: edge cases, time buckets, future timestamps
- sessionDisplayName: labels, kinds, channels, UUID truncation
- messagesToMarkdown: roles, blocks, tool calls, system events
- Add test and test:watch npm scripts
- Add test step to CI workflow
2026-02-13 06:58:39 +00:00
Nicolas Varrot
f05db6aa6d refactor: replace console.log with debug logger in gateway client
WebSocket debug logs are now silent by default. Enable with:
  localStorage.setItem('pinchchat:debug', '1')

Reduces console noise in production while keeping full debug
visibility available for developers.
2026-02-13 06:41:26 +00:00
Nicolas Varrot
6b0261f9c1 perf: reduce bundle size by using custom highlight.js subset
Replace highlight.js/lib/common (36 languages) with a curated subset
of 16 languages relevant for coding-assistant chat UIs. Both ToolCall
(direct hljs) and ChatMessage (rehype-highlight) now share the same
custom bundle from src/lib/highlight.ts.

Languages included: bash, css, diff, dockerfile, go, ini, javascript,
json, markdown, python, rust, shell, sql, typescript, xml, yaml.

Markdown chunk: 477KB → 336KB (-30%, -45KB gzipped)
2026-02-13 06:11:46 +00:00
Nicolas Varrot
de6976bae8 fix: add missing aria-labels to icon-only buttons for accessibility
- Sidebar close button: aria-label for screen readers
- Sidebar search clear button: aria-label
- ChatMessage raw JSON copy button: aria-label
- Added i18n keys: sidebar.close, sidebar.clearSearch (EN + FR)
2026-02-13 05:42:23 +00:00
Nicolas Varrot
5a4c5ba457 feat: add service worker for PWA support (offline caching, installability)
- Add sw.js with stale-while-revalidate caching for static assets
- Network-first for HTML navigation, skip API/WS requests
- Register service worker in main.tsx on page load
- Enhanced manifest.json with orientation, categories, and all icon sizes
- App is now installable as a standalone PWA on mobile and desktop
2026-02-13 05:11:39 +00:00
Nicolas Varrot
5f3f73e4c9 fix: add loading skeleton and error fallback for images
- Show a pulsing placeholder while images load
- Display a graceful error state with ImageOff icon when images fail to load
- Prevents broken image icons from cluttering the chat
2026-02-13 04:56:47 +00:00
Nicolas Varrot
dfbfc375da fix: open external links in new tab with rel=noopener noreferrer
Markdown links pointing to external URLs (http/https) now open in a
new tab with target=_blank and rel='noopener noreferrer' for security.
Internal/relative links are unaffected.
2026-02-13 04:42:39 +00:00
Nicolas Varrot
2157d7ebd5 feat: add System theme option that follows OS color scheme
Adds a 'System' option to the theme switcher that automatically uses
light or dark theme based on the OS prefers-color-scheme setting.
Dynamically updates when the OS preference changes (e.g. scheduled
dark mode). i18n labels added for EN/FR.
2026-02-13 04:13:01 +00:00
Nicolas Varrot
1770e95d0a fix: resolve all ESLint warnings (setState in useEffect)
Suppress 3 react-hooks/set-state-in-effect warnings with targeted
eslint-disable comments. These are intentional patterns:
- ChatInput: restore draft text on session switch
- MessageSearch: reset active index on query change
- ToolCall: sync open state with global collapse/expand toggle

Lint now passes with 0 errors and 0 warnings.
2026-02-13 03:41:39 +00:00
Nicolas Varrot
f09482e6cb feat: multi-tab split view for 2 sessions side by side
- Add split view button (columns icon) in sidebar session actions
- Click to open any session in a secondary pane alongside the primary
- Resizable divider between panes (drag to resize, persisted in localStorage)
- Secondary pane supports full chat: history, streaming, send, abort
- Close split view via X button or clicking the split icon again
- Each pane has independent scroll, search, and tool collapse
- Keyboard shortcut and i18n support (EN/FR)
2026-02-13 02:44:33 +00:00
Nicolas Varrot
b0492434d0 feat: syntax highlighting in chat input textarea
Real-time markdown syntax coloring while typing using a transparent
textarea overlay approach. Highlights: code blocks, inline code,
bold, italic, headings, and links. Toggle button (highlighter icon)
to enable/disable, persisted in localStorage.
2026-02-13 02:26:15 +00:00
Nicolas Varrot
35652eaeb5 feat: drag & drop session reordering in sidebar
- Drag sessions to reorder within pinned/unpinned groups
- Custom order persists in localStorage
- Visual feedback: dragged item fades, drop target highlights
- Disabled during search filtering
- Works alongside existing pin feature (pinned group stays on top)
2026-02-13 02:10:53 +00:00
Nicolas Varrot
4dfaaff2b5 feat: live markdown preview toggle in chat input
- Eye icon button next to file picker toggles preview on/off
- Shows rendered markdown above textarea in real-time
- Lazy-loads ReactMarkdown (no bundle impact when off)
- Preference persisted in localStorage
- i18n: EN/FR labels for show/hide preview
2026-02-13 01:56:13 +00:00
Nicolas Varrot
82d2e37a27 feat: raw JSON viewer toggle on each message
Add a {⁠} button (visible on hover) that toggles a collapsible panel
showing the full raw gateway JSON payload for any message.
Includes copy-to-clipboard, word-wrap, and i18n (EN/FR).
Useful for debugging and understanding the gateway protocol.

Closes feedback #52
2026-02-13 01:41:04 +00:00
Nicolas Varrot
c7cd47b09a feat: strip webhook/hook scaffolding from user messages
Messages from /hooks/agent containing SECURITY NOTICE blocks and
<<<EXTERNAL_UNTRUSTED_CONTENT>>> delimiters are now cleaned up.
Only the actual user content is displayed, with a small webhook
badge indicator showing the message originated from a webhook.

Closes feedback #54
2026-02-13 01:12:04 +00:00
Nicolas Varrot
6c19c26b84 feat: message search with Ctrl+F — filter and navigate matches in conversation 2026-02-13 00:57:19 +00:00
Nicolas Varrot
664fc0e109 feat: display thinking/reasoning content during streaming
Extract thinking blocks from delta events and render them inline
using the existing ThinkingBlock component. Previously, thinking
content was only visible after the stream finished (via history
reload). Now it appears in real-time as the agent reasons.

Closes feedback #57.
2026-02-13 00:41:23 +00:00