feat(shortcuts): copy active thread reference #8994
Mergedmaria-rcksmerged 7 commits into
main fromrefs/pull/8994/headmerged by maria-rcks View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/web/src/components/CommandPalette.tsx line 618OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -590,0 +598,21 @@598+ : (projects.find(599+ (project) =>600+ project.environmentId === activeThread.environmentId &&601+ project.id === activeThread.projectId,602+ ) ?? null),603+ [activeThread, projects],604+ );605+ const activeThreadCwd = activeThread?.worktreePath ?? activeThreadProject?.workspaceRoot ?? null;606+ const activeThreadGitStatus = useEnvironmentQuery(607+ activeThread != null &&608+ activeThread.linkedPullRequest == null &&609+ activeThread.branch !== null &&610+ activeThreadCwd !== null611+ ? vcsEnvironment.status({612+ environmentId: activeThread.environmentId,613+ input: { cwd: activeThreadCwd },614+ })615+ : null,616+ ).data;617+ const detectedPullRequestUrl =618+ activeThread?.branch != null && activeThreadGitStatus?.refName === activeThread.branchapps/web/src/components/CommandPalette.tsx line 2249OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -2167,3 +2245,5 @@21672245 return;21682246 }21692247 }2248+ if (command === "thread.copyReference") {2249+ const matchingItem = displayedGroups
- apps/mobile/src/features/keyboard/HardwareKeyboardCommandProvider.tsx line 136Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -37,3 +127,8 @@37127 (command: HardwareKeyboardCommand) => {38128 if (dispatchHardwareKeyboardCommand(command)) return;39129130+ if (command === "copyThreadReference") {131+ if (copyTarget === null) return;132+ void tryCopyTextWithHaptic(copyTarget.value, {133+ target: copyTarget.clipboardTarget,134+ }).then((didCopy) => {apps/mobile/src/features/keyboard/HardwareKeyboardCommandProvider.tsx lines 71 to 80Resolvedby maria-rcks@@ -18,0 +60,21 @@60+ ? vcsEnvironment.status({61+ environmentId: activeThread.environmentId,62+ input: { cwd: activeThreadCwd },63+ })64+ : null,65+ ).data;66+ const detectedPullRequestUrl =67+ activeThread?.branch != null && gitStatus?.refName === activeThread.branch68+ ? (gitStatus.pr?.url ?? null)69+ : null;70+ const copyTarget = useMemo(71+ () =>72+ activeThread === null73+ ? null74+ : resolveThreadReferenceCopyTarget({75+ threadId: activeThread.id,76+ linkedPullRequestUrl: activeThread.linkedPullRequest?.url ?? null,77+ detectedPullRequestUrl,78+ }),79+ [activeThread, detectedPullRequestUrl],80+ );
- @@ -2167,4 +2248,11 @@21672248 return;21682249 }21692250 }2251+ if (command === "thread.copyReference" && activeThreadReferenceCopyTarget !== null) {2252+ event.preventDefault();2253+ event.stopPropagation();2254+ setOpen(false);2255+ void copyActiveThreadReference();2256+ return;2257+ }21702258@@ -590,0 +600,21 @@600+ const activeThreadProject = useProject(601+ activeThread === null602+ ? null603+ : scopeProjectRef(activeThread.environmentId, activeThread.projectId),604+ );605+ const activeThreadCwd = activeThread?.worktreePath ?? activeThreadProject?.workspaceRoot ?? null;606+ const activeThreadGitStatus = useEnvironmentQuery(607+ activeThread != null &&608+ activeThread.linkedPullRequest == null &&609+ activeThread.branch !== null &&610+ activeThreadCwd !== null611+ ? vcsEnvironment.status({612+ environmentId: activeThread.environmentId,613+ input: { cwd: activeThreadCwd },614+ })615+ : null,616+ ).data;617+ const detectedPullRequestUrl =618+ activeThread == null || activeThread.linkedPullRequest != null619+ ? null620+ : (ThreadPr.resolveDisplayedThreadPr({
- apps/mobile/modules/t3-native-controls/android/src/main/java/expo/modules/t3nativecontrols/T3KeyboardCommandsModule.kt line 44Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +24,21 @@24+class T3KeyboardCommandsView(25+ context: Context,26+ appContext: AppContext27+) : ExpoView(context, appContext) {28+ private val onCommand by EventDispatcher()29+ var enabledCommands = emptySet<String>()30+31+ override fun dispatchKeyEvent(event: KeyEvent): Boolean {32+ val copiesThreadReference =33+ event.action == KeyEvent.ACTION_DOWN &&34+ event.repeatCount == 0 &&35+ event.keyCode == KeyEvent.KEYCODE_C &&36+ event.isCtrlPressed &&37+ event.isShiftPressed &&38+ !event.isAltPressed &&39+ enabledCommands.contains("copyThreadReference")40+ if (copiesThreadReference) {41+ onCommand(mapOf("command" to "copyThreadReference"))42+ return true43+ }44+ return super.dispatchKeyEvent(event)
- apps/web/src/components/ChatView.tsx lines 5340 to 5345Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -5301,3 +5337,9 @@53015337 });53025338 if (!command) return;530353395340+ if (command === "thread.copyReference") {5341+ event.preventDefault();5342+ event.stopPropagation();5343+ copyActiveThreadReference();5344+ return;5345+ }
- apps/mobile/src/features/keyboard/HardwareKeyboardCommandProvider.tsx line 122OutdatedResolvedby maria-rcks@@ -25,7 +115,8 @@25115 const commands = new Set<HardwareKeyboardCommand>(getRegisteredHardwareKeyboardCommands());26116 commands.add("newTask");27117 if (pathname !== "/" || navigation.canGoBack()) commands.add("back");28- if (parseActiveThreadPath(pathname)) {118+ if (activeThreadRef !== null) {29119 commands.add("files");30120 commands.add("terminal");31121 commands.add("review");122+ if (!/\/terminal(?:\/|$)/.test(pathname)) commands.add("copyThreadReference");
- @@ -4600,3 +4601,13 @@46004601 linkedPullRequest: linkedThreadPullRequest,46014602 linkedPullRequestStatus,46024603 });4604+ const activeThreadReferenceCopyTarget = useMemo(4605+ () =>4606+ activeThreadId === null4607+ ? null4608+ : resolveThreadReferenceCopyTarget({4609+ threadId: activeThreadId,4610+ linkedPullRequestUrl: linkedThreadPullRequest?.url ?? null,4611+ detectedPullRequestUrl: activeThreadPr?.url ?? null,4612+ }),4613+ [activeThreadId, activeThreadPr?.url, linkedThreadPullRequest?.url],
maria-rcks merged this2d156a8
maria-rcks closed this
Sign in to join this conversation.


macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed