targetactivation

package
v1.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package targetactivation is the state-free half of Sidecar's one jump service: it answers "what should happen when someone activates this target" without touching a model, a plugin, or the filesystem. The app shell owns execution (focusing plugins, switching projects); this package owns the decision, so a headless caller — a CLI action, a test, a future API — can adopt the same answer unchanged.

Safety rules for every consumer

The scanner (internal/terminallink) deliberately does not sanitize; the surfaces do. Both halves of that discipline live here so a new consumer cannot miss them:

  1. URL activation refuses anything terminallink.SafeHTTPURL rejects. Resolve enforces it; no caller should open a URL it did not get back in a Plan.
  2. Any surface that renders untrusted text through terminallink.Decorate must call terminallink.StripOSC8 on the line first. Otherwise a hostile OSC 8 hyperlink already embedded in the text survives decoration and the rendered link no longer means what the scanned span says it means. Activation cannot defend against this — it never sees the raw line — so the rule belongs at every render site that feeds this service.

A file target's Path is the token as the text wrote it — it may be absolute, because a terminal surface resolves it against its own root. The project-relative constraint belongs to the one execution that needs it, the canonical app.NavigateToFileMsg, and lives in RelativeProjectPath.

Index

Constants

View Source
const FileBrowserPluginID = "file-browser"

FileBrowserPluginID is the plugin that owns file targets.

View Source
const TasksPluginID = "tasks"

TasksPluginID owns task targets.

View Source
const WorkspacePluginID = "workspace-manager"

WorkspacePluginID owns the content panes — issue, diff, resource — and the tmux sessions a session target attaches to.

Variables

View Source
var ErrUnsupportedKind = errors.New("target kind is not activatable yet")

ErrUnsupportedKind reports a target kind this service does not route yet. Callers migrating a surface one kind at a time can keep their existing branch for these rather than treating them as malformed.

Functions

func RelativeProjectPath

func RelativeProjectPath(value string) (string, error)

RelativeProjectPath cleans a file plan's Path for the canonical file message (app.NavigateToFileMsg), which is defined relative to the project's workdir. An absolute path, a "~" path, or one that climbs out with ".." is refused rather than resolved. Hosts that resolve against their own root — the terminal surfaces — do not call this.

Types

type Plan

type Plan struct {
	Kind     PlanKind
	PluginID string
	Path     string
	Line     int
	URL      string
	Issue    string
	Spec     string
	Provider string
	Matcher  string
	Locator  string
	Session  string
	Task     string
	Note     string
}

Plan is what the shell executes. It is data, not commands: the shell turns it into tea.Cmds, and a headless caller can act on the same fields.

func PlanForSpan

func PlanForSpan(span terminallink.Span) (Plan, error)

PlanForSpan is the whole span→activation path in one call: the shared span→uirequest.Target mapping followed by Resolve. Surfaces use it so a scanned link means the same thing wherever it was scanned.

func Resolve

func Resolve(target uirequest.Target) (Plan, error)

Resolve decides how a target is activated. It touches nothing: no model, no filesystem, no network. Errors are user-facing refusals ("why nothing happened"), never diagnostics.

type PlanKind

type PlanKind string

PlanKind names the executable shape of a resolved activation.

const (
	// PlanOpenFile focuses PluginID and asks it to reveal Path (Line optional).
	PlanOpenFile PlanKind = "open-file"
	// PlanOpenURL opens an already-validated http(s) URL in the browser.
	PlanOpenURL PlanKind = "open-url"
	// PlanOpenIssue opens Issue in an issue pane.
	PlanOpenIssue PlanKind = "open-issue"
	// PlanOpenDiff opens the git spec in Spec in a diff pane. The spec is
	// re-resolved by the host against its own checkout: this package does not
	// run git.
	PlanOpenDiff PlanKind = "open-diff"
	// PlanOpenResource opens an external provider's locator in a resource
	// pane. Matcher may be empty — a host with a live matcher snapshot decides
	// which matcher claims the locator.
	PlanOpenResource PlanKind = "open-resource"
	// PlanAttachSession attaches the tmux session named Session.
	PlanAttachSession PlanKind = "attach-session"
	// PlanOpenTask focuses the Tasks tab on Task. Landing on the specific
	// task inside the embedded model is best effort — the host does what its
	// embedded UI allows — but focusing the tab always happens, so the jump is
	// never a no-op.
	PlanOpenTask PlanKind = "open-task"
	// PlanOpenNote opens Note in a read-only note pane.
	PlanOpenNote PlanKind = "open-note"
)

func PlanKindsFromSpans

func PlanKindsFromSpans() []PlanKind

PlanKindsFromSpans lists every plan kind a scanned terminal-link span can produce. It is the parity contract between the surfaces: each of them must dispatch all of these, and TestSpanKindsCoverPlanKinds keeps the list honest against terminallink.Activatable.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL