Skip to content

fix: 🐛 inline icon bug#205

Open
clins1994 wants to merge 3 commits into
beeper:mainfrom
clins1994:codex/fix-inline-icon-bug
Open

fix: 🐛 inline icon bug#205
clins1994 wants to merge 3 commits into
beeper:mainfrom
clins1994:codex/fix-inline-icon-bug

Conversation

@clins1994

@clins1994 clins1994 commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Fixes #195.

⚠️ needs verification/testing

Summary

  • Handle LINE inline sticon replacement metadata before standalone sticker fallback.
  • Convert LINE UTF-16 replacement offsets before slicing message text.
  • Replace hidden LINE placeholder glyphs with safe Matrix fallback text.

Tests

  • go test ./pkg/connector/handlers ./pkg/connector

Co-authored-by: Codex <codex@openai.com>
@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: dc917d0e-636f-47c7-9434-42a757c9e9b0

📥 Commits

Reviewing files that changed from the base of the PR and between b3e9574 and ccfca0e.

📒 Files selected for processing (1)
  • pkg/connector/handlers/emoji_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/connector/handlers/emoji_test.go
📜 Recent review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: Lint with 1.25

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Enhanced inline emoji/sticon handling for LINE messages, with more accurate detection of both placeholder-based and metadata-based replacements.
    • Improved rendering of sticons in plain text and formatted (HTML) output.
  • Bug Fixes
    • Corrected replacement positioning for multi-byte characters for more reliable mapping.
    • Improved fallback behavior for incomplete/invalid sticon data, including consistent removal of hidden placeholders.
  • Tests
    • Added a comprehensive test suite covering placeholder detection and sticon replacement generation (including edge cases).

Walkthrough

Inline LINE sticon detection is broadened, sticon replacement offsets now use UTF-16 code units, and message bodies are rebuilt with placeholder cleanup and HTML rendering. New helpers expose sticon-body and placeholder detection, with tests covering the updated conversion path.

Changes

Inline sticon detection and conversion rework

Layer / File(s) Summary
Broaden inline sticon detection trigger
pkg/connector/handle_message.go
convertLineMessage now routes messages through ConvertInlineEmoji when HasSticonBody or ContainsLineSticonPlaceholder detect sticon content, in addition to STICON_OWNERSHIP.
Sticon reference regex and fallback constants
pkg/connector/handlers/emoji.go
Adds imports for sorting and UTF-8 handling, introduces inlineSticonFallbackText and LINE placeholder bounds, updates the sticon reference regex to accept alphanumeric IDs, and changes sticon offset semantics to UTF-16 code-unit positions.
ConvertInlineEmoji resolution ordering
pkg/connector/handlers/emoji.go
Reorders resolution to try bodyText sticon-resource parsing before the direct STKID/STKPKGID path, cleaning hidden placeholder glyphs on fallback.
UTF-16 offset to byte range conversion
pkg/connector/handlers/emoji.go
Adds sticonResourceByteRange and utf16OffsetToByteIndex to convert UTF-16 code-unit offsets into validated byte indices.
Rebuild sticon message body construction
pkg/connector/handlers/emoji.go
Reworks convertSticonParts to build replacements from validated byte ranges and upload sticons, delegating to buildSticonMessageBodies for interleaved plain/HTML output with <img> tags or escaped fallback text.
Placeholder detection and body-check helpers
pkg/connector/handlers/emoji.go
Adds exported ContainsLineSticonPlaceholder, internal placeholder cleanup helpers, and exported HasSticonBody for detecting sticon metadata in a decrypted body.
Unit tests for sticon logic
pkg/connector/handlers/emoji_test.go
Adds tests for sticonResourceByteRange, buildSticonMessageBodies, cleanInlineSticonPlaceholders, ContainsLineSticonPlaceholder, HasSticonBody, sticonRefRegex, and a utf16Units helper.

Estimated code review effort: 3 (Moderate) | ~30 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and clearly points to the inline sticker bug fix.
Description check ✅ Passed The description matches the implemented LINE inline sticker handling and test updates.
Linked Issues check ✅ Passed The changes address #195 by fixing garbled LINE inline stickers and placeholder artifacts.
Out of Scope Changes check ✅ Passed The diff stays focused on LINE inline sticker handling and related tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@clins1994 clins1994 marked this pull request as ready for review July 5, 2026 11:07

@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: 1

🧹 Nitpick comments (1)
pkg/connector/handlers/emoji_test.go (1)

8-88: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider adding failure-path coverage.

All tests exercise only the happy path. sticonResourceByteRange returns false when r.End <= r.Start or when offsets don't resolve (per the upstream contract in emoji.go), and buildSticonMessageBodies silently skips replacements with invalid/overlapping ranges (r.start < pos || r.end <= r.start || ...). These fallback branches protect against malformed LINE payloads (the exact class of bug this PR fixes), so a regression there could reintroduce garbled output without any test failing.

🤖 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/handlers/emoji_test.go` around lines 8 - 88, Add failure-path
coverage for the emoji helpers: extend the tests around sticonResourceByteRange
and buildSticonMessageBodies to verify they return false/skip replacements when
ranges are invalid, reversed, overlapping, or otherwise unresolvable. Use the
existing symbols sticonResourceByteRange, buildSticonMessageBodies, and
SticonResource to target the fallback branches in emoji_test.go so malformed
LINE payloads don’t regress silently.
🤖 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/handlers/emoji.go`:
- Around line 365-367: The placeholder check in isLineSticonPlaceholderRune is
too broad because unicode.Is(unicode.Co, r) matches every private-use rune,
causing unrelated PUA text to be treated as LINE placeholders. Narrow the logic
in isLineSticonPlaceholderRune, and any callers like ConvertInlineEmoji that
depend on it, so it only recognizes the actual LINE placeholder code points or
range instead of the entire Co category.

---

Nitpick comments:
In `@pkg/connector/handlers/emoji_test.go`:
- Around line 8-88: Add failure-path coverage for the emoji helpers: extend the
tests around sticonResourceByteRange and buildSticonMessageBodies to verify they
return false/skip replacements when ranges are invalid, reversed, overlapping,
or otherwise unresolvable. Use the existing symbols sticonResourceByteRange,
buildSticonMessageBodies, and SticonResource to target the fallback branches in
emoji_test.go so malformed LINE payloads don’t regress silently.
🪄 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: 82f433fa-42c2-4028-95ab-dbb5602e2841

📥 Commits

Reviewing files that changed from the base of the PR and between db69682 and ecfedcd.

📒 Files selected for processing (3)
  • pkg/connector/handle_message.go
  • pkg/connector/handlers/emoji.go
  • pkg/connector/handlers/emoji_test.go
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: Lint with 1.25
🧰 Additional context used
📓 Path-based instructions (2)
**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

**/*.go: Use go fmt for code formatting across all Go files
Use goimports with -local "github.com/highesttt/matrix-line-messenger" flag to group project-local imports correctly
Use zerolog for logging throughout the codebase
Do not use Msgf in logging; use Msg with structured fields instead
Use Stringer interface where applicable in Go code

Files:

  • pkg/connector/handle_message.go
  • pkg/connector/handlers/emoji_test.go
  • pkg/connector/handlers/emoji.go
**/!(ltsm)/**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

**/!(ltsm)/**/*.go: Run staticcheck on all Go files excluding pkg/ltsm package (transpiled WASM code)
Run go vet on all Go files excluding pkg/ltsm package (transpiled WASM code)

Files:

  • pkg/connector/handle_message.go
  • pkg/connector/handlers/emoji_test.go
  • pkg/connector/handlers/emoji.go
🔇 Additional comments (11)
pkg/connector/handlers/emoji_test.go (5)

8-22: LGTM!


