René's URL Explorer Experiment


Title: Fix: Enable Bracketed Paste Mode in `useTerminalInput` by hqwlkj · Pull Request #45 · lessweb/deepcode-cli · GitHub

Open Graph Title: Fix: Enable Bracketed Paste Mode in `useTerminalInput` by hqwlkj · Pull Request #45 · lessweb/deepcode-cli

X Title: Fix: Enable Bracketed Paste Mode in `useTerminalInput` by hqwlkj · Pull Request #45 · lessweb/deepcode-cli

Description: Summary 修复 useTerminalInput 中 Bracketed Paste Mode(括号粘贴模式)的粘贴处理代码因未启用而成为死代码的问题,使粘贴多行代码时能够作为原子输入正确处理。 Problem 在之前的 commit 4c015a3 中,useTerminalInput 添加了完整的 Bracketed Paste Mode 处理逻辑: 解析终端发送的粘贴起止标记 \u001B[200~ / \u001B[201~ 累加粘贴内容并在结束后一次性交付 行尾归一化处理(\r\n / \r → \n) 新增 paste 标志位区分粘贴与按键输入 但在实际运行中,Bracketed Paste Mode 从未被启用: Ink 框架将 setBracketedPasteMode 方法仅暴露在内部 API(useStdinContext)中,公开的 useStdin() hook 不包含此方法 useTerminalInput 从未调用该方法或直接写入 ANSI 转义序列来启用该模式 终端未进入 bracketed paste 模式,不会发送 \u001B[200~ / \u001B[201~ 标记 粘贴处理分支(约 40 行代码)永远不会被执行 因此粘贴多行文本时,终端逐行发送数据,粘贴内容中的 \r 字符会被 parseTerminalInput 误判为 Enter 键,导致粘贴内容被拆解为零散的按键事件,无法正确保留原始格式。 Solution 在 useTerminalInput 中与 setRawMode(true) 同级启用 bracketed paste mode,通过直接写入 ANSI 转义序列到 stdout: // 启用 bracketed paste mode process.stdout.write("\u001B[?2004h"); // 组件卸载时关闭 process.stdout.write("\u001B[?2004l"); 这与 Ink 内部 App 组件的 handleSetBracketedPasteMode 实现方式完全一致,都是向终端发送 \u001B[?2004h(启用)/ \u001B[?2004l(关闭)来控制 bracketed paste mode。 Changes File Change src/ui/prompt/useTerminalInput.ts 在 useEffect 中新增 process.stdout.write("\u001B[?2004h") 和对应的清理逻辑 Diff useEffect(() => { if (!isActive) { return; } setRawMode(true); + // Enable bracketed paste mode so the terminal wraps pasted text in + // \u001B[200~ / \u001B[201~ markers, allowing us to deliver the full + // paste as a single atomic input instead of fragmented key events. + process.stdout.write("\u001B[?2004h"); return () => { setRawMode(false); + process.stdout.write("\u001B[?2004l"); }; }, [isActive, setRawMode]); Effect Before(Bracketed Paste 未启用) 粘贴 hello\nworld 时,终端发送 h e l l o \r w o r l d,其中 \r 被 parseTerminalInput 识别为 key.return = true,粘贴内容被拆分为多个独立事件。 After(Bracketed Paste 已启用) 粘贴 hello\nworld 时,终端发送包裹后的完整内容: \u001B[200~hello\rworld\u001B[201~ useTerminalInput 累加起止标记之间的全部文本,归一化行尾符后作为一次原子操作交付给 PromptInput.tsx,key.return = false,所有其他按键标志也为 false,仅 paste = true。 效果对比 场景 修改前 修改后 粘贴多行代码 每行作为独立事件,\r 被误判为 Enter 完整粘贴,一次原子操作,换行正确保留 粘贴含控制字符的内容 Tab 等可能触发自动补全 所有控制字符安全传递(key.tab = false) 跨平台换行符 仅靠 PromptInput.tsx 归一化 双重保障:hook 层 + PromptInput 层 Verification typecheck : ✅ 无错误 lint : ✅ 0 errors, 0 warnings format : ✅ All matched files use Prettier code style test : ✅ 150/150 pass, 0 fail Notes Ink 5.x 的 setBracketedPasteMode 仅通过内部 useStdinContext 暴露,不在公开 API useStdin 中。由于本项目使用自定义的 useTerminalInput(直接监听 stdin.on("data") 而非 Ink 的 useInput / usePaste),直接写入 ANSI 转义序列是最简洁且与 Ink 内部行为一致的方案。 paste 标志位在 InputKey 中已就绪,可供后续需要区分粘贴与普通输入的场景使用。

Open Graph Description: Summary 修复 useTerminalInput 中 Bracketed Paste Mode(括号粘贴模式)的粘贴处理代码因未启用而成为死代码的问题,使粘贴多行代码时能够作为原子输入正确处理。 Problem 在之前的 commit 4c015a3 中,useTerminalInput 添加了完整的 Bracketed Paste Mode 处理逻辑: 解析终端发送的粘贴起止标记 ...

X Description: Summary 修复 useTerminalInput 中 Bracketed Paste Mode(括号粘贴模式)的粘贴处理代码因未启用而成为死代码的问题,使粘贴多行代码时能够作为原子输入正确处理。 Problem 在之前的 commit 4c015a3 中,useTerminalInput 添加了完整的 Bracketed Paste Mode 处理逻辑: 解析终端发送的粘贴起止标记 ...

Opengraph URL: https://github.com/lessweb/deepcode-cli/pull/45

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:ebd6871d-2081-d4d0-8fc6-70180f870d8a
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idA0AA:FB1CA:D98124:12C62ED:6A4DCE55
html-safe-nonced1bb2436b4525512defdc6933758e5f7ccedc5d6a27670c9a2b11dbd291766de
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMEFBOkZCMUNBOkQ5ODEyNDoxMkM2MkVEOjZBNERDRTU1IiwidmlzaXRvcl9pZCI6IjExMzM4MzE2MjY1OTUwOTQxMDEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac2fe65c725da973e04b3f9f1f0ab88938b58894baaa968de98926fa52de46e1be
hovercard-subject-tagpull_request:3659994920
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/lessweb/deepcode-cli/pull/45/files
twitter:imagehttps://avatars.githubusercontent.com/u/12181423?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/12181423?s=400&v=4
og:image:altSummary 修复 useTerminalInput 中 Bracketed Paste Mode(括号粘贴模式)的粘贴处理代码因未启用而成为死代码的问题,使粘贴多行代码时能够作为原子输入正确处理。 Problem 在之前的 commit 4c015a3 中,useTerminalInput 添加了完整的 Bracketed Paste Mode 处理逻辑: 解析终端发送的粘贴起止标记 ...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None06b8a6144231bf3a234f1c2e9993861e07ce98a905912b114aa386c2d7e84b33
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/lessweb/deepcode-cli git https://github.com/lessweb/deepcode-cli.git
octolytics-dimension-user_id118287711
octolytics-dimension-user_loginlessweb
octolytics-dimension-repository_id1223512305
octolytics-dimension-repository_nwolessweb/deepcode-cli
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1223512305
octolytics-dimension-repository_network_root_nwolessweb/deepcode-cli
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release1d344bdb7547fe6bca17a59bb2b8aac3dc9532a0
ui-targetcanary-2
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/lessweb/deepcode-cli/pull/45/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Flessweb%2Fdeepcode-cli%2Fpull%2F45%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Flessweb%2Fdeepcode-cli%2Fpull%2F45%2Ffiles
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=lessweb%2Fdeepcode-cli
Reloadhttps://github.com/lessweb/deepcode-cli/pull/45/files
Reloadhttps://github.com/lessweb/deepcode-cli/pull/45/files
Reloadhttps://github.com/lessweb/deepcode-cli/pull/45/files
Please reload this pagehttps://github.com/lessweb/deepcode-cli/pull/45/files
lessweb https://github.com/lessweb
deepcode-clihttps://github.com/lessweb/deepcode-cli
Notifications https://github.com/login?return_to=%2Flessweb%2Fdeepcode-cli
Fork 152 https://github.com/login?return_to=%2Flessweb%2Fdeepcode-cli
Star 1.7k https://github.com/login?return_to=%2Flessweb%2Fdeepcode-cli
Code https://github.com/lessweb/deepcode-cli
Issues 43 https://github.com/lessweb/deepcode-cli/issues
Pull requests 22 https://github.com/lessweb/deepcode-cli/pulls
Actions https://github.com/lessweb/deepcode-cli/actions
Projects https://github.com/lessweb/deepcode-cli/projects
Security and quality 0 https://github.com/lessweb/deepcode-cli/security
Insights https://github.com/lessweb/deepcode-cli/pulse
Code https://github.com/lessweb/deepcode-cli
Issues https://github.com/lessweb/deepcode-cli/issues
Pull requests https://github.com/lessweb/deepcode-cli/pulls
Actions https://github.com/lessweb/deepcode-cli/actions
Projects https://github.com/lessweb/deepcode-cli/projects
Security and quality https://github.com/lessweb/deepcode-cli/security
Insights https://github.com/lessweb/deepcode-cli/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Flessweb%2Fdeepcode-cli%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Flessweb%2Fdeepcode-cli%2Fissues%2Fnew%2Fchoose
hqwlkjhttps://github.com/hqwlkj
lessweb:mainhttps://github.com/lessweb/deepcode-cli/tree/main
hqwlkj:mainhttps://github.com/hqwlkj/deepcode-cli/tree/main
Conversation 0 https://github.com/lessweb/deepcode-cli/pull/45
Commits 6 https://github.com/lessweb/deepcode-cli/pull/45/commits
Checks 0 https://github.com/lessweb/deepcode-cli/pull/45/checks
Files changed https://github.com/lessweb/deepcode-cli/pull/45/files
Please reload this pagehttps://github.com/lessweb/deepcode-cli/pull/45/files
Fix: Enable Bracketed Paste Mode in useTerminalInput https://github.com/lessweb/deepcode-cli/pull/45/files#top
Show all changes 6 commits https://github.com/lessweb/deepcode-cli/pull/45/files
68e7bbf feat(terminal): 支持括号粘贴模式以完整接收粘贴输入 hqwlkj May 11, 2026 https://github.com/lessweb/deepcode-cli/pull/45/commits/68e7bbf1a4ce925a166eca81a300b6efb39be4b6
afca105 feat(terminal): 支持括号粘贴模式以完整接收粘贴输入 hqwlkj May 11, 2026 https://github.com/lessweb/deepcode-cli/pull/45/commits/afca105c1340c50741ea54d6c5376cab464d0446
d7efb97 Merge branch 'lessweb:main' into main hqwlkj May 12, 2026 https://github.com/lessweb/deepcode-cli/pull/45/commits/d7efb97545255faf06b7fd27fb5557b002243331
b28c8f6 Merge branch 'lessweb:main' into main hqwlkj May 12, 2026 https://github.com/lessweb/deepcode-cli/pull/45/commits/b28c8f69d7d3426396893ece9b1da28de12d27bc
82b56e8 Merge branch 'lessweb:main' into main hqwlkj May 13, 2026 https://github.com/lessweb/deepcode-cli/pull/45/commits/82b56e8bf55ccf6c0bd062802b29509de8b2b411
3faa42e refactor(ui): 使用通用 DropdownMenu 组件替换技能和模型选择菜单 hqwlkj May 13, 2026 https://github.com/lessweb/deepcode-cli/pull/45/commits/3faa42ec027db3c54eaac50776cd690dde1ad7ee
Clear filters https://github.com/lessweb/deepcode-cli/pull/45/files
Please reload this pagehttps://github.com/lessweb/deepcode-cli/pull/45/files
Please reload this pagehttps://github.com/lessweb/deepcode-cli/pull/45/files
session.ts https://github.com/lessweb/deepcode-cli/pull/45/files#diff-96998a2148aa3d52ad3e80303d0ad88fc43a4afd08966b5330a5657021ae52bb
read-handler.ts https://github.com/lessweb/deepcode-cli/pull/45/files#diff-e5adca29476c2cd8ce119a173f5216b4cd11df4962aec3517f3a8140a93806e3
DropdownMenu.tsx https://github.com/lessweb/deepcode-cli/pull/45/files#diff-a2b9c0f15201e52cbb3cd5e55aed1c3c20ac5b988582ccc57d7ac5db39140c51
PromptInput.tsx https://github.com/lessweb/deepcode-cli/pull/45/files#diff-82045eb6c45c8c094739d89e1eb59b5ca893247cff1a12ef81af2ed6231b6be2
useTerminalInput.ts https://github.com/lessweb/deepcode-cli/pull/45/files#diff-f6c0e8110e67628fb13983eab6e596fb5615a429b47b89469c24555f64d90b26
src/session.tshttps://github.com/lessweb/deepcode-cli/pull/45/files#diff-96998a2148aa3d52ad3e80303d0ad88fc43a4afd08966b5330a5657021ae52bb
View file https://github.com/hqwlkj/deepcode-cli/blob/3faa42ec027db3c54eaac50776cd690dde1ad7ee/src/session.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/lessweb/deepcode-cli/pull/45/{{ revealButtonHref }}
https://github.com/lessweb/deepcode-cli/pull/45/files#diff-96998a2148aa3d52ad3e80303d0ad88fc43a4afd08966b5330a5657021ae52bb
https://github.com/lessweb/deepcode-cli/pull/45/files#diff-96998a2148aa3d52ad3e80303d0ad88fc43a4afd08966b5330a5657021ae52bb
src/tools/read-handler.tshttps://github.com/lessweb/deepcode-cli/pull/45/files#diff-e5adca29476c2cd8ce119a173f5216b4cd11df4962aec3517f3a8140a93806e3
View file https://github.com/hqwlkj/deepcode-cli/blob/3faa42ec027db3c54eaac50776cd690dde1ad7ee/src/tools/read-handler.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/lessweb/deepcode-cli/pull/45/{{ revealButtonHref }}
https://github.com/lessweb/deepcode-cli/pull/45/files#diff-e5adca29476c2cd8ce119a173f5216b4cd11df4962aec3517f3a8140a93806e3
https://github.com/lessweb/deepcode-cli/pull/45/files#diff-e5adca29476c2cd8ce119a173f5216b4cd11df4962aec3517f3a8140a93806e3
https://github.com/lessweb/deepcode-cli/pull/45/files#diff-e5adca29476c2cd8ce119a173f5216b4cd11df4962aec3517f3a8140a93806e3
src/ui/DropdownMenu.tsxhttps://github.com/lessweb/deepcode-cli/pull/45/files#diff-a2b9c0f15201e52cbb3cd5e55aed1c3c20ac5b988582ccc57d7ac5db39140c51
View file https://github.com/hqwlkj/deepcode-cli/blob/3faa42ec027db3c54eaac50776cd690dde1ad7ee/src/ui/DropdownMenu.tsx
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/lessweb/deepcode-cli/pull/45/{{ revealButtonHref }}
src/ui/PromptInput.tsxhttps://github.com/lessweb/deepcode-cli/pull/45/files#diff-82045eb6c45c8c094739d89e1eb59b5ca893247cff1a12ef81af2ed6231b6be2
View file https://github.com/hqwlkj/deepcode-cli/blob/3faa42ec027db3c54eaac50776cd690dde1ad7ee/src/ui/PromptInput.tsx
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/lessweb/deepcode-cli/pull/45/{{ revealButtonHref }}
https://github.com/lessweb/deepcode-cli/pull/45/files#diff-82045eb6c45c8c094739d89e1eb59b5ca893247cff1a12ef81af2ed6231b6be2
https://github.com/lessweb/deepcode-cli/pull/45/files#diff-82045eb6c45c8c094739d89e1eb59b5ca893247cff1a12ef81af2ed6231b6be2
https://github.com/lessweb/deepcode-cli/pull/45/files#diff-82045eb6c45c8c094739d89e1eb59b5ca893247cff1a12ef81af2ed6231b6be2
https://github.com/lessweb/deepcode-cli/pull/45/files#diff-82045eb6c45c8c094739d89e1eb59b5ca893247cff1a12ef81af2ed6231b6be2
https://github.com/lessweb/deepcode-cli/pull/45/files#diff-82045eb6c45c8c094739d89e1eb59b5ca893247cff1a12ef81af2ed6231b6be2
https://github.com/lessweb/deepcode-cli/pull/45/files#diff-82045eb6c45c8c094739d89e1eb59b5ca893247cff1a12ef81af2ed6231b6be2
https://github.com/lessweb/deepcode-cli/pull/45/files#diff-82045eb6c45c8c094739d89e1eb59b5ca893247cff1a12ef81af2ed6231b6be2
https://github.com/lessweb/deepcode-cli/pull/45/files#diff-82045eb6c45c8c094739d89e1eb59b5ca893247cff1a12ef81af2ed6231b6be2
https://github.com/lessweb/deepcode-cli/pull/45/files#diff-82045eb6c45c8c094739d89e1eb59b5ca893247cff1a12ef81af2ed6231b6be2
https://github.com/lessweb/deepcode-cli/pull/45/files#diff-82045eb6c45c8c094739d89e1eb59b5ca893247cff1a12ef81af2ed6231b6be2
Please reload this pagehttps://github.com/lessweb/deepcode-cli/pull/45/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.