Skip to content

Link selected text in comments with Cmd+K or by pasting a URL - #298

Merged
HamptonMakes merged 10 commits into
block:mainfrom
arielahdoot:comment-composer-links
Nov 9, 2026
Merged

HamptonMakes merged 10 commits into
block:mainfrom
arielahdoot:comment-composer-links

Conversation

@arielahdoot

@arielahdoot arielahdoot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Tried this out in the new-comment, reply, and edit composers, in light and dark themes, with a second person watching the same document.

  • Select text and press ⌘K (Ctrl+K elsewhere). A floating picker keeps the draft visible; search plans and people or paste a URI, including codex://. Selecting a result or inserting the URI adds [text](uri) without posting. Undo and redo work.
  • With nothing selected, ⌘K inserts [](url) with the cursor in the label.
  • Pasting a URI over selected text links it. Application schemes are supported; executable browser schemes remain blocked. Pasting ordinary text works as before.
  • The posted comment shows a normal link for the author, and for the other viewer live.
  • Both shortcuts are listed under "Writing comments" in the shortcut help.
Selected After ⌘K

URL pasted over "details" Other viewer, live (dark) Shortcut help

@arielahdoot
arielahdoot marked this pull request as ready for review November 3, 2026 02:32
@HamptonMakes
HamptonMakes requested a balanced review from Copilot November 3, 2026 17:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The link command and paste handler do not escape Markdown delimiters in labels and URLs, which can break links or truncate valid destinations.

1 open issue
What changed in this PR

Adds Markdown link creation to CoPlan’s shared comment composer using Cmd/Ctrl+K or by pasting a URL over selected text.

Changes:

  • Adds link insertion with browser undo support and an empty-label option.
  • Wires keyboard and paste actions into the shared composer and documents them in shortcut help.
  • Adds system coverage for insertion, undo/redo, cancellation, paste handling, and posted links.
File Description
spec/​system/​comment_composer_links_spec.rb Tests link creation and related composer behavior.
engine/​config/​keyboard_shortcuts.json Lists link shortcuts under writing comments.
engine/​app/​views/​coplan/​comment_threads/​_composer_fields.html.erb Binds keyboard and paste events to link handlers.
engine/​app/​javascript/​controllers/​coplan/​comment_form_controller.js Implements URL prompting, paste-to-link, and undo-aware insertion.

Review effort: Balanced

Copy link
Copy Markdown
Collaborator

🤖 @codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-06T15:36:27.379194Z e9929c7 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0ea4cec012

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@HamptonMakes

HamptonMakes commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

🤖 Cleanup pushed in 03966ec: Cmd/Ctrl+K and paste-to-link now share Markdown escaping for label brackets/backslashes and destination parentheses/backslashes. The two bot findings described the same defect; both are answered and resolved.

Validation: six new rendered-link browser regressions failed before the fix and pass after it. The complete composer-link and Markdown-helper selection passes (55 examples); targeted RuboCop and diff checks pass. Verified posted comments/replies in the shared demo in light and dark themes. All 15 current-head checks are green, including MySQL/PostgreSQL suites, all browser groups, all stress runs, lint, security scans, and DCO. The final local code review found no additional escaping defects. GitHub reports conflict-free/MERGEABLE and REVIEW_REQUIRED: the remaining merge gate is one approving review with code-owner coverage. No merge has been performed.

Agent recommendation: accept the small, dependency-free link shortcut feature after final verification and product review. It supports CoPlan's central comment workflow and keeps undo intact. UX limitation for Hampton to consider: Cmd+K uses a blocking browser prompt; Chrome system tests pass, but Codex's embedded browser rejects prompt(), while paste-to-link works there. An in-app URL field would improve compatibility and consistency; this focused escaping patch does not redesign that interaction.

Light theme:
Literal labels remain intact in posted links

Dark theme:
Same discussion in dark theme

@HamptonMakes

Copy link
Copy Markdown
Collaborator

🤖 Implemented @HamptonMakes's requested pre-shipping fix: Cmd+K must work inside the in-app browser, not silently fail on an unsupported browser prompt.

The composer now shows a server-rendered Link URL field in place. Opening it preserves the draft selection and window geometry; Enter or Insert link inserts without posting, and Escape or Cancel link restores the unchanged draft and focus. The same shared control works in new comments, replies, and edits. Undo/redo and Markdown escaping remain intact. Invalid URLs receive inline feedback. Pending mention searches are cancelled when opening the URL field.

