Skip to content

feat(shell): add visible underline to clickable links in terminal output#631

Merged
tnaum-ms merged 5 commits into
nextfrom
dev/tnaum/updated-shell-link-formatting
May 12, 2026
Merged

feat(shell): add visible underline to clickable links in terminal output#631
tnaum-ms merged 5 commits into
nextfrom
dev/tnaum/updated-shell-link-formatting

Conversation

@tnaum-ms
Copy link
Copy Markdown
Collaborator

Summary

Clickable action links in the Interactive Shell terminal output (Collection View, Query Playground, Settings) are now visually underlined, making them discoverable without requiring a hover.

Problem

The shell emits clickable sentinels after query results and on error hints. These links are registered with VS Code's TerminalLinkProvider API, which only highlights them on hover or Ctrl+click. There is no API flag to make extension-provided terminal links visually distinct at rest. Users had no visual cue that the text was clickable.

Solution

Emit ANSI underline escape codes (\x1b[4m / \x1b[24m) around each link sentinel at the point of output. This is a purely visual change; the existing ShellTerminalLinkProvider regex patterns already tolerate ANSI escape sequences at link boundaries, so no link detection logic needed to change.

Key decisions:

  • \x1b[24m (underline-off) instead of \x1b[0m (full reset): Preserves surrounding styles (e.g., gray from formatSystemMessage) instead of clobbering them.
  • Underline is not gated by colorSupport setting: Underline communicates clickability, not decoration. Users who disable colors still benefit from knowing what is clickable.
  • Entire sentinel is underlined: The visible underline region matches the clickable hit area reported by startIndex/length in the link provider, so visual and interactive boundaries align.
  • No markup-tag abstraction: The extension has a small ANSI constants table and only three link types. A markup parser layer would add complexity without proportional benefit.

Changes

  • ShellOutputFormatter.ts: Added underline/noUnderline to the ANSI constants table. Added formatLinkSentinel(text) helper.
  • DocumentDBShellPty.ts: Wrapped each link sentinel with formatLinkSentinel() at all three emission sites (maybeWriteActionLine, initializeSession settings hint, handleEvalError settings hint).
  • ShellTerminalLinkProvider.test.ts: Added 4 test cases verifying link detection works with underline-wrapped sentinels (standalone, combined with gray, and multi-link lines).

Testing

  • All 1937 tests pass (including 4 new ones).
  • Lint, prettier, and build all clean.

tnaum-ms added 3 commits May 12, 2026 09:46
Add underline/noUnderline ANSI escape codes to the ANSI constants table
and a formatLinkSentinel() helper that wraps text in underline codes.

Uses \x1b[24m (no-underline) instead of \x1b[0m (full reset) so that
surrounding styles like gray from formatSystemMessage are preserved.

The underline is applied regardless of the colorSupport setting because
it communicates clickability, not decoration.
Wrap each clickable action sentinel with ANSI underline codes so that
links are visually discoverable without hovering.

Updated emission sites:
- maybeWriteActionLine: each of the two link segments (Collection View,
  Query Playground) is underlined separately; the gap between them stays
  un-underlined.
- initializeSession settings-hint: only the clickable portion is underlined.
- handleEvalError settings-hint: same treatment.
Verify that ShellTerminalLinkProvider regex patterns correctly match
action sentinels wrapped in ANSI underline codes, both standalone and
combined with the existing gray color wrapping.

New test cases:
- Underline-only wrapped collection view action line
- Gray + underline wrapped collection view action line
- Underline-wrapped settings action line
- Both collection view and playground links with individual underline
  wrapping on the same line
Copilot AI review requested due to automatic review settings May 12, 2026 09:47
@tnaum-ms tnaum-ms requested a review from a team as a code owner May 12, 2026 09:47
Copy link
Copy Markdown
Contributor

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

Note

Copilot was unable to run its full agentic suite in this review.

Adds persistent visual discoverability for extension-provided terminal links in the Interactive Shell by underlining link sentinels using ANSI SGR codes, while preserving surrounding styling.

Changes:

  • Added ANSI underline constants and a formatLinkSentinel() helper to wrap clickable sentinel text.
  • Updated shell PTY output sites to underline Collection View / Playground / Settings sentinels.
  • Expanded terminal link provider tests to cover underline-wrapped (and gray+underline) lines, including multi-link lines.

Reviewed changes

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

File Description
src/documentdb/shell/ShellTerminalLinkProvider.test.ts Adds link-detection tests for underline-wrapped link sentinels, including multiple links in one line.
src/documentdb/shell/ShellOutputFormatter.ts Introduces underline/no-underline ANSI codes and a helper to wrap link sentinel output.
src/documentdb/shell/DocumentDBShellPty.ts Applies underline wrapping when emitting clickable terminal sentinel text.
docs/ai-and-plans/PRs/631-visible-underline-shell-links.md Documents rationale, scope, and technical approach for underlined terminal links.

Comment thread src/documentdb/shell/ShellTerminalLinkProvider.test.ts
Comment thread src/documentdb/shell/DocumentDBShellPty.ts Outdated
…tings hint helper

- Add startIndex/length assertions to all 4 underline-wrapped link tests
  to verify visual and interactive boundaries stay aligned (LOW-1)
- Extract private writeSettingsHintLine() to deduplicate the settings hint
  formatting pattern in DocumentDBShellPty (INFO-1)
@tnaum-ms tnaum-ms force-pushed the dev/tnaum/updated-shell-link-formatting branch from af29ae5 to 715f9b2 Compare May 12, 2026 11:24
@tnaum-ms
Copy link
Copy Markdown
Collaborator Author

Review fixes applied — 715f9b24

Both Copilot review comments addressed:

LOW-1: Added startIndex/length assertions to underline link tests

All 4 new underline-wrapped tests now assert the clickable region boundaries. The multi-link test uses computed parts (collectionPart.length, + 2 separator) rather than magic numbers, keeping assertions self-documenting.

INFO-1: Extracted writeSettingsHintLine() private method

Consolidated the duplicated settings hint formatting pattern from initializeSession and handleEvalError into a single private helper.

Additional self-review

Performed a full review of all changed files — no additional issues found at confidence > 80%. Verified:

  • ANSI escape pairing (\x1b[4m / \x1b[24m) is correct
  • Regex patterns tolerate underline codes via existing (?:\x1b[\d+m)*
  • colorSupport bypass is intentional and correct
  • No security concerns

Checklist

  • ✅ Prettier
  • ✅ ESLint
  • ✅ 1937/1937 tests pass
  • ✅ Build clean

@github-actions
Copy link
Copy Markdown
Contributor

✅ Code Quality Checks

Check Status How to fix
Localization (l10n) ✅ Passed
ESLint ✅ Passed
Prettier formatting ✅ Passed

This comment is updated automatically on each push.

@github-actions
Copy link
Copy Markdown
Contributor

📦 Build Size Report

Metric Base (next) PR Delta
VSIX (vscode-documentdb-0.8.0-beta.vsix) 6.79 MB 6.79 MB ⬆️ +0 KB (+0.0%)
Webview bundle (views.js) 5.79 MB 5.79 MB ✅ 0 KB (0.0%)

Download artifact · updated automatically on each push.

@tnaum-ms tnaum-ms merged commit c09f3b8 into next May 12, 2026
8 checks passed
@tnaum-ms tnaum-ms deleted the dev/tnaum/updated-shell-link-formatting branch May 12, 2026 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants