Skip to content

fix(tool-titles): decode percent-escaped paths in channel tool titles - #38644

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
fix/29871-decode-percent-tool-titles
Nov 19, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
fix/29871-decode-percent-tool-titles

Conversation

@bolichen97

@bolichen97 bolichen97 commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A chat channel's tool titles show a percent-encoded file path decoded, the way the dashboard shows the same call.

When a tool names a file by its URL-encoded spelling, the task label a chat channel shows (Discord, for one) spells every space as %20: Edit drafts/The%20Power%20of%20Running.md. The dashboard shows the same call as Edit drafts/The Power of Running.md.

Why it matters

Channel users read an escaped path that the dashboard hides, for every file a tool names by its encoded spelling. The Python title module exists so that a channel and the dashboard show one label for the same call.

Not a goal

  • Changing how files are opened or probed: the decoded text is for display only.
  • Shell command titles: the dashboard does not decode them either.

What changed (motivation → approach → change)

Channel task labels show a b.md where they showed a%20b.md, the same as the dashboard.

The cause: classify_native in tool_call_title.py handed native tool paths to rel_display_path as written, while its TypeScript twin decodes them first with decodePathForDisplay.

tool_call_title.py gains decode_path_for_display, a port of that function, and classify_native's rel helper calls it. Each path segment decodes on its own and keeps its encoded form when it has a malformed escape, is not valid UTF-8, or would decode to a separator, a control or a bidi character. The checks walk the characters; there is no regex. New cases in the shared test/fixtures/tool_call_titles.json pin the same titles on the Python and TypeScript sides.

Backwards compatibility

Compatible: only the display title of a native tool call whose path holds a percent-escape changes, with the action path it is rendered from; nothing is rejected, renamed or removed.

Removes nothing: the change adds a display decode and keeps every input, field and title shape.

Tests

Proof: PROVEN test/test_tool_call_title.py::test_fixture_conformance[fs_write percent-encoded path is decoded for display], test/test_tool_call_title.py::test_fixture_conformance[fs_read percent-encoded path is decoded before cwd is stripped], test/test_tool_call_title.py::test_native_titles_decode_percent_escaped_paths_like_the_dashboard, test/test_tool_call_title.py::test_read_title_decodes_each_segment_like_decodePathForDisplay[x/a%20b.md-x/a b.md], test/test_tool_call_title.py::test_read_title_decodes_each_segment_like_decodePathForDisplay[ok%20dir/50%off.md-ok dir/50%off.md] (head 4858bf1)

  • test_fixture_conformance, four new shared cases: two decoded titles (an edit, and a read whose cwd is stripped after decoding) and two kept-encoded guards (%2F, a malformed %of). The TypeScript suite runs the same cases.
  • test_native_titles_decode_percent_escaped_paths_like_the_dashboard: the issue's edit title and a read title.
  • test_read_title_decodes_each_segment_like_decodePathForDisplay: per-segment decoding and each guard (separator, backslash, control, bidi, malformed escape, not UTF-8).

Determinism: test/test_tool_call_title.py passed 20 of 20 runs at -n0, 10 of 10 at -n 4 --dist loadgroup --max-worker-restart=2 with test/test_tool_call_title_facade.py and test/test_messaging_transport.py as co-tenants, and one shuffled-order run (seed 2039, 289 ids). The TypeScript half, website/src/utils/toolCallTitle.test.ts, passes on the same fixture.

Manual verification

Reproduced and smoke-tested on a Linux (Ubuntu 24.04) host. A throwaway script drove the real channel TurnDriver (messaging/driver.py) with a scripted provider that yields one native fs_write edit of drafts/The%20Power%20of%20Running.md and a recording renderer, and printed the title of the TOOL_CALL event the renderer received, and called the dashboard-to-channel mirror's _mirror_task_label on the same event.

Before the fix (base):

[FAIL] tool_input={"command":"str_replace","path":"drafts/The%20Power%20of%20Running.md"}
    renderer TOOL_CALL title: 'Edit drafts/The%20Power%20of%20Running.md'
    _mirror_task_label:       'Edit drafts/The%20Power%20of%20Running.md'

After the fix (this head):

[PASS] tool_input={"command":"str_replace","path":"drafts/The%20Power%20of%20Running.md"}
    renderer TOOL_CALL title: 'Edit drafts/The Power of Running.md'
    _mirror_task_label:       'Edit drafts/The Power of Running.md'
[PASS] tool_input={"command":"str_replace","path":"drafts/plain name.md"}
    renderer TOOL_CALL title: 'Edit drafts/plain name.md'
[PASS] tool_input={"command":"str_replace","path":"a%2Fb%20c.md"}
    renderer TOOL_CALL title: 'Edit a%2Fb%20c.md'
[PASS] tool_input={"command":"str_replace","path":"50%off%20now.md"}
    renderer TOOL_CALL title: 'Edit 50%off%20now.md'
ALL PASS

A plain path is unchanged, a segment that would gain a separator or has a malformed escape stays encoded, and the same script's direct derive_tool_call_title call for an fs_read of a%20b.md inside its session cwd printed Read a b.md (the channel driver itself passes no cwd). No live chat workspace was connected; the renderer received exactly the title a channel posts.

Screenshots / video

N/A — the diff touches no frontend file; a channel task label is plain text.

Related Issues

Closes #29871

Builds on #29875 by @rohnkum.

Sibling sweep

Swept: git grep -n 'rel_display_path|short_display_path' -- src/kiro_crew, plus the TypeScript classifyNative and readFromKiroCliTitle in website/src/utils/toolCallTitle.ts
Sibling: src/kiro_crew/tool_call_title.py -- changed here
Sibling: src/kiro_crew/tool_call_title_shell_classify.py -- not affected -- shell titles use short_display_path, which the TypeScript side does not decode either
Sibling: src/kiro_crew/tool_call_title_shell_parse.py -- not affected -- it defines and uses short_display_path for shell titles, which the TypeScript side does not decode either
Sibling: website/src/utils/toolCallTitle.ts -- not affected -- it already decodes through decodePathForDisplay

Pattern harvest

Rule candidate: review-prompt
Pattern: When a fix lands in one half of a mirrored TypeScript and Python module, port it to the other half and add a shared fixture case.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision b9745d1ede77c6d781a9eabe0dec0164b39dc313 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of b9745d1ede77c6d781a9eabe0dec0164b39dc313 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

No design-level concerns. This ports the dashboard's display-only decodePathForDisplay to the Python side, and a shared fixture keeps the two in step.

Notes

  • action.path now holds the decoded spelling too. Keep it display-only: no Python reader should open or probe a file from it, as decode_path_for_display's docstring already warns.

[DESIGN-REVIEWED] b9745d1

Description read

[DESCRIPTION-READ] 9f377e212c536d67eccccf9cf571481948d10331c1b9059b809cd1b3eb144c5b

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of b9745d1ede77c6d781a9eabe0dec0164b39dc313 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks. The fix decodes inside classify_native's rel helper, the one place native paths become channel titles, and a linked issue (#29871) plus a base reproduction back the defect.

What this change ships

Inventory (3 items) — 3 justified

Intent: chat-channel users see the same decoded file path in a tool title that the dashboard shows. This is a FIX.

  1. Channel read and edit titles show a percent-encoded path segment decoded (a%20b.md → a b.md). Tag: justified
  2. A segment stays encoded when it is malformed, is not valid UTF-8, or would decode to a separator, control or bidi character. Tag: justified
  3. A new public helper, decode_path_for_display, in tool_call_title.py. A grep for decode_path_for_display finds 2 hits, both in that file, so its only consumer is rel. No existing Python display decoder exists to reuse. Tag: justified

[FIRST-PRINCIPLES-REVIEWED] b9745d1

Description read

[DESCRIPTION-READ] 2812ae87c40a0b1d7c1f6647534935eea047718d21f4f2514b7fea1de96b6e8d

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed b9745d1ede77c6d781a9eabe0dec0164b39dc313 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] b9745d1

Verdict parsed from the review's SHA-scoped output markers for commit b9745d1ede77c6d781a9eabe0dec0164b39dc313.

False positive or not applicable? A repository writer can comment:
/ai-review override fable b9745d1ede77c6d781a9eabe0dec0164b39dc313 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of b9745d1ede77c6d781a9eabe0dec0164b39dc313 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] b9745d1

False positive or not applicable? A repository writer can comment:
/ai-review override gpt b9745d1ede77c6d781a9eabe0dec0164b39dc313 false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 17, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in src/kiro_crew/messaging/driver.py and src/kiro_crew/dashboard/chat_turn/tool_rows.py (the two callers of the changed title function) and about 5,500 other files since this head's CI ran (d155058 -> d38cadb). CI's SAST (Semgrep) job baselines on the merge-base, so on the old base it was scanning 4,777 files that main changed rather than this diff. The new head also splits and joins path segments on the module's DISPLAY_SEP instead of a literal "/", the line PR Policy's Cross-Platform Portability check flagged; the rest of the patch and its author are unchanged. CI re-running.

[operator: bolichen97]

@bolichen97
bolichen97 force-pushed the fix/29871-decode-percent-tool-titles branch from 5972ed7 to 4858bf1 Compare November 19, 2026 14:45
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 19, 2026
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 19, 2026
The Python title mirror in tool_call_title.py passed native tool paths to rel_display_path as written. A path such as drafts/The%20Power%20of%20Running.md showed as Edit drafts/The%20Power%20of%20Running.md in Slack and Discord task labels. The dashboard already decodes it through decodePathForDisplay in pathBasename.ts.

Add decode_path_for_display, a port of decodePathForDisplay, and call it in classify_native's rel helper. Each segment decodes on its own. A segment keeps its encoded form when it has a malformed escape, is not valid UTF-8, or would decode to a separator, a control or a bidi character. The escape check walks each "%" and tests the next two characters against a hex-digit set. The unsafe check tests each decoded character against C0 controls, DEL and an explicit set of separators and bidi controls. No regex is used. New shared fixture cases pin the decoded titles and both guards on the Python and TypeScript sides.

Closes #29871
@bolichen97
bolichen97 force-pushed the fix/29871-decode-percent-tool-titles branch from 4858bf1 to b9745d1 Compare November 19, 2026 16:02
@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] Rebased onto current main with no conflicts; the change itself is byte-identical to the previous head, so the description is unchanged.

The three red Windows backend shards on the previous head were not caused by this change, so there was nothing to fix in this PR:

Formatting, lint, the related Python and TypeScript tests, the flake-pattern ratchet and semgrep were re-run on the rebased tree. CI is re-running.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 19, 2026
@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: A person should decide

Why: the decider estimates a 7% chance that this change introduces a defect, within the 12% limit for approving on its own, but it is held at tier pending: being reviewed.

This PR ports the dashboard's decodePathForDisplay (website/src/utils/pathBasename.ts) to Python as decode_path_for_display. It applies it in classify_native's rel helper the same way the TypeScript twin does (toolCallTitle.ts:248 calls relDisplayPath(decodePathForDisplay(p), inp.cwd)). The two implementations agree on every point I checked:

  • The early return only fires when the path holds some %XX escape.
  • Paths are split on '/' only (DISPLAY_SEP is "/").
  • A segment with a malformed escape, or one that is not valid UTF-8, stays encoded. In TypeScript, decodeURIComponent throws on these; in Python, the pre-scan plus unquote(errors='strict') catches them.
  • The set of characters a decoded segment must not gain is the same: C0 controls, DEL, U+200E/U+200F, U+202A–U+202E, U+2066–U+2069, '/' and ''.

The output is display-only. Its consumers are the channel driver (_derived.title, which is redacted afterwards) and the Slack mirror's _mirror_task_label. No Python code reads action.path to open or probe a file. Decoding happens before the existing title redaction, so it cannot get a credential past the redactors. The new cases go in the shared fixture, so the

Tier: pending: being reviewed.

An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit b9745d1ede · 173 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed head b9745d1. The new decode_path_for_display matches the dashboard's decodePathForDisplay segment for segment: the same malformed-escape, invalid UTF-8, separator, control and bidi guards. A randomized differential comparison of the two implementations found no divergence. The decoded text only feeds the display title and its action path. Nothing opens or probes a file with it, and title redaction still runs on the result. The tool title tests and facade tests pass on this head, and I found no defect that blocks merging.

@KiroCrewCaptain
KiroCrewCaptain merged commit a97153f into main Nov 19, 2026
99 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the fix/29871-decode-percent-tool-titles branch November 19, 2026 17:19
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Slack and Discord tool titles show %20 in percent-encoded file paths

3 participants