Skip to content

fix(hooks): map prompt-submit to Copilot's userPromptSubmitted - #3030

Merged
Daniel Meppiel (danielmeppiel) merged 4 commits into
microsoft:mainfrom
sheilagithub:fix/copilot-user-prompt-submitted
Sep 22, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 4 commits into
microsoft:mainfrom
sheilagithub:fix/copilot-user-prompt-submitted

Conversation

@sheilagithub

@sheilagithub Sheila Shahpari (sheilagithub) commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Description

For the copilot target, apm renames UserPromptSubmit and userPromptSubmit
to userPromptSubmit. Copilot CLI has no event by that name, so prompt hooks
installed for Copilot never run, and Copilot logs nothing.

Copilot's hooks reference
(https://docs.github.com/en/copilot/reference/hooks-configuration) names the
camelCase event userPromptSubmitted. UserPromptSubmit is only its
VS Code-compatible PascalCase variant, which switches the payload to
snake_case. The copilot target writes camelCase, so userPromptSubmitted is
the right name.

Changes:

  • hook_integrator.py: UserPromptSubmit, userPromptSubmit and
    userPromptSubmitted now map to userPromptSubmitted for copilot.
  • test_hook_event_normalization.py: three alias cases.
  • test_hook_integrator_copilot_casing_e2e.py: expects userPromptSubmitted
    and asserts userPromptSubmit is no longer written. It previously asserted
    the wrong name.
  • CHANGELOG.md: one Fixed entry.

Reproduction (apm 0.31.0, Copilot CLI 1.0.86, Windows 11):

  1. A package with target: [copilot] and .apm/hooks/x.json:
    {"hooks":{"UserPromptSubmit":[{"hooks":[{"type":"command","command":"echo hit >> hook.log"}]}]}}
  2. A project that depends on it, with target: [copilot], then apm install.
    .github/hooks/pkg-x.json holds "userPromptSubmit".
  3. Start copilot and send a prompt: no hook.log is written.
  4. Rename the key to "userPromptSubmitted", restart and send a prompt:
    hook.log contains hit.

Issue and approved scope

Fixes #3031

Human scope-approval comment: approved scope and review contact.

The reverse direction is out of scope: a Copilot-authored
userPromptSubmitted hook installed for claude, codex or kiro still passes
through unrenamed. I can open a separate issue for that if it's wanted.

Broader hook-semantics and translation redesign remain out of scope.
Background context is preserved in the maintainer handoff.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally: the new and changed cases fail on main (4 failed)
    and pass with the fix. The 6 hook test files pass (516 tests).
  • All existing tests pass: on Windows 11 (Python 3.11), tests/unit
    gives 443 failed and 44 errors. Those files also fail on unmodified
    main, apart from a few auth/network tests that flip between runs.
    None of the failures is in a hook test. Relying on CI for the full suite.
  • Added tests for new functionality (if applicable)
  • Manual (Windows 11, Copilot CLI 1.0.86): with 0.31.0, the reproduction
    above never fires. With this branch, apm install writes
    "userPromptSubmitted" to .github/hooks/pkg-x.json, and the first
    prompt writes hit to hook.log with no hand edits.

Spec conformance (OpenAPM v0.1)

  • N/A -- this PR does not change OpenAPM-observable behaviour.

The copilot target renamed UserPromptSubmit and userPromptSubmit to
userPromptSubmit, which is not a Copilot CLI event, so prompt hooks never
ran. Copilot's camelCase event is userPromptSubmitted. Map all three
spellings to it and correct the tests that asserted the old name.

Claude-Session: https://claude.ai/code/session_01AqoPHorErGdiZcExmLWBzp
@sheilagithub

Copy link
Copy Markdown
Contributor Author

sheilagithub please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@microsoft-github-policy-service agree

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

User-facing hook documentation must be synchronized with the new Copilot mapping.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Low severity

Open (1)
What changed in this PR

Fixes Copilot prompt hooks by mapping prompt-submit aliases to userPromptSubmitted.

Changes:

  • Updates Copilot event normalization.
  • Adds unit and integration regression coverage.
  • Adds a changelog entry.
File Description
src/​apm_cli/​integration/​hook_integrator.py Maps prompt aliases to Copilot’s valid event.
tests/​unit/​integration/​test_hook_event_normalization.py Covers the three aliases.
tests/​integration/​test_hook_integrator_copilot_casing_e2e.py Verifies generated Copilot keys.
CHANGELOG.md Records the bug fix.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/apm_cli/integration/hook_integrator.py
@sergio-sisternes-epam

Copy link
Copy Markdown
Collaborator

Thank you for contributing this pull request and for filing #3031. APM starts with an issue, not an implementation (https://github.com/microsoft/apm/blob/main/CONTRIBUTING.md). #3031 is not labelled status/accepted yet, so a maintainer still needs to review and accept the scope first. This PR is labelled status/deferred until that happens.

CODEOWNERS for this change are Daniel Meppiel (@danielmeppiel) and Sergio Sisternes (@sergio-sisternes-epam). Existing review requests are unchanged.

This comment is advisory classification only. It is not merge approval and it is not scope acceptance.


Generated by autopilot-pr-triage-worker. This comment is AI-generated and may contain errors.

@sergio-sisternes-epam Sergio Sisternes (sergio-sisternes-epam) added triage/recommended Automated advice completed; not human scope approval. status/deferred Not invited for implementation now; no release commitment. type/bug Something does not work as documented. area/multi-target Multi-target deploy spec, target directory creation, agent surface routing. status/accepted Human scope approval; verify the issue's approval record and review contact before work. labels Sep 20, 2026
@sheilagithub

Copy link
Copy Markdown
Contributor Author

Sergio Sisternes (@sergio-sisternes-epam) thanks so much for the feedback! I wasn't entirely sure on the PR process since last issue I submitted I was asked to submit a PR so I went ahead and did the work for that, but someone else resolved the issue in the meantime. Will follow your required process moving forward.

@danielmeppiel

Copy link
Copy Markdown
Collaborator

Sheila Shahpari (@sheilagithub), thank you for the fix and the documentation follow-up. I have approved the bounded Copilot prompt-event correction on #3031: #3031 (comment). I am the review contact.

We can review this existing PR; there is no need to restart the contribution. I am linking that approval in the PR body and clearing the scope-related deferred label. The review will be launched separately, and scope approval is not merge approval.

For background, #2111 is the separate discussion of broader hook semantics. I am keeping that reference here rather than in the PR scope section so #3031 is the sole nominated scope issue. Reverse aliases for other targets, other hook events, and broader translation redesign remain out of scope.

@danielmeppiel Daniel Meppiel (danielmeppiel) removed the status/deferred Not invited for implementation now; no release commitment. label Sep 22, 2026
@danielmeppiel

Copy link
Copy Markdown
Collaborator

APM Review Panel: ship_now

Bugfix maps Copilot prompt-submit aliases to the correct userPromptSubmitted event, restoring hook dispatch that previously failed silently.

panel-mode=full; personas=python-architect,devx-ux-expert,doc-writer,test-coverage-expert,apm-ceo

cc Sheila Shahpari (@sheilagithub) Sergio Sisternes (@sergio-sisternes-epam) -- a fresh advisory pass is ready for your review.

All four specialist lenses -- architecture, developer experience, documentation, and test coverage -- converged with zero findings on this three-line production correction and its supporting tests and docs. The python-architect confirmed the lookup-table design is the simplest correct approach for a bounded alias fix. The devx-ux-expert (added because the change alters consumer-observable installed behavior) confirmed the silent-failure bug is resolved without surface-area churn. The doc-writer verified both alias tables now match at 052bf14, fully addressing the earlier inline docs feedback. The test-coverage-expert independently ran 26 focused tests (0.38s) covering all three alias spellings plus the real-file deployment assertion and Claude control.

Verification limits are real and should be stated plainly: the panel confirmed 26 targeted tests pass on macOS Python 3.12.9 at the reviewed head, using the existing project venv after local frozen-dependency downloads failed. No full suite, fresh-main lint mirror, Windows reproduction, or Copilot runtime test was performed by the panel. The author reports 516 hook tests green, Windows Copilot 1.0.86 runtime success, and 443 failures / 44 errors present on both branch and main -- these are author claims carried as context, not independently established.

No panelist raised a concern, and the bounded scope (issue #3031) explicitly excludes reverse mappings, other events, and broader hook redesign. There is nothing controversial here: a factual correction to a lookup table, with docs, tests, and changelog aligned.

Aligned with: Multi Harness Multi Host: Restores correct Copilot hook dispatch; the three prompt-submit aliases now resolve to the runtime's canonical userPromptSubmitted event. Pragmatic As Npm: Authors write familiar aliases; APM transparently emits the event name each harness expects.

Panel summary

Persona B R N Takeaway
Python Architect 0 0 0 Copilot alias correction stays in the canonical event map; other targets and integration structure are unchanged.
Devx Ux Expert 0 0 0 Prompt-submit mapping fix resolves a consumer-facing silent-failure bug; docs, tests, and changelog are clear and in sync.
Doc Writer 0 0 0 Both alias tables and the changelog accurately describe the Copilot-only fix and unchanged Claude limitation. The prior docs feedback is addressed.
Test Coverage Expert 0 0 0 Three aliases have unit coverage; real-file deployment catches the wrong Copilot key and retains the Claude control. Focused checks passed.

B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.

Architecture

classDiagram
    class BaseIntegrator
    class HookIntegrator
    class _MergeHookConfig
    BaseIntegrator <|-- HookIntegrator
    HookIntegrator ..> _MergeHookConfig : uses
Loading
flowchart LR
    A[Package hook JSON] --> B[HookIntegrator]
    B --> C[Copilot event map]
    C --> D[userPromptSubmitted]
    D --> E[Generated .github/hooks JSON]
Loading

Recommendation

The panel found no issues across architecture, DevX, documentation, and test coverage. The fix is a clean, bounded lookup-table correction with aligned docs, changelog, and regression tests. Sheila Shahpari (@sheilagithub)'s contribution is well-scoped and well-tested within the stated verification envelope. CODEOWNERS danielmeppiel and Sergio Sisternes (@sergio-sisternes-epam) can review with confidence, bearing in mind that full-suite CI, Windows, and Copilot runtime reproduction remain outside the panel's independent verification. No follow-ups are recommended.


Full per-persona findings

Python Architect

No findings.

Devx Ux Expert

No findings.

Doc Writer

No findings.

Test Coverage Expert

No findings.

This panel is advisory. It does not block merge. Re-apply the
panel-review label after addressing feedback to re-run.


Generated by autopilot-pr-review-worker. This comment is AI-generated and may contain errors.

@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 4631342 into microsoft:main Sep 22, 2026
65 of 77 checks passed
@sasanchezcorrea

Copy link
Copy Markdown

When are you planning to release this? Sergio Sisternes (@sergio-sisternes-epam)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/multi-target Multi-target deploy spec, target directory creation, agent surface routing. status/accepted Human scope approval; verify the issue's approval record and review contact before work. triage/recommended Automated advice completed; not human scope approval. type/bug Something does not work as documented.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Copilot target writes userPromptSubmit; Copilot's event is userPromptSubmitted, so prompt hooks never run

5 participants