Skip to content

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

Closed
rohnkum wants to merge 1 commit into
kirodotdev:mainfrom
rohnkum:fix/tool-titles-decode-percent-paths
Closed

rohnkum wants to merge 1 commit into
kirodotdev:mainfrom
rohnkum:fix/tool-titles-decode-percent-paths

Conversation

@rohnkum

@rohnkum rohnkum commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

classify_native in src/kiro_crew/tool_call_title.py passes native tool paths to rel_display_path as written. For the path drafts/The%20Power%20of%20Running.md, derive_tool_call_title returns Edit drafts/The%20Power%20of%20Running.md. The dashboard renders Edit drafts/The Power of Running.md for the same call, because toolCallTitle.ts runs decodePathForDisplay first.

Goal: Slack and Discord tool titles decode percent-escaped paths the same way the dashboard does.

Why it matters

Slack and Discord task labels come from this module. The module promises the same title as the dashboard for every call. Today a channel user sees %20 where the dashboard shows a space.

Not a goal

Changing how files are opened or probed. The decoded text is for display only. Shell command titles are also unchanged, since the TypeScript side does not decode them either.

What changed

  • src/kiro_crew/tool_call_title.py: add decode_path_for_display, a port of decodePathForDisplay, and call it in the rel helper of classify_native. 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 checks in decode_path_for_display use no regex. _scan_escapes walks each % and tests the next two characters against a hex-digit set. _is_unsafe_decoded tests each decoded character against C0 controls, DEL and an explicit set of separators and bidi controls.
  • test/fixtures/tool_call_titles.json: add four shared cases, two decoded titles and two kept-encoded guards, so the Python and TypeScript suites both pin them.
  • test/test_tool_call_title.py: add direct tests for decoded edit and read titles and for each per-segment guard.

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 2a6f18a)

  • test_fixture_conformance[fs_write percent-encoded path is decoded for display] pins Edit drafts/The Power of Running.md on both sides.
  • test_fixture_conformance[fs_read percent-encoded path is decoded before cwd is stripped] pins that decoding happens before the cwd prefix is removed.
  • test_fixture_conformance guard cases pin that %2F and a malformed %of keep the segment encoded.
  • test_native_titles_decode_percent_escaped_paths_like_the_dashboard pins the decoded edit and read titles.
  • test_read_title_decodes_each_segment_like_decodePathForDisplay pins per-segment decoding and the separator, backslash, control, bidi, malformed and non-UTF-8 guards.

Sibling sweep

Swept: every caller of rel_display_path and short_display_path under src/kiro_crew, and the TypeScript classifyNative and readFromKiroCliTitle.
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: 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.

Closes #29871

@rohnkum
rohnkum requested review from a team and KiroCrewCaptain as code owners November 4, 2026 19:01
@rohnkum
rohnkum requested a review from dodgeblaster November 4, 2026 19:01
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: checking Automated validation is still running labels Nov 4, 2026
@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ⏭️ skipped

Revision 2a6f18a2a5de09d8b900c04cd7dec25ea85ed1c1 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 4, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of 2a6f18a2a5de09d8b900c04cd7dec25ea85ed1c1 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

This is a display-only port that matches the TS call site (relDisplayPath(decodePathForDisplay(p), inp.cwd)), and both suites check it against the shared fixture. It removes nothing, so nothing blocks.

[DESIGN-REVIEWED] 2a6f18a

Description read

[DESCRIPTION-READ] 930cbdd33228bee38b45c6e3ee36efc23b895307ebade7f905acda75e0a47c4b

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 4, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed 2a6f18a2a5de09d8b900c04cd7dec25ea85ed1c1 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 2a6f18a

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of 2a6f18a2a5de09d8b900c04cd7dec25ea85ed1c1 via the fork AI-review pipeline — 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. A Python port of the dashboard's display decoder is added at the one native-path funnel (rel), and the shared fixture pins that both sides give the same title.

What this change ships

Inventory (3 items) — 3 justified

Intent: Slack and Discord users see readable file names in tool titles, as the dashboard already shows them. This is a FIX.

  1. Native read and edit titles on channels now show decoded paths (%20 becomes a space), segment by segment, matching website/src/utils/toolCallTitle.ts:248. — justified
  2. A segment stays encoded when it has a malformed escape, is not valid UTF-8, or would decode to a separator, a control or a bidi character. — justified
  3. New module-level decode_path_for_display that other code may call. — justified

[FIRST-PRINCIPLES-REVIEWED] 2a6f18a

Description read

[DESCRIPTION-READ] 3e4a624f11f75561d783d12052d62eff193cc8372dad84eec63baca741322719

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.

@bolichen97 bolichen97 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.

Requesting changes on 22cf093. The goal, showing a%20b.md as a b.md in tool titles, is good, and decoding per segment with a fallback to the encoded form is the right shape.

