Skip to content

Copilot workspace.yaml: consolidate duplicate regex parsers and replace verbatim prompt-text matching; add tests #38

Description

@shmuelie

Summary

The Copilot session tooling contains two independently-written, regex-based
YAML parsers
for the same workspace.yaml format, plus a fragile
string-matching heuristic — all without tests.

Details

  • Get-CopilotLaunchPlan.ps1 (~lines 700-720) parses cwd/summary/name/
    branch out of workspace.yaml with one set of regexes.
  • SessionMaintenance.ps1 Merge-CopilotSession (~lines 237-259) rewrites
    the name: field with a different, independently-written block-scalar
    handler.

Because neither uses a real YAML parser, an edge case (folded > scalars,
different indentation, quoted flow scalars, CRLF vs LF) may be read correctly in
one place and mis-parsed/corrupted in the other, and a fix in one won't apply to
the other.

  • Get-CopilotLaunchPlan.ps1 ($ignoredSessionNames, ~line 700) excludes
    auto-generated maintenance sessions from auto-resume by matching the session
    name against verbatim hardcoded copies of the Copilot CLI's internal
    maintenance-prompt text
    . Any upstream wording/punctuation/localization change
    silently breaks the exclusion (maintenance sessions start appearing as
    resumable), with nothing to catch the drift.

Recommendation

  • Extract one shared internal helper
    (Get-CopilotWorkspaceField / Set-CopilotWorkspaceField) used by both call
    sites.
  • Prefer a stable signal (a session kind/purpose field, tag, or naming prefix)
    over verbatim prompt-text matching; if none exists, add a regression test that
    fails loudly when the upstream session shape no longer matches.
  • Add unit tests covering quoted values, block scalars (|, |-, >, >-),
    and CRLF content.

Filed from an automated peer review (Skeptic persona); please validate before acting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions