@deepseek-harness-tui/dsh-tui 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (638) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +235 -0
  3. package/bin/dsh-tui.js +95 -0
  4. package/cordis.patch.yml +218 -0
  5. package/cordis.yml +185 -0
  6. package/lib/invariant.js +28 -0
  7. package/lib/types/activityPrefs.d.ts +29 -0
  8. package/lib/types/activityPrefs.d.ts.map +1 -0
  9. package/lib/types/activityPrefs.js +60 -0
  10. package/lib/types/bootstrap/state.d.ts +13 -0
  11. package/lib/types/bootstrap/state.d.ts.map +1 -0
  12. package/lib/types/bootstrap/state.js +12 -0
  13. package/lib/types/cc/cliHighlight.d.ts +20 -0
  14. package/lib/types/cc/cliHighlight.d.ts.map +1 -0
  15. package/lib/types/cc/cliHighlight.js +53 -0
  16. package/lib/types/cc/figures.d.ts +59 -0
  17. package/lib/types/cc/figures.d.ts.map +1 -0
  18. package/lib/types/cc/figures.js +69 -0
  19. package/lib/types/cc/format.d.ts +26 -0
  20. package/lib/types/cc/format.d.ts.map +1 -0
  21. package/lib/types/cc/format.js +55 -0
  22. package/lib/types/cc/hash.d.ts +25 -0
  23. package/lib/types/cc/hash.d.ts.map +1 -0
  24. package/lib/types/cc/hash.js +41 -0
  25. package/lib/types/cc/hyperlink.d.ts +21 -0
  26. package/lib/types/cc/hyperlink.d.ts.map +1 -0
  27. package/lib/types/cc/hyperlink.js +31 -0
  28. package/lib/types/cc/markdown.d.ts +43 -0
  29. package/lib/types/cc/markdown.d.ts.map +1 -0
  30. package/lib/types/cc/markdown.js +345 -0
  31. package/lib/types/cc/spinnerVerbs.d.ts +3 -0
  32. package/lib/types/cc/spinnerVerbs.d.ts.map +1 -0
  33. package/lib/types/cc/spinnerVerbs.js +190 -0
  34. package/lib/types/cc/terminal.d.ts +15 -0
  35. package/lib/types/cc/terminal.d.ts.map +1 -0
  36. package/lib/types/cc/terminal.js +84 -0
  37. package/lib/types/channel.d.ts +672 -0
  38. package/lib/types/channel.d.ts.map +1 -0
  39. package/lib/types/channel.js +2427 -0
  40. package/lib/types/childStderr.d.ts +63 -0
  41. package/lib/types/childStderr.d.ts.map +1 -0
  42. package/lib/types/childStderr.js +161 -0
  43. package/lib/types/commands.d.ts +55 -0
  44. package/lib/types/commands.d.ts.map +1 -0
  45. package/lib/types/commands.js +101 -0
  46. package/lib/types/components/ActivityLine.d.ts +29 -0
  47. package/lib/types/components/ActivityLine.d.ts.map +1 -0
  48. package/lib/types/components/ActivityLine.js +47 -0
  49. package/lib/types/components/ActivityPicker.d.ts +13 -0
  50. package/lib/types/components/ActivityPicker.d.ts.map +1 -0
  51. package/lib/types/components/ActivityPicker.js +24 -0
  52. package/lib/types/components/CommandSuggestions.d.ts +14 -0
  53. package/lib/types/components/CommandSuggestions.d.ts.map +1 -0
  54. package/lib/types/components/CommandSuggestions.js +33 -0
  55. package/lib/types/components/FileSuggestions.d.ts +12 -0
  56. package/lib/types/components/FileSuggestions.d.ts.map +1 -0
  57. package/lib/types/components/FileSuggestions.js +26 -0
  58. package/lib/types/components/GoalTodoPanel.d.ts +13 -0
  59. package/lib/types/components/GoalTodoPanel.d.ts.map +1 -0
  60. package/lib/types/components/GoalTodoPanel.js +57 -0
  61. package/lib/types/components/HelpMenu.d.ts +12 -0
  62. package/lib/types/components/HelpMenu.d.ts.map +1 -0
  63. package/lib/types/components/HelpMenu.js +12 -0
  64. package/lib/types/components/HistorySearchDialog.d.ts +16 -0
  65. package/lib/types/components/HistorySearchDialog.d.ts.map +1 -0
  66. package/lib/types/components/HistorySearchDialog.js +31 -0
  67. package/lib/types/components/InterruptedByUser.d.ts +7 -0
  68. package/lib/types/components/InterruptedByUser.d.ts.map +1 -0
  69. package/lib/types/components/InterruptedByUser.js +9 -0
  70. package/lib/types/components/LoadedContextPanel.d.ts +20 -0
  71. package/lib/types/components/LoadedContextPanel.d.ts.map +1 -0
  72. package/lib/types/components/LoadedContextPanel.js +30 -0
  73. package/lib/types/components/LogoV2.d.ts +23 -0
  74. package/lib/types/components/LogoV2.d.ts.map +1 -0
  75. package/lib/types/components/LogoV2.js +95 -0
  76. package/lib/types/components/Markdown.d.ts +24 -0
  77. package/lib/types/components/Markdown.d.ts.map +1 -0
  78. package/lib/types/components/Markdown.js +106 -0
  79. package/lib/types/components/MarkdownTable.d.ts +17 -0
  80. package/lib/types/components/MarkdownTable.d.ts.map +1 -0
  81. package/lib/types/components/MarkdownTable.js +272 -0
  82. package/lib/types/components/MessageList.d.ts +41 -0
  83. package/lib/types/components/MessageList.d.ts.map +1 -0
  84. package/lib/types/components/MessageList.js +303 -0
  85. package/lib/types/components/ModelPicker.d.ts +14 -0
  86. package/lib/types/components/ModelPicker.d.ts.map +1 -0
  87. package/lib/types/components/ModelPicker.js +15 -0
  88. package/lib/types/components/PresetPicker.d.ts +17 -0
  89. package/lib/types/components/PresetPicker.d.ts.map +1 -0
  90. package/lib/types/components/PresetPicker.js +25 -0
  91. package/lib/types/components/PromptInput.d.ts +67 -0
  92. package/lib/types/components/PromptInput.d.ts.map +1 -0
  93. package/lib/types/components/PromptInput.js +778 -0
  94. package/lib/types/components/ResumePicker.d.ts +15 -0
  95. package/lib/types/components/ResumePicker.d.ts.map +1 -0
  96. package/lib/types/components/ResumePicker.js +34 -0
  97. package/lib/types/components/RewindPicker.d.ts +14 -0
  98. package/lib/types/components/RewindPicker.d.ts.map +1 -0
  99. package/lib/types/components/RewindPicker.js +23 -0
  100. package/lib/types/components/SearchBox.d.ts +20 -0
  101. package/lib/types/components/SearchBox.d.ts.map +1 -0
  102. package/lib/types/components/SearchBox.js +33 -0
  103. package/lib/types/components/Select.d.ts +22 -0
  104. package/lib/types/components/Select.d.ts.map +1 -0
  105. package/lib/types/components/Select.js +19 -0
  106. package/lib/types/components/Spinner/GlimmerMessage.d.ts +19 -0
  107. package/lib/types/components/Spinner/GlimmerMessage.d.ts.map +1 -0
  108. package/lib/types/components/Spinner/GlimmerMessage.js +78 -0
  109. package/lib/types/components/Spinner/SpinnerAnimationRow.d.ts +31 -0
  110. package/lib/types/components/Spinner/SpinnerAnimationRow.d.ts.map +1 -0
  111. package/lib/types/components/Spinner/SpinnerAnimationRow.js +162 -0
  112. package/lib/types/components/Spinner/SpinnerGlyph.d.ts +16 -0
  113. package/lib/types/components/Spinner/SpinnerGlyph.d.ts.map +1 -0
  114. package/lib/types/components/Spinner/SpinnerGlyph.js +36 -0
  115. package/lib/types/components/Spinner/spinnerMode.d.ts +6 -0
  116. package/lib/types/components/Spinner/spinnerMode.d.ts.map +1 -0
  117. package/lib/types/components/Spinner/spinnerMode.js +1 -0
  118. package/lib/types/components/Spinner/spinnerUtils.d.ts +41 -0
  119. package/lib/types/components/Spinner/spinnerUtils.d.ts.map +1 -0
  120. package/lib/types/components/Spinner/spinnerUtils.js +104 -0
  121. package/lib/types/components/Spinner/useStalledAnimation.d.ts +16 -0
  122. package/lib/types/components/Spinner/useStalledAnimation.d.ts.map +1 -0
  123. package/lib/types/components/Spinner/useStalledAnimation.js +71 -0
  124. package/lib/types/components/StreamingMarkdown.d.ts +12 -0
  125. package/lib/types/components/StreamingMarkdown.d.ts.map +1 -0
  126. package/lib/types/components/StreamingMarkdown.js +39 -0
  127. package/lib/types/components/ThemePicker.d.ts +22 -0
  128. package/lib/types/components/ThemePicker.d.ts.map +1 -0
  129. package/lib/types/components/ThemePicker.js +51 -0
  130. package/lib/types/components/ThinkingToggle.d.ts +17 -0
  131. package/lib/types/components/ThinkingToggle.d.ts.map +1 -0
  132. package/lib/types/components/ThinkingToggle.js +30 -0
  133. package/lib/types/components/ToolUseLoader.d.ts +13 -0
  134. package/lib/types/components/ToolUseLoader.d.ts.map +1 -0
  135. package/lib/types/components/ToolUseLoader.js +17 -0
  136. package/lib/types/components/Whale.d.ts +22 -0
  137. package/lib/types/components/Whale.d.ts.map +1 -0
  138. package/lib/types/components/Whale.js +78 -0
  139. package/lib/types/components/WorkingSpinner.d.ts +26 -0
  140. package/lib/types/components/WorkingSpinner.d.ts.map +1 -0
  141. package/lib/types/components/WorkingSpinner.js +68 -0
  142. package/lib/types/components/activityFrames.d.ts +31 -0
  143. package/lib/types/components/activityFrames.d.ts.map +1 -0
  144. package/lib/types/components/activityFrames.js +83 -0
  145. package/lib/types/components/bigfont.d.ts +28 -0
  146. package/lib/types/components/bigfont.d.ts.map +1 -0
  147. package/lib/types/components/bigfont.js +91 -0
  148. package/lib/types/components/design-system/Byline.d.ts +14 -0
  149. package/lib/types/components/design-system/Byline.d.ts.map +1 -0
  150. package/lib/types/components/design-system/Byline.js +17 -0
  151. package/lib/types/components/design-system/Divider.d.ts +40 -0
  152. package/lib/types/components/design-system/Divider.d.ts.map +1 -0
  153. package/lib/types/components/design-system/Divider.js +24 -0
  154. package/lib/types/components/design-system/KeyboardShortcutHint.d.ts +19 -0
  155. package/lib/types/components/design-system/KeyboardShortcutHint.d.ts.map +1 -0
  156. package/lib/types/components/design-system/KeyboardShortcutHint.js +14 -0
  157. package/lib/types/components/design-system/ListItem.d.ts +36 -0
  158. package/lib/types/components/design-system/ListItem.d.ts.map +1 -0
  159. package/lib/types/components/design-system/ListItem.js +48 -0
  160. package/lib/types/components/design-system/LoadingState.d.ts +19 -0
  161. package/lib/types/components/design-system/LoadingState.d.ts.map +1 -0
  162. package/lib/types/components/design-system/LoadingState.js +22 -0
  163. package/lib/types/components/design-system/Pane.d.ts +17 -0
  164. package/lib/types/components/design-system/Pane.d.ts.map +1 -0
  165. package/lib/types/components/design-system/Pane.js +15 -0
  166. package/lib/types/components/design-system/ProgressBar.d.ts +22 -0
  167. package/lib/types/components/design-system/ProgressBar.d.ts.map +1 -0
  168. package/lib/types/components/design-system/ProgressBar.js +27 -0
  169. package/lib/types/components/design-system/StatusIcon.d.ts +15 -0
  170. package/lib/types/components/design-system/StatusIcon.d.ts.map +1 -0
  171. package/lib/types/components/design-system/StatusIcon.js +20 -0
  172. package/lib/types/components/design-system/ThemeProvider.d.ts +11 -0
  173. package/lib/types/components/design-system/ThemeProvider.d.ts.map +1 -0
  174. package/lib/types/components/design-system/ThemeProvider.js +135 -0
  175. package/lib/types/components/design-system/ThemedBox.d.ts +37 -0
  176. package/lib/types/components/design-system/ThemedBox.d.ts.map +1 -0
  177. package/lib/types/components/design-system/ThemedBox.js +26 -0
  178. package/lib/types/components/design-system/ThemedText.d.ts +56 -0
  179. package/lib/types/components/design-system/ThemedText.d.ts.map +1 -0
  180. package/lib/types/components/design-system/ThemedText.js +45 -0
  181. package/lib/types/components/messages/AssistantTextMessage.d.ts +18 -0
  182. package/lib/types/components/messages/AssistantTextMessage.d.ts.map +1 -0
  183. package/lib/types/components/messages/AssistantTextMessage.js +15 -0
  184. package/lib/types/components/messages/AssistantThinkingMessage.d.ts +23 -0
  185. package/lib/types/components/messages/AssistantThinkingMessage.d.ts.map +1 -0
  186. package/lib/types/components/messages/AssistantThinkingMessage.js +23 -0
  187. package/lib/types/components/messages/AssistantToolUseMessage.d.ts +23 -0
  188. package/lib/types/components/messages/AssistantToolUseMessage.d.ts.map +1 -0
  189. package/lib/types/components/messages/AssistantToolUseMessage.js +220 -0
  190. package/lib/types/components/messages/MessageMetadata.d.ts +15 -0
  191. package/lib/types/components/messages/MessageMetadata.d.ts.map +1 -0
  192. package/lib/types/components/messages/MessageMetadata.js +20 -0
  193. package/lib/types/components/messages/UserPromptMessage.d.ts +19 -0
  194. package/lib/types/components/messages/UserPromptMessage.d.ts.map +1 -0
  195. package/lib/types/components/messages/UserPromptMessage.js +15 -0
  196. package/lib/types/components/questions/AskUserQuestionPanel.d.ts +39 -0
  197. package/lib/types/components/questions/AskUserQuestionPanel.d.ts.map +1 -0
  198. package/lib/types/components/questions/AskUserQuestionPanel.js +228 -0
  199. package/lib/types/components/shimmer.d.ts +35 -0
  200. package/lib/types/components/shimmer.d.ts.map +1 -0
  201. package/lib/types/components/shimmer.js +43 -0
  202. package/lib/types/components/whaleFrames.d.ts +25 -0
  203. package/lib/types/components/whaleFrames.d.ts.map +1 -0
  204. package/lib/types/components/whaleFrames.js +419 -0
  205. package/lib/types/customTheme.d.ts +104 -0
  206. package/lib/types/customTheme.d.ts.map +1 -0
  207. package/lib/types/customTheme.js +268 -0
  208. package/lib/types/effortPrefs.d.ts +22 -0
  209. package/lib/types/effortPrefs.d.ts.map +1 -0
  210. package/lib/types/effortPrefs.js +45 -0
  211. package/lib/types/history.d.ts +24 -0
  212. package/lib/types/history.d.ts.map +1 -0
  213. package/lib/types/history.js +75 -0
  214. package/lib/types/hooks/useBlink.d.ts +11 -0
  215. package/lib/types/hooks/useBlink.d.ts.map +1 -0
  216. package/lib/types/hooks/useBlink.js +20 -0
  217. package/lib/types/i18n.d.ts +926 -0
  218. package/lib/types/i18n.d.ts.map +1 -0
  219. package/lib/types/i18n.js +356 -0
  220. package/lib/types/index.d.ts +70 -0
  221. package/lib/types/index.d.ts.map +1 -0
  222. package/lib/types/index.js +31 -0
  223. package/lib/types/ink/Ansi.d.ts +11 -0
  224. package/lib/types/ink/Ansi.d.ts.map +1 -0
  225. package/lib/types/ink/Ansi.js +269 -0
  226. package/lib/types/ink/bidi.d.ts +18 -0
  227. package/lib/types/ink/bidi.d.ts.map +1 -0
  228. package/lib/types/ink/bidi.js +119 -0
  229. package/lib/types/ink/clearTerminal.d.ts +22 -0
  230. package/lib/types/ink/clearTerminal.d.ts.map +1 -0
  231. package/lib/types/ink/clearTerminal.js +72 -0
  232. package/lib/types/ink/colorize.d.ts +33 -0
  233. package/lib/types/ink/colorize.d.ts.map +1 -0
  234. package/lib/types/ink/colorize.js +213 -0
  235. package/lib/types/ink/components/AlternateScreen.d.ts +22 -0
  236. package/lib/types/ink/components/AlternateScreen.d.ts.map +1 -0
  237. package/lib/types/ink/components/AlternateScreen.js +74 -0
  238. package/lib/types/ink/components/App.d.ts +73 -0
  239. package/lib/types/ink/components/App.d.ts.map +1 -0
  240. package/lib/types/ink/components/App.js +597 -0
  241. package/lib/types/ink/components/AppContext.d.ts +15 -0
  242. package/lib/types/ink/components/AppContext.d.ts.map +1 -0
  243. package/lib/types/ink/components/AppContext.js +11 -0
  244. package/lib/types/ink/components/Box.d.ts +49 -0
  245. package/lib/types/ink/components/Box.d.ts.map +1 -0
  246. package/lib/types/ink/components/Box.js +153 -0
  247. package/lib/types/ink/components/Button.d.ts +37 -0
  248. package/lib/types/ink/components/Button.d.ts.map +1 -0
  249. package/lib/types/ink/components/Button.js +166 -0
  250. package/lib/types/ink/components/ClockContext.d.ts +10 -0
  251. package/lib/types/ink/components/ClockContext.d.ts.map +1 -0
  252. package/lib/types/ink/components/ClockContext.js +108 -0
  253. package/lib/types/ink/components/CursorDeclarationContext.d.ts +30 -0
  254. package/lib/types/ink/components/CursorDeclarationContext.d.ts.map +1 -0
  255. package/lib/types/ink/components/CursorDeclarationContext.js +6 -0
  256. package/lib/types/ink/components/ErrorOverview.d.ts +7 -0
  257. package/lib/types/ink/components/ErrorOverview.d.ts.map +1 -0
  258. package/lib/types/ink/components/ErrorOverview.js +49 -0
  259. package/lib/types/ink/components/Link.d.ts +8 -0
  260. package/lib/types/ink/components/Link.d.ts.map +1 -0
  261. package/lib/types/ink/components/Link.js +33 -0
  262. package/lib/types/ink/components/Newline.d.ts +13 -0
  263. package/lib/types/ink/components/Newline.d.ts.map +1 -0
  264. package/lib/types/ink/components/Newline.js +29 -0
  265. package/lib/types/ink/components/NoSelect.d.ts +20 -0
  266. package/lib/types/ink/components/NoSelect.d.ts.map +1 -0
  267. package/lib/types/ink/components/NoSelect.js +56 -0
  268. package/lib/types/ink/components/RawAnsi.d.ts +17 -0
  269. package/lib/types/ink/components/RawAnsi.d.ts.map +1 -0
  270. package/lib/types/ink/components/RawAnsi.js +45 -0
  271. package/lib/types/ink/components/ScrollBox.d.ts +78 -0
  272. package/lib/types/ink/components/ScrollBox.d.ts.map +1 -0
  273. package/lib/types/ink/components/ScrollBox.js +174 -0
  274. package/lib/types/ink/components/Spacer.d.ts +6 -0
  275. package/lib/types/ink/components/Spacer.d.ts.map +1 -0
  276. package/lib/types/ink/components/Spacer.js +19 -0
  277. package/lib/types/ink/components/StdinContext.d.ts +32 -0
  278. package/lib/types/ink/components/StdinContext.d.ts.map +1 -0
  279. package/lib/types/ink/components/StdinContext.js +16 -0
  280. package/lib/types/ink/components/TerminalFocusContext.d.ts +11 -0
  281. package/lib/types/ink/components/TerminalFocusContext.d.ts.map +1 -0
  282. package/lib/types/ink/components/TerminalFocusContext.js +45 -0
  283. package/lib/types/ink/components/TerminalSizeContext.d.ts +6 -0
  284. package/lib/types/ink/components/TerminalSizeContext.d.ts.map +1 -0
  285. package/lib/types/ink/components/TerminalSizeContext.js +3 -0
  286. package/lib/types/ink/components/Text.d.ts +56 -0
  287. package/lib/types/ink/components/Text.d.ts.map +1 -0
  288. package/lib/types/ink/components/Text.js +194 -0
  289. package/lib/types/ink/constants.d.ts +3 -0
  290. package/lib/types/ink/constants.d.ts.map +1 -0
  291. package/lib/types/ink/constants.js +2 -0
  292. package/lib/types/ink/cursor.d.ts +11 -0
  293. package/lib/types/ink/cursor.d.ts.map +1 -0
  294. package/lib/types/ink/cursor.js +1 -0
  295. package/lib/types/ink/devtools.d.ts +7 -0
  296. package/lib/types/ink/devtools.d.ts.map +1 -0
  297. package/lib/types/ink/devtools.js +1 -0
  298. package/lib/types/ink/dom.d.ts +178 -0
  299. package/lib/types/ink/dom.d.ts.map +1 -0
  300. package/lib/types/ink/dom.js +424 -0
  301. package/lib/types/ink/events/click-event.d.ts +32 -0
  302. package/lib/types/ink/events/click-event.d.ts.map +1 -0
  303. package/lib/types/ink/events/click-event.js +36 -0
  304. package/lib/types/ink/events/dispatcher.d.ts +63 -0
  305. package/lib/types/ink/events/dispatcher.d.ts.map +1 -0
  306. package/lib/types/ink/events/dispatcher.js +194 -0
  307. package/lib/types/ink/events/emitter.d.ts +20 -0
  308. package/lib/types/ink/events/emitter.d.ts.map +1 -0
  309. package/lib/types/ink/events/emitter.js +43 -0
  310. package/lib/types/ink/events/event-handlers.d.ts +47 -0
  311. package/lib/types/ink/events/event-handlers.d.ts.map +1 -0
  312. package/lib/types/ink/events/event-handlers.js +30 -0
  313. package/lib/types/ink/events/event.d.ts +19 -0
  314. package/lib/types/ink/events/event.d.ts.map +1 -0
  315. package/lib/types/ink/events/event.js +22 -0
  316. package/lib/types/ink/events/focus-event.d.ts +19 -0
  317. package/lib/types/ink/events/focus-event.d.ts.map +1 -0
  318. package/lib/types/ink/events/focus-event.js +21 -0
  319. package/lib/types/ink/events/input-event.d.ts +53 -0
  320. package/lib/types/ink/events/input-event.d.ts.map +1 -0
  321. package/lib/types/ink/events/input-event.js +180 -0
  322. package/lib/types/ink/events/keyboard-event.d.ts +40 -0
  323. package/lib/types/ink/events/keyboard-event.d.ts.map +1 -0
  324. package/lib/types/ink/events/keyboard-event.js +65 -0
  325. package/lib/types/ink/events/paste-event.d.ts +11 -0
  326. package/lib/types/ink/events/paste-event.d.ts.map +1 -0
  327. package/lib/types/ink/events/paste-event.js +13 -0
  328. package/lib/types/ink/events/resize-event.d.ts +13 -0
  329. package/lib/types/ink/events/resize-event.d.ts.map +1 -0
  330. package/lib/types/ink/events/resize-event.js +16 -0
  331. package/lib/types/ink/events/terminal-event.d.ts +112 -0
  332. package/lib/types/ink/events/terminal-event.d.ts.map +1 -0
  333. package/lib/types/ink/events/terminal-event.js +131 -0
  334. package/lib/types/ink/events/terminal-focus-event.d.ts +21 -0
  335. package/lib/types/ink/events/terminal-focus-event.d.ts.map +1 -0
  336. package/lib/types/ink/events/terminal-focus-event.js +18 -0
  337. package/lib/types/ink/focus.d.ts +74 -0
  338. package/lib/types/ink/focus.d.ts.map +1 -0
  339. package/lib/types/ink/focus.js +188 -0
  340. package/lib/types/ink/frame.d.ts +119 -0
  341. package/lib/types/ink/frame.d.ts.map +1 -0
  342. package/lib/types/ink/frame.js +43 -0
  343. package/lib/types/ink/get-max-width.d.ts +20 -0
  344. package/lib/types/ink/get-max-width.d.ts.map +1 -0
  345. package/lib/types/ink/get-max-width.js +25 -0
  346. package/lib/types/ink/hit-test.d.ts +47 -0
  347. package/lib/types/ink/hit-test.d.ts.map +1 -0
  348. package/lib/types/ink/hit-test.js +126 -0
  349. package/lib/types/ink/hooks/use-animation-frame.d.ts +27 -0
  350. package/lib/types/ink/hooks/use-animation-frame.d.ts.map +1 -0
  351. package/lib/types/ink/hooks/use-animation-frame.js +48 -0
  352. package/lib/types/ink/hooks/use-app.d.ts +8 -0
  353. package/lib/types/ink/hooks/use-app.d.ts.map +1 -0
  354. package/lib/types/ink/hooks/use-app.js +8 -0
  355. package/lib/types/ink/hooks/use-copy-on-select.d.ts +22 -0
  356. package/lib/types/ink/hooks/use-copy-on-select.d.ts.map +1 -0
  357. package/lib/types/ink/hooks/use-copy-on-select.js +40 -0
  358. package/lib/types/ink/hooks/use-declared-cursor.d.ts +31 -0
  359. package/lib/types/ink/hooks/use-declared-cursor.d.ts.map +1 -0
  360. package/lib/types/ink/hooks/use-declared-cursor.js +65 -0
  361. package/lib/types/ink/hooks/use-input.d.ts +41 -0
  362. package/lib/types/ink/hooks/use-input.d.ts.map +1 -0
  363. package/lib/types/ink/hooks/use-input.js +73 -0
  364. package/lib/types/ink/hooks/use-interval.d.ts +23 -0
  365. package/lib/types/ink/hooks/use-interval.d.ts.map +1 -0
  366. package/lib/types/ink/hooks/use-interval.js +58 -0
  367. package/lib/types/ink/hooks/use-search-highlight.d.ts +34 -0
  368. package/lib/types/ink/hooks/use-search-highlight.d.ts.map +1 -0
  369. package/lib/types/ink/hooks/use-search-highlight.js +35 -0
  370. package/lib/types/ink/hooks/use-selection.d.ts +44 -0
  371. package/lib/types/ink/hooks/use-selection.d.ts.map +1 -0
  372. package/lib/types/ink/hooks/use-selection.js +64 -0
  373. package/lib/types/ink/hooks/use-stdin.d.ts +8 -0
  374. package/lib/types/ink/hooks/use-stdin.d.ts.map +1 -0
  375. package/lib/types/ink/hooks/use-stdin.js +8 -0
  376. package/lib/types/ink/hooks/use-tab-status.d.ts +18 -0
  377. package/lib/types/ink/hooks/use-tab-status.d.ts.map +1 -0
  378. package/lib/types/ink/hooks/use-tab-status.js +58 -0
  379. package/lib/types/ink/hooks/use-terminal-focus.d.ts +11 -0
  380. package/lib/types/ink/hooks/use-terminal-focus.d.ts.map +1 -0
  381. package/lib/types/ink/hooks/use-terminal-focus.js +15 -0
  382. package/lib/types/ink/hooks/use-terminal-size.d.ts +6 -0
  383. package/lib/types/ink/hooks/use-terminal-size.d.ts.map +1 -0
  384. package/lib/types/ink/hooks/use-terminal-size.js +12 -0
  385. package/lib/types/ink/hooks/use-terminal-title.d.ts +14 -0
  386. package/lib/types/ink/hooks/use-terminal-title.d.ts.map +1 -0
  387. package/lib/types/ink/hooks/use-terminal-title.js +30 -0
  388. package/lib/types/ink/hooks/use-terminal-viewport.d.ts +32 -0
  389. package/lib/types/ink/hooks/use-terminal-viewport.d.ts.map +1 -0
  390. package/lib/types/ink/hooks/use-terminal-viewport.js +79 -0
  391. package/lib/types/ink/ink.d.ts +370 -0
  392. package/lib/types/ink/ink.d.ts.map +1 -0
  393. package/lib/types/ink/ink.js +1665 -0
  394. package/lib/types/ink/instances.d.ts +10 -0
  395. package/lib/types/ink/instances.d.ts.map +1 -0
  396. package/lib/types/ink/instances.js +13 -0
  397. package/lib/types/ink/layout/engine.d.ts +7 -0
  398. package/lib/types/ink/layout/engine.d.ts.map +1 -0
  399. package/lib/types/ink/layout/engine.js +8 -0
  400. package/lib/types/ink/layout/geometry.d.ts +86 -0
  401. package/lib/types/ink/layout/geometry.d.ts.map +1 -0
  402. package/lib/types/ink/layout/geometry.js +95 -0
  403. package/lib/types/ink/layout/node.d.ts +151 -0
  404. package/lib/types/ink/layout/node.d.ts.map +1 -0
  405. package/lib/types/ink/layout/node.js +72 -0
  406. package/lib/types/ink/layout/yoga.d.ts +69 -0
  407. package/lib/types/ink/layout/yoga.d.ts.map +1 -0
  408. package/lib/types/ink/layout/yoga.js +249 -0
  409. package/lib/types/ink/line-width-cache.d.ts +9 -0
  410. package/lib/types/ink/line-width-cache.d.ts.map +1 -0
  411. package/lib/types/ink/line-width-cache.js +45 -0
  412. package/lib/types/ink/log-update.d.ts +57 -0
  413. package/lib/types/ink/log-update.d.ts.map +1 -0
  414. package/lib/types/ink/log-update.js +710 -0
  415. package/lib/types/ink/measure-element.d.ts +19 -0
  416. package/lib/types/ink/measure-element.d.ts.map +1 -0
  417. package/lib/types/ink/measure-element.js +10 -0
  418. package/lib/types/ink/measure-text.d.ts +13 -0
  419. package/lib/types/ink/measure-text.d.ts.map +1 -0
  420. package/lib/types/ink/measure-text.js +38 -0
  421. package/lib/types/ink/node-cache.d.ts +33 -0
  422. package/lib/types/ink/node-cache.d.ts.map +1 -0
  423. package/lib/types/ink/node-cache.js +42 -0
  424. package/lib/types/ink/optimizer.d.ts +18 -0
  425. package/lib/types/ink/optimizer.d.ts.map +1 -0
  426. package/lib/types/ink/optimizer.js +83 -0
  427. package/lib/types/ink/output.d.ts +200 -0
  428. package/lib/types/ink/output.d.ts.map +1 -0
  429. package/lib/types/ink/output.js +663 -0
  430. package/lib/types/ink/parse-keypress.d.ts +132 -0
  431. package/lib/types/ink/parse-keypress.d.ts.map +1 -0
  432. package/lib/types/ink/parse-keypress.js +707 -0
  433. package/lib/types/ink/reconciler.d.ts +43 -0
  434. package/lib/types/ink/reconciler.d.ts.map +1 -0
  435. package/lib/types/ink/reconciler.js +413 -0
  436. package/lib/types/ink/render-border.d.ts +36 -0
  437. package/lib/types/ink/render-border.d.ts.map +1 -0
  438. package/lib/types/ink/render-border.js +143 -0
  439. package/lib/types/ink/render-node-to-output.d.ts +93 -0
  440. package/lib/types/ink/render-node-to-output.d.ts.map +1 -0
  441. package/lib/types/ink/render-node-to-output.js +1290 -0
  442. package/lib/types/ink/render-to-screen.d.ts +65 -0
  443. package/lib/types/ink/render-to-screen.d.ts.map +1 -0
  444. package/lib/types/ink/render-to-screen.js +189 -0
  445. package/lib/types/ink/renderer.d.ts +24 -0
  446. package/lib/types/ink/renderer.d.ts.map +1 -0
  447. package/lib/types/ink/renderer.js +136 -0
  448. package/lib/types/ink/root.d.ts +91 -0
  449. package/lib/types/ink/root.d.ts.map +1 -0
  450. package/lib/types/ink/root.js +93 -0
  451. package/lib/types/ink/screen.d.ts +443 -0
  452. package/lib/types/ink/screen.d.ts.map +1 -0
  453. package/lib/types/ink/screen.js +1295 -0
  454. package/lib/types/ink/searchHighlight.d.ts +25 -0
  455. package/lib/types/ink/searchHighlight.d.ts.map +1 -0
  456. package/lib/types/ink/searchHighlight.js +82 -0
  457. package/lib/types/ink/selection.d.ts +323 -0
  458. package/lib/types/ink/selection.d.ts.map +1 -0
  459. package/lib/types/ink/selection.js +881 -0
  460. package/lib/types/ink/squash-text-nodes.d.ts +30 -0
  461. package/lib/types/ink/squash-text-nodes.d.ts.map +1 -0
  462. package/lib/types/ink/squash-text-nodes.js +63 -0
  463. package/lib/types/ink/stringWidth.d.ts +11 -0
  464. package/lib/types/ink/stringWidth.d.ts.map +1 -0
  465. package/lib/types/ink/stringWidth.js +209 -0
  466. package/lib/types/ink/styles.d.ts +324 -0
  467. package/lib/types/ink/styles.d.ts.map +1 -0
  468. package/lib/types/ink/styles.js +307 -0
  469. package/lib/types/ink/supports-hyperlinks.d.ts +20 -0
  470. package/lib/types/ink/supports-hyperlinks.d.ts.map +1 -0
  471. package/lib/types/ink/supports-hyperlinks.js +44 -0
  472. package/lib/types/ink/tabstops.d.ts +9 -0
  473. package/lib/types/ink/tabstops.d.ts.map +1 -0
  474. package/lib/types/ink/tabstops.js +46 -0
  475. package/lib/types/ink/terminal-focus-state.d.ts +35 -0
  476. package/lib/types/ink/terminal-focus-state.d.ts.map +1 -0
  477. package/lib/types/ink/terminal-focus-state.js +57 -0
  478. package/lib/types/ink/terminal-querier.d.ts +161 -0
  479. package/lib/types/ink/terminal-querier.d.ts.map +1 -0
  480. package/lib/types/ink/terminal-querier.js +204 -0
  481. package/lib/types/ink/terminal.d.ts +80 -0
  482. package/lib/types/ink/terminal.d.ts.map +1 -0
  483. package/lib/types/ink/terminal.js +268 -0
  484. package/lib/types/ink/termio/ansi.d.ts +75 -0
  485. package/lib/types/ink/termio/ansi.d.ts.map +1 -0
  486. package/lib/types/ink/termio/ansi.js +79 -0
  487. package/lib/types/ink/termio/csi.d.ts +253 -0
  488. package/lib/types/ink/termio/csi.d.ts.map +1 -0
  489. package/lib/types/ink/termio/csi.js +347 -0
  490. package/lib/types/ink/termio/dec.d.ts +61 -0
  491. package/lib/types/ink/termio/dec.d.ts.map +1 -0
  492. package/lib/types/ink/termio/dec.js +76 -0
  493. package/lib/types/ink/termio/esc.d.ts +15 -0
  494. package/lib/types/ink/termio/esc.d.ts.map +1 -0
  495. package/lib/types/ink/termio/esc.js +57 -0
  496. package/lib/types/ink/termio/osc.d.ts +208 -0
  497. package/lib/types/ink/termio/osc.d.ts.map +1 -0
  498. package/lib/types/ink/termio/osc.js +466 -0
  499. package/lib/types/ink/termio/parser.d.ts +46 -0
  500. package/lib/types/ink/termio/parser.d.ts.map +1 -0
  501. package/lib/types/ink/termio/parser.js +366 -0
  502. package/lib/types/ink/termio/sgr.d.ts +17 -0
  503. package/lib/types/ink/termio/sgr.d.ts.map +1 -0
  504. package/lib/types/ink/termio/sgr.js +300 -0
  505. package/lib/types/ink/termio/tokenize.d.ts +50 -0
  506. package/lib/types/ink/termio/tokenize.d.ts.map +1 -0
  507. package/lib/types/ink/termio/tokenize.js +266 -0
  508. package/lib/types/ink/termio/types.d.ts +211 -0
  509. package/lib/types/ink/termio/types.d.ts.map +1 -0
  510. package/lib/types/ink/termio/types.js +68 -0
  511. package/lib/types/ink/termio.d.ts +25 -0
  512. package/lib/types/ink/termio.d.ts.map +1 -0
  513. package/lib/types/ink/termio.js +24 -0
  514. package/lib/types/ink/truncateToWidth.d.ts +7 -0
  515. package/lib/types/ink/truncateToWidth.d.ts.map +1 -0
  516. package/lib/types/ink/truncateToWidth.js +18 -0
  517. package/lib/types/ink/useTerminalNotification.d.ts +45 -0
  518. package/lib/types/ink/useTerminalNotification.d.ts.map +1 -0
  519. package/lib/types/ink/useTerminalNotification.js +70 -0
  520. package/lib/types/ink/warn.d.ts +7 -0
  521. package/lib/types/ink/warn.d.ts.map +1 -0
  522. package/lib/types/ink/warn.js +15 -0
  523. package/lib/types/ink/widest-line.d.ts +7 -0
  524. package/lib/types/ink/widest-line.d.ts.map +1 -0
  525. package/lib/types/ink/widest-line.js +19 -0
  526. package/lib/types/ink/wrap-text.d.ts +10 -0
  527. package/lib/types/ink/wrap-text.d.ts.map +1 -0
  528. package/lib/types/ink/wrap-text.js +61 -0
  529. package/lib/types/ink/wrapAnsi.d.ts +18 -0
  530. package/lib/types/ink/wrapAnsi.d.ts.map +1 -0
  531. package/lib/types/ink/wrapAnsi.js +16 -0
  532. package/lib/types/invariant.d.ts +20 -0
  533. package/lib/types/invariant.d.ts.map +1 -0
  534. package/lib/types/invariant.js +26 -0
  535. package/lib/types/modelPrefs.d.ts +37 -0
  536. package/lib/types/modelPrefs.d.ts.map +1 -0
  537. package/lib/types/modelPrefs.js +66 -0
  538. package/lib/types/modelRoute.d.ts +79 -0
  539. package/lib/types/modelRoute.d.ts.map +1 -0
  540. package/lib/types/modelRoute.js +96 -0
  541. package/lib/types/native-ts/yoga-layout/enums.d.ts +183 -0
  542. package/lib/types/native-ts/yoga-layout/enums.d.ts.map +1 -0
  543. package/lib/types/native-ts/yoga-layout/enums.js +150 -0
  544. package/lib/types/native-ts/yoga-layout/index.d.ts +788 -0
  545. package/lib/types/native-ts/yoga-layout/index.d.ts.map +1 -0
  546. package/lib/types/native-ts/yoga-layout/index.js +2571 -0
  547. package/lib/types/packaged-skills.d.ts +10 -0
  548. package/lib/types/packaged-skills.d.ts.map +1 -0
  549. package/lib/types/packaged-skills.js +63 -0
  550. package/lib/types/plugin.d.ts +33 -0
  551. package/lib/types/plugin.d.ts.map +1 -0
  552. package/lib/types/plugin.js +454 -0
  553. package/lib/types/presetPrefs.d.ts +29 -0
  554. package/lib/types/presetPrefs.d.ts.map +1 -0
  555. package/lib/types/presetPrefs.js +61 -0
  556. package/lib/types/presets.d.ts +110 -0
  557. package/lib/types/presets.d.ts.map +1 -0
  558. package/lib/types/presets.js +114 -0
  559. package/lib/types/questions.d.ts +97 -0
  560. package/lib/types/questions.d.ts.map +1 -0
  561. package/lib/types/questions.js +201 -0
  562. package/lib/types/screens/Chat.d.ts +23 -0
  563. package/lib/types/screens/Chat.d.ts.map +1 -0
  564. package/lib/types/screens/Chat.js +1263 -0
  565. package/lib/types/screens/StatusLine.d.ts +16 -0
  566. package/lib/types/screens/StatusLine.d.ts.map +1 -0
  567. package/lib/types/screens/StatusLine.js +105 -0
  568. package/lib/types/screens/StatusMetrics.d.ts +87 -0
  569. package/lib/types/screens/StatusMetrics.d.ts.map +1 -0
  570. package/lib/types/screens/StatusMetrics.js +252 -0
  571. package/lib/types/sessionHistory.d.ts +32 -0
  572. package/lib/types/sessionHistory.d.ts.map +1 -0
  573. package/lib/types/sessionHistory.js +87 -0
  574. package/lib/types/theme.d.ts +115 -0
  575. package/lib/types/theme.d.ts.map +1 -0
  576. package/lib/types/theme.js +300 -0
  577. package/lib/types/themePrefs.d.ts +28 -0
  578. package/lib/types/themePrefs.d.ts.map +1 -0
  579. package/lib/types/themePrefs.js +59 -0
  580. package/lib/types/ui.d.ts +28 -0
  581. package/lib/types/ui.d.ts.map +1 -0
  582. package/lib/types/ui.js +25 -0
  583. package/lib/types/update.d.ts +76 -0
  584. package/lib/types/update.d.ts.map +1 -0
  585. package/lib/types/update.js +203 -0
  586. package/lib/types/utils/clipboard.d.ts +43 -0
  587. package/lib/types/utils/clipboard.d.ts.map +1 -0
  588. package/lib/types/utils/clipboard.js +82 -0
  589. package/lib/types/utils/debug.d.ts +8 -0
  590. package/lib/types/utils/debug.d.ts.map +1 -0
  591. package/lib/types/utils/debug.js +12 -0
  592. package/lib/types/utils/earlyInput.d.ts +7 -0
  593. package/lib/types/utils/earlyInput.d.ts.map +1 -0
  594. package/lib/types/utils/earlyInput.js +6 -0
  595. package/lib/types/utils/env.d.ts +10 -0
  596. package/lib/types/utils/env.d.ts.map +1 -0
  597. package/lib/types/utils/env.js +9 -0
  598. package/lib/types/utils/envUtils.d.ts +8 -0
  599. package/lib/types/utils/envUtils.d.ts.map +1 -0
  600. package/lib/types/utils/envUtils.js +13 -0
  601. package/lib/types/utils/execFileNoThrow.d.ts +34 -0
  602. package/lib/types/utils/execFileNoThrow.d.ts.map +1 -0
  603. package/lib/types/utils/execFileNoThrow.js +31 -0
  604. package/lib/types/utils/fullscreen.d.ts +8 -0
  605. package/lib/types/utils/fullscreen.d.ts.map +1 -0
  606. package/lib/types/utils/fullscreen.js +10 -0
  607. package/lib/types/utils/intl.d.ts +7 -0
  608. package/lib/types/utils/intl.d.ts.map +1 -0
  609. package/lib/types/utils/intl.js +9 -0
  610. package/lib/types/utils/loaded-context.d.ts +20 -0
  611. package/lib/types/utils/loaded-context.d.ts.map +1 -0
  612. package/lib/types/utils/loaded-context.js +36 -0
  613. package/lib/types/utils/log.d.ts +7 -0
  614. package/lib/types/utils/log.d.ts.map +1 -0
  615. package/lib/types/utils/log.js +9 -0
  616. package/lib/types/utils/mentions.d.ts +30 -0
  617. package/lib/types/utils/mentions.d.ts.map +1 -0
  618. package/lib/types/utils/mentions.js +72 -0
  619. package/lib/types/utils/narration.d.ts +11 -0
  620. package/lib/types/utils/narration.d.ts.map +1 -0
  621. package/lib/types/utils/narration.js +16 -0
  622. package/lib/types/utils/semver.d.ts +9 -0
  623. package/lib/types/utils/semver.d.ts.map +1 -0
  624. package/lib/types/utils/semver.js +24 -0
  625. package/lib/types/utils/sliceAnsi.d.ts +12 -0
  626. package/lib/types/utils/sliceAnsi.d.ts.map +1 -0
  627. package/lib/types/utils/sliceAnsi.js +79 -0
  628. package/lib/types/working-activity.d.ts +19 -0
  629. package/lib/types/working-activity.d.ts.map +1 -0
  630. package/lib/types/working-activity.js +18 -0
  631. package/package.json +141 -0
  632. package/skills/audit/SKILL.md +24 -0
  633. package/skills/bug/SKILL.md +27 -0
  634. package/skills/pr-comments/SKILL.md +20 -0
  635. package/skills/practice/SKILL.md +22 -0
  636. package/skills/release-notes/SKILL.md +25 -0
  637. package/skills/review/SKILL.md +25 -0
  638. package/skills/vuln-check/SKILL.md +25 -0