24-55: LGTM! Directly exercising buildSticonMessageBodies with byte offsets (bypassing the UTF-16 converter, already covered separately) is a clean way to isolate the body-construction logic, and the out-of-order replacement input correctly exercises the internal sort.


64-69: LGTM! Using a raw (backtick) string here keeps the \u escapes as literal JSON text rather than compiling to actual surrogate-half runes, which correctly simulates the raw payload HasSticonBody would receive.


71-76: LGTM!


1-6: LGTM!

Also applies to: 78-88

pkg/connector/handle_message.go (1)

378-390: LGTM!

pkg/connector/handlers/emoji.go (5)

73-80: LGTM!


103-176: LGTM!


187-275: LGTM!


277-313: LGTM!


387-395: LGTM!

Comment thread pkg/connector/handlers/emoji.go
Co-authored-by: Codex <codex@openai.com>

@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.

🧹 Nitpick comments (1)
pkg/connector/handlers/emoji_test.go (1)

43-44: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider extracting the LINE placeholder literals to a shared test constant.

\U00100084/\U00100085 are hardcoded repeatedly across multiple test functions. A single shared var/const (e.g., linePlaceholder1, linePlaceholder2) would reduce duplication and keep intent clearer if the placeholder set ever grows.

♻️ Example refactor
+const (
+	testLineSticonPlaceholder1 = "\U00100084"
+	testLineSticonPlaceholder2 = "\U00100085"
+)

Also applies to: 76-76, 110-110, 117-124

🤖 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/handlers/emoji_test.go` around lines 43 - 44, The test code
repeats the LINE placeholder literals in multiple places, so extract them into
shared test constants in emoji_test.go and update the affected test functions to
use those named placeholders instead of hardcoded values. Use clear symbols such
as linePlaceholder1 and linePlaceholder2 near the existing first/second
declarations so the intent stays obvious and any future placeholder expansion
only needs one update.
🤖 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.

Nitpick comments:
In `@pkg/connector/handlers/emoji_test.go`:
- Around line 43-44: The test code repeats the LINE placeholder literals in
multiple places, so extract them into shared test constants in emoji_test.go and
update the affected test functions to use those named placeholders instead of
hardcoded values. Use clear symbols such as linePlaceholder1 and
linePlaceholder2 near the existing first/second declarations so the intent stays
obvious and any future placeholder expansion only needs one update.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f89a0160-a0fb-4625-990c-5a25c0854486

📥 Commits

Reviewing files that changed from the base of the PR and between ecfedcd and b3e9574.

📒 Files selected for processing (2)
  • pkg/connector/handlers/emoji.go
  • pkg/connector/handlers/emoji_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/connector/handlers/emoji.go
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: Lint with 1.25
🧰 Additional context used
📓 Path-based instructions (2)
**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

**/*.go: Use go fmt for code formatting across all Go files
Use goimports with -local "github.com/highesttt/matrix-line-messenger" flag to group project-local imports correctly
Use zerolog for logging throughout the codebase
Do not use Msgf in logging; use Msg with structured fields instead
Use Stringer interface where applicable in Go code

Files:

  • pkg/connector/handlers/emoji_test.go
**/!(ltsm)/**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

**/!(ltsm)/**/*.go: Run staticcheck on all Go files excluding pkg/ltsm package (transpiled WASM code)
Run go vet on all Go files excluding pkg/ltsm package (transpiled WASM code)

Files:

  • pkg/connector/handlers/emoji_test.go
🔇 Additional comments (3)
pkg/connector/handlers/emoji_test.go (3)

8-22: LGTM!


24-107: LGTM!

Verified against sticonResourceByteRange and buildSticonMessageBodies implementations — the empty/reversed/negative/unresolvable and overlap/empty/reversed/out-of-range skip cases are all correctly exercised.


109-126: LGTM!

Co-authored-by: Codex <codex@openai.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

bug: 🐛 inline stickers

1 participant