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:
- URL activation refuses anything terminallink.SafeHTTPURL rejects. Resolve enforces it; no caller should open a URL it did not get back in a Plan.
- 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 ¶
const FileBrowserPluginID = "file-browser"
FileBrowserPluginID is the plugin that owns file targets.
const TasksPluginID = "tasks"
TasksPluginID owns task targets.
const WorkspacePluginID = "workspace-manager"
WorkspacePluginID owns the content panes — issue, diff, resource — and the tmux sessions a session target attaches to.
Variables ¶
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 ¶
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
}
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.
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" )
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.