fix(deliverables): keep scoped packages and emails out of file links - #310
Open
lswang9 wants to merge 1 commit into
Open
fix(deliverables): keep scoped packages and emails out of file links#310lswang9 wants to merge 1 commit into
lswang9 wants to merge 1 commit into
Conversation
`localPathReference` treated any inline-code token containing a slash as a local path, and any `name.suffix` token as a filename. Scoped package names (`@deepseek-ai/cordis`) and email addresses (`user@example.com`) matched both rules, so assistant prose rendered them as clickable produced-file chips that opened a path which never existed. Reject those two exact shapes after the absolute/relative prefix check, so an explicit `./@scope/pkg` or `node_modules/@foo/bar/lib/client.js` still resolves as a path. Only a bare `@scope/name` with a single slash, or a bare `local@domain.tld`, goes inert. Fixes dataelement#85
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #85
Problem
localPathReferencerenders inline code as a clickable produced-file chip. Its fallback accepted two shapes far too eagerly:/→ a scoped package name like@deepseek-ai/cordislooked like a pathname.suffix→ an email address likeuser@example.comlooked like a filenameSo assistant prose mentioning a package or an email rendered a file chip that opens a path which never existed. Verified against the pristine vendored
0.1.2-rc.1bundle with only the currentmainpatch applied:Change
Two rejection rules in
patches/@deepseek-ai+dsh-client-ui-deliverables+0.1.2-rc.1.patch, placed after the absolute/relative prefix check so explicit paths keep winning:Only a bare
@scope/namewith a single slash, or a barelocal@domain.tld, goes inert. Paths that merely contain an@segment are unaffected —./@scope/pkg,/tmp/@scope/pkg/index.jsandnode_modules/@foo/bar/lib/client.jsstill resolve, because the prefix check or the multi-segment slash rule matches first.Nothing else moves: produced-file resolution, basename matching,
#L42/:42:7suffix stripping, and thepaths ?? []fallback are untouched.Verification
Ran against the real target, not the installed tree — my
node_modulesheld0.1.1-rc.1, so I extracted the vendoredpackages/harness-0.1.2-rc.1/npm-dsh/deepseek-ai-dsh-client-ui-deliverables-0.1.2-rc.1.tgzand worked from that.patch-packageapplies to pristine0.1.2-rc.1:@deepseek-ai/dsh-client-ui-deliverables@0.1.2-rc.1 ✔main's patch against the same pristine bundle (5 false links above), confirming this is not an artifact of my setupnpx vitest run test/local-path-links.test.ts→ 6/6 passmainbaseline: 29 failed / 656 passed before, 29 failed / 661 passed after — same 12 failing files, the 5 extra passes are the new cases. Pre-existing failures come from stale local deps, not this changenpm run typecheck: 10 errors before and after, none in the touched filesTest
test/local-path-links.test.tskeeps the 5 original text assertions and adds behavioural coverage. It evaluates the helper extracted from the patch text rather than fromnode_modules, so it stays honest when the installed Harness build and the patch target disagree.Note for reviewers
One judgement call:
Array.prototype.mapandv0.7.1also come back as links from the samename.suffixrule. I left them alone — tightening that needs either an extension allowlist or a stricter last-segment test, and both risk dropping legitimate uncommon file types. Happy to follow up separately if you want it narrowed.