Added a named “Comments: link selected text” scenario to the shared demo library, with reseeding coverage, and updated the served comment instructions. Verified the exact hi → Cmd+K → paste URL → Enter flow in Codex's embedded browser in light and dark themes, including undo and posting the complete link. No browser errors were reported.

Validation: the final composer-link/source-comment run passes all 38 examples; the broader composer and agent-instructions checks also passed, as did seed/reseed checks, targeted RuboCop, and diff checks. Current-head CI and a fresh Codex review are being checked before the final readiness report. No merge performed.

In-app URL field in light theme

In-app URL field in dark theme

🤖 @codex review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b37f9883fa

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@HamptonMakes

Copy link
Copy Markdown
Collaborator

🤖 Completed the pre-shipping fixes requested by @HamptonMakes. Cmd+K/Ctrl+K now opens an in-composer URL field that works in the embedded browser. Enter inserts without posting; Escape/Cancel restores the draft; closing and reopening the composer clears link-entry mode without losing the draft. Invalid URLs and drafts changed by dictation show actionable feedback.

Head: 64f1baf8. Integrated main in 5fdaef18; addressed both fresh Codex findings in f5bad057; repaired two upstream browser-test fixtures for immutable plan versions in f097b564 and 60cfaf5a; added the close/reopen regression fix in 64f1baf8.

Validation: 123 relevant specs passed after integrating main; final link/source-comment regression run passed all 42 examples; checkbox/link coverage passed 27 examples; navigation coverage passed 3 examples. Focused demo seed/reseed checks, lint, and whitespace checks pass. Verified the interaction in the embedded browser in light and dark themes. All four review threads are resolved.

Preview: http://localhost:3298/hampton/demo-content/rich-text/comments-link-selected-text — refresh once, add a comment, select hi, press Cmd+K, enter a plain URL, and press Enter. The preview remains running.

In-composer URL field in light theme

In-composer URL field in dark theme

Final gate: all 15 CI checks pass on 64f1baf8bc9e61a513c52f799263bd1cea4b2bc7. GitHub reports MERGEABLE (no conflicts). Required reviewer approval remains outstanding; this PR has not been approved or merged.

@HamptonMakes

Copy link
Copy Markdown
Collaborator

🤖 @codex review

@HamptonMakes requested that Cmd+K keep the comment visible, offer search for content on the site, and accept application URIs such as codex://. Implemented in 19ef42b8; integrated current main in e9929c77 and adopted its shared immutable-version test fixtures.

The link picker now floats beside/above the visible draft, searches authorized plans and people, supports keyboard result selection, and inserts without navigating or posting. Paste-over-selection still works, including application URIs. The shared Markdown sanitizer preserves application links on anchors while retaining HTML/image sanitization and excluding executable URL schemes. The named demo and served composer guide describe the new behavior.

Local validation: 107 composer/source-comment/rendering/search checks passed; seed/reseed and agent-guide checks passed; the final keyboard-search and sanitizer regression checks passed. Light/dark embedded-browser tryouts verified visible drafts and working search/URI insertion. CI and fresh automated review are pending on this head; merge conflicts are resolved. No approval or merge performed.

Link picker keeps the comment visible in light mode

Link picker keeps the comment visible in dark mode

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e9929c771a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

arielahdoot and others added 9 commits November 6, 2026 21:02
Mod+K in a comment, reply or edit textarea prompts for a URL with the
document editor's prompt and validation, then writes [selection](url),
or [](url) with the caret between the brackets when nothing is selected.
Pasting a single http(s) or mailto URL over a selection links it.
Edits go through insertText so Cmd+Z undoes them and input listeners
(mentions, dictation) stay in sync. Both appear in the shortcut help.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Ctrl+Z and Ctrl+Y don't undo or redo in Chrome on macOS, so the spec
would fail on Mac development machines. Use Cmd there, like the other
editor specs, and Mod+Shift+Z for redo on both platforms.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Hampton Lintorn-Catlin <hampton@squareup.com>
Signed-off-by: Hampton Lintorn-Catlin <hampton@squareup.com>
Signed-off-by: Hampton Lintorn-Catlin <hampton@squareup.com>
Signed-off-by: Hampton Lintorn-Catlin <hampton@squareup.com>
Signed-off-by: Hampton Lintorn-Catlin <hampton@squareup.com>
Signed-off-by: Hampton Lintorn-Catlin <hampton@squareup.com>
Signed-off-by: Hampton Lintorn-Catlin <hampton@squareup.com>
@HamptonMakes
HamptonMakes force-pushed the comment-composer-links branch from e9929c7 to 1e52528 Compare November 7, 2026 03:05
@HamptonMakes

