fix: mentions for users with UTC-16 characters#222
Conversation
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
📜 Recent review details⏰ Context from checks skipped due to timeout. (4)
🧰 Additional context used📓 Path-based instructions (2)**/*.go📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/!(ltsm)/**/*.go📄 CodeRabbit inference engine (AGENTS.md)
Files:
🔇 Additional comments (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughLINE mention metadata now uses UTF-16 code-unit offsets consistently. New conversion helpers support outbound metadata generation and inbound mention parsing, with tests covering user mentions, room mentions, emoji, MXID mapping, and formatted HTML links. ChangesLINE mention offset handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@pkg/connector/send_message.go`:
- Around line 966-974: Update the room-mention matching logic surrounding
byteIndexToUTF16Offset to perform case-insensitive searches directly against
body rather than a lowercased copy. Preserve the original body byte indexes for
`@room`, `@all`, and `@everyone` matches so mentionEntry generation is not dropped for
UTF-8 content.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: a3eda935-c2c4-4272-a88a-65d4ff4fea53
📒 Files selected for processing (5)
pkg/connector/handle_message.gopkg/connector/handle_message_test.gopkg/connector/send_message.gopkg/connector/send_message_test.gopkg/connector/text_offsets.go
📜 Review details
⏰ Context from checks skipped due to timeout. (4)
- GitHub Check: build-docker
- GitHub Check: Lint with 1.25
- GitHub Check: build-docker
- GitHub Check: Lint with 1.25
🧰 Additional context used
📓 Path-based instructions (2)
**/*.go
📄 CodeRabbit inference engine (AGENTS.md)
**/*.go: Usego fmtfor code formatting across all Go files
Usegoimportswith-local "github.com/highesttt/matrix-line-messenger"flag to group project-local imports correctly
Usezerologfor logging throughout the codebase
Do not useMsgfin logging; useMsgwith structured fields instead
UseStringerinterface where applicable in Go code
Files:
pkg/connector/text_offsets.gopkg/connector/handle_message_test.gopkg/connector/handle_message.gopkg/connector/send_message_test.gopkg/connector/send_message.go
**/!(ltsm)/**/*.go
📄 CodeRabbit inference engine (AGENTS.md)
**/!(ltsm)/**/*.go: Runstaticcheckon all Go files excludingpkg/ltsmpackage (transpiled WASM code)
Rungo veton all Go files excludingpkg/ltsmpackage (transpiled WASM code)
Files:
pkg/connector/text_offsets.gopkg/connector/handle_message_test.gopkg/connector/handle_message.gopkg/connector/send_message_test.gopkg/connector/send_message.go
🔇 Additional comments (5)
pkg/connector/text_offsets.go (1)
5-58: LGTM!pkg/connector/send_message.go (1)
1009-1017: LGTM!pkg/connector/send_message_test.go (1)
4-79: LGTM!pkg/connector/handle_message.go (1)
483-503: LGTM!pkg/connector/handle_message_test.go (1)
167-202: LGTM!
| start, startOK := byteIndexToUTF16Offset(body, pos) | ||
| end, endOK := byteIndexToUTF16Offset(body, pos+matchLen) | ||
| if startOK && endOK { | ||
| mentionees = append(mentionees, mentionEntry{ | ||
| S: strconv.Itoa(start), | ||
| E: strconv.Itoa(end), | ||
| A: "1", | ||
| }) | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
python3 - <<'PY'
text = "K `@ROOM`"
lower = text.lower()
assert text.encode().index(b"@") == 4
assert lower.encode().index(b"@") == 2
print("Lowercasing changed the UTF-8 byte coordinate of @.")
PYRepository: beeper/line
Length of output: 201
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Locate the relevant function and inspect the surrounding lines.
file="pkg/connector/send_message.go"
sed -n '930,1025p' "$file" | cat -nRepository: beeper/line
Length of output: 3476
Keep room-mention matching in body’s byte space. strings.ToLower(body) can change UTF-8 byte offsets before the @room/@all/@everyone match, so byteIndexToUTF16Offset may reject the position and silently drop the room mention. Match case-insensitively on body directly so the indexes stay aligned.
🤖 Prompt for 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.
In `@pkg/connector/send_message.go` around lines 966 - 974, Update the
room-mention matching logic surrounding byteIndexToUTF16Offset to perform
case-insensitive searches directly against body rather than a lowercased copy.
Preserve the original body byte indexes for `@room`, `@all`, and `@everyone` matches
so mentionEntry generation is not dropped for UTF-8 content.
No description provided.