NAME

Developer::Dashboard::CLI::Ticket - private tmux ticket helper for Developer Dashboard

SYNOPSIS

use Developer::Dashboard::CLI::Ticket qw(run_ticket_command);
run_ticket_command( args => \@ARGV );

DESCRIPTION

Provides the shared implementation behind the private ticket helper staged under ~/.developer-dashboard/cli/dd/ so dashboard ticket can stay part of the dashboard toolchain without installing a public top-level executable.

PURPOSE

This module owns the workspace-session runtime behind dashboard workspace. It resolves the requested workspace reference, builds the tmux environment, decides whether the session already exists, creates the session when needed, and attaches the terminal to the chosen workspace session. Logical dotted names are mapped to tmux's underscore-normalized names because tmux parses a period as a session/window target separator. Existing tagged sessions are checked against WORKSPACE_REF to avoid reusing a name collision for another workspace. If concurrent callers race to create the same session, a duplicate-session response is accepted only after a second tmux query confirms the session exists.

WHY IT EXISTS

It exists because ticket-session behavior needs to stay deterministic and testable. Keeping session naming, environment variables, create-vs-attach decisions, and tmux error handling in one module prevents wrappers and prompt helpers from inventing different rules.

WHEN TO USE

Use this file when changing how dashboard ticket chooses the ticket name, what tmux environment variables it seeds, or how create/attach failures are reported back to the user.

HOW TO USE

Call run_ticket_command from the staged helper, passing the raw argv list. With an explicit ticket argument, that becomes both the tmux session name and the seeded TICKET_REF/B/OB environment set. Without an explicit argument, the module falls back to $ENV{TICKET_REF} when present. If the session does not exist it creates a detached Code1 window in the current working directory before attaching; if the session already exists it skips creation and attaches directly. Dotted workspace references use underscores in the tmux session name while their original dotted value remains in WORKSPACE_REF. If a normalized name is tagged for another workspace, the command reports the collision instead of attaching to that unrelated session. If another caller creates the session between the initial check and create request, it rechecks the named session and attaches only after confirming the duplicate exists; unrelated create errors remain visible.

The -c option may appear before or after the workspace name. It resolves configured path aliases first, then skill-qualified methods from each installed skill's lib/Folder.pm through the shared validated d2 paths/cdr loader. Dotted nested-skill names are supported at arbitrary installed depth, for example parent.child.work. The session and its layered environment refresh both start in the resolved directory. If no alias resolves, -c fails with an explicit error. If another command creates the session between the initial existence check and the create request, the helper rechecks the exact name and attaches only when that session is confirmed; other create errors remain visible.

WHAT USES IT

It is used by the dashboard ticket helper, by prompt/bootstrap flows that want consistent ticket-session environment variables, and by regression tests that verify explicit ticket selection, environment fallback, and tmux create/attach error handling.

EXAMPLES

dashboard ticket DD-123
dashboard ticket
TICKET_REF=DD-123 dashboard ticket
dashboard ticket feature-branch-42
dashboard workspace parent.child.work -c
perl -Ilib -MDeveloper::Dashboard::CLI::Ticket=list_sessions -e 'print join qq(\n), list_sessions()'