HamptonMakes commented Nov 7, 2026 •

Copy link
Copy Markdown
Collaborator

🤖 Rebased at @HamptonMakes' request onto current main (2f0e7ded), preserving its title and Coplan spelling changes. New head: 1e52528f. The branch is conflict-free.

Fixed Codex finding 4494248246 in df914412: comment fragment caches now include the Markdown renderer version, so existing application URI links refresh without editing the comment. The cache regression fails before the fix and passes afterward. Also kept validation messages from overlapping the visible draft. The latest Codex review covered the picker/search/URI scope; these bounded corrections address its finding and do not need a duplicate review request. All five review threads are resolved.

After rebase: 143 relevant examples pass, including the full theme spec, comment/source-comment flows, search authorization, URI sanitization, and cache invalidation. Lint and whitespace checks pass. The earlier CI failure was Net::ReadTimeout at visit sign_in_path in app_theme_spec.rb:34, before any theme assertion; a sibling browser job was cancelled by fail-fast. This is a suspected navigation/startup flake, not a verified link regression. Fresh CI is now queued on the new head; I am monitoring it through completion.

The preview is running at http://localhost:3298/hampton/demo-content/rich-text/comments-link-selected-text and has been checked after rebase. Existing light/dark picker evidence is in the preceding cleanup comment. No approval or merge performed.

Rebased picker with draft visible and application URI

Final result: all 15 CI checks passed on 1e52528f04b09d92143e59fa1a5a5c165f8f02b2, including the previously failing browser group and its previously cancelled sibling. An additional 59 demo seed/reseed and served agent-guide examples passed locally. GitHub reports MERGEABLE with no conflicts against 2f0e7ded; required reviewer approval remains outstanding. The working tree is clean and the preview remains available.

Signed-off-by: Hampton Lintorn-Catlin <hampton@squareup.com>
@HamptonMakes

Copy link
Copy Markdown
Collaborator

🤖 Merged current main (af594b7b, including #318) into this branch and pushed 153704a3. The Markdown conflict preserves both application URI links and math rendering; renderer cache version 29 also invalidates cached comment HTML.

Validation: 96 focused helper, sanitizer, request, and comment-link browser examples passed; lint and diff checks passed. All 15 GitHub checks are green on 153704a3. Reviewed the merge resolution with no new findings; all five existing review threads remain resolved. GitHub reports MERGEABLE, with reviewer approval still required. No merge performed.

Rechecked the running preview in Chrome: the floating ⌘K picker keeps the draft visible, and selecting hi then inserting codex://threads/example produces [hi](codex://threads/example) without posting. Preview remains available at http://localhost:3298/hampton/demo-content/rich-text/comments-link-selected-text . Prior light/dark evidence remains in the earlier review comments.

@HamptonMakes
HamptonMakes merged commit b40c2c3 into block:main Nov 9, 2026
15 checks passed
@HamptonMakes HamptonMakes mentioned this pull request Nov 9, 2026
5 tasks done
@HamptonMakes

Copy link
Copy Markdown
Collaborator

🤖 Post-merge verification and release-note evidence

Merged as b40c2c3 on November 9 at 18:04 UTC. Post-merge CI completed successfully: all 12 jobs passed, covering lint, MySQL/PostgreSQL suites, browser shards, and browser stress runs.

Release note: Link selected text in comments with ⌘K (Ctrl+K) using a floating picker that keeps your draft visible. Search Coplan plans and people or paste a URI, including application links such as codex://. Pasting a URI over selected text also creates a link. Works in new comments, replies, and comment edits; executable browser schemes remain blocked.

Evidence: feature review and light/dark checks, integration checks and preview verification. Contributor: @arielahdoot. This confirms the code is merged; it does not claim a gem release or deployment.

No remaining human action or follow-up in this chat. The existing local preview is preserved at http://localhost:3298/hampton/demo-content/rich-text/comments-link-selected-text .

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.

3 participants