The blocker is that decode_path_for_display in tool_call_title.py adds three new regexes in product code, _UNSAFE_DECODED_RE, _PERCENT_ESCAPE_RE and _MALFORMED_ESCAPE_RE, and uses them to decide whether and how a path is decoded. We don't take new regex-based parsing in product code. Please replace them with a structured check, for example:

  • Escape check: walk the segment once. For each %, require the next two characters to be in a hex-digit set; any other % means "keep the segment encoded". The same walk tells you whether there is any escape at all, so the early return needs no pattern either.
  • Unsafe decoded characters: a set of the separators, plus a check per character on the decoded text: ord(c) < 0x20 or ord(c) == 0x7f, or c in an explicit set of the bidi controls (\u200e, \u200f, \u202a to \u202e, \u2066 to \u2069). Or use unicodedata.category(c) in {"Cc", "Cf"} if the wider class is intended.

The test rows you already have should carry over unchanged, which shows the behaviour is the same.

All checks pass on this head; only PR Readiness is still running.

@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 5, 2026
@rohnkum
rohnkum force-pushed the fix/tool-titles-decode-percent-paths branch from 22cf093 to 6e22b2b Compare November 6, 2026 14:34
@rohnkum

rohnkum commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

Updated on 6e22b2b, rebased onto current main.

  1. decode_path_for_display no longer uses a regex, and the three patterns are gone. A new helper, _scan_escapes, walks each % once and tests the next two characters against a hex-digit set. It reports whether any escape exists, which drives the early return, and whether any % is malformed, which keeps that segment encoded. A second helper, _is_unsafe_decoded, checks each decoded character for ord(c) < 0x20, ord(c) == 0x7f, or membership in an explicit set holding /, \ and the bidi controls \u200e, \u200f, \u202a to \u202e and \u2066 to \u2069. This matches UNSAFE_DECODED_RE in pathBasename.ts. Behavior is unchanged: the existing rows in test_read_title_decodes_each_segment_like_decodePathForDisplay and the shared fixture cases pass unchanged.

@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 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed 2a6f18a2a5de09d8b900c04cd7dec25ea85ed1c1 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 2a6f18a

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

Copy link
Copy Markdown
Contributor

Thanks for replacing the regexes: the hex-digit set and the explicit character set do the same job, the test rows carried over, and my earlier change request on 22cf093 is addressed. The code looks good to me on 6e22b2b.

One step is left: could you update this branch onto main? Its merge base is behind main by 34 commits, and Backend Tests (3.12, 2) fails on test_the_package_stays_within_its_line_budget in test_security_gate_liveness.py. That is a main failure, not from this change (it does not touch that package). It was fixed by 484ef40 (#31469), which merged today at 15:48 UTC and is not in this branch yet.

Real Adapter Contract Tests also failed here on a runner sandbox error (bwrap: loopback: Failed RTM_NEWADDR), which does not point at this change either. It will run again on the new head. Once the branch is updated and CI is green, I will approve.

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 kirodotdev#29871
@rohnkum
rohnkum force-pushed the fix/tool-titles-decode-percent-paths branch from 6e22b2b to 2a6f18a Compare November 6, 2026 16:13
@rohnkum

rohnkum commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

Thanks. I rebased the branch onto main at 89a6107, which includes 484ef40. It is one commit again (2a6f18a) with the same change, and the Proof line names the new head. The tool title tests pass locally on it (289 passed), so Backend Tests and the adapter contract tests should run clean on this head.

@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 6, 2026

@bolichen97 bolichen97 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.

Approving head 2a6f18a. decode_path_for_display no longer uses a regex: _scan_escapes walks each %, _is_unsafe_decoded checks each decoded character, and the test rows carried over unchanged.

The one red lane, Real Adapter Contract Tests (test_codex_inner_sandbox_approval.py), is not this change: it fails the same way on other PRs cut from the same base, and #31758 fixed it on main. Could you rebase onto main? The push will dismiss this approval, and I will re-approve once it is green.

@bolichen97
bolichen97 enabled auto-merge (squash) November 8, 2026 19:53
@rohnkum

rohnkum commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

@bolichen97 the only red check on this head is Real Adapter Contract Tests. That is the sandbox loopback failure that #31758 fixed on main, and only a new head picks the fix up. A push here would turn off the auto-merge you enabled. Is it OK if I rebase onto main and push, so you can turn auto-merge back on?

@bolichen97

Copy link
Copy Markdown
Contributor

[operator: bolichen97] Continuing this in #38644; thanks for the start.

@rohnkum

rohnkum commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

Closing this in favour of #38644, which carries the fix forward. Thanks for picking it up.

@rohnkum rohnkum closed this Nov 18, 2026
auto-merge was automatically disabled November 18, 2026 16:46

Pull request was closed

@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor)

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

2 participants