Skip to content

Add turbo_visit action#335

Open
myabc wants to merge 2 commits into
marcoroth:mainfrom
myabc:feature/turbo_visit
Open

Add turbo_visit action#335
myabc wants to merge 2 commits into
marcoroth:mainfrom
myabc:feature/turbo_visit

Conversation

@myabc

@myabc myabc commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Implements the turbo_visit action, which navigates via Turbo.visit(location, { action, frame }).

<turbo-stream action="turbo_visit" location="/somewhere" turbo-action="replace"></turbo-stream>
<turbo-stream action="turbo_visit" location="/somewhere" turbo-frame="modals"></turbo-stream>
  • Added turbo_visit to src/actions/turbo.ts and registered it.
  • location attribute (default /), turbo-action attribute (default advance), turbo-frame attribute (mapped to Turbo.visit's frame option, mirroring redirect_to).
  • Added test/turbo/turbo_visit.test.jslocation fallbacks (including the bare attribute), turbo-action values, and turbo-frame.
  • Documented under Turbo Actions in the README: turbo_visit(location, turbo_action = "advance", turbo_frame = nil, **attributes).

Closes #18

🤖 Generated with Claude Code

Wraps `Turbo.visit(location, { action })` with `location` and
`turbo-action` attributes (defaults: "/" and "advance").

Closes marcoroth#18.
Copilot AI review requested due to automatic review settings June 27, 2026 12:53

Copilot AI 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.

Pull request overview

Adds a new Turbo Stream action, turbo_visit, to allow stream-driven client-side navigation via Turbo.visit(location, { action }), complementing the existing Turbo-related stream actions.

Changes:

  • Implemented and registered the turbo_visit stream action in the Turbo actions module.
  • Added test coverage validating location defaulting and turbo-action option handling.
  • Documented the new action in the README’s Turbo Actions list.

Reviewed changes

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

File Description
src/actions/turbo.ts Adds turbo_visit action and registers it alongside other Turbo actions.
test/turbo/turbo_visit.test.js Introduces tests for turbo_visit covering location fallback and action option handling.
README.md Documents the new turbo_visit action in the Turbo Actions section.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/actions/turbo.ts
Comment on lines +26 to +34
export function turbo_visit(this: StreamElement) {
const location = this.getAttribute("location") || "/"
const turboAction = (this.getAttribute("turbo-action") || "advance") as Action
const options: Partial<VisitOptions> = {
action: turboAction,
}

window.Turbo.visit(location, options)
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure about this. A handful of options:

  1. follow Copilot's suggestion - for parity with redirect_to
  2. no guard - symmetry with turbo_clear_cache
  3. a simpler guard:
if (window.Turbo) {
  window.Turbo.visit(location, options)
}

I'd personally opt for 2..

Comment thread test/turbo/turbo_visit.test.js
Map the `turbo-frame` attribute to `Turbo.visit`'s `frame` option,
mirroring `redirect_to`. Also cover the bare `location` attribute
fallback for parity.

Copilot AI 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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread src/actions/turbo.ts
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.

Implement turbo_visit action

2 participants