@@ -0,0 +1,597 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { PureComponent } from "react";
3
+ import { updateLastInteractionTime } from "../../bootstrap/state.js";
4
+ import { logForDebugging } from "../../utils/debug.js";
5
+ import { stopCapturingEarlyInput } from "../../utils/earlyInput.js";
6
+ import { isEnvTruthy } from "../../utils/envUtils.js";
7
+ import { isMouseClicksDisabled } from "../../utils/fullscreen.js";
8
+ import { logError } from "../../utils/log.js";
9
+ import { EventEmitter } from "../events/emitter.js";
10
+ import { InputEvent } from "../events/input-event.js";
11
+ import { TerminalFocusEvent } from "../events/terminal-focus-event.js";
12
+ import { INITIAL_STATE, parseMultipleKeypresses, } from "../parse-keypress.js";
13
+ import reconciler from "../reconciler.js";
14
+ import { finishSelection, hasSelection, startSelection, } from "../selection.js";
15
+ import { isXtermJs, setXtversionName, supportsExtendedKeys, } from "../terminal.js";
16
+ import { getTerminalFocused, setTerminalFocused, } from "../terminal-focus-state.js";
17
+ import { TerminalQuerier, xtversion } from "../terminal-querier.js";
18
+ import { DISABLE_KITTY_KEYBOARD, DISABLE_MODIFY_OTHER_KEYS, ENABLE_KITTY_KEYBOARD, ENABLE_MODIFY_OTHER_KEYS, FOCUS_IN, FOCUS_OUT, } from "../termio/csi.js";
19
+ import { DBP, DFE, DISABLE_MOUSE_TRACKING, EBP, EFE, HIDE_CURSOR, SHOW_CURSOR, } from "../termio/dec.js";
20
+ import AppContext from "./AppContext.js";
21
+ import { ClockProvider } from "./ClockContext.js";
22
+ import CursorDeclarationContext from "./CursorDeclarationContext.js";
23
+ import ErrorOverview from "./ErrorOverview.js";
24
+ import StdinContext from "./StdinContext.js";
25
+ import { TerminalFocusProvider } from "./TerminalFocusContext.js";
26
+ import { TerminalSizeContext } from "./TerminalSizeContext.js";
27
+ import { TerminalWriteProvider } from "../useTerminalNotification.js";
28
+ // Platforms that support Unix-style process suspension (SIGSTOP/SIGCONT)
29
+ const SUPPORTS_SUSPEND = process.platform !== "win32";
30
+ // After this many milliseconds of stdin silence, the next chunk triggers
31
+ // a terminal mode re-assert (mouse tracking). Catches tmux detach→attach,
32
+ // ssh reconnect, and laptop wake — the terminal resets DEC private modes
33
+ // but no signal reaches us. 5s is well above normal inter-keystroke gaps
34
+ // but short enough that the first scroll after reattach works.
35
+ const STDIN_RESUME_GAP_MS = 5000;
36
+ // Multi-click detection thresholds. 500ms is the macOS default; a small
37
+ // position tolerance allows for trackpad jitter between clicks.
38
+ const MULTI_CLICK_TIMEOUT_MS = 500;
39
+ const MULTI_CLICK_DISTANCE = 1;
40
+ // Root component for all Ink apps
41
+ // It renders stdin and stdout contexts, so that children can access them if needed
42
+ // It also handles Ctrl+C exiting and cursor visibility
43
+ export default class App extends PureComponent {
44
+ static displayName = "InternalApp";
45
+ static getDerivedStateFromError(error) {
46
+ return {
47
+ error,
48
+ };
49
+ }
50
+ state = {
51
+ error: undefined,
52
+ };
53
+ // Count how many components enabled raw mode to avoid disabling
54
+ // raw mode until all components don't need it anymore
55
+ rawModeEnabledCount = 0;
56
+ internal_eventEmitter = new EventEmitter();
57
+ keyParseState = INITIAL_STATE;
58
+ // Timer for flushing incomplete escape sequences
59
+ incompleteEscapeTimer = null;
60
+ // Deferred XTVERSION probe (setImmediate). Cleared on unmount so the
61
+ // DA1 sentinel it flushes cannot land after raw mode is off.
62
+ xtversionProbe = null;
63
+ // Timeout durations for incomplete sequences (ms)
64
+ NORMAL_TIMEOUT = 50; // Short timeout for regular esc sequences
65
+ PASTE_TIMEOUT = 500; // Longer timeout for paste operations
66
+ // Terminal query/response dispatch. Responses arrive on stdin (parsed
67
+ // out by parse-keypress) and are routed to pending promise resolvers.
68
+ querier = new TerminalQuerier(this.props.stdout);
69
+ // Multi-click tracking for double/triple-click text selection. A click
70
+ // within MULTI_CLICK_TIMEOUT_MS and MULTI_CLICK_DISTANCE of the previous
71
+ // click increments clickCount; otherwise it resets to 1.
72
+ lastClickTime = 0;
73
+ lastClickCol = -1;
74
+ lastClickRow = -1;
75
+ clickCount = 0;
76
+ // Deferred hyperlink-open timer — cancelled if a second click arrives
77
+ // within MULTI_CLICK_TIMEOUT_MS (so double-clicking a hyperlink selects
78
+ // the word without also opening the browser). DOM onClick dispatch is
79
+ // NOT deferred — it returns true from onClickAt and skips this timer.
80
+ pendingHyperlinkTimer = null;
81
+ // Last mode-1003 motion position. Terminals already dedupe to cell
82
+ // granularity but this also lets us skip dispatchHover entirely on
83
+ // repeat events (drag-then-release at same cell, etc.).
84
+ lastHoverCol = -1;
85
+ lastHoverRow = -1;
86
+ // Timestamp of last stdin chunk. Used to detect long gaps (tmux attach,
87
+ // ssh reconnect, laptop wake) and trigger terminal mode re-assert.
88
+ // Initialized to now so startup doesn't false-trigger.
89
+ lastStdinTime = Date.now();
90
+ // Raw stdout writer for control sequences that must bypass the frame
91
+ // pipeline (alt-screen enter/exit, mouse-tracking toggles, notifications).
92
+ // A class property (not a render-local closure) so the context value keeps
93
+ // a stable identity — a fresh function per render would re-run
94
+ // <AlternateScreen>'s insertion effect every frame, flapping the alt
95
+ // screen on/off.
96
+ writeRaw = (data) => {
97
+ this.props.stdout.write(data);
98
+ };
99
+ // Determines if TTY is supported on the provided stdin
100
+ isRawModeSupported() {
101
+ return this.props.stdin.isTTY;
102
+ }
103
+ render() {
104
+ return (_jsx(TerminalWriteProvider, { value: this.writeRaw, children: _jsx(TerminalSizeContext.Provider, { value: {
105
+ columns: this.props.terminalColumns,
106
+ rows: this.props.terminalRows,
107
+ }, children: _jsx(AppContext.Provider, { value: {
108
+ exit: this.handleExit,
109
+ }, children: _jsx(StdinContext.Provider, { value: {
110
+ stdin: this.props.stdin,
111
+ setRawMode: this.handleSetRawMode,
112
+ isRawModeSupported: this.isRawModeSupported(),
113
+ internal_exitOnCtrlC: this.props.exitOnCtrlC,
114
+ internal_eventEmitter: this.internal_eventEmitter,
115
+ internal_querier: this.querier,
116
+ }, children: _jsx(TerminalFocusProvider, { children: _jsx(ClockProvider, { children: _jsx(CursorDeclarationContext.Provider, { value: this.props.onCursorDeclaration ?? (() => { }), children: this.state.error ? (_jsx(ErrorOverview, { error: this.state.error })) : (this.props.children) }) }) }) }) }) }) }));
117
+ }
118
+ componentDidMount() {
119
+ // In accessibility mode, keep the native cursor visible for screen magnifiers and other tools
120
+ if (this.props.stdout.isTTY &&
121
+ !isEnvTruthy(process.env.CLAUDE_CODE_ACCESSIBILITY)) {
122
+ this.props.stdout.write(HIDE_CURSOR);
123
+ }
124
+ }
125
+ componentWillUnmount() {
126
+ if (this.props.stdout.isTTY) {
127
+ this.props.stdout.write(SHOW_CURSOR);
128
+ }
129
+ // Clear any pending timers
130
+ if (this.incompleteEscapeTimer) {
131
+ clearTimeout(this.incompleteEscapeTimer);
132
+ this.incompleteEscapeTimer = null;
133
+ }
134
+ if (this.pendingHyperlinkTimer) {
135
+ clearTimeout(this.pendingHyperlinkTimer);
136
+ this.pendingHyperlinkTimer = null;
137
+ }
138
+ if (this.xtversionProbe) {
139
+ clearImmediate(this.xtversionProbe);
140
+ this.xtversionProbe = null;
141
+ }
142
+ // ignore calling setRawMode on an handle stdin it cannot be called
143
+ if (this.isRawModeSupported()) {
144
+ this.handleSetRawMode(false);
145
+ }
146
+ }
147
+ componentDidCatch(error) {
148
+ this.handleExit(error);
149
+ }
150
+ handleSetRawMode = (isEnabled) => {
151
+ const { stdin } = this.props;
152
+ if (!this.isRawModeSupported()) {
153
+ if (stdin === process.stdin) {
154
+ throw new Error("Raw mode is not supported on the current process.stdin, which Ink uses as input stream by default.\nRead about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported");
155
+ }
156
+ else {
157
+ throw new Error("Raw mode is not supported on the stdin provided to Ink.\nRead about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported");
158
+ }
159
+ }
160
+ stdin.setEncoding("utf8");
161
+ if (isEnabled) {
162
+ // Ensure raw mode is enabled only once
163
+ if (this.rawModeEnabledCount === 0) {
164
+ // Stop early input capture right before we add our own readable handler.
165
+ // Both use the same stdin 'readable' + read() pattern, so they can't
166
+ // coexist -- our handler would drain stdin before Ink's can see it.
167
+ // The buffered text is preserved for REPL.tsx via consumeEarlyInput().
168
+ stopCapturingEarlyInput();
169
+ stdin.ref();
170
+ stdin.setRawMode(true);
171
+ stdin.addListener("readable", this.handleReadable);
172
+ // Enable bracketed paste mode
173
+ this.props.stdout.write(EBP);
174
+ // Enable terminal focus reporting (DECSET 1004)
175
+ this.props.stdout.write(EFE);
176
+ // Enable extended key reporting so ctrl+shift+<letter> is
177
+ // distinguishable from ctrl+<letter>. We write both the kitty stack
178
+ // push (CSI >1u) and xterm modifyOtherKeys level 2 (CSI >4;2m) —
179
+ // terminals honor whichever they implement (tmux only accepts the
180
+ // latter).
181
+ if (supportsExtendedKeys()) {
182
+ this.props.stdout.write(ENABLE_KITTY_KEYBOARD);
183
+ this.props.stdout.write(ENABLE_MODIFY_OTHER_KEYS);
184
+ }
185
+ // Probe terminal identity. XTVERSION survives SSH (query/reply goes
186
+ // through the pty), unlike TERM_PROGRAM. Used for wheel-scroll base
187
+ // detection when env vars are absent. Fire-and-forget: the DA1
188
+ // sentinel bounds the round-trip, and if the terminal ignores the
189
+ // query, flush() still resolves and name stays undefined.
190
+ // Deferred to next tick so it fires AFTER the current synchronous
191
+ // init sequence completes — avoids interleaving with alt-screen/mouse
192
+ // tracking enable writes that may happen in the same render cycle.
193
+ this.xtversionProbe = setImmediate(() => {
194
+ this.xtversionProbe = null;
195
+ // A short-lived raw-mode borrower (ThemeProvider's OSC 11 theme
196
+ // probe) can acquire and release raw mode entirely within this
197
+ // tick, so this deferred probe may fire after echo has already
198
+ // been restored — the terminal's replies would then echo onto
199
+ // the screen as visible garbage. Only query while raw mode is
200
+ // still held; if it was released, the next acquisition (count
201
+ // 0→1) queues a fresh probe.
202
+ if (this.rawModeEnabledCount === 0) {
203
+ return;
204
+ }
205
+ void Promise.all([
206
+ this.querier.send(xtversion()),
207
+ this.querier.flush(),
208
+ ]).then(([r]) => {
209
+ if (r) {
210
+ setXtversionName(r.name);
211
+ logForDebugging(`XTVERSION: terminal identified as "${r.name}"`);
212
+ }
213
+ else {
214
+ logForDebugging("XTVERSION: no reply (terminal ignored query)");
215
+ }
216
+ });
217
+ });
218
+ }
219
+ this.rawModeEnabledCount++;
220
+ return;
221
+ }
222
+ // Disable raw mode only when no components left that are using it
223
+ if (--this.rawModeEnabledCount === 0) {
224
+ this.props.stdout.write(DISABLE_MODIFY_OTHER_KEYS);
225
+ this.props.stdout.write(DISABLE_KITTY_KEYBOARD);
226
+ // Disable terminal focus reporting (DECSET 1004)
227
+ this.props.stdout.write(DFE);
228
+ // Disable bracketed paste mode
229
+ this.props.stdout.write(DBP);
230
+ stdin.setRawMode(false);
231
+ stdin.removeListener("readable", this.handleReadable);
232
+ stdin.unref();
233
+ }
234
+ };
235
+ // Helper to flush incomplete escape sequences
236
+ flushIncomplete = () => {
237
+ // Clear the timer reference
238
+ this.incompleteEscapeTimer = null;
239
+ // Only proceed if we have incomplete sequences
240
+ if (!this.keyParseState.incomplete)
241
+ return;
242
+ // Fullscreen: if stdin has data waiting, it's almost certainly the
243
+ // continuation of the buffered sequence (e.g. `[<64;74;16M` after a
244
+ // lone ESC). Node's event loop runs the timers phase before the poll
245
+ // phase, so when a heavy render blocks the loop past 50ms, this timer
246
+ // fires before the queued readable event even though the bytes are
247
+ // already buffered. Re-arm instead of flushing: handleReadable will
248
+ // drain stdin next and clear this timer. Prevents both the spurious
249
+ // Escape key and the lost scroll event.
250
+ if (this.props.stdin.readableLength > 0) {
251
+ this.incompleteEscapeTimer = setTimeout(this.flushIncomplete, this.NORMAL_TIMEOUT);
252
+ return;
253
+ }
254
+ // Process incomplete as a flush operation (input=null)
255
+ // This reuses all existing parsing logic
256
+ this.processInput(null);
257
+ };
258
+ // Process input through the parser and handle the results
259
+ processInput = (input) => {
260
+ // Parse input using our state machine
261
+ const [keys, newState] = parseMultipleKeypresses(this.keyParseState, input);
262
+ this.keyParseState = newState;
263
+ // Process ALL keys in a SINGLE discreteUpdates call to prevent
264
+ // "Maximum update depth exceeded" error when many keys arrive at once
265
+ // (e.g., from paste operations or holding keys rapidly).
266
+ // This batches all state updates from handleInput and all useInput
267
+ // listeners together within one high-priority update context.
268
+ if (keys.length > 0) {
269
+ reconciler.discreteUpdates(processKeysInBatch, this, keys, undefined, undefined);
270
+ }
271
+ // If we have incomplete escape sequences, set a timer to flush them
272
+ if (this.keyParseState.incomplete) {
273
+ // Cancel any existing timer first
274
+ if (this.incompleteEscapeTimer) {
275
+ clearTimeout(this.incompleteEscapeTimer);
276
+ }
277
+ this.incompleteEscapeTimer = setTimeout(this.flushIncomplete, this.keyParseState.mode === "IN_PASTE"
278
+ ? this.PASTE_TIMEOUT
279
+ : this.NORMAL_TIMEOUT);
280
+ }
281
+ };
282
+ handleReadable = () => {
283
+ // Detect long stdin gaps (tmux attach, ssh reconnect, laptop wake).
284
+ // The terminal may have reset DEC private modes; re-assert mouse
285
+ // tracking. Checked before the read loop so one Date.now() covers
286
+ // all chunks in this readable event.
287
+ const now = Date.now();
288
+ if (now - this.lastStdinTime > STDIN_RESUME_GAP_MS) {
289
+ this.props.onStdinResume?.();
290
+ }
291
+ this.lastStdinTime = now;
292
+ try {
293
+ let chunk;
294
+ while ((chunk = this.props.stdin.read()) !== null) {
295
+ // Process the input chunk
296
+ this.processInput(chunk);
297
+ }
298
+ }
299
+ catch (error) {
300
+ // In Bun, an uncaught throw inside a stream 'readable' handler can
301
+ // permanently wedge the stream: data stays buffered and 'readable'
302
+ // never re-emits. Catching here ensures the stream stays healthy so
303
+ // subsequent keystrokes are still delivered.
304
+ logError(error);
305
+ // Re-attach the listener in case the exception detached it.
306
+ // Bun may remove the listener after an error; without this,
307
+ // the session freezes permanently (stdin reader dead, event loop alive).
308
+ const { stdin } = this.props;
309
+ if (this.rawModeEnabledCount > 0 &&
310
+ !stdin.listeners("readable").includes(this.handleReadable)) {
311
+ logForDebugging("handleReadable: re-attaching stdin readable listener after error recovery", {
312
+ level: "warn",
313
+ });
314
+ stdin.addListener("readable", this.handleReadable);
315
+ }
316
+ }
317
+ };
318
+ handleInput = (input) => {
319
+ // Exit on Ctrl+C
320
+ if (input === "\x03" && this.props.exitOnCtrlC) {
321
+ this.handleExit();
322
+ }
323
+ // Note: Ctrl+Z (suspend) is now handled in processKeysInBatch using the
324
+ // parsed key to support both raw (\x1a) and CSI u format from Kitty
325
+ // keyboard protocol terminals (Ghostty, iTerm2, kitty, WezTerm)
326
+ };
327
+ handleExit = (error) => {
328
+ if (this.isRawModeSupported()) {
329
+ this.handleSetRawMode(false);
330
+ }
331
+ this.props.onExit(error);
332
+ };
333
+ handleTerminalFocus = (isFocused) => {
334
+ // setTerminalFocused notifies subscribers: TerminalFocusProvider (context)
335
+ // and Clock (interval speed) — no App setState needed.
336
+ setTerminalFocused(isFocused);
337
+ };
338
+ handleSuspend = () => {
339
+ if (!this.isRawModeSupported()) {
340
+ return;
341
+ }
342
+ // Store the exact raw mode count to restore it properly
343
+ const rawModeCountBeforeSuspend = this.rawModeEnabledCount;
344
+ // Completely disable raw mode before suspending
345
+ while (this.rawModeEnabledCount > 0) {
346
+ this.handleSetRawMode(false);
347
+ }
348
+ // Show cursor, disable focus reporting, and disable mouse tracking
349
+ // before suspending. DISABLE_MOUSE_TRACKING is a no-op if tracking
350
+ // wasn't enabled, so it's safe to emit unconditionally — without
351
+ // it, SGR mouse sequences would appear as garbled text at the
352
+ // shell prompt while suspended.
353
+ if (this.props.stdout.isTTY) {
354
+ this.props.stdout.write(SHOW_CURSOR + DFE + DISABLE_MOUSE_TRACKING);
355
+ }
356
+ // Emit suspend event for Claude Code to handle. Mostly just has a notification
357
+ this.internal_eventEmitter.emit("suspend");
358
+ // Set up resume handler
359
+ const resumeHandler = () => {
360
+ // Restore raw mode to exact previous state
361
+ for (let i = 0; i < rawModeCountBeforeSuspend; i++) {
362
+ if (this.isRawModeSupported()) {
363
+ this.handleSetRawMode(true);
364
+ }
365
+ }
366
+ // Hide cursor (unless in accessibility mode) and re-enable focus reporting after resuming
367
+ if (this.props.stdout.isTTY) {
368
+ if (!isEnvTruthy(process.env.CLAUDE_CODE_ACCESSIBILITY)) {
369
+ this.props.stdout.write(HIDE_CURSOR);
370
+ }
371
+ // Re-enable focus reporting to restore terminal state
372
+ this.props.stdout.write(EFE);
373
+ }
374
+ // Emit resume event for Claude Code to handle
375
+ this.internal_eventEmitter.emit("resume");
376
+ process.removeListener("SIGCONT", resumeHandler);
377
+ };
378
+ process.on("SIGCONT", resumeHandler);
379
+ process.kill(process.pid, "SIGSTOP");
380
+ };
381
+ }
382
+ // Helper to process all keys within a single discrete update context.
383
+ // discreteUpdates expects (fn, a, b, c, d) -> fn(a, b, c, d)
384
+ function processKeysInBatch(app, items, _unused1, _unused2) {
385
+ // Update interaction time for notification timeout tracking.
386
+ // This is called from the central input handler to avoid having multiple
387
+ // stdin listeners that can cause race conditions and dropped input.
388
+ // Terminal responses (kind: 'response') are automated, not user input.
389
+ // Mode-1003 no-button motion is also excluded — passive cursor drift is
390
+ // not engagement (would suppress idle notifications + defer housekeeping).
391
+ if (items.some((i) => i.kind === "key" ||
392
+ (i.kind === "mouse" &&
393
+ !((i.button & 0x20) !== 0 && (i.button & 0x03) === 3)))) {
394
+ updateLastInteractionTime();
395
+ }
396
+ for (const item of items) {
397
+ // Terminal responses (DECRPM, DA1, OSC replies, etc.) are not user
398
+ // input — route them to the querier to resolve pending promises.
399
+ if (item.kind === "response") {
400
+ app.querier.onResponse(item.response);
401
+ continue;
402
+ }
403
+ // Mouse click/drag events update selection state (fullscreen only).
404
+ // Terminal sends 1-indexed col/row; convert to 0-indexed for the
405
+ // screen buffer. Button bit 0x20 = drag (motion while button held).
406
+ if (item.kind === "mouse") {
407
+ handleMouseEvent(app, item);
408
+ continue;
409
+ }
410
+ const sequence = item.sequence;
411
+ // Handle terminal focus events (DECSET 1004)
412
+ if (sequence === FOCUS_IN) {
413
+ app.handleTerminalFocus(true);
414
+ const event = new TerminalFocusEvent("terminalfocus");
415
+ app.internal_eventEmitter.emit("terminalfocus", event);
416
+ continue;
417
+ }
418
+ if (sequence === FOCUS_OUT) {
419
+ app.handleTerminalFocus(false);
420
+ // Defensive: if we lost the release event (mouse released outside
421
+ // terminal window — some emulators drop it rather than capturing the
422
+ // pointer), focus-out is the next observable signal that the drag is
423
+ // over. Without this, drag-to-scroll's timer runs until the scroll
424
+ // boundary is hit.
425
+ if (app.props.selection.isDragging) {
426
+ finishSelection(app.props.selection);
427
+ app.props.onSelectionChange();
428
+ }
429
+ const event = new TerminalFocusEvent("terminalblur");
430
+ app.internal_eventEmitter.emit("terminalblur", event);
431
+ continue;
432
+ }
433
+ // Failsafe: if we receive input, the terminal must be focused
434
+ if (!getTerminalFocused()) {
435
+ setTerminalFocused(true);
436
+ }
437
+ // Handle Ctrl+Z (suspend) using parsed key to support both raw (\x1a) and
438
+ // CSI u format (\x1b[122;5u) from Kitty keyboard protocol terminals
439
+ if (item.name === "z" && item.ctrl && SUPPORTS_SUSPEND) {
440
+ app.handleSuspend();
441
+ continue;
442
+ }
443
+ app.handleInput(sequence);
444
+ const event = new InputEvent(item);
445
+ app.internal_eventEmitter.emit("input", event);
446
+ // Also dispatch through the DOM tree so onKeyDown handlers fire.
447
+ app.props.dispatchKeyboardEvent(item);
448
+ }
449
+ }
450
+ /** Exported for testing. Mutates app.props.selection and click/hover state. */
451
+ export function handleMouseEvent(app, m) {
452
+ // Allow disabling click handling while keeping wheel scroll (which goes
453
+ // through the keybinding system as 'wheelup'/'wheeldown', not here).
454
+ if (isMouseClicksDisabled())
455
+ return;
456
+ const sel = app.props.selection;
457
+ // Terminal coords are 1-indexed; screen buffer is 0-indexed
458
+ const col = m.col - 1;
459
+ const row = m.row - 1;
460
+ const baseButton = m.button & 0x03;
461
+ if (m.action === "press") {
462
+ if ((m.button & 0x20) !== 0 && baseButton === 3) {
463
+ // Mode-1003 motion with no button held. Dispatch hover; skip the
464
+ // rest of this handler (no selection, no click-count side effects).
465
+ // Lost-release recovery: no-button motion while isDragging=true means
466
+ // the release happened outside the terminal window (iTerm2 doesn't
467
+ // capture the pointer past window bounds, so the SGR 'm' never
468
+ // arrives). Finish the selection here so copy-on-select fires. The
469
+ // FOCUS_OUT handler covers the "switched apps" case but not "released
470
+ // past the edge, came back" — and tmux drops focus events unless
471
+ // `focus-events on` is set, so this is the more reliable signal.
472
+ if (sel.isDragging) {
473
+ finishSelection(sel);
474
+ app.props.onSelectionChange();
475
+ }
476
+ if (col === app.lastHoverCol && row === app.lastHoverRow)
477
+ return;
478
+ app.lastHoverCol = col;
479
+ app.lastHoverRow = row;
480
+ app.props.onHoverAt(col, row);
481
+ return;
482
+ }
483
+ if (baseButton !== 0) {
484
+ // Non-left press breaks the multi-click chain.
485
+ app.clickCount = 0;
486
+ return;
487
+ }
488
+ if ((m.button & 0x20) !== 0) {
489
+ // Drag motion: mode-aware extension (char/word/line). onSelectionDrag
490
+ // calls notifySelectionChange internally — no extra onSelectionChange.
491
+ app.props.onSelectionDrag(col, row);
492
+ return;
493
+ }
494
+ // Lost-release fallback for mode-1002-only terminals: a fresh press
495
+ // while isDragging=true means the previous release was dropped (cursor
496
+ // left the window). Finish that selection so copy-on-select fires
497
+ // before startSelection/onMultiClick clobbers it. Mode-1003 terminals
498
+ // hit the no-button-motion recovery above instead, so this is rare.
499
+ if (sel.isDragging) {
500
+ finishSelection(sel);
501
+ app.props.onSelectionChange();
502
+ }
503
+ // Fresh left press. Detect multi-click HERE (not on release) so the
504
+ // word/line highlight appears immediately and a subsequent drag can
505
+ // extend by word/line like native macOS. Previously detected on
506
+ // release, which meant (a) visible latency before the word highlights
507
+ // and (b) double-click+drag fell through to char-mode selection.
508
+ const now = Date.now();
509
+ const nearLast = now - app.lastClickTime < MULTI_CLICK_TIMEOUT_MS &&
510
+ Math.abs(col - app.lastClickCol) <= MULTI_CLICK_DISTANCE &&
511
+ Math.abs(row - app.lastClickRow) <= MULTI_CLICK_DISTANCE;
512
+ app.clickCount = nearLast ? app.clickCount + 1 : 1;
513
+ app.lastClickTime = now;
514
+ app.lastClickCol = col;
515
+ app.lastClickRow = row;
516
+ if (app.clickCount >= 2) {
517
+ // Cancel any pending hyperlink-open from the first click — this is
518
+ // a double-click, not a single-click on a link.
519
+ if (app.pendingHyperlinkTimer) {
520
+ clearTimeout(app.pendingHyperlinkTimer);
521
+ app.pendingHyperlinkTimer = null;
522
+ }
523
+ // Cap at 3 (line select) for quadruple+ clicks.
524
+ const count = app.clickCount === 2 ? 2 : 3;
525
+ app.props.onMultiClick(col, row, count);
526
+ return;
527
+ }
528
+ startSelection(sel, col, row);
529
+ // SGR bit 0x08 = alt (xterm.js wires altKey here, not metaKey — see
530
+ // comment at the hyperlink-open guard below). On macOS xterm.js,
531
+ // receiving alt means macOptionClickForcesSelection is OFF (otherwise
532
+ // xterm.js would have consumed the event for native selection).
533
+ sel.lastPressHadAlt = (m.button & 0x08) !== 0;
534
+ app.props.onSelectionChange();
535
+ return;
536
+ }
537
+ // Release: end the drag even for non-zero button codes. Some terminals
538
+ // encode release with the motion bit or button=3 "no button" (carried
539
+ // over from pre-SGR X10 encoding) — filtering those would orphan
540
+ // isDragging=true and leave drag-to-scroll's timer running until the
541
+ // scroll boundary. Only act on non-left releases when we ARE dragging
542
+ // (so an unrelated middle/right click-release doesn't touch selection).
543
+ if (baseButton !== 0) {
544
+ if (!sel.isDragging)
545
+ return;
546
+ finishSelection(sel);
547
+ app.props.onSelectionChange();
548
+ return;
549
+ }
550
+ finishSelection(sel);
551
+ // NOTE: unlike the old release-based detection we do NOT reset clickCount
552
+ // on release-after-drag. This aligns with NSEvent.clickCount semantics:
553
+ // an intervening drag doesn't break the click chain. Practical upside:
554
+ // trackpad jitter during an intended double-click (press→wobble→release
555
+ // →press) now correctly resolves to word-select instead of breaking to a
556
+ // fresh single click. The nearLast window (500ms, 1 cell) bounds the
557
+ // effect — a deliberate drag past that just starts a fresh chain.
558
+ // A press+release with no drag in char mode is a click: anchor set,
559
+ // focus null → hasSelection false. In word/line mode the press already
560
+ // set anchor+focus (hasSelection true), so release just keeps the
561
+ // highlight. The anchor check guards against an orphaned release (no
562
+ // prior press — e.g. button was held when mouse tracking was enabled).
563
+ if (!hasSelection(sel) && sel.anchor) {
564
+ // Single click: dispatch DOM click immediately (cursor repositioning
565
+ // etc. are latency-sensitive). If no DOM handler consumed it, defer
566
+ // the hyperlink check so a second click can cancel it.
567
+ if (!app.props.onClickAt(col, row)) {
568
+ // Resolve the hyperlink URL synchronously while the screen buffer
569
+ // still reflects what the user clicked — deferring only the
570
+ // browser-open so double-click can cancel it.
571
+ const url = app.props.getHyperlinkAt(col, row);
572
+ // xterm.js (VS Code, Cursor, Windsurf, etc.) has its own OSC 8 link
573
+ // handler that fires on Cmd+click *without consuming the mouse event*
574
+ // (Linkifier._handleMouseUp calls link.activate() but never
575
+ // preventDefault/stopPropagation). The click is also forwarded to the
576
+ // pty as SGR, so both VS Code's terminalLinkManager AND our handler
577
+ // here would open the URL — twice. We can't filter on Cmd: xterm.js
578
+ // drops metaKey before SGR encoding (ICoreMouseEvent has no meta
579
+ // field; the SGR bit we call 'meta' is wired to alt). Let xterm.js
580
+ // own link-opening; Cmd+click is the native UX there anyway.
581
+ // TERM_PROGRAM is the sync fast-path; isXtermJs() is the XTVERSION
582
+ // probe result (catches SSH + non-VS Code embedders like Hyper).
583
+ if (url && process.env.TERM_PROGRAM !== "vscode" && !isXtermJs()) {
584
+ // Clear any prior pending timer — clicking a second link
585
+ // supersedes the first (only the latest click opens).
586
+ if (app.pendingHyperlinkTimer) {
587
+ clearTimeout(app.pendingHyperlinkTimer);
588
+ }
589
+ app.pendingHyperlinkTimer = setTimeout((app, url) => {
590
+ app.pendingHyperlinkTimer = null;
591
+ app.props.onOpenHyperlink(url);
592
+ }, MULTI_CLICK_TIMEOUT_MS, app, url);
593
+ }
594
+ }
595
+ }
596
+ app.props.onSelectionChange();
597
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The `AppContext` value: a function to manually exit (unmount) the Ink app.
3
+ */
4
+ export type Props = {
5
+ /**
6
+ * Exit (unmount) the whole Ink app.
7
+ */
8
+ readonly exit: (error?: Error) => void;
9
+ };
10
+ /**
11
+ * `AppContext` is a React context, which exposes a method to manually exit the app (unmount).
12
+ */
13
+ declare const AppContext: import("react").Context<Props>;
14
+ export default AppContext;
15
+ //# sourceMappingURL=AppContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppContext.d.ts","sourceRoot":"","sources":["../../../../src/ink/components/AppContext.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,MAAM,KAAK,GAAG;IAClB;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,KAAK,IAAI,CAAA;CACvC,CAAA;AAED;;GAEG;AAEH,QAAA,MAAM,UAAU,gCAEd,CAAA;AAKF,eAAe,UAAU,CAAA"}
@@ -0,0 +1,11 @@
1
+ import { createContext } from 'react';
2
+ /**
3
+ * `AppContext` is a React context, which exposes a method to manually exit the app (unmount).
4
+ */
5
+ // eslint-disable-next-line @typescript-eslint/naming-convention
6
+ const AppContext = createContext({
7
+ exit() { },
8
+ });
9
+ // eslint-disable-next-line custom-rules/no-top-level-side-effects
10
+ AppContext.displayName = 'InternalAppContext';
11
+ export default AppContext;