prompt-url-widget: before_agent_start throws "Cannot read properties of undefined (reading 'match')" on every background/extension turn
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
- Domain
- developer-experience
Research direction
Read packages/coding-agent/src/core/extensions/builtin/prompt-url-widget.ts and the BeforeAgentStartEvent definition in packages/coding-agent/src/core/extensions/types.ts. Check how delivery and extension turns populate the event, then verify the extension handles turns without prompt text and the type reflects that contract. Done means background turns no longer produce the reported error while prompt URL matching still works.
Written by the indexing model from the issue text.
Description
Summary
The builtin prompt-url-widget extension throws on every non-prompt turn:
prompt-url-widget failed during before_agent_start.
Cannot read properties of undefined (reading 'match')
It fires reliably (>10 times per session) whenever a turn starts from background activity — e.g. a delegated subagent finishing, or any trigger: "extension" / "delivery" turn.
Environment
@code-yeongyu/senpi2026.9.27- Linux x64, Bun global install
- Occurs in the TUI with a UI context available (
ctx.hasUI === true)
Reproduction
- Start a session in the TUI.
- Delegate work to a background subagent (or let any background activity complete so it starts a turn).
- On the resulting
before_agent_start, the extension errors out.
No GitHub PR/issue URL is involved — the failure happens before any pattern matching could meaningfully run.
Root cause
packages/coding-agent/src/core/extensions/builtin/prompt-url-widget.ts:103
const onBeforeAgentStart: ExtensionHandler<BeforeAgentStartEvent, BeforeAgentStartEventResult> = async (
event,
ctx,
) => {
if (event.preview === true || !ctx.hasUI) return;
const match = extractPromptMatch(event.prompt); // <- event.prompt is undefined here
and extractPromptMatch (:26) dereferences unconditionally:
function extractPromptMatch(prompt: string): PromptMatch | undefined {
const prMatch = prompt.match(PR_PROMPT_PATTERN); // TypeError
BeforeAgentStartEvent.prompt is typed as prompt: string (non-optional) in
packages/coding-agent/src/core/extensions/types.ts:1745, but the same interface documents that
turns can start with trigger: "delivery" or trigger: "extension", where no user prompt exists.
So the declared type does not match the runtime contract.
Suggested fix
Two independent layers (either one stops the crash; both together fix the contract):
1. Defensive guard in the extension (extractPromptMatch):
function extractPromptMatch(prompt: string | undefined): PromptMatch | undefined {
if (typeof prompt !== "string") return undefined;
const prMatch = prompt.match(PR_PROMPT_PATTERN);
// ...
2. Correct the event type so extension authors are not misled:
export interface BeforeAgentStartEvent {
type: "before_agent_start";
/** The raw user prompt text (after expansion). Absent for `delivery` / `extension` turns. */
prompt?: string;
trigger: "prompt" | "delivery" | "extension";
// ...
Verified locally: with the guard applied, undefined / null / "" / non-string inputs all return undefined instead of throwing, and legitimate PR/issue prompts still resolve correctly.
Impact
Low (cosmetic) — the throw is caught by the extension host and surfaced as a UI error notice; it does not block the turn or corrupt state. But it produces a spurious red error line on essentially every background-triggered turn, which trains users to ignore extension errors.
Workaround
Apply the guard to the compiled artifact until a release ships:
node_modules/@code-yeongyu/senpi/dist/core/extensions/builtin/prompt-url-widget.js
or delete ~/.config/pi/extensions/prompt-url-widget.js to disable the builtin extension entirely.
- Dominant language
- TypeScript
- Stars
- 521
- Forks
- 167
- Avg merge
- 23h 39m
- Merged PRs (30d)
- 692
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from code-yeongyu/senpi
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
code-yeongyu/senpi#7007 ·
Maintainers usually reply within 1 day
-
Follow-up (#7003 review L1): replace the browser-opener guard test's setTimeout poll with fs.watchOpen
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
code-yeongyu/senpi#7005 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
code-yeongyu/senpi#6998 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
code-yeongyu/senpi#6995 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
code-yeongyu/senpi#6974 ·
Maintainers usually reply within 1 day
All issues in code-yeongyu/senpi
Similar issues
-
bug documentation
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Potential Bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Comfy-Org/ComfyUI_frontend#23773 ·
Maintainers usually reply within 1 day
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 85/100
lingdojo/kana-dojo#34301 · 1 comment · 5 reactions ·
Maintainers usually reply within 1 day
-
code-quality refactoring
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
github/gh-aw-firewall#11797 ·
Maintainers usually reply within 1 day
-
area/renderer bug plugin/echarts priority/P3
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day