Skip to content

feat(cli): show the links hidden behind text and buttons in --json - #16

Merged
RealDoc06 merged 2 commits into
mainfrom
feat/json-links
Nov 21, 2026
Merged

RealDoc06 merged 2 commits into
mainfrom
feat/json-links

Conversation

@RealDoc06

@RealDoc06 RealDoc06 commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

An agent using tg lost the real URLs in deal channels: posts hide the Amazon or AliExpress link behind words like "➡ BUY HERE" or behind an inline button, and --json only gave the visible text.

Messages in --json now carry links: [{"text", "url"}] when there are any: the links behind words of the text (text link entities), then the link buttons of the keyboard, login buttons included. Telegram places entities in UTF-16 code units, so the text is sliced in those; an emoji before a link no longer shifts its label, and a range past the text is clamped instead of panicking. The demo has a text link and a link button, and guide.txt documents the field.

Proved with go test ./... (a focused test for UTF-16 slicing and clamping), go vet, gofmt, and the demo output below.

Before

links-before

After

links-after

Council review

Rounds: 2

Delegate Round 1 Round 2
Claude Opus 5.5 8.5/10 9.5/10
GPT 6.2 Sol 9/10 9.5/10
Gemini 4 Neon 9/10 9.5/10
Muse Wonder 1.0 no score no score

Muse Wonder was unavailable (quota exhausted).

Created with Claude Opus 5.5 in Claude Code (T3 Code); council reviews by Claude Opus 5.5, GPT 6.2 Sol and Gemini 4 Neon.

🤖 Generated with Claude Code

Note

Add hidden-text and button links to --json message output

  • Adds a Links field to core.Message, serialized as "links" and omitted when empty; each link carries the display text and URL.
  • Extracts hidden-text links from Telegram MessageEntityTextURL entities, converting UTF-16 offsets to text ranges and clamping out-of-bounds ranges (convert.go).
  • Treats URL-auth inline buttons as URL buttons, and appends button links after text-entity links.
  • Includes tests for emoji offsets, non-URL entities, and clamped ranges, plus demo-backend fixtures.
  • Behavioral Change: JSON output of regular Telegram messages can now contain a links array; existing consumers of core.Message JSON should tolerate the new optional field.

Macroscope summarized cd6aa85.

Summary by CodeRabbit

  • New Features
    • JSON message output now includes a links array for URLs embedded in message text or buttons. Each entry contains the visible link text and its URL.
    • Links are listed in their displayed order, and non-link buttons are excluded.
  • Documentation
    • Updated the CLI guide to describe the link information included in JSON output.

RealDoc06 and others added 2 commits November 21, 2026 05:56
Messages in --json carry links: the URLs behind words of the text
(text link entities, sliced in UTF-16 code units) and the link buttons
of the keyboard. Agents lost both before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

The change adds a Links field to messages. Telegram conversion populates it from text URL entities and inline buttons. The demo fixture and CLI guide show and document the links in JSON output.

Changes: Message Link Output

Layer / File(s) Summary
Link model and Telegram conversion
internal/core/core.go, internal/mtp/convert.go, internal/mtp/mtp_test.go
Message adds a Links field and a Link type. Conversion extracts links from text URL entities and URL buttons. Tests cover entity offsets around emoji and text boundaries.
Demo fixture and output documentation
internal/demo/demo.go, internal/cli/guide.txt
The demo combines configured text links with links derived from buttons. The CLI guide documents the JSON links array and its text and url fields.

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

Change: Feature

Suggested reviewers: macroscopeapp

Merge Risk: Minimal · up to cd6aa

The change adds a links field to JSON message output so hidden URLs behind text and buttons become visible. It is additive and conditional, so existing output is unaffected. No merge-blocking risk was identified.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@macroscopeapp

macroscopeapp Bot commented Nov 21, 2026

Copy link
Copy Markdown

Approvability

Verdict: Approved at cd6aa85

Macroscope's review found this PR approvable — Adds hidden-text and button URLs to JSON message output, with documentation, demo data, and UTF-16 tests. URLs remain data: the change neither opens them automatically nor authorizes website logins.

You can add or adjust custom eligibility rules. Learn more.

@RealDoc06
RealDoc06 merged commit c2ebfb0 into main Nov 21, 2026
3 of 4 checks passed
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.

1 participant