Skip to content

fix(skills): payload-cli's PTY driver stalls — chalk colours break its prompt regex #751

Closed

Description

@sydevs-bot

Summary

.claude/skills/payload-cli/interactive.py exists to answer drizzle's rename-vs-create prompts so migrate:create cannot hang. It no longer answers them: the prompt regex matches plain text, but the child runs on a PTY, so chalk colours the column and table names and the escape codes sit inside the match. The driver reads the prompt, matches nothing, and waits until the caller's timeout kills it — exit 124, no migration, and nothing in the log saying why.

Hit while generating the migration for #706. The workaround was a patched copy run from a scratchpad.

Approach

interactive.py:88:

match = re.search(r'Is (\w+) column in (\w+) table created or renamed', text)

What actually arrives on the PTY (/tmp/payload-pty.log):

Is \x1b[1m\x1b[34mcommon_chrome\x1b[39m\x1b[22m column in \x1b[1m\x1b[34msy_atlas_translations_locales\x1b[39m\x1b[22m table created or renamed from another column?

\w+ cannot span the escapes, so the match fails. Starting migration and Accept warnings and push schema to database? still match, because chalk does not colour those — which is why the phase-boundary reset looks like it is working right up to the first real prompt.

Strip the escapes before matching, leaving the raw bytes going to the log untouched:

ANSI = re.compile(r'\x1b\[[0-9;]*[A-Za-z]')
...
text = ANSI.sub('', buf.decode('utf-8', 'replace'))

Verified: with that one change the driver answered all 62 prompts for #706's migration and exited 0.

Two things worth doing in the same change:

  • Fail loudly instead of hanging. The driver should give up and say so — "saw a prompt I could not parse", with the last 200 characters — rather than let the caller's timeout decide. A silent 124 gives the next reader no clue which of the two documented failure modes they are in.
  • Update the skill's own record. SKILL.md lists "three bugs already fixed in this driver". This is the fourth, and the sentence that files it is the only thing standing between the next person and the same 400-second wait.

interactive.py also resolves the repo root by walking four dirnames from __file__, so a copy cannot be run from elsewhere. An env override (PAYLOAD_PTY_CWD) would make the workaround above unnecessary next time, but that is optional.

Acceptance criteria

  • The driver answers a coloured rename-vs-create prompt.
  • A prompt it cannot parse ends the run with a non-zero exit and a message naming what it saw, rather than hanging.
  • /tmp/payload-pty.log still records the raw, coloured output — only the matching copy is stripped.
  • .claude/skills/payload-cli/SKILL.md records this as the fourth bug.

Verification checklist

  • Make any schema change, then run the driver as documented in SKILL.md and confirm grep -c '\[pty\] answered' /tmp/payload-pty.log is greater than zero and a migration file appears.
  • Temporarily change the regex to something that cannot match, re-run, and confirm the run exits non-zero within seconds with the unparsed-prompt message.

Notes

Found while implementing #706; the migration there was generated with a patched copy, so #706 is not blocked on this.

⚠ Both files live under .claude/, where Claude Code's Protected Paths guard makes any write need interactive approval. An unattended run does not fail on that prompt — it waits, invisibly. This one has to be done attended.

🤖 Written by the sydevs autonomous loop — see what this is

Activity

  1. added theissue type on Sep 9, 2026
  2. added
    proposal
    on Sep 9, 2026
  3. Ardnived commented on Sep 10, 2026

    @Ardnived
    Contributor

    @sydevs-bot Implement this

  4. added
    bot:working
    and removed
    proposal
    on Sep 10, 2026
  5. moved this from Proposed to Approved in SYDevelopers Technical Roadmapon Sep 10, 2026
  6. sydevs-bot commented on Sep 10, 2026

    @sydevs-bot
    ContributorAuthor

    🤖 no session running

    recent dispatches
    • 05:08Z implement · attempt 1 · session · done
    • 05:08Z implement · attempt 1 · session

    Written by the sydevs dispatcher. Sessions never edit this comment.

  7. removed
    bot:working
    on Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    Priority

    Medium

    Hold Until

    None yet

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions