Skip to content

Add voice-message transcript persistence and fix newest-N conversation range queries#5

Merged
chz160 merged 12 commits into
mainfrom
copilot/add-voice-message-transcripts
May 11, 2026
Merged

Add voice-message transcript persistence and fix newest-N conversation range queries#5
chz160 merged 12 commits into
mainfrom
copilot/add-voice-message-transcripts

Conversation

Copy link
Copy Markdown

Copilot AI commented May 11, 2026

  • Review the new transcript-tool feedback and inspect recent workflow runs
  • Validate that set_message_transcript rejects missing or invalid transcript arguments instead of treating them as clears
  • Add focused MCP tool coverage for missing/invalid transcript argument handling
  • Run targeted tests, then final validation
  • Reply on the PR thread with the fixing commit hash

Agent-Logs-Url: https://github.com/chz160/openmessage/sessions/a58e6320-ec26-4c07-8b30-972656dcbd8a

Co-authored-by: chz160 <3420276+chz160@users.noreply.github.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds end-to-end support for persisting and displaying voice-message transcripts across the DB layer, REST API, MCP tools, and the web UI so transcripts survive re-syncs and are visible to clients.

Changes:

  • Extend messages schema + hydration to include transcript, transcribed_at, and transcript_model, and add Store.SetMessageTranscript(...).
  • Add a REST write endpoint (POST /api/transcript) plus an MCP tool (set_message_transcript) to update transcripts for existing messages.
  • Render transcripts in the web UI under audio messages and append transcript text to MCP-formatted message output; add tests for DB + API flows.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
internal/web/static/index.html Adds transcript styling and renders transcript text beneath audio messages.
internal/web/api.go Adds POST /api/transcript endpoint to persist transcripts and publish updates.
internal/web/api_test.go Adds success-path coverage for the transcript API.
internal/tools/tools.go Extends MCP message formatting to append transcript text.
internal/tools/tools_test.go Updates tests for new formatter signature and adds transcript assertion.
internal/tools/story.go Threads transcript through message formatting in story output.
internal/tools/set_message_transcript.go Introduces MCP tool/handler for setting message transcripts.
internal/tools/search_messages.go Threads transcript through message formatting in search output.
internal/db/messages.go Adds transcript columns to selects/upserts and implements SetMessageTranscript.
internal/db/messages_test.go Adds DB coverage for transcript set/overwrite and non-clobber on resync.
internal/db/db.go Adds migrations + struct fields for transcript metadata.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/db/messages.go Outdated
Comment thread internal/tools/set_message_transcript.go Outdated
Comment thread internal/web/api_test.go
Comment thread internal/tools/tools.go Outdated
Comment thread internal/db/messages.go Outdated
@chz160
Copy link
Copy Markdown
Owner

chz160 commented May 11, 2026

@copilot apply changes based on the comments in this thread

Copilot AI and others added 3 commits May 11, 2026 02:53
Agent-Logs-Url: https://github.com/chz160/openmessage/sessions/1c368499-860a-4116-846b-1c47ced45e1d

Co-authored-by: chz160 <3420276+chz160@users.noreply.github.com>
Agent-Logs-Url: https://github.com/chz160/openmessage/sessions/1c368499-860a-4116-846b-1c47ced45e1d

Co-authored-by: chz160 <3420276+chz160@users.noreply.github.com>
Agent-Logs-Url: https://github.com/chz160/openmessage/sessions/1c368499-860a-4116-846b-1c47ced45e1d

Co-authored-by: chz160 <3420276+chz160@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented May 11, 2026

@copilot apply changes based on the comments in this thread

Applied the review-thread changes in 9c1f44e, 41c9f9f, and 498fb84: transcript writes now preserve timestamps on identical rewrites, clear stale metadata on empty transcripts, use a clearer message-specific not-found error, handle MCP reload errors explicitly, safely quote transcript text in MCP output, and cover the API 404 path.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • instantmessaging-pa.googleapis.com
    • Triggering command: /tmp/TestBuiltBinaryAcceptsPairCommand3431148170/001/openmessage /tmp/TestBuiltBinaryAcceptsPairCommand3431148170/001/openmessage pair -m l/linux_amd64/compile --ctstate INVALID,NEW -j DROP 8443285/b127/ riemap.go (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of chz160 May 11, 2026 02:57
Copilot AI requested a review from chz160 May 11, 2026 02:57
@chz160
Copy link
Copy Markdown
Owner

chz160 commented May 11, 2026

@copilot

Bug fix: GetMessagesByConversations[Range] returns oldest-N instead of newest-N

The bug

internal/db/messages.go has two query functions that take a conversation-ID list and a limit:

  • GetMessagesByConversations(conversationIDs, limit)
  • GetMessagesByConversationsRange(conversationIDs, afterMS, beforeMS, limit)

Both use ORDER BY timestamp_ms ASC LIMIT ?. When the matching rows exceed limit, SQLite returns the oldest N. Callers like
get_person_messages_range (in internal/tools/story.go) need the newest N — that's what "messages with X in the last N days" should
mean. Currently a busy conversation with 2000 messages in 60 days returns the oldest 500 and silently truncates the recent edge.

The fix

In both GetMessagesByConversations and GetMessagesByConversationsRange, wrap the SELECT in a subquery that picks newest-N then
re-sorts ascending for display:

SELECT * FROM (
SELECT
FROM messages
WHERE
ORDER BY timestamp_ms DESC
LIMIT ?
) ORDER BY timestamp_ms ASC

That keeps the API contract (chronological output) but selects from the recent edge. No call sites need to change.

Files

  • internal/db/messages.go — update both functions' SQL
  • internal/db/messages_test.go — add a test that proves newest-N is selected when the range has more rows than limit

Test

In messages_test.go, add a test that:

  1. Inserts 10 messages into one conversation with timestamps 1..10
  2. Calls GetMessagesByConversationsRange([conv], 0, 99, 3)
  3. Asserts the returned slice has timestamps [8, 9, 10] in ascending order — i.e. the newest 3, chronologically ordered

Without the fix this test fails (returns 1,2,3). Same test pattern for GetMessagesByConversations.

Acceptance

  1. go build ./... clean.
  2. go test ./... passes including the new tests.
  3. Manual sanity: against a high-volume conversation (any contact with >500 messages in the last 60 days),
    get_person_messages_range should return the most recent activity, not 2024-era history.

Copilot AI and others added 2 commits May 11, 2026 03:00
Copy link
Copy Markdown
Author

Copilot AI commented May 11, 2026

@copilot

Bug fix: GetMessagesByConversations[Range] returns oldest-N instead of newest-N
...

Applied in 867fd9f and polished in ff68759. Both cross-conversation helpers now pick the newest matching rows in a descending subquery before re-sorting ascending for display, and I added DB regression coverage for both limited helpers. No UI changes for this DB-only fix.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • instantmessaging-pa.googleapis.com
    • Triggering command: /tmp/TestBuiltBinaryAcceptsPairCommand1214210179/001/openmessage /tmp/TestBuiltBinaryAcceptsPairCommand1214210179/001/openmessage pair -stringintconv l/linux_amd64/compile /tmp/go-build2474396421/b387/vet.cfg pkg/mod/golang.o-p 0.1-go1.25.0.lingo.mau.fi/util/curl ux-amd64/pkg/tool/linux_amd64/vet o .go -o ux-amd64/pkg/too-buildtags (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title Add transcript persistence and rendering for voice messages Add voice-message transcript persistence and fix newest-N conversation range queries May 11, 2026
Copilot finished work on behalf of chz160 May 11, 2026 03:04
@chz160 chz160 requested a review from Copilot May 11, 2026 03:43
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Comment thread internal/web/api.go
Comment thread internal/db/messages.go Outdated
Comment thread internal/db/messages.go Outdated
Comment thread internal/db/messages.go Outdated
@chz160
Copy link
Copy Markdown
Owner

chz160 commented May 11, 2026

@copilot apply changes based on the comments in this thread

Copilot AI and others added 2 commits May 11, 2026 04:10
Copy link
Copy Markdown
Author

Copilot AI commented May 11, 2026

@copilot apply changes based on the comments in this thread

Applied in 99fc57e and polished in 4a73b81. Transcript writes now distinguish omitted fields from explicit empty strings, preserve the stored model unless a caller explicitly replaces it or clears the transcript, and the newest-N cross-conversation queries now use deterministic message_id tie-breakers with added regression coverage. No UI changes for this follow-up.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • instantmessaging-pa.googleapis.com
    • Triggering command: /tmp/TestBuiltBinaryAcceptsPairCommand684224804/001/openmessage /tmp/TestBuiltBinaryAcceptsPairCommand684224804/001/openmessage pair /home/REDACTED/go/pkg/mod/github.com/yosida95/uritemplate/v3@v3.0.2/compile.go l/linux_amd64/compile 1888�� uf@v1.36.11/inte-p .cfg 0.1-go1.25.0.lin-lang=go1.25 .pb.go 1888327/b115/ (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Comment thread internal/db/messages.go Outdated
@chz160
Copy link
Copy Markdown
Owner

chz160 commented May 11, 2026

@copilot apply changes based on the comments in this thread

Copy link
Copy Markdown
Author

Copilot AI commented May 11, 2026

@copilot apply changes based on the comments in this thread

Applied in 449a9f2. UpsertMessage now stops binding transcript fields entirely, so transcript persistence is clearly routed through SetMessageTranscript, and I added DB coverage to lock in that contract. No UI changes here, so there isn’t a screenshot to share.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • instantmessaging-pa.googleapis.com
    • Triggering command: /tmp/TestBuiltBinaryAcceptsPairCommand1375898697/001/openmessage /tmp/TestBuiltBinaryAcceptsPairCommand1375898697/001/openmessage pair sLJeHVmz52a-3xsqc64n/sLJeHVmz52a-3xsqc64n l/linux_amd64/vet go1.25.0 -c=4 -nolocalimports -importcfg /tmp/go-build3447027998/b424/importcfg -embedcfg /tmp/go-build3447027998/b424/embedcfg -pack -I slices/cast.go slices/chunk.go ux-amd64/pkg/tool/linux_amd64/vet --gdwarf-5 --64 -o ux-amd64/pkg/too-trimpath (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Comment thread internal/db/messages.go
Comment thread internal/tools/set_message_transcript.go
Comment thread internal/web/api.go
@chz160
Copy link
Copy Markdown
Owner

chz160 commented May 11, 2026

@copilot apply changes based on the comments in this thread

Copilot AI and others added 2 commits May 11, 2026 04:45
Agent-Logs-Url: https://github.com/chz160/openmessage/sessions/33e37296-e1f2-4d84-9338-f6249ac2433a

Co-authored-by: chz160 <3420276+chz160@users.noreply.github.com>
Agent-Logs-Url: https://github.com/chz160/openmessage/sessions/33e37296-e1f2-4d84-9338-f6249ac2433a

Co-authored-by: chz160 <3420276+chz160@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented May 11, 2026

@copilot apply changes based on the comments in this thread

Applied in e0f5836 (follow-up on 75218b2). SetMessageTranscript now short-circuits true no-op rewrites/clears, and the MCP/API transcript length values now use Unicode character counts instead of byte length. No UI changes here, so there isn’t a screenshot to include.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • instantmessaging-pa.googleapis.com
    • Triggering command: /tmp/TestBuiltBinaryAcceptsPairCommand2013218824/001/openmessage /tmp/TestBuiltBinaryAcceptsPairCommand2013218824/001/openmessage pair (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of chz160 May 11, 2026 04:49
@chz160 chz160 requested a review from Copilot May 11, 2026 04:51
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Comment thread internal/tools/set_message_transcript.go
Agent-Logs-Url: https://github.com/chz160/openmessage/sessions/a8d8a620-8381-49bf-a5ab-20366d4353c9

Co-authored-by: chz160 <3420276+chz160@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented May 11, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • instantmessaging-pa.googleapis.com
    • Triggering command: /tmp/TestBuiltBinaryAcceptsPairCommand3881549288/001/openmessage /tmp/TestBuiltBinaryAcceptsPairCommand3881549288/001/openmessage pair (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of chz160 May 11, 2026 05:01
@chz160 chz160 marked this pull request as ready for review May 11, 2026 05:10
@chz160 chz160 merged commit fee5c64 into main May 11, 2026
@chz160 chz160 deleted the copilot/add-voice-message-transcripts branch May 11, 2026 05:10
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.

3 participants