Skip to content

fix(tui): rewrite #N ticket refs as markdown links, restore full markdown rendering#24

Merged
terrxo merged 1 commit into
devfrom
fix/ticket-ref-markdown-links
May 31, 2026
Merged

fix(tui): rewrite #N ticket refs as markdown links, restore full markdown rendering#24
terrxo merged 1 commit into
devfrom
fix/ticket-ref-markdown-links

Conversation

@terrxo
Copy link
Copy Markdown

@terrxo terrxo commented May 31, 2026

Summary

Replaces the split+inline- approach with a simpler strategy: rewrite #N[#N](https://hivemind.grunt.si/tasks/N) in assistant text and feed through the markdown renderer.

Changes

  • index.tsx (TextPart): Instead of splitting text on #N refs and falling back to plain <span> text (losing all markdown formatting) when any ref is present, rewrite each #N as a markdown link and pass the entire string through <markdown>. Retired the splitOnTicketRefs function and TicketRef import.
  • ticket-ref.tsx: Changed HIVEMIND_UI_BASE default from http://localhost:5173https://hivemind.grunt.si

Bugs fixed

# Bug Fix
1 Ticket ref URLs point at localhost:5173 Default URL is now https://hivemind.grunt.si (env override preserved)
3 Full markdown formatting lost for paragraphs containing #N refs No more split/fallback — the whole string goes through <markdown>

Bug 2 (hover preview) is tracked separately — restoring it requires a renderNode-hook spike.

Verification

bun run typecheck passes (19/19 tasks).

Replaces the splitOnTicketRefs + inline <TicketRef> approach with a
simpler strategy: rewrite #N → [#N](https://hivemind.grunt.si/tasks/N)
in assistant text and feed through the markdown renderer.

Fixes:
- Bug 1: HIVEMIND_UI_BASE default changed to https://hivemind.grunt.si
- Bug 3: full markdown formatting restored for paragraphs containing #N refs
  (bold, italic, code, lists no longer lost to plain <span> fallback)
- The markdown renderer linkifies [text](url) into OSC-8 hyperlinks,
  so refs remain clickable

Bug 2 (hover preview) tracked separately — will restore via renderNode hook.
@github-actions
Copy link
Copy Markdown

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions
Copy link
Copy Markdown

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@terrxo terrxo merged commit dd6a749 into dev May 31, 2026
3 of 10 checks passed
terrxo added a commit that referenced this pull request Jun 1, 2026
…mouse overlay (anomalyco#331)

PR #24 fixed #N rendering by rewriting refs to markdown links fed through
<markdown>, but that killed the hover-card preview: OpenTUI inline link
chunks are TextNodes that can't hold mouse listeners (only block-level
Box/Text are on the mouse hit-grid).

Restore hover (Model A) without touching PR #24's rendering: wrap the
existing TextPart <box> with onMouseMove/onMouseOut, translate absolute
mouse coords -> local row/col via the box's screenX/Y + width, then map to
the nearest ticket ref using a source-text scan. Drives the existing
(intact-but-untriggered) TicketHoverCard context. No change to wrap layout,
so the anomalyco#250 fix is preserved.

New: ticket-ref-scan.ts (scanTicketRefs + resolveRefAt + nearestRefId).
terrxo added a commit that referenced this pull request Jun 1, 2026
…overlay (anomalyco#331)

Nik reported two bugs on the prior approach: (1) the markdown rewrite
[#N](url) leaked the literal URL into the visible text, (2) hover was 'all
over the place'.

Root cause confirmed by build-test (test harness, no tree-sitter — same as
the real app's <markdown>): a [#N](url) link renders its URL literally; NO
markup form (link/bold/code) conceals it. Only PLAIN #N is leak-free. The
hover drift came from estimating wrap geometry against the rewritten content,
whose [#N](url) strings were far longer than the visible text.

Fix (Option 1 — keep PR #24's wrap-correct <markdown> flow, drop the rewrite):
- Render source text directly as plain #N. No URL leak, wrap unchanged.
- Line-based hover resolver: cursor row -> source line -> ref on that line
  (single = exact; multi = nearest by column). Now accurate because the
  scanned/estimated text IS the visible text.
- Click-to-open via overlay onMouseUp (replaces the lost OSC-8 click).
- HIVEMIND_UI_BASE default -> https://hivemind.grunt.si.

Tests: 13 resolver unit tests + full TUI suite (146 pass) green; typecheck clean.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant