Skip to content

Comments

Fix message attribution and add timestamp support#10

Open
tassa-yoniso-manasi-karoto wants to merge 2 commits intoagarwalvishal:mainfrom
tassa-yoniso-manasi-karoto:fix-attribution-and-timestamps
Open

Fix message attribution and add timestamp support#10
tassa-yoniso-manasi-karoto wants to merge 2 commits intoagarwalvishal:mainfrom
tassa-yoniso-manasi-karoto:fix-attribution-and-timestamps

Conversation

@tassa-yoniso-manasi-karoto

This PR addresses two issues:

Bug Fix: Message Attribution (Fixes #8)

All messages were incorrectly attributed to Claude because copy buttons exist on both user messages and Claude responses. The original code clicked all copy buttons, capturing everything as "Claude responses".

Solution: Distinguish Claude's copy buttons by checking if the Message Actions group contains feedback buttons:

  • User message action bars have: Copy + Edit buttons (no feedback)
  • Claude message action bars have: Copy + Feedback buttons (no edit)

Also fixed the edit button detection which was failing due to DOM structure changes (the edit button is in a sibling Message Actions group, not inside the same .group ancestor).

Feature: Timestamp Support (Closes #9)

Added full timestamp support for exported messages by fetching data from Claude's conversation API.

Why API? DOM-based approaches failed because:

  • React Fiber internals are stripped in production
  • Radix tooltips don't respond to synthetic events (check event.isTrusted)
  • Timestamps aren't stored in __NEXT_DATA__ or sessionStorage

Solution: Fetch timestamps from /api/organizations/{org_id}/chat_conversations/{conversation_id} which returns created_at fields for each message.

Timestamps are displayed on human messages only (Claude responses are usually seconds after).

Output Format

## Human (Dec 27, 2025, 1:22 PM):

User message content...

---

## Claude:

Claude response content...

---

Fixes #8
Closes #9

Copy buttons exist on both user messages and Claude responses, causing all
messages to be captured as Claude's. This fix identifies Claude's copy buttons
by checking if the Message actions group contains feedback buttons (which only
appear on Claude's responses).

- Distinguish Claude's copy buttons from user's by checking for feedback buttons
- Fix edit button search by traversing up DOM to find Message actions group
- Add messageActionsGroup and feedbackButton selectors for maintainability
- Update countClaudeCopyButtons to use correct identification logic

Fixes message attribution bug where user messages appeared as Claude's responses

Co-Authored-By: Claude <noreply@anthropic.com>
- Fetch message timestamps from /api/organizations/.../chat_conversations/...
- Display full timestamps on human messages (e.g., "Dec 27, 2025, 1:22 PM")
- Skip timestamps on Claude responses (usually seconds after)
- Use API response for conversation title as fallback

Co-Authored-By: Claude <noreply@anthropic.com>
@KanTakahiro
Copy link

I tested the PR version, on Chrome it works fine but on Firefox it doesn't fetch the claude responses. On console, it only show "Clicked copy button x/x" but no "Captured Claude response N".

@stdedos
Copy link

stdedos commented Feb 4, 2026

In Brave, only the Human has timestamps. Claude messages don't 🙏

@KanTakahiro
Copy link

I build a new snippet that fixed the Firefox issue. This may help you @stdedos . Feel free to give it a try.

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.

Timestamp support All user messages are attributed to Claude

3 participants