feat(mobile): add iPad keyboard shortcuts and command palette (#11679)
Co-authored-by: Julius Marminge <[email protected]>
This commit is contained in:
1 parent
b20d29dc43
commit
26b8f985d8
36 files changed
+1303
-122
No files matched your search
@@ -87,6 +87,9 @@ public class T3ComposerEditorModule: Module {
|
||||
Prop("spellCheck") { (view: T3ComposerEditorView, spellCheck: Bool) in
|
||||
view.setSpellCheck(spellCheck)
|
||||
}
|
||||
Prop("enterBehavior") { (view: T3ComposerEditorView, behavior: String) in
|
||||
view.setEnterBehavior(behavior)
|
||||
}
|
||||
Prop("textPasteThresholdBytes") { (view: T3ComposerEditorView, threshold: Int) in
|
||||
view.setTextPasteThresholdBytes(threshold)
|
||||
}
|
||||
|
||||
@@ -45,6 +45,11 @@ private struct ComposerChipStyle {
|
||||
let textColor: UIColor
|
||||
}
|
||||
|
||||
private enum ComposerEnterBehavior: String {
|
||||
case send
|
||||
case newline
|
||||
}
|
||||
|
||||
private final class ComposerTextAttachment: NSTextAttachment {
|
||||
let source: String
|
||||
let label: String
|
||||
@@ -93,10 +98,12 @@ private final class ComposerTextView: UITextView {
|
||||
var isReadOnly = false
|
||||
var textPasteThresholdBytes = 0
|
||||
var maxInputChars = Int.max
|
||||
var enterBehavior: ComposerEnterBehavior = .send
|
||||
private var bypassTextPasteInterception = false
|
||||
|
||||
override var keyCommands: [UIKeyCommand]? {
|
||||
var commands = super.keyCommands ?? []
|
||||
guard !isReadOnly, markedTextRange == nil else { return commands }
|
||||
let submit = UIKeyCommand(
|
||||
input: "\r",
|
||||
modifierFlags: .command,
|
||||
@@ -105,6 +112,25 @@ private final class ComposerTextView: UITextView {
|
||||
submit.discoverabilityTitle = "Send Message"
|
||||
submit.wantsPriorityOverSystemBehavior = true
|
||||
commands.append(submit)
|
||||
if enterBehavior == .send {
|
||||
let submitOnReturn = UIKeyCommand(
|
||||
input: "\r",
|
||||
modifierFlags: [],
|
||||
action: #selector(submitMessage(_:))
|
||||
)
|
||||
submitOnReturn.discoverabilityTitle = "Send Message"
|
||||
submitOnReturn.wantsPriorityOverSystemBehavior = true
|
||||
commands.append(submitOnReturn)
|
||||
|
||||
let newline = UIKeyCommand(
|
||||
input: "\r",
|
||||
modifierFlags: .shift,
|
||||
action: #selector(insertNewline(_:))
|
||||
)
|
||||
newline.discoverabilityTitle = "New Line"
|
||||
newline.wantsPriorityOverSystemBehavior = true
|
||||
commands.append(newline)
|
||||
}
|
||||
if textPasteThresholdBytes > 0 {
|
||||
let pasteAsText = UIKeyCommand(
|
||||
input: "v",
|
||||
@@ -119,9 +145,15 @@ private final class ComposerTextView: UITextView {
|
||||
}
|
||||
|
||||
@objc private func submitMessage(_ sender: UIKeyCommand) {
|
||||
guard !isReadOnly, markedTextRange == nil else { return }
|
||||
onSubmit?()
|
||||
}
|
||||
|
||||
@objc private func insertNewline(_ sender: UIKeyCommand) {
|
||||
guard !isReadOnly, markedTextRange == nil else { return }
|
||||
insertText("\n")
|
||||
}
|
||||
|
||||
@objc private func pasteInline(_ sender: UIKeyCommand) {
|
||||
guard !isReadOnly else {
|
||||
return
|
||||
@@ -132,6 +164,9 @@ private final class ComposerTextView: UITextView {
|
||||
}
|
||||
|
||||
override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
|
||||
if action == #selector(submitMessage(_:)) || action == #selector(insertNewline(_:)) {
|
||||
return isEditable && !isReadOnly && markedTextRange == nil
|
||||
}
|
||||
if isReadOnly && Self.readOnlyActions.contains(NSStringFromSelector(action)) {
|
||||
return false
|
||||
}
|
||||
@@ -657,6 +692,10 @@ public final class T3ComposerEditorView: ExpoView, UITextViewDelegate, UITextDro
|
||||
textView.spellCheckingType = spellCheck ? .yes : .no
|
||||
}
|
||||
|
||||
func setEnterBehavior(_ behavior: String) {
|
||||
textView.enterBehavior = ComposerEnterBehavior(rawValue: behavior) ?? .send
|
||||
}
|
||||
|
||||
func setTextPasteThresholdBytes(_ threshold: Int) {
|
||||
textView.textPasteThresholdBytes = threshold
|
||||
}
|
||||
|
||||
@@ -20,11 +20,26 @@ public final class T3KeyboardCommandsView: ExpoView {
|
||||
|
||||
public override var canBecomeFirstResponder: Bool { true }
|
||||
|
||||
public override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
|
||||
if action == #selector(openCommandPalette) || action == #selector(paletteNext) || action == #selector(palettePrevious) || action == #selector(paletteDismiss),
|
||||
let input = window?.t3FirstResponder as? UITextInput,
|
||||
input.markedTextRange != nil {
|
||||
return false
|
||||
}
|
||||
return super.canPerformAction(action, withSender: sender)
|
||||
}
|
||||
|
||||
public override var keyCommands: [UIKeyCommand]? {
|
||||
[
|
||||
let isPad = UIDevice.current.userInterfaceIdiom == .pad
|
||||
var commands = [
|
||||
enabledCommand("newTask", input: "n", modifiers: .command, action: #selector(newTask), title: "New Task"),
|
||||
enabledCommand("focusSearch", input: "f", modifiers: .command, action: #selector(focusSearch), title: "Find"),
|
||||
enabledCommand("focusSearch", input: "k", modifiers: .command, action: #selector(focusSearch), title: "Focus Search"),
|
||||
isPad
|
||||
? enabledCommand("commandPalette", input: "k", modifiers: .command, action: #selector(openCommandPalette), title: "Command Palette")
|
||||
: enabledCommand("focusSearch", input: "k", modifiers: .command, action: #selector(focusSearch), title: "Focus Search"),
|
||||
enabledCommand("paletteNext", input: UIKeyCommand.inputDownArrow, modifiers: [], action: #selector(paletteNext), title: "Next Result"),
|
||||
enabledCommand("palettePrevious", input: UIKeyCommand.inputUpArrow, modifiers: [], action: #selector(palettePrevious), title: "Previous Result"),
|
||||
enabledCommand("paletteDismiss", input: UIKeyCommand.inputEscape, modifiers: [], action: #selector(paletteDismiss), title: "Close Command Palette"),
|
||||
enabledCommand("back", input: "[", modifiers: .command, action: #selector(goBack), title: "Back"),
|
||||
enabledCommand("files", input: "f", modifiers: [.command, .shift], action: #selector(openFiles), title: "Open Files"),
|
||||
enabledCommand("terminal", input: "t", modifiers: [.command, .shift], action: #selector(openTerminal), title: "Open Terminal"),
|
||||
@@ -38,6 +53,18 @@ public final class T3KeyboardCommandsView: ExpoView {
|
||||
),
|
||||
enabledCommand("toggleSidebar", input: "\\", modifiers: .command, action: #selector(handleToggleSidebar), title: "Toggle Sidebar"),
|
||||
].compactMap { $0 }
|
||||
if isPad {
|
||||
commands += (1...9).compactMap { index in
|
||||
enabledCommand(
|
||||
"thread.jump.\(index)",
|
||||
input: String(index),
|
||||
modifiers: .command,
|
||||
action: #selector(jumpToThread(_:)),
|
||||
title: "Go to Thread \(index)"
|
||||
)
|
||||
}
|
||||
}
|
||||
return commands
|
||||
}
|
||||
|
||||
func setEnabledCommands(_ commands: [String]) {
|
||||
@@ -108,6 +135,14 @@ public final class T3KeyboardCommandsView: ExpoView {
|
||||
}
|
||||
|
||||
@objc private func newTask() { emit("newTask") }
|
||||
@objc private func openCommandPalette() { emit("commandPalette") }
|
||||
@objc private func paletteNext() { emit("paletteNext") }
|
||||
@objc private func palettePrevious() { emit("palettePrevious") }
|
||||
@objc private func paletteDismiss() { emit("paletteDismiss") }
|
||||
@objc private func jumpToThread(_ sender: UIKeyCommand) {
|
||||
guard let input = sender.input else { return }
|
||||
emit("thread.jump.\(input)")
|
||||
}
|
||||
@objc private func focusSearch() { emit("focusSearch") }
|
||||
@objc private func goBack() { emit("back") }
|
||||
@objc private func openFiles() { emit("files") }
|
||||
|
||||
@@ -38,6 +38,8 @@ void SplashScreen.preventAutoHideAsync().catch(() => {
|
||||
|
||||
const appLinking = {
|
||||
prefixes: [Linking.createURL("/"), "t3code://", "t3code-dev://", "t3code-preview://"],
|
||||
// Keep the compact thread list available beneath a directly opened thread.
|
||||
config: { initialRouteName: "Home" },
|
||||
// The Expo dev client launches the app via
|
||||
// <scheme>://expo-development-client/?url=<packager> — that URL addresses
|
||||
// the launcher, not app navigation. Without this filter it falls through
|
||||
|
||||
@@ -23,7 +23,10 @@ import { useConnectOnboardingNavigation } from "./features/cloud/connectOnboardi
|
||||
import { AttachmentFileScreen } from "./features/files/AttachmentFileScreen";
|
||||
import { ThreadFilesTreeScreen, ThreadFileScreen } from "./features/files/ThreadFilesRouteScreen";
|
||||
import { AdaptiveWorkspaceLayout } from "./features/layout/AdaptiveWorkspaceLayout";
|
||||
import { HardwareKeyboardCommandProvider } from "./features/keyboard/HardwareKeyboardCommandProvider";
|
||||
import {
|
||||
HardwareKeyboardCommandOverlay,
|
||||
HardwareKeyboardCommandProvider,
|
||||
} from "./features/keyboard/HardwareKeyboardCommandProvider";
|
||||
import { ReviewCommentComposerSheet } from "./features/review/ReviewCommentComposerSheet";
|
||||
import { ReviewSheet } from "./features/review/ReviewSheet";
|
||||
import { ThreadTerminalRouteScreen } from "./features/terminal/ThreadTerminalRouteScreen";
|
||||
@@ -56,6 +59,7 @@ import { SettingsClientStorageRouteScreen } from "./features/settings/SettingsCl
|
||||
import { SettingsDiagnosticsRouteScreen } from "./features/diagnostics/SettingsDiagnosticsRouteScreen";
|
||||
import { SettingsAuthRouteScreen } from "./features/settings/SettingsAuthRouteScreen";
|
||||
import { SettingsEnvironmentsRouteScreen } from "./features/settings/SettingsEnvironmentsRouteScreen";
|
||||
import { SettingsKeyboardRouteScreen } from "./features/settings/SettingsKeyboardRouteScreen";
|
||||
import { SettingsLegalRouteScreen } from "./features/settings/SettingsLegalRouteScreen";
|
||||
import {
|
||||
SettingsOpenSourceLicenseRouteScreen,
|
||||
@@ -192,6 +196,13 @@ const SettingsContentStack = createNativeStackNavigator({
|
||||
title: "Project Grouping",
|
||||
},
|
||||
}),
|
||||
SettingsKeyboard: createNativeStackScreen({
|
||||
screen: SettingsKeyboardRouteScreen,
|
||||
linking: "keyboard",
|
||||
options: {
|
||||
title: "Keyboard",
|
||||
},
|
||||
}),
|
||||
SettingsClientStorage: createNativeStackScreen({
|
||||
screen: SettingsClientStorageRouteScreen,
|
||||
linking: "client-storage",
|
||||
@@ -381,17 +392,20 @@ const WORKSPACE_OVERLAY_ROUTES = new Set([
|
||||
]);
|
||||
|
||||
/**
|
||||
* Pathname of the topmost NON-overlay route — the screen the workspace is
|
||||
* actually "on", regardless of any sheets floating above it.
|
||||
* Location of the topmost non-overlay route, including its key so thread
|
||||
* selection can dismiss sheets without replacing the wrong destination.
|
||||
*/
|
||||
function workspacePathFromState(state: NavigationState): string {
|
||||
function workspaceLocationFromState(state: NavigationState) {
|
||||
const routes = state.routes.filter((route) => !WORKSPACE_OVERLAY_ROUTES.has(route.name));
|
||||
const effectiveState =
|
||||
routes.length > 0 && routes.length !== state.routes.length
|
||||
? ({ ...state, routes, index: routes.length - 1 } as NavigationState)
|
||||
: state;
|
||||
const path = getPathFromState(effectiveState, navigationPathConfig);
|
||||
return path.startsWith("/") ? path : `/${path}`;
|
||||
return {
|
||||
pathname: path.startsWith("/") ? path : `/${path}`,
|
||||
routeKey: effectiveState.routes[effectiveState.index]?.key,
|
||||
};
|
||||
}
|
||||
|
||||
// The drain hook subscribes to the outbox, all thread shells, projects, and
|
||||
@@ -435,15 +449,19 @@ function RootStackLayout(props: {
|
||||
// workspace layout only reacts to the underlying non-overlay route.
|
||||
const path = getPathFromState(props.state, navigationPathConfig);
|
||||
const pathname = path.startsWith("/") ? path : `/${path}`;
|
||||
const workspacePathname = workspacePathFromState(props.state);
|
||||
const workspaceLocation = workspaceLocationFromState(props.state);
|
||||
|
||||
return (
|
||||
<HardwareKeyboardCommandProvider pathname={pathname}>
|
||||
<ThreadOutboxDrainWorker />
|
||||
<ShowcaseCaptureCoordinator pathname={pathname} />
|
||||
<ExistingThreadSettingsRouteProvider>
|
||||
<AdaptiveWorkspaceLayout pathname={workspacePathname}>
|
||||
<AdaptiveWorkspaceLayout
|
||||
pathname={workspaceLocation.pathname}
|
||||
workspaceRouteKey={workspaceLocation.routeKey}
|
||||
>
|
||||
{props.children}
|
||||
<HardwareKeyboardCommandOverlay />
|
||||
</AdaptiveWorkspaceLayout>
|
||||
</ExistingThreadSettingsRouteProvider>
|
||||
</HardwareKeyboardCommandProvider>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { ComposerContextId } from "@t3tools/contracts";
|
||||
import { useAtomValue } from "@effect/atom-react";
|
||||
import { AsyncResult } from "effect/unstable/reactivity";
|
||||
import { useEffect, useMemo, useRef, useState } from "react";
|
||||
import { Alert } from "react-native";
|
||||
import type { EnvironmentId } from "@t3tools/contracts";
|
||||
@@ -19,6 +21,7 @@ import {
|
||||
useComposerDraft,
|
||||
} from "../state/use-composer-drafts";
|
||||
import { importComposerContextClipboard } from "../lib/composerContextClipboard";
|
||||
import { mobilePreferencesAtom } from "../state/preferences";
|
||||
import { ComposerContextSheet } from "./ComposerContextSheet";
|
||||
import { AppText as Text } from "./AppText";
|
||||
import {
|
||||
@@ -53,6 +56,10 @@ export function ComposerEditor({
|
||||
...props
|
||||
}: ComposerEditorProps) {
|
||||
const draft = useComposerDraft(draftKey ?? null);
|
||||
const preferencesResult = useAtomValue(mobilePreferencesAtom);
|
||||
const preferredEnterBehavior = AsyncResult.isSuccess(preferencesResult)
|
||||
? preferencesResult.value.composerEnterBehavior
|
||||
: undefined;
|
||||
const contextHistory = useMemo(() => createComposerDraftContextHistory(), [draftKey]);
|
||||
useEffect(() => () => contextHistory.dispose(), [contextHistory]);
|
||||
const changeText = (text: string) => {
|
||||
@@ -158,6 +165,7 @@ export function ComposerEditor({
|
||||
<>
|
||||
<NativeComposerEditor
|
||||
{...props}
|
||||
enterBehavior={props.enterBehavior ?? preferredEnterBehavior}
|
||||
onChangeText={changeText}
|
||||
readOnly={props.readOnly || importing}
|
||||
onSubmit={importing ? undefined : props.onSubmit}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
import type { ComponentProps, ReactNode } from "react";
|
||||
import { Pressable, View } from "react-native";
|
||||
import { GestureDetector } from "react-native-gesture-handler";
|
||||
|
||||
import { cn } from "../lib/cn";
|
||||
import { useHoverGesture } from "../lib/useHoverGesture";
|
||||
|
||||
/** Shared row feedback, layered over the background so selection stays visible. */
|
||||
export function RowPressable({
|
||||
children,
|
||||
className,
|
||||
interactionClassName = "bg-primary",
|
||||
...props
|
||||
}: Omit<ComponentProps<typeof Pressable>, "children"> & {
|
||||
readonly children: ReactNode;
|
||||
readonly interactionClassName?: string;
|
||||
}) {
|
||||
const { hovered, hoverGesture } = useHoverGesture(props.disabled ?? false);
|
||||
return (
|
||||
<GestureDetector gesture={hoverGesture}>
|
||||
<Pressable {...props} className={cn("relative overflow-hidden", className)}>
|
||||
{({ pressed }) => (
|
||||
<>
|
||||
<View
|
||||
pointerEvents="none"
|
||||
className={cn("absolute inset-0", interactionClassName)}
|
||||
style={{ opacity: props.disabled ? 0 : pressed ? 0.2 : hovered ? 0.1 : 0 }}
|
||||
/>
|
||||
{children}
|
||||
</>
|
||||
)}
|
||||
</Pressable>
|
||||
</GestureDetector>
|
||||
);
|
||||
}
|
||||
@@ -37,6 +37,7 @@ import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass";
|
||||
import { mobilePreferencesAtom, updateMobilePreferencesAtom } from "../../state/preferences";
|
||||
import { useThreadSearch } from "../../state/queries";
|
||||
import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
|
||||
import { useThreadJumpShortcuts } from "../keyboard/threadKeyboardShortcuts";
|
||||
import { useThreadListV2Enabled } from "../threads/use-thread-list-v2-enabled";
|
||||
import { usePendingThreadOrder } from "../../state/thread-order";
|
||||
import { environmentServerConfigsAtom } from "../../state/server";
|
||||
@@ -775,6 +776,11 @@ export function HomeScreen(props: HomeScreenProps) {
|
||||
[settledShelfExpanded, snoozedShelfExpanded, threadListV2Layout, v2PendingTasks],
|
||||
);
|
||||
|
||||
useThreadJumpShortcuts(
|
||||
threadListV2Enabled ? threadListV2Items : listLayout.items,
|
||||
props.onSelectThread,
|
||||
);
|
||||
|
||||
const renderV2Item = useCallback(
|
||||
({ item, index }: { readonly item: ThreadListV2ListItem; readonly index: number }) => {
|
||||
const nextItem = threadListV2Items[index + 1];
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
type HomeListItem,
|
||||
} from "./homeListItems";
|
||||
import type { HomeThreadGroup } from "./homeThreadList";
|
||||
import { threadJumpTarget } from "../keyboard/threadKeyboardShortcuts";
|
||||
|
||||
const environmentId = EnvironmentId.make("environment-1");
|
||||
|
||||
@@ -87,6 +88,28 @@ function displayStates(
|
||||
return new Map(Object.entries(entries));
|
||||
}
|
||||
|
||||
describe("threadJumpTarget", () => {
|
||||
it("numbers only displayed threads across groups, skipping collapsed groups and pagination rows", () => {
|
||||
const layout = buildHomeListLayout({
|
||||
groups: [makeGroup("collapsed", 3), makeGroup("alpha", 8), makeGroup("beta", 3)],
|
||||
displayStates: displayStates({ collapsed: { collapsed: true, visibleCount: 6 } }),
|
||||
});
|
||||
expect(threadJumpTarget(layout.items, "thread.jump.1")?.id).toBe("alpha-thread-0");
|
||||
expect(threadJumpTarget(layout.items, "thread.jump.7")?.id).toBe("beta-thread-0");
|
||||
expect(threadJumpTarget(layout.items, "thread.jump.9")?.id).toBe("beta-thread-2");
|
||||
});
|
||||
|
||||
it("ignores missing positions and unrelated commands", () => {
|
||||
const layout = buildHomeListLayout({
|
||||
groups: [makeGroup("alpha", 1)],
|
||||
displayStates: displayStates({}),
|
||||
});
|
||||
expect(threadJumpTarget(layout.items, "thread.jump.2")).toBeNull();
|
||||
expect(threadJumpTarget([], "thread.jump.1")).toBeNull();
|
||||
expect(threadJumpTarget(layout.items, "commandPalette")).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("buildHomeListLayout", () => {
|
||||
it("renders a header plus all threads for a small group without a show-more row", () => {
|
||||
const layout = buildHomeListLayout({
|
||||
|
||||
@@ -0,0 +1,472 @@
|
||||
import { useNavigation } from "@react-navigation/native";
|
||||
import type { EnvironmentThreadSearchMatch } from "@t3tools/client-runtime/state/thread-search";
|
||||
import { THREAD_JUMP_KEYBINDING_COMMANDS } from "@t3tools/contracts";
|
||||
import { threadPullRequestSearchTerms } from "@t3tools/shared/threadPullRequests";
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import {
|
||||
FlatList,
|
||||
KeyboardAvoidingView,
|
||||
Modal,
|
||||
Pressable,
|
||||
TextInput,
|
||||
useWindowDimensions,
|
||||
View,
|
||||
} from "react-native";
|
||||
|
||||
import { GestureHandlerRootView } from "react-native-gesture-handler";
|
||||
|
||||
import { RowPressable } from "../../components/RowPressable";
|
||||
import { AppText as Text } from "../../components/AppText";
|
||||
import { SymbolView, type AppSymbolName } from "../../components/AppSymbol";
|
||||
import { GlassSurface } from "../../components/GlassSurface";
|
||||
import { scopedProjectKey, scopedThreadKey } from "../../lib/scopedEntities";
|
||||
import { T3KeyboardCommands } from "../../native/T3KeyboardCommands";
|
||||
import { useProjects, useThreadShell, useThreadShells } from "../../state/entities";
|
||||
import { useThreadSearch } from "../../state/queries";
|
||||
import { useWorkspaceState } from "../../state/workspace";
|
||||
import { useSavedRemoteConnections } from "../../state/use-remote-environment-registry";
|
||||
import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
|
||||
import { ThreadSearchMatchExcerpt } from "../threads/thread-search-match";
|
||||
import {
|
||||
filterCommandPaletteItems,
|
||||
nextPaletteIndex,
|
||||
type CommandPaletteItem,
|
||||
} from "./commandPaletteItems";
|
||||
import { parseActiveThreadPath, type HardwareKeyboardCommand } from "./hardwareKeyboardCommands";
|
||||
import { threadJumpIndex } from "./threadKeyboardShortcuts";
|
||||
|
||||
const PALETTE_COMMANDS: ReadonlyArray<HardwareKeyboardCommand> = [
|
||||
"commandPalette",
|
||||
"paletteDismiss",
|
||||
"paletteNext",
|
||||
"palettePrevious",
|
||||
...THREAD_JUMP_KEYBINDING_COMMANDS,
|
||||
];
|
||||
const ROW_HEIGHT = 50;
|
||||
|
||||
const ACTION_ICONS: Record<string, AppSymbolName> = {
|
||||
newTask: "square.and.pencil",
|
||||
newThread: "square.and.pencil",
|
||||
addProject: "folder.badge.plus",
|
||||
settings: "gearshape",
|
||||
appearance: "paintbrush",
|
||||
environments: "desktopcomputer",
|
||||
usage: "chart.bar.xaxis",
|
||||
archive: "archivebox",
|
||||
files: "doc.text",
|
||||
terminal: "terminal",
|
||||
review: "arrow.triangle.pull",
|
||||
copyThreadReference: "link",
|
||||
};
|
||||
|
||||
function itemIcon(item: CommandPaletteItem): AppSymbolName {
|
||||
if (item.kind === "project") return "folder";
|
||||
if (item.kind === "thread") return "text.bubble";
|
||||
return ACTION_ICONS[item.key] ?? "ellipsis";
|
||||
}
|
||||
|
||||
function PaletteRow(props: {
|
||||
readonly item: CommandPaletteItem;
|
||||
readonly index: number;
|
||||
readonly selected: boolean;
|
||||
readonly searchMatch?: EnvironmentThreadSearchMatch;
|
||||
readonly searchQuery: string;
|
||||
readonly onSelect: () => void;
|
||||
}) {
|
||||
return (
|
||||
<RowPressable
|
||||
accessibilityRole="button"
|
||||
accessibilityState={{ selected: props.selected }}
|
||||
onPress={props.onSelect}
|
||||
className={
|
||||
props.selected
|
||||
? "mx-2 flex-row items-center gap-3 rounded-xl bg-primary/10 px-3"
|
||||
: "mx-2 flex-row items-center gap-3 rounded-xl px-3"
|
||||
}
|
||||
style={{ height: ROW_HEIGHT }}
|
||||
>
|
||||
<View className="w-7 items-center">
|
||||
<SymbolView name={itemIcon(props.item)} size={20} tintColorClassName="accent-icon" />
|
||||
</View>
|
||||
<View className="flex-1">
|
||||
<Text numberOfLines={1} className="text-base">
|
||||
{props.item.title}
|
||||
</Text>
|
||||
{props.searchMatch ? (
|
||||
<ThreadSearchMatchExcerpt match={props.searchMatch} query={props.searchQuery} compact />
|
||||
) : props.item.detail ? (
|
||||
<Text numberOfLines={1} className="text-sm text-foreground-muted">
|
||||
{props.item.detail}
|
||||
</Text>
|
||||
) : null}
|
||||
</View>
|
||||
{props.index < 9 ? (
|
||||
<Text className="text-sm text-foreground-muted">⌘{props.index + 1}</Text>
|
||||
) : null}
|
||||
</RowPressable>
|
||||
);
|
||||
}
|
||||
|
||||
/** Mounted only while open, so the app root does not subscribe to the full thread catalog. */
|
||||
export function CommandPalette(props: {
|
||||
readonly pathname: string;
|
||||
readonly onClose: () => void;
|
||||
readonly onCommand: (command: HardwareKeyboardCommand) => void;
|
||||
}) {
|
||||
const navigation = useNavigation();
|
||||
const { selectThread } = useAdaptiveWorkspaceLayout();
|
||||
const runCommand = props.onCommand;
|
||||
const projects = useProjects();
|
||||
const threads = useThreadShells();
|
||||
const activeThreadRef = useMemo(() => parseActiveThreadPath(props.pathname), [props.pathname]);
|
||||
const activeThread = useThreadShell(activeThreadRef);
|
||||
const { environments } = useWorkspaceState();
|
||||
const { savedConnectionsById } = useSavedRemoteConnections();
|
||||
const [query, setQuery] = useState("");
|
||||
const [selection, setSelection] = useState<string | null>(null);
|
||||
const [visible, setVisible] = useState(true);
|
||||
const pendingAction = useRef<(() => void) | null>(null);
|
||||
const closing = useRef(false);
|
||||
const inputRef = useRef<TextInput>(null);
|
||||
const listRef = useRef<FlatList<CommandPaletteItem>>(null);
|
||||
const { width, height } = useWindowDimensions();
|
||||
const searchEnvironmentIds = useMemo(
|
||||
() =>
|
||||
environments
|
||||
.filter((environment) => environment.connectionState === "connected")
|
||||
.map((environment) => environment.environmentId),
|
||||
[environments],
|
||||
);
|
||||
const search = useThreadSearch(searchEnvironmentIds, query.startsWith(">") ? "" : query);
|
||||
const matchedThreadKeys = useMemo(
|
||||
() =>
|
||||
new Set(search.matches.map((match) => scopedThreadKey(match.environmentId, match.threadId))),
|
||||
[search.matches],
|
||||
);
|
||||
const contentMatchByKey = useMemo(
|
||||
() =>
|
||||
new Map(
|
||||
search.matches
|
||||
.filter((match) => match.source === "user" || match.source === "assistant")
|
||||
.map((match) => [scopedThreadKey(match.environmentId, match.threadId), match]),
|
||||
),
|
||||
[search.matches],
|
||||
);
|
||||
const items = useMemo(() => {
|
||||
const actions: CommandPaletteItem[] = [
|
||||
{
|
||||
key: "newTask",
|
||||
kind: "action",
|
||||
title: "New thread in…",
|
||||
searchTerms: ["new task", "chat", "create", "project"],
|
||||
run: () => navigation.navigate("NewTaskSheet", { screen: "NewTask" }),
|
||||
},
|
||||
{
|
||||
key: "addProject",
|
||||
kind: "action",
|
||||
title: "Add project",
|
||||
searchTerms: ["folder", "clone", "repository", "git"],
|
||||
run: () => navigation.navigate("NewTaskSheet", { screen: "AddProject" }),
|
||||
},
|
||||
{
|
||||
key: "settings",
|
||||
kind: "action",
|
||||
title: "Open settings",
|
||||
searchTerms: ["preferences", "configuration"],
|
||||
run: () =>
|
||||
navigation.navigate("SettingsSheet", {
|
||||
screen: "SettingsContent",
|
||||
params: { screen: "Settings" },
|
||||
}),
|
||||
},
|
||||
{
|
||||
key: "appearance",
|
||||
kind: "action",
|
||||
title: "Appearance",
|
||||
searchTerms: ["theme", "colors", "dark", "light"],
|
||||
run: () =>
|
||||
navigation.navigate("SettingsSheet", {
|
||||
screen: "SettingsContent",
|
||||
params: { screen: "SettingsAppearance" },
|
||||
}),
|
||||
},
|
||||
{
|
||||
key: "environments",
|
||||
kind: "action",
|
||||
title: "Manage environments",
|
||||
searchTerms: ["connections", "server", "remote"],
|
||||
run: () =>
|
||||
navigation.navigate("SettingsSheet", {
|
||||
screen: "SettingsContent",
|
||||
params: { screen: "SettingsEnvironments" },
|
||||
}),
|
||||
},
|
||||
{
|
||||
key: "usage",
|
||||
kind: "action",
|
||||
title: "Usage",
|
||||
searchTerms: ["limits", "accounts", "quota"],
|
||||
run: () =>
|
||||
navigation.navigate("SettingsSheet", {
|
||||
screen: "SettingsContent",
|
||||
params: { screen: "SettingsUsage" },
|
||||
}),
|
||||
},
|
||||
{
|
||||
key: "archive",
|
||||
kind: "action",
|
||||
title: "Archived threads",
|
||||
searchTerms: ["restore", "history"],
|
||||
run: () =>
|
||||
navigation.navigate("SettingsSheet", {
|
||||
screen: "SettingsContent",
|
||||
params: { screen: "SettingsArchive" },
|
||||
}),
|
||||
},
|
||||
];
|
||||
const projectByKey = new Map(
|
||||
projects.map((project) => [scopedProjectKey(project.environmentId, project.id), project]),
|
||||
);
|
||||
const activeProject = activeThread
|
||||
? projectByKey.get(scopedProjectKey(activeThread.environmentId, activeThread.projectId))
|
||||
: null;
|
||||
if (activeProject) {
|
||||
actions.unshift({
|
||||
key: "newThread",
|
||||
kind: "action",
|
||||
title: `New thread in ${activeProject.title}`,
|
||||
searchTerms: ["new task", "chat", "create"],
|
||||
run: () =>
|
||||
navigation.navigate("NewTaskSheet", {
|
||||
screen: "NewTaskDraft",
|
||||
params: {
|
||||
environmentId: activeProject.environmentId,
|
||||
projectId: activeProject.id,
|
||||
title: activeProject.title,
|
||||
},
|
||||
}),
|
||||
});
|
||||
}
|
||||
if (activeThreadRef) {
|
||||
const threadActions = [
|
||||
["files", "Go to file", ["open", "files", "browse", "search"]],
|
||||
["terminal", "Open terminal", ["shell", "console"]],
|
||||
["review", "Review changes", ["diff", "git", "pull request"]],
|
||||
["copyThreadReference", "Copy PR link or thread ID", ["reference", "clipboard"]],
|
||||
] as const;
|
||||
actions.push(
|
||||
...threadActions.map(([command, title, searchTerms]) => ({
|
||||
key: command,
|
||||
kind: "action" as const,
|
||||
title,
|
||||
searchTerms,
|
||||
run: () => runCommand(command),
|
||||
})),
|
||||
);
|
||||
}
|
||||
const projectItems: CommandPaletteItem[] = projects.map((project) => ({
|
||||
key: `project:${scopedProjectKey(project.environmentId, project.id)}`,
|
||||
kind: "project",
|
||||
title: project.title,
|
||||
detail: `New thread · ${savedConnectionsById[project.environmentId]?.environmentLabel ?? project.environmentId}`,
|
||||
searchTerms: [project.workspaceRoot, "new thread", "project"],
|
||||
run: () =>
|
||||
navigation.navigate("NewTaskSheet", {
|
||||
screen: "NewTaskDraft",
|
||||
params: {
|
||||
environmentId: project.environmentId,
|
||||
projectId: project.id,
|
||||
title: project.title,
|
||||
},
|
||||
}),
|
||||
}));
|
||||
const threadItems: CommandPaletteItem[] = threads
|
||||
.filter((thread) => thread.archivedAt === null)
|
||||
.sort((left, right) =>
|
||||
(right.latestUserMessageAt ?? right.updatedAt).localeCompare(
|
||||
left.latestUserMessageAt ?? left.updatedAt,
|
||||
),
|
||||
)
|
||||
.map((thread) => {
|
||||
const project = projectByKey.get(scopedProjectKey(thread.environmentId, thread.projectId));
|
||||
const environment =
|
||||
savedConnectionsById[thread.environmentId]?.environmentLabel ?? thread.environmentId;
|
||||
return {
|
||||
key: scopedThreadKey(thread.environmentId, thread.id),
|
||||
kind: "thread",
|
||||
title: thread.title || "Untitled thread",
|
||||
detail: [project?.title, environment].filter(Boolean).join(" · "),
|
||||
searchTerms: [
|
||||
project?.title ?? "",
|
||||
environment,
|
||||
thread.branch ?? "",
|
||||
...threadPullRequestSearchTerms(thread),
|
||||
],
|
||||
run: () => selectThread(thread),
|
||||
};
|
||||
});
|
||||
return [...actions, ...projectItems, ...threadItems];
|
||||
}, [
|
||||
activeThread,
|
||||
activeThreadRef,
|
||||
navigation,
|
||||
projects,
|
||||
runCommand,
|
||||
savedConnectionsById,
|
||||
selectThread,
|
||||
threads,
|
||||
]);
|
||||
const results = useMemo(
|
||||
() => filterCommandPaletteItems(items, query, matchedThreadKeys),
|
||||
[items, matchedThreadKeys, query],
|
||||
);
|
||||
const selectedIndex = Math.max(
|
||||
0,
|
||||
results.findIndex((item) => item.key === selection),
|
||||
);
|
||||
const selectedKey = results[selectedIndex]?.key;
|
||||
useEffect(() => {
|
||||
if (selectedIndex === 0) {
|
||||
// Centering before the list measures its height scrolls half the first row out of view.
|
||||
listRef.current?.scrollToOffset({ offset: 0, animated: false });
|
||||
} else if (selectedKey !== undefined) {
|
||||
listRef.current?.scrollToIndex({ index: selectedIndex, animated: false, viewPosition: 0.5 });
|
||||
}
|
||||
}, [selectedIndex, selectedKey]);
|
||||
|
||||
const dismissed = useRef(false);
|
||||
const handleDismissed = useCallback(() => {
|
||||
if (dismissed.current) return;
|
||||
dismissed.current = true;
|
||||
// Present navigation sheets only after UIKit has dismissed this modal.
|
||||
props.onClose();
|
||||
pendingAction.current?.();
|
||||
}, [props]);
|
||||
|
||||
// iOS drops Modal onDismiss when the VC is dismissed mid-presentation (e.g.
|
||||
// ⌘K during the fade-in) or raced by another sheet — without a fallback the
|
||||
// palette stays mounted-but-invisible and ⌘K dead-ends on a stale open state.
|
||||
useEffect(() => {
|
||||
if (visible) return;
|
||||
const fallback = setTimeout(handleDismissed, 400);
|
||||
return () => clearTimeout(fallback);
|
||||
}, [visible, handleDismissed]);
|
||||
|
||||
function close(run?: () => void) {
|
||||
if (closing.current) return;
|
||||
closing.current = true;
|
||||
pendingAction.current = run ?? null;
|
||||
setVisible(false);
|
||||
}
|
||||
|
||||
function onCommand(command: HardwareKeyboardCommand) {
|
||||
if (command === "commandPalette" || command === "paletteDismiss") {
|
||||
close();
|
||||
} else if (command === "paletteNext" || command === "palettePrevious") {
|
||||
setSelection(
|
||||
results[nextPaletteIndex(selectedIndex, command === "paletteNext" ? 1 : -1, results.length)]
|
||||
?.key ?? null,
|
||||
);
|
||||
} else {
|
||||
const item = results[threadJumpIndex(command)];
|
||||
if (item) close(item.run);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Modal
|
||||
visible={visible}
|
||||
transparent
|
||||
animationType="fade"
|
||||
onShow={() => inputRef.current?.focus()}
|
||||
onRequestClose={() => close()}
|
||||
onDismiss={handleDismissed}
|
||||
>
|
||||
<GestureHandlerRootView className="flex-1">
|
||||
<T3KeyboardCommands enabledCommands={PALETTE_COMMANDS} onCommand={onCommand}>
|
||||
<KeyboardAvoidingView
|
||||
behavior="padding"
|
||||
className="flex-1 items-center justify-center p-4"
|
||||
>
|
||||
<Pressable
|
||||
className="absolute inset-0 bg-black/15"
|
||||
accessibilityLabel="Close command palette"
|
||||
onPress={() => close()}
|
||||
/>
|
||||
<GlassSurface
|
||||
accessibilityViewIsModal
|
||||
style={{
|
||||
width: Math.min(600, width - 32),
|
||||
height: Math.min(520, height - 80),
|
||||
borderRadius: 20,
|
||||
}}
|
||||
>
|
||||
<View className="px-3 pb-2.5 pt-3.5">
|
||||
<View className="h-[38px] flex-row items-center gap-1.5 pr-2.5 pl-[11px]">
|
||||
<SymbolView
|
||||
name="magnifyingglass"
|
||||
size={15}
|
||||
tintColorClassName="accent-foreground-muted"
|
||||
type="monochrome"
|
||||
/>
|
||||
<TextInput
|
||||
ref={inputRef}
|
||||
accessibilityLabel="Search commands, projects, and threads"
|
||||
placeholder="Search commands, projects, and threads…"
|
||||
placeholderTextColorClassName="accent-placeholder"
|
||||
autoCorrect={false}
|
||||
autoCapitalize="none"
|
||||
clearButtonMode="while-editing"
|
||||
className="h-[34px] flex-1 px-0 py-0 font-sans text-base text-foreground"
|
||||
value={query}
|
||||
onChangeText={(value) => {
|
||||
setQuery(value);
|
||||
setSelection(null);
|
||||
listRef.current?.scrollToOffset({ offset: 0, animated: false });
|
||||
}}
|
||||
returnKeyType="go"
|
||||
submitBehavior="submit"
|
||||
onSubmitEditing={() => {
|
||||
const item = results[selectedIndex];
|
||||
if (item) close(item.run);
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
<FlatList
|
||||
ref={listRef}
|
||||
data={results}
|
||||
extraData={selectedKey}
|
||||
keyboardShouldPersistTaps="handled"
|
||||
keyExtractor={(item) => item.key}
|
||||
getItemLayout={(_, index) => ({
|
||||
length: ROW_HEIGHT,
|
||||
offset: ROW_HEIGHT * index,
|
||||
index,
|
||||
})}
|
||||
contentContainerClassName="pb-2"
|
||||
ListEmptyComponent={
|
||||
<Text className="p-5 text-center text-foreground-muted">
|
||||
{search.isPending ? "Searching…" : "No results"}
|
||||
</Text>
|
||||
}
|
||||
renderItem={({ item, index }) => (
|
||||
<PaletteRow
|
||||
item={item}
|
||||
index={index}
|
||||
selected={item.key === selectedKey}
|
||||
searchMatch={
|
||||
item.kind === "thread" ? contentMatchByKey.get(item.key) : undefined
|
||||
}
|
||||
searchQuery={query}
|
||||
onSelect={() => close(item.run)}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</GlassSurface>
|
||||
</KeyboardAvoidingView>
|
||||
</T3KeyboardCommands>
|
||||
</GestureHandlerRootView>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
import { StackActions, useNavigation } from "@react-navigation/native";
|
||||
import { resolveThreadReferenceCopyTarget } from "@t3tools/shared/threadReference";
|
||||
import {
|
||||
createContext,
|
||||
use,
|
||||
useCallback,
|
||||
useEffect,
|
||||
useMemo,
|
||||
@@ -8,6 +10,7 @@ import {
|
||||
useState,
|
||||
useSyncExternalStore,
|
||||
type PropsWithChildren,
|
||||
type ReactNode,
|
||||
} from "react";
|
||||
|
||||
import { tryCopyTextWithHaptic } from "../../lib/copyTextWithHaptic";
|
||||
@@ -15,6 +18,7 @@ import { T3KeyboardCommands } from "../../native/T3KeyboardCommands";
|
||||
import { useThreadShell } from "../../state/entities";
|
||||
import type { GitActionProgress } from "../../state/use-vcs-action-state";
|
||||
import { GitActionProgressOverlay } from "../threads/GitActionProgressOverlay";
|
||||
import { CommandPalette } from "./CommandPalette";
|
||||
import {
|
||||
dispatchHardwareKeyboardCommand,
|
||||
getHardwareKeyboardCommandRegistrationVersion,
|
||||
@@ -31,11 +35,20 @@ const EMPTY_COPY_FEEDBACK: GitActionProgress = {
|
||||
};
|
||||
const COPY_FEEDBACK_DISMISS_MS = 3_000;
|
||||
|
||||
const CommandPaletteContext = createContext<ReactNode>(null);
|
||||
|
||||
/** Render inside the workspace so palette actions share its navigation and pane state. */
|
||||
export function HardwareKeyboardCommandOverlay() {
|
||||
return use(CommandPaletteContext);
|
||||
}
|
||||
|
||||
export function HardwareKeyboardCommandProvider({
|
||||
children,
|
||||
pathname,
|
||||
}: PropsWithChildren<{ readonly pathname: string }>) {
|
||||
const navigation = useNavigation();
|
||||
const [paletteOpen, setPaletteOpen] = useState(false);
|
||||
const closePalette = useCallback(() => setPaletteOpen(false), []);
|
||||
const activeThreadRef = useMemo(() => parseActiveThreadPath(pathname), [pathname]);
|
||||
const activeThread = useThreadShell(activeThreadRef);
|
||||
const copyTarget = useMemo(
|
||||
@@ -86,6 +99,12 @@ export function HardwareKeyboardCommandProvider({
|
||||
const enabledCommands = useMemo(() => {
|
||||
const commands = new Set<HardwareKeyboardCommand>(getRegisteredHardwareKeyboardCommands());
|
||||
commands.add("newTask");
|
||||
commands.add("commandPalette");
|
||||
if (pathname !== "/" && !pathname.startsWith("/threads/")) {
|
||||
for (const command of commands) {
|
||||
if (command.startsWith("thread.jump.")) commands.delete(command);
|
||||
}
|
||||
}
|
||||
if (pathname !== "/" || navigation.canGoBack()) commands.add("back");
|
||||
if (activeThreadRef !== null) {
|
||||
commands.add("files");
|
||||
@@ -94,10 +113,14 @@ export function HardwareKeyboardCommandProvider({
|
||||
if (pathname.split("/")[4] !== "terminal") commands.add("copyThreadReference");
|
||||
}
|
||||
return [...commands];
|
||||
}, [pathname, registrationVersion, navigation]);
|
||||
}, [activeThreadRef, pathname, registrationVersion, navigation]);
|
||||
|
||||
const onCommand = useCallback(
|
||||
(command: HardwareKeyboardCommand) => {
|
||||
if (command === "commandPalette") {
|
||||
setPaletteOpen(true);
|
||||
return;
|
||||
}
|
||||
if (dispatchHardwareKeyboardCommand(command)) return;
|
||||
|
||||
if (command === "copyThreadReference") {
|
||||
@@ -152,12 +175,20 @@ export function HardwareKeyboardCommandProvider({
|
||||
[copyTarget, navigation, pathname, showCopyFeedback],
|
||||
);
|
||||
|
||||
const palette = useMemo(
|
||||
() =>
|
||||
paletteOpen ? (
|
||||
<CommandPalette pathname={pathname} onClose={closePalette} onCommand={onCommand} />
|
||||
) : null,
|
||||
[closePalette, onCommand, paletteOpen, pathname],
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<CommandPaletteContext value={palette}>
|
||||
<T3KeyboardCommands enabledCommands={enabledCommands} onCommand={onCommand}>
|
||||
{children}
|
||||
</T3KeyboardCommands>
|
||||
<GitActionProgressOverlay progress={copyFeedback} onDismiss={dismissCopyFeedback} />
|
||||
</>
|
||||
</CommandPaletteContext>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import {
|
||||
filterCommandPaletteItems,
|
||||
nextPaletteIndex,
|
||||
type CommandPaletteItem,
|
||||
} from "./commandPaletteItems";
|
||||
|
||||
function item(
|
||||
key: string,
|
||||
title: string,
|
||||
kind: CommandPaletteItem["kind"],
|
||||
searchTerms: string[] = [],
|
||||
): CommandPaletteItem {
|
||||
return { key, title, kind, searchTerms, run: () => {} };
|
||||
}
|
||||
|
||||
const items = [
|
||||
item("new", "New thread in…", "action", ["project", "create"]),
|
||||
item("settings", "Open settings", "action", ["preferences"]),
|
||||
item("project", "Mobile app", "project", ["/workspaces/mobile", "new thread"]),
|
||||
item("siva:one", "Keyboard shortcuts", "thread", ["Mobile app", "Siva"]),
|
||||
item("mac:one", "Mobile app", "thread", ["Mac"]),
|
||||
];
|
||||
const emptyMatches = new Set<string>();
|
||||
|
||||
describe("filterCommandPaletteItems", () => {
|
||||
it("shows actions and recent threads in their original order when the query is empty", () => {
|
||||
expect(filterCommandPaletteItems(items, "", emptyMatches).map((item) => item.key)).toEqual([
|
||||
"new",
|
||||
"settings",
|
||||
"siva:one",
|
||||
"mac:one",
|
||||
]);
|
||||
});
|
||||
|
||||
it("matches query tokens across titles and metadata and ranks exact titles first", () => {
|
||||
expect(
|
||||
filterCommandPaletteItems(items, " MOBILE app ", emptyMatches).map((item) => item.key),
|
||||
).toEqual(["project", "mac:one", "siva:one"]);
|
||||
expect(
|
||||
filterCommandPaletteItems(items, "siva keyboard", emptyMatches).map((item) => item.key),
|
||||
).toEqual(["siva:one"]);
|
||||
});
|
||||
|
||||
it("supports the desktop actions-only prefix and action aliases", () => {
|
||||
expect(filterCommandPaletteItems(items, ">", emptyMatches).map((item) => item.key)).toEqual([
|
||||
"new",
|
||||
"settings",
|
||||
]);
|
||||
expect(
|
||||
filterCommandPaletteItems(items, "> preferences", emptyMatches).map((item) => item.key),
|
||||
).toEqual(["settings"]);
|
||||
expect(
|
||||
filterCommandPaletteItems(items, "> new thread", emptyMatches).map((item) => item.key),
|
||||
).toEqual(["new"]);
|
||||
});
|
||||
|
||||
it("includes server content matches scoped to the correct environment, except in actions-only mode", () => {
|
||||
const matches = new Set(["siva:one", "project"]);
|
||||
expect(
|
||||
filterCommandPaletteItems(items, "message content", matches).map((item) => item.key),
|
||||
).toEqual(["siva:one"]);
|
||||
expect(filterCommandPaletteItems(items, "> message content", matches)).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("nextPaletteIndex", () => {
|
||||
it("wraps arrow navigation in both directions and handles empty results", () => {
|
||||
expect(nextPaletteIndex(0, -1, 3)).toBe(2);
|
||||
expect(nextPaletteIndex(2, 1, 3)).toBe(0);
|
||||
expect(nextPaletteIndex(0, 1, 3)).toBe(1);
|
||||
expect(nextPaletteIndex(0, -1, 0)).toBe(0);
|
||||
expect(nextPaletteIndex(0, 1, 0)).toBe(0);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,46 @@
|
||||
export interface CommandPaletteItem {
|
||||
readonly key: string;
|
||||
readonly kind: "action" | "project" | "thread";
|
||||
readonly title: string;
|
||||
readonly detail?: string;
|
||||
readonly searchTerms: ReadonlyArray<string>;
|
||||
readonly run: () => void;
|
||||
}
|
||||
|
||||
/** `>` narrows to actions, matching the desktop palette. Stable ties retain recent-thread order. */
|
||||
export function filterCommandPaletteItems(
|
||||
items: ReadonlyArray<CommandPaletteItem>,
|
||||
query: string,
|
||||
matchedThreadKeys: ReadonlySet<string>,
|
||||
) {
|
||||
const actionsOnly = query.startsWith(">");
|
||||
const normalized = (actionsOnly ? query.slice(1) : query).trim().toLocaleLowerCase();
|
||||
const tokens = normalized.split(/\s+/);
|
||||
return items
|
||||
.flatMap((item, index) => {
|
||||
if (actionsOnly && item.kind !== "action") return [];
|
||||
if (!normalized) return item.kind === "project" ? [] : [{ item, rank: 0, index }];
|
||||
const title = item.title.toLocaleLowerCase();
|
||||
const haystack = [title, ...item.searchTerms].join(" ").toLocaleLowerCase();
|
||||
if (
|
||||
!tokens.every((token) => haystack.includes(token)) &&
|
||||
!(item.kind === "thread" && matchedThreadKeys.has(item.key))
|
||||
)
|
||||
return [];
|
||||
const rank =
|
||||
title === normalized
|
||||
? 3
|
||||
: title.startsWith(normalized)
|
||||
? 2
|
||||
: title.includes(normalized)
|
||||
? 1
|
||||
: 0;
|
||||
return [{ item, rank, index }];
|
||||
})
|
||||
.sort((left, right) => right.rank - left.rank || left.index - right.index)
|
||||
.map(({ item }) => item);
|
||||
}
|
||||
|
||||
export function nextPaletteIndex(index: number, direction: -1 | 1, count: number) {
|
||||
return count === 0 ? 0 : (index + direction + count) % count;
|
||||
}
|
||||
@@ -1,7 +1,12 @@
|
||||
import { EnvironmentId, ThreadId } from "@t3tools/contracts";
|
||||
import { EnvironmentId, ThreadId, type ThreadJumpKeybindingCommand } from "@t3tools/contracts";
|
||||
import { useEffect } from "react";
|
||||
|
||||
export type HardwareKeyboardCommand =
|
||||
| ThreadJumpKeybindingCommand
|
||||
| "commandPalette"
|
||||
| "paletteNext"
|
||||
| "palettePrevious"
|
||||
| "paletteDismiss"
|
||||
| "newTask"
|
||||
| "focusSearch"
|
||||
| "back"
|
||||
@@ -11,7 +16,7 @@ export type HardwareKeyboardCommand =
|
||||
| "copyThreadReference"
|
||||
| "toggleSidebar";
|
||||
|
||||
type CommandHandler = () => boolean | void;
|
||||
type CommandHandler = (command: HardwareKeyboardCommand) => boolean | void;
|
||||
|
||||
const handlers = new Map<HardwareKeyboardCommand, Set<CommandHandler>>();
|
||||
const registrationListeners = new Set<() => void>();
|
||||
@@ -22,18 +27,24 @@ let registrationVersion = 0;
|
||||
* the first chance to consume the command, allowing focused screens to override app defaults.
|
||||
*/
|
||||
export function useHardwareKeyboardCommand(
|
||||
command: HardwareKeyboardCommand,
|
||||
command: HardwareKeyboardCommand | ReadonlyArray<HardwareKeyboardCommand>,
|
||||
handler: CommandHandler,
|
||||
): void {
|
||||
useEffect(() => {
|
||||
const commandHandlers = handlers.get(command) ?? new Set<CommandHandler>();
|
||||
commandHandlers.add(handler);
|
||||
handlers.set(command, commandHandlers);
|
||||
const commands = typeof command === "string" ? [command] : command;
|
||||
for (const command of commands) {
|
||||
const commandHandlers = handlers.get(command) ?? new Set<CommandHandler>();
|
||||
commandHandlers.add(handler);
|
||||
handlers.set(command, commandHandlers);
|
||||
}
|
||||
registrationVersion += 1;
|
||||
registrationListeners.forEach((listener) => listener());
|
||||
return () => {
|
||||
commandHandlers.delete(handler);
|
||||
if (commandHandlers.size === 0) handlers.delete(command);
|
||||
for (const command of commands) {
|
||||
const commandHandlers = handlers.get(command);
|
||||
commandHandlers?.delete(handler);
|
||||
if (commandHandlers?.size === 0) handlers.delete(command);
|
||||
}
|
||||
registrationVersion += 1;
|
||||
registrationListeners.forEach((listener) => listener());
|
||||
};
|
||||
@@ -58,7 +69,7 @@ export function dispatchHardwareKeyboardCommand(command: HardwareKeyboardCommand
|
||||
if (!commandHandlers) return false;
|
||||
// `.reverse()` on a copy, not `.toReversed()`: Hermes has no ES2023 array methods.
|
||||
for (const handler of [...commandHandlers].reverse()) {
|
||||
if (handler() !== false) return true;
|
||||
if (handler(command) !== false) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell";
|
||||
import { THREAD_JUMP_KEYBINDING_COMMANDS } from "@t3tools/contracts";
|
||||
import { useCallback } from "react";
|
||||
|
||||
import type { HomeListItem } from "../home/homeListItems";
|
||||
import type { ThreadListV2ListItem } from "../threads/threadListV2";
|
||||
import {
|
||||
useHardwareKeyboardCommand,
|
||||
type HardwareKeyboardCommand,
|
||||
} from "./hardwareKeyboardCommands";
|
||||
|
||||
type ThreadShortcutListItem =
|
||||
| HomeListItem
|
||||
| ThreadListV2ListItem
|
||||
| { readonly type: "v2-show-more" };
|
||||
|
||||
export function threadJumpIndex(command: HardwareKeyboardCommand) {
|
||||
return THREAD_JUMP_KEYBINDING_COMMANDS.findIndex((candidate) => candidate === command);
|
||||
}
|
||||
|
||||
/** Uses the rendered list so filters, collapsed groups and shelves keep their order. */
|
||||
export function threadJumpTarget(
|
||||
items: ReadonlyArray<ThreadShortcutListItem>,
|
||||
command: HardwareKeyboardCommand,
|
||||
) {
|
||||
let index = threadJumpIndex(command);
|
||||
if (index < 0) return null;
|
||||
for (const item of items) {
|
||||
const thread =
|
||||
item.type === "thread" ? item.thread : item.type === "v2-thread" ? item.item.thread : null;
|
||||
if (thread !== null && index-- === 0) return thread;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export function useThreadJumpShortcuts(
|
||||
items: ReadonlyArray<ThreadShortcutListItem>,
|
||||
onSelectThread: (thread: EnvironmentThreadShell) => void,
|
||||
) {
|
||||
const jumpToThread = useCallback(
|
||||
(command: HardwareKeyboardCommand) => {
|
||||
const thread = threadJumpTarget(items, command);
|
||||
if (thread !== null) onSelectThread(thread);
|
||||
return true;
|
||||
},
|
||||
[items, onSelectThread],
|
||||
);
|
||||
useHardwareKeyboardCommand(THREAD_JUMP_KEYBINDING_COMMANDS, jumpToThread);
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import { EnvironmentId, ThreadId, type SidebarProjectGroupingMode } from "@t3too
|
||||
import { useAtomValue } from "@effect/atom-react";
|
||||
import { useFocusEffect } from "@react-navigation/native";
|
||||
import {
|
||||
CommonActions,
|
||||
NavigationContext,
|
||||
NavigationRouteContext,
|
||||
StackActions,
|
||||
@@ -39,7 +40,10 @@ import {
|
||||
type WorkspaceAuxiliaryPaneRole,
|
||||
type WorkspacePaneLayout,
|
||||
} from "../../lib/layout";
|
||||
import { resolveThreadSelectionNavigationAction } from "../../lib/adaptive-navigation";
|
||||
import {
|
||||
resolveThreadSelectionNavigationAction,
|
||||
resolveThreadSelectionOverlayState,
|
||||
} from "../../lib/adaptive-navigation";
|
||||
import { scopedThreadKey } from "../../lib/scopedEntities";
|
||||
import { mobilePreferencesAtom } from "../../state/preferences";
|
||||
import {
|
||||
@@ -63,6 +67,7 @@ interface AdaptiveWorkspaceContextValue {
|
||||
readonly panes: WorkspacePaneLayout;
|
||||
readonly fileInspector: FileInspectorPaneLayout;
|
||||
readonly primarySidebarSearchQuery: string;
|
||||
readonly selectThread: (thread: EnvironmentThreadShell) => void;
|
||||
readonly activateAuxiliaryPaneRole: (role: WorkspaceAuxiliaryPaneRole) => () => void;
|
||||
/**
|
||||
* Route screens hand their inspector pane content to the workspace so it
|
||||
@@ -96,6 +101,7 @@ const AdaptiveWorkspaceContext = createContext<AdaptiveWorkspaceContextValue>({
|
||||
panes: compactPanes,
|
||||
fileInspector: compactFileInspector,
|
||||
primarySidebarSearchQuery: "",
|
||||
selectThread: () => undefined,
|
||||
activateAuxiliaryPaneRole: () => () => undefined,
|
||||
registerWorkspaceInspector: () => () => undefined,
|
||||
setPrimarySidebarSearchQuery: () => undefined,
|
||||
@@ -198,6 +204,7 @@ export function useRegisterWorkspaceInspector(render: (() => ReactNode) | undefi
|
||||
export function AdaptiveWorkspaceLayout(props: {
|
||||
readonly children: ReactNode;
|
||||
readonly pathname: string;
|
||||
readonly workspaceRouteKey: string | undefined;
|
||||
}) {
|
||||
const preferencesResult = useAtomValue(mobilePreferencesAtom);
|
||||
if (!AsyncResult.isSuccess(preferencesResult)) {
|
||||
@@ -221,6 +228,7 @@ function AdaptiveWorkspaceLayoutContent(
|
||||
props: {
|
||||
readonly children: ReactNode;
|
||||
readonly pathname: string;
|
||||
readonly workspaceRouteKey: string | undefined;
|
||||
} & {
|
||||
readonly projectGroupingMode: SidebarProjectGroupingMode;
|
||||
},
|
||||
@@ -408,35 +416,6 @@ function AdaptiveWorkspaceLayoutContent(
|
||||
},
|
||||
[auxiliaryPaneRole],
|
||||
);
|
||||
const contextValue = useMemo(
|
||||
() => ({
|
||||
layout,
|
||||
panes,
|
||||
fileInspector,
|
||||
primarySidebarSearchQuery,
|
||||
activateAuxiliaryPaneRole,
|
||||
registerWorkspaceInspector,
|
||||
setPrimarySidebarSearchQuery,
|
||||
showAuxiliaryPane,
|
||||
toggleAuxiliaryPane,
|
||||
togglePrimarySidebar,
|
||||
setAuxiliaryPaneWidth,
|
||||
}),
|
||||
[
|
||||
activateAuxiliaryPaneRole,
|
||||
fileInspector,
|
||||
layout,
|
||||
panes,
|
||||
primarySidebarSearchQuery,
|
||||
registerWorkspaceInspector,
|
||||
showAuxiliaryPane,
|
||||
setPrimarySidebarSearchQuery,
|
||||
setAuxiliaryPaneWidth,
|
||||
toggleAuxiliaryPane,
|
||||
togglePrimarySidebar,
|
||||
],
|
||||
);
|
||||
|
||||
const handleOpenSettings = useCallback(() => {
|
||||
navigation.navigate("SettingsSheet", {
|
||||
screen: "SettingsContent",
|
||||
@@ -526,6 +505,17 @@ function AdaptiveWorkspaceLayoutContent(
|
||||
usesSplitView: layout.usesSplitView,
|
||||
pathname,
|
||||
});
|
||||
const overlayState = resolveThreadSelectionOverlayState({
|
||||
state: navigation.getState(),
|
||||
workspaceRouteKey: props.workspaceRouteKey,
|
||||
action: navigationAction,
|
||||
params,
|
||||
});
|
||||
if (overlayState !== null) {
|
||||
setFileInspectorPreferredVisible(false);
|
||||
navigation.dispatch(CommonActions.reset(overlayState));
|
||||
return;
|
||||
}
|
||||
if (navigationAction === "set-params") {
|
||||
const nextThreadKey = scopedThreadKey(thread.environmentId, thread.id);
|
||||
if (nextThreadKey === selectedThreadKey) {
|
||||
@@ -542,7 +532,38 @@ function AdaptiveWorkspaceLayoutContent(
|
||||
}
|
||||
navigation.navigate("Thread", params);
|
||||
},
|
||||
[layout.usesSplitView, pathname, navigation, selectedThreadKey],
|
||||
[layout.usesSplitView, pathname, navigation, selectedThreadKey, props.workspaceRouteKey],
|
||||
);
|
||||
|
||||
const contextValue = useMemo(
|
||||
() => ({
|
||||
layout,
|
||||
panes,
|
||||
fileInspector,
|
||||
primarySidebarSearchQuery,
|
||||
selectThread: handleSelectThread,
|
||||
activateAuxiliaryPaneRole,
|
||||
registerWorkspaceInspector,
|
||||
setPrimarySidebarSearchQuery,
|
||||
showAuxiliaryPane,
|
||||
toggleAuxiliaryPane,
|
||||
togglePrimarySidebar,
|
||||
setAuxiliaryPaneWidth,
|
||||
}),
|
||||
[
|
||||
activateAuxiliaryPaneRole,
|
||||
fileInspector,
|
||||
handleSelectThread,
|
||||
layout,
|
||||
panes,
|
||||
primarySidebarSearchQuery,
|
||||
registerWorkspaceInspector,
|
||||
showAuxiliaryPane,
|
||||
setPrimarySidebarSearchQuery,
|
||||
setAuxiliaryPaneWidth,
|
||||
toggleAuxiliaryPane,
|
||||
togglePrimarySidebar,
|
||||
],
|
||||
);
|
||||
|
||||
return (
|
||||
|
||||
@@ -20,7 +20,6 @@ interface WorkspacePaneDividerProps {
|
||||
export function WorkspacePaneDivider(props: WorkspacePaneDividerProps) {
|
||||
const latestProps = useRef(props);
|
||||
latestProps.current = props;
|
||||
const [hovered, setHovered] = useState(false);
|
||||
const [dragging, setDragging] = useState(false);
|
||||
const handleResizeStart = useCallback(() => {
|
||||
setDragging(true);
|
||||
@@ -63,7 +62,7 @@ export function WorkspacePaneDivider(props: WorkspacePaneDividerProps) {
|
||||
return (
|
||||
<GestureDetector gesture={resizeGesture}>
|
||||
<Pressable
|
||||
className="relative z-[100] -mx-[22px] w-11 self-stretch cursor-pointer justify-center"
|
||||
className="relative z-[100] -mx-[22px] w-11 self-stretch justify-center"
|
||||
accessibilityActions={[
|
||||
{ name: "increment", label: "Make pane wider" },
|
||||
{ name: "decrement", label: "Make pane narrower" },
|
||||
@@ -75,15 +74,13 @@ export function WorkspacePaneDivider(props: WorkspacePaneDividerProps) {
|
||||
text: `${Math.round(props.currentWidth)} points wide`,
|
||||
}}
|
||||
onAccessibilityAction={handleAccessibilityAction}
|
||||
onHoverIn={() => setHovered(true)}
|
||||
onHoverOut={() => setHovered(false)}
|
||||
>
|
||||
<View
|
||||
className={cn(
|
||||
"h-full self-center bg-border opacity-70",
|
||||
hovered || dragging ? "w-0.5 bg-primary opacity-100" : "w-px",
|
||||
dragging ? "w-0.5 bg-primary opacity-100" : "w-px",
|
||||
)}
|
||||
style={[styles.line, (hovered || dragging) && styles.activeLine]}
|
||||
style={[styles.line, dragging && styles.activeLine]}
|
||||
/>
|
||||
</Pressable>
|
||||
</GestureDetector>
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
import { useAtomSet, useAtomValue } from "@effect/atom-react";
|
||||
import { useNavigation } from "@react-navigation/native";
|
||||
import { AsyncResult } from "effect/unstable/reactivity";
|
||||
import { Platform, Pressable, ScrollView, View } from "react-native";
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
|
||||
import { AndroidScreenHeader } from "../../components/AndroidScreenHeader";
|
||||
import { AppText as Text } from "../../components/AppText";
|
||||
import { SymbolView } from "../../components/AppSymbol";
|
||||
import { NativeStackScreenOptions } from "../../native/StackHeader";
|
||||
import {
|
||||
DEFAULT_COMPOSER_ENTER_BEHAVIOR,
|
||||
type ComposerEnterBehavior,
|
||||
} from "../../lib/composerEnterBehavior";
|
||||
import { mobilePreferencesAtom, updateMobilePreferencesAtom } from "../../state/preferences";
|
||||
import { SettingsSection } from "./components/SettingsSection";
|
||||
|
||||
const ENTER_BEHAVIOR_OPTIONS: ReadonlyArray<{
|
||||
readonly behavior: ComposerEnterBehavior;
|
||||
readonly label: string;
|
||||
readonly description: string;
|
||||
}> = [
|
||||
{
|
||||
behavior: "send",
|
||||
label: "Send message",
|
||||
description: "Return sends the message. Shift-Return inserts a new line.",
|
||||
},
|
||||
{
|
||||
behavior: "newline",
|
||||
label: "Insert new line",
|
||||
description: "Return inserts a new line. Command-Return sends the message.",
|
||||
},
|
||||
];
|
||||
|
||||
export function SettingsKeyboardRouteScreen() {
|
||||
const navigation = useNavigation();
|
||||
const insets = useSafeAreaInsets();
|
||||
const preferencesResult = useAtomValue(mobilePreferencesAtom);
|
||||
const savePreferences = useAtomSet(updateMobilePreferencesAtom);
|
||||
const preferencesReady = AsyncResult.isSuccess(preferencesResult) && !preferencesResult.waiting;
|
||||
const selectedBehavior = AsyncResult.isSuccess(preferencesResult)
|
||||
? (preferencesResult.value.composerEnterBehavior ?? DEFAULT_COMPOSER_ENTER_BEHAVIOR)
|
||||
: null;
|
||||
|
||||
return (
|
||||
<View collapsable={false} className="flex-1 bg-sheet">
|
||||
{Platform.OS === "android" ? (
|
||||
<>
|
||||
<NativeStackScreenOptions options={{ headerShown: false }} />
|
||||
<AndroidScreenHeader title="Keyboard" onBack={() => navigation.goBack()} />
|
||||
</>
|
||||
) : null}
|
||||
<ScrollView
|
||||
contentInsetAdjustmentBehavior="automatic"
|
||||
showsVerticalScrollIndicator={false}
|
||||
className="flex-1"
|
||||
contentContainerClassName="gap-3 px-5 pt-4"
|
||||
contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 18) + 18 }}
|
||||
>
|
||||
<SettingsSection title="Return key">
|
||||
{ENTER_BEHAVIOR_OPTIONS.map((option, index) => (
|
||||
<Pressable
|
||||
key={option.behavior}
|
||||
accessibilityRole="radio"
|
||||
accessibilityState={{
|
||||
checked: selectedBehavior === option.behavior,
|
||||
disabled: !preferencesReady,
|
||||
}}
|
||||
disabled={!preferencesReady}
|
||||
onPress={() => savePreferences({ composerEnterBehavior: option.behavior })}
|
||||
className={
|
||||
index === 0
|
||||
? "flex-row items-center gap-4 p-4"
|
||||
: "flex-row items-center gap-4 border-t border-border-subtle p-4"
|
||||
}
|
||||
>
|
||||
<View className="min-w-0 flex-1 gap-1">
|
||||
<Text className="text-lg text-foreground">{option.label}</Text>
|
||||
<Text className="text-sm leading-normal text-foreground-muted">
|
||||
{option.description}
|
||||
</Text>
|
||||
</View>
|
||||
{selectedBehavior === option.behavior ? (
|
||||
<SymbolView
|
||||
name="checkmark"
|
||||
size={18}
|
||||
tintColorClassName={"accent-icon"}
|
||||
type="monochrome"
|
||||
weight="semibold"
|
||||
/>
|
||||
) : null}
|
||||
</Pressable>
|
||||
))}
|
||||
</SettingsSection>
|
||||
<Text className="px-2 text-sm text-foreground-muted">
|
||||
Applies to the composer when a hardware keyboard is connected.
|
||||
</Text>
|
||||
</ScrollView>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -598,6 +598,9 @@ function GeneralSettingsSection() {
|
||||
return (
|
||||
<SettingsSection title="General">
|
||||
<SettingsRow icon="folder" label="Project Grouping" target="SettingsProjectGrouping" />
|
||||
{Platform.OS === "ios" ? (
|
||||
<SettingsRow icon="keyboard" label="Keyboard" target="SettingsKeyboard" />
|
||||
) : null}
|
||||
<AutoSettleSettingsRows />
|
||||
<SettingsRow icon="chart.bar.xaxis" label="Usage" target="SettingsUsage" />
|
||||
</SettingsSection>
|
||||
|
||||
@@ -2,6 +2,7 @@ export type SettingsSheetTarget =
|
||||
| "SettingsEnvironments"
|
||||
| "SettingsArchive"
|
||||
| "SettingsAppearance"
|
||||
| "SettingsKeyboard"
|
||||
| "SettingsProjectGrouping"
|
||||
| "SettingsClientStorage"
|
||||
| "SettingsDiagnostics"
|
||||
|
||||
@@ -1396,6 +1396,9 @@ export function NewTaskDraftScreen(props: {
|
||||
skills={composerMenu.skills}
|
||||
selection={composerMenu.selection}
|
||||
onChangeText={flow.setPrompt}
|
||||
onSubmit={() => {
|
||||
if (canStart) void handleStart();
|
||||
}}
|
||||
onSelectionChange={composerMenu.onSelectionChange}
|
||||
onFocus={() => setIsComposerFocused(true)}
|
||||
onBlur={() => setIsComposerFocused(false)}
|
||||
|
||||
@@ -38,6 +38,7 @@ import { useQueuedThreadKeys } from "../../state/use-thread-outbox";
|
||||
import { useWorkspaceState } from "../../state/workspace";
|
||||
import { useSavedRemoteConnections } from "../../state/use-remote-environment-registry";
|
||||
import { useHardwareKeyboardCommand } from "../keyboard/hardwareKeyboardCommands";
|
||||
import { useThreadJumpShortcuts } from "../keyboard/threadKeyboardShortcuts";
|
||||
import {
|
||||
hasCustomHomeListOptions,
|
||||
PROJECT_SORT_OPTIONS,
|
||||
@@ -801,6 +802,7 @@ function ThreadNavigationSidebarPane(
|
||||
threadSearchMatchByKey,
|
||||
],
|
||||
);
|
||||
useThreadJumpShortcuts(listItems, handleSelectThread);
|
||||
const sidebarItemsAreEqual = useCallback(
|
||||
(previous: SidebarListItem, item: SidebarListItem): boolean => {
|
||||
if (previous.type === "v2-thread" && item.type === "v2-thread") {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { useRecyclingState } from "@legendapp/list/react-native";
|
||||
import type {
|
||||
EnvironmentProject,
|
||||
EnvironmentThreadShell,
|
||||
@@ -13,6 +12,7 @@ import type { SwipeableMethods } from "react-native-gesture-handler/ReanimatedSw
|
||||
import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
|
||||
import Svg, { Circle, Path } from "react-native-svg";
|
||||
|
||||
import { RowPressable } from "../../components/RowPressable";
|
||||
import { AppText as Text } from "../../components/AppText";
|
||||
import { ControlPillMenu } from "../../components/ControlPill";
|
||||
import { EnvironmentMachineSymbol } from "../../components/EnvironmentMachineSymbol";
|
||||
@@ -20,7 +20,6 @@ import { ProjectFavicon } from "../../components/ProjectFavicon";
|
||||
import { cn } from "../../lib/cn";
|
||||
import { HOME_HORIZONTAL_INSET } from "../../lib/layoutMetrics";
|
||||
import { relativeTime } from "../../lib/time";
|
||||
import { themeColorWithAlpha } from "../../lib/mobileTheme";
|
||||
import { useUniwindTheme } from "../../lib/useUniwindTheme";
|
||||
import type { PendingNewTask } from "../../state/use-pending-new-tasks";
|
||||
import { useThreadPr, type ThreadPrPresentation } from "../../state/use-thread-pr";
|
||||
@@ -358,11 +357,12 @@ export const PendingTaskListRow = memo(function PendingTaskListRow(props: {
|
||||
: "Sends when the environment reconnects. Opens the task for editing";
|
||||
|
||||
const rowContent = compact ? (
|
||||
<Pressable
|
||||
<RowPressable
|
||||
key={pendingTask.key}
|
||||
accessibilityHint={accessibilityHint}
|
||||
accessibilityLabel={pendingTask.title}
|
||||
accessibilityRole="button"
|
||||
className="bg-screen active:opacity-70"
|
||||
className="bg-screen"
|
||||
onPress={() => onSelectPendingTask(pendingTask)}
|
||||
>
|
||||
<View className="pr-[18px] pt-[10px]" style={{ paddingLeft: THREAD_LIST_COMPACT_INSET }}>
|
||||
@@ -387,17 +387,16 @@ export const PendingTaskListRow = memo(function PendingTaskListRow(props: {
|
||||
{subtitleRow}
|
||||
</View>
|
||||
</View>
|
||||
</Pressable>
|
||||
</RowPressable>
|
||||
) : (
|
||||
<Pressable
|
||||
<RowPressable
|
||||
key={pendingTask.key}
|
||||
accessibilityHint={accessibilityHint}
|
||||
accessibilityLabel={pendingTask.title}
|
||||
accessibilityRole="button"
|
||||
className="active:bg-subtle"
|
||||
onPress={() => onSelectPendingTask(pendingTask)}
|
||||
style={{
|
||||
borderRadius: SIDEBAR_ROW_RADIUS,
|
||||
cursor: "pointer",
|
||||
minHeight: 64,
|
||||
justifyContent: "center",
|
||||
paddingHorizontal: 12,
|
||||
@@ -420,7 +419,7 @@ export const PendingTaskListRow = memo(function PendingTaskListRow(props: {
|
||||
</View>
|
||||
{subtitleRow}
|
||||
</View>
|
||||
</Pressable>
|
||||
</RowPressable>
|
||||
);
|
||||
|
||||
return (
|
||||
@@ -472,14 +471,9 @@ export const ThreadListRow = memo(function ThreadListRow(props: {
|
||||
const compact = props.variant === "compact";
|
||||
const selected = props.selected === true;
|
||||
const visuallySelected = selected && (!compact || materialYouStyleLayoutActive);
|
||||
// Recycling-safe: resets when the list container is reused for another
|
||||
// thread, so a hover highlight can't leak across rows.
|
||||
const [hovered, setHovered] = useRecyclingState(false);
|
||||
|
||||
const theme = useUniwindTheme();
|
||||
const screenColor = theme["--color-screen"];
|
||||
const drawerColor = theme["--color-drawer"];
|
||||
const pressedBackgroundColor = theme["--color-subtle"];
|
||||
const selectedBackgroundColor = theme["--color-user-bubble"];
|
||||
const materialSelectedBackgroundColor = theme["--color-thread-selected"];
|
||||
const materialSelectedForegroundColor = theme["--color-thread-selected-foreground"];
|
||||
@@ -516,9 +510,6 @@ export const ThreadListRow = memo(function ThreadListRow(props: {
|
||||
const effectiveSelectedForeground = materialYouStyleLayoutActive
|
||||
? materialSelectedForegroundColor
|
||||
: selectedForegroundColor;
|
||||
const effectivePressedBackground = visuallySelected
|
||||
? themeColorWithAlpha(String(effectiveSelectedForeground), 0.16)
|
||||
: pressedBackgroundColor;
|
||||
const effectiveStatus =
|
||||
visuallySelected && status
|
||||
? {
|
||||
@@ -665,11 +656,19 @@ export const ThreadListRow = memo(function ThreadListRow(props: {
|
||||
|
||||
const rowContent = (close: () => void) =>
|
||||
compact ? (
|
||||
<Pressable
|
||||
<RowPressable
|
||||
key={`${thread.environmentId}:${thread.id}`}
|
||||
interactionClassName={
|
||||
visuallySelected
|
||||
? materialYouStyleLayoutActive
|
||||
? "bg-thread-selected-foreground"
|
||||
: "bg-user-bubble-foreground"
|
||||
: "bg-primary"
|
||||
}
|
||||
accessibilityHint="Swipe left for archive and delete actions"
|
||||
accessibilityLabel={threadAccessibilityLabel}
|
||||
accessibilityRole="button"
|
||||
className="bg-screen active:opacity-70"
|
||||
className="bg-screen"
|
||||
style={
|
||||
materialYouStyleLayoutActive
|
||||
? {
|
||||
@@ -735,32 +734,33 @@ export const ThreadListRow = memo(function ThreadListRow(props: {
|
||||
{subtitleRow}
|
||||
</View>
|
||||
</View>
|
||||
</Pressable>
|
||||
</RowPressable>
|
||||
) : (
|
||||
<Pressable
|
||||
<RowPressable
|
||||
key={`${thread.environmentId}:${thread.id}`}
|
||||
interactionClassName={
|
||||
visuallySelected
|
||||
? materialYouStyleLayoutActive
|
||||
? "bg-thread-selected-foreground"
|
||||
: "bg-user-bubble-foreground"
|
||||
: "bg-primary"
|
||||
}
|
||||
accessibilityHint="Opens the thread"
|
||||
accessibilityLabel={threadAccessibilityLabel}
|
||||
accessibilityRole="button"
|
||||
accessibilityState={{ selected }}
|
||||
onHoverIn={() => setHovered(true)}
|
||||
onHoverOut={() => setHovered(false)}
|
||||
onPress={() => {
|
||||
close();
|
||||
onSelectThread(thread);
|
||||
}}
|
||||
style={({ pressed }) => ({
|
||||
backgroundColor: visuallySelected
|
||||
? effectiveSelectedBackground
|
||||
: pressed || hovered
|
||||
? effectivePressedBackground
|
||||
: backgroundColor,
|
||||
style={{
|
||||
backgroundColor: visuallySelected ? effectiveSelectedBackground : backgroundColor,
|
||||
borderRadius: SIDEBAR_ROW_RADIUS,
|
||||
cursor: "pointer",
|
||||
minHeight: 64,
|
||||
justifyContent: "center",
|
||||
paddingHorizontal: 12,
|
||||
paddingVertical: 10,
|
||||
})}
|
||||
}}
|
||||
>
|
||||
<View className="gap-[3px]">
|
||||
<View className="flex-row items-center justify-between gap-2">
|
||||
@@ -806,7 +806,7 @@ export const ThreadListRow = memo(function ThreadListRow(props: {
|
||||
) : null}
|
||||
{subtitleRow}
|
||||
</View>
|
||||
</Pressable>
|
||||
</RowPressable>
|
||||
);
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { RowPressable } from "../../components/RowPressable";
|
||||
import { CustomSnoozeSheet } from "./CustomSnoozeSheet";
|
||||
import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
|
||||
import { appAtomRegistry } from "../../state/atom-registry";
|
||||
@@ -302,7 +303,7 @@ export const ThreadListV2PendingRow = memo(function ThreadListV2PendingRow(props
|
||||
onPressAction={handleMenuAction}
|
||||
shouldOpenOnLongPress
|
||||
>
|
||||
<Pressable
|
||||
<RowPressable
|
||||
accessibilityHint={
|
||||
isDraft
|
||||
? "Opens the draft in the new task composer"
|
||||
@@ -310,7 +311,8 @@ export const ThreadListV2PendingRow = memo(function ThreadListV2PendingRow(props
|
||||
}
|
||||
accessibilityLabel={pendingTask.title}
|
||||
accessibilityRole="button"
|
||||
className={sidebarPane ? "bg-drawer active:bg-subtle" : undefined}
|
||||
key={pendingTask.key}
|
||||
className={sidebarPane ? "bg-drawer" : "bg-screen"}
|
||||
onPress={() => onSelectPendingTask(pendingTask)}
|
||||
style={
|
||||
sidebarPane
|
||||
@@ -319,20 +321,20 @@ export const ThreadListV2PendingRow = memo(function ThreadListV2PendingRow(props
|
||||
paddingHorizontal: 12,
|
||||
paddingVertical: 10,
|
||||
}
|
||||
: ({ pressed }) => ({ opacity: pressed ? 0.7 : 1 })
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
{sidebarPane ? (
|
||||
rowContent
|
||||
) : (
|
||||
<View className="bg-screen">
|
||||
<View>
|
||||
<View className="px-5 py-2.5">{rowContent}</View>
|
||||
{props.showTrailingDivider !== false ? (
|
||||
<View className="ml-5 h-px bg-border-subtle" />
|
||||
) : null}
|
||||
</View>
|
||||
)}
|
||||
</Pressable>
|
||||
</RowPressable>
|
||||
</ControlPillMenu>
|
||||
</>
|
||||
);
|
||||
@@ -441,7 +443,6 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
|
||||
const theme = useUniwindTheme();
|
||||
const screenColor = theme["--color-screen"];
|
||||
const drawerColor = theme["--color-drawer"];
|
||||
const pressedBackgroundColor = theme["--color-subtle"];
|
||||
const selectedBackgroundColor =
|
||||
theme[materialYouStyleLayoutActive ? "--color-thread-selected" : "--color-user-bubble"];
|
||||
const sidebarPane = props.pane === "sidebar";
|
||||
@@ -930,7 +931,16 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
|
||||
|
||||
const rowContent = (close: () => void) =>
|
||||
variant === "card" ? (
|
||||
<Pressable
|
||||
<RowPressable
|
||||
key={`${thread.environmentId}:${thread.id}`}
|
||||
interactionClassName={
|
||||
selected && (sidebarPane || materialYouStyleLayoutActive)
|
||||
? materialYouStyleLayoutActive
|
||||
? "bg-thread-selected-foreground"
|
||||
: "bg-user-bubble-foreground"
|
||||
: "bg-primary"
|
||||
}
|
||||
className={sidebarPane || materialYouStyleLayoutActive ? undefined : "bg-screen"}
|
||||
accessibilityHint={swipeAccessibilityHint}
|
||||
accessibilityLabel={
|
||||
props.hasQueuedMessages ? `${thread.title}, messages queued to send` : thread.title
|
||||
@@ -943,18 +953,16 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
|
||||
}}
|
||||
style={
|
||||
sidebarPane || materialYouStyleLayoutActive
|
||||
? ({ pressed }) => ({
|
||||
? {
|
||||
backgroundColor: selected
|
||||
? selectedBackgroundColor
|
||||
: pressed
|
||||
? pressedBackgroundColor
|
||||
: sidebarPane
|
||||
? drawerColor
|
||||
: screenColor,
|
||||
: sidebarPane
|
||||
? drawerColor
|
||||
: screenColor,
|
||||
borderRadius: SIDEBAR_V2_ROW_RADIUS,
|
||||
...(sidebarPane ? { paddingHorizontal: 12, paddingVertical: 10 } : null),
|
||||
})
|
||||
: ({ pressed }) => ({ opacity: pressed ? 0.7 : 1 })
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
{sidebarPane ? (
|
||||
@@ -964,16 +972,24 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
|
||||
labels and text hierarchy carry state, an inset hairline
|
||||
separates rows. The opaque screen background stays so swipe
|
||||
actions reveal behind the row. */
|
||||
<View className={materialYouStyleLayoutActive ? undefined : "bg-screen"}>
|
||||
<View>
|
||||
<View className="px-5 py-2.5">{cardContent}</View>
|
||||
{props.showTrailingDivider !== false ? (
|
||||
<View className="ml-5 h-px bg-border-subtle" />
|
||||
) : null}
|
||||
</View>
|
||||
)}
|
||||
</Pressable>
|
||||
</RowPressable>
|
||||
) : (
|
||||
<Pressable
|
||||
<RowPressable
|
||||
key={`${thread.environmentId}:${thread.id}`}
|
||||
interactionClassName={
|
||||
selected && (sidebarPane || materialYouStyleLayoutActive)
|
||||
? materialYouStyleLayoutActive
|
||||
? "bg-thread-selected-foreground"
|
||||
: "bg-user-bubble-foreground"
|
||||
: "bg-primary"
|
||||
}
|
||||
accessibilityHint={swipeAccessibilityHint}
|
||||
accessibilityLabel={
|
||||
props.hasQueuedMessages ? `${thread.title}, messages queued to send` : thread.title
|
||||
@@ -987,17 +1003,15 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
|
||||
}}
|
||||
style={
|
||||
sidebarPane || materialYouStyleLayoutActive
|
||||
? ({ pressed }) => ({
|
||||
? {
|
||||
backgroundColor: selected
|
||||
? selectedBackgroundColor
|
||||
: pressed
|
||||
? pressedBackgroundColor
|
||||
: sidebarPane
|
||||
? drawerColor
|
||||
: screenColor,
|
||||
: sidebarPane
|
||||
? drawerColor
|
||||
: screenColor,
|
||||
borderRadius: SIDEBAR_V2_ROW_RADIUS,
|
||||
})
|
||||
: ({ pressed }) => ({ opacity: pressed ? 0.7 : 1 })
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
{/* Settled history recedes: dimmed favicon + muted title. */}
|
||||
@@ -1059,7 +1073,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
|
||||
: timeLabel}
|
||||
</Text>
|
||||
</View>
|
||||
</Pressable>
|
||||
</RowPressable>
|
||||
);
|
||||
|
||||
return (
|
||||
|
||||
@@ -22,6 +22,7 @@ import {
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import type { PendingNewTask } from "../../state/use-pending-new-tasks";
|
||||
import { threadJumpTarget } from "../keyboard/threadKeyboardShortcuts";
|
||||
import {
|
||||
buildThreadListV2Items,
|
||||
buildThreadListV2ListItems,
|
||||
@@ -1050,6 +1051,9 @@ describe("buildThreadListV2ListItems", () => {
|
||||
"v2-settled-shelf",
|
||||
"v2-thread",
|
||||
]);
|
||||
expect(threadJumpTarget(items, "thread.jump.1")?.id).toBe("active");
|
||||
expect(threadJumpTarget(items, "thread.jump.2")?.id).toBe("settled");
|
||||
expect(threadJumpTarget(items, "thread.jump.3")).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
isBaseThreadRoute,
|
||||
resolveFileSelectionNavigationAction,
|
||||
resolveThreadSelectionNavigationAction,
|
||||
resolveThreadSelectionOverlayState,
|
||||
} from "./adaptive-navigation";
|
||||
|
||||
describe("isBaseThreadRoute", () => {
|
||||
@@ -66,3 +67,72 @@ describe("resolveFileSelectionNavigationAction", () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveThreadSelectionOverlayState", () => {
|
||||
const stack = {
|
||||
key: "workspace",
|
||||
type: "stack",
|
||||
stale: false as const,
|
||||
routeNames: ["Home", "Thread", "ThreadFiles", "SettingsSheet", "SettingsLegal"],
|
||||
};
|
||||
const home = { key: "home", name: "Home" };
|
||||
const thread = {
|
||||
key: "thread",
|
||||
name: "Thread",
|
||||
params: { environmentId: "environment", threadId: "old-thread" },
|
||||
};
|
||||
const files = { key: "files", name: "ThreadFiles", params: thread.params };
|
||||
const settings = { key: "settings", name: "SettingsSheet" };
|
||||
const params = { environmentId: "environment", threadId: "new-thread" };
|
||||
|
||||
it("replaces the underlying file route and dismisses every overlay above it", () => {
|
||||
expect(
|
||||
resolveThreadSelectionOverlayState({
|
||||
state: {
|
||||
...stack,
|
||||
index: 4,
|
||||
routes: [home, thread, files, settings, { key: "legal", name: "SettingsLegal" }],
|
||||
},
|
||||
workspaceRouteKey: files.key,
|
||||
action: "replace",
|
||||
params,
|
||||
}),
|
||||
).toEqual({ ...stack, index: 2, routes: [home, thread, { name: "Thread", params }] });
|
||||
});
|
||||
|
||||
it("dismisses an overlay when selecting the current thread without replacing its route key", () => {
|
||||
expect(
|
||||
resolveThreadSelectionOverlayState({
|
||||
state: { ...stack, index: 2, routes: [home, thread, settings] },
|
||||
workspaceRouteKey: thread.key,
|
||||
action: "set-params",
|
||||
params: thread.params,
|
||||
}),
|
||||
).toEqual({ ...stack, index: 1, routes: [home, thread] });
|
||||
});
|
||||
|
||||
it.each([home, files])(
|
||||
"keeps $name in the back stack when pushing from beneath a sheet",
|
||||
(route) => {
|
||||
expect(
|
||||
resolveThreadSelectionOverlayState({
|
||||
state: { ...stack, index: 1, routes: [route, settings] },
|
||||
workspaceRouteKey: route.key,
|
||||
action: "push",
|
||||
params,
|
||||
}),
|
||||
).toEqual({ ...stack, index: 1, routes: [route, { name: "Thread", params }] });
|
||||
},
|
||||
);
|
||||
|
||||
it("leaves ordinary thread selection alone when no overlay is present", () => {
|
||||
expect(
|
||||
resolveThreadSelectionOverlayState({
|
||||
state: { ...stack, index: 2, routes: [home, thread, files] },
|
||||
workspaceRouteKey: files.key,
|
||||
action: "replace",
|
||||
params,
|
||||
}),
|
||||
).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -1,3 +1,5 @@
|
||||
import type { NavigationState } from "@react-navigation/native";
|
||||
|
||||
export type AdaptiveNavigationAction = "push" | "replace" | "set-params";
|
||||
|
||||
const BASE_THREAD_ROUTE_PATTERN = /^\/threads\/[^/]+\/[^/]+\/?$/;
|
||||
@@ -23,6 +25,33 @@ export function resolveThreadSelectionNavigationAction(input: {
|
||||
return isBaseThreadRoute(input.pathname) ? "set-params" : "replace";
|
||||
}
|
||||
|
||||
/** Dismiss sheets and select their underlying workspace destination in one stack update. */
|
||||
export function resolveThreadSelectionOverlayState(input: {
|
||||
readonly state: NavigationState | undefined;
|
||||
readonly workspaceRouteKey: string | undefined;
|
||||
readonly action: AdaptiveNavigationAction;
|
||||
readonly params: ReactNavigation.RootParamList["Thread"];
|
||||
}) {
|
||||
if (input.state === undefined) return null;
|
||||
const workspaceIndex = input.state.routes.findIndex(
|
||||
(route) => route.key === input.workspaceRouteKey,
|
||||
);
|
||||
if (workspaceIndex < 0 || workspaceIndex >= input.state.index) return null;
|
||||
|
||||
const workspaceRoute = input.state.routes[workspaceIndex];
|
||||
const routes = input.state.routes.slice(0, workspaceIndex + (input.action === "push" ? 1 : 0));
|
||||
return {
|
||||
...input.state,
|
||||
index: routes.length,
|
||||
routes: [
|
||||
...routes,
|
||||
input.action === "set-params" && workspaceRoute?.name === "Thread"
|
||||
? { ...workspaceRoute, params: { ...workspaceRoute.params, ...input.params } }
|
||||
: { name: "Thread", params: input.params },
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* On regular-width layouts, the file browser and preview occupy one workspace
|
||||
* destination. Replacing the browser route keeps a single back step to chat.
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* What the Return key does in the composer on a hardware keyboard. `send`
|
||||
* submits the draft and Shift-Return inserts a newline; `newline` inserts a
|
||||
* newline and Command-Return submits. Applies on iOS only — Android's composer
|
||||
* has no hardware Return handling.
|
||||
*/
|
||||
export type ComposerEnterBehavior = "send" | "newline";
|
||||
|
||||
export const DEFAULT_COMPOSER_ENTER_BEHAVIOR: ComposerEnterBehavior = "send";
|
||||
@@ -0,0 +1,24 @@
|
||||
import { useMemo, useState } from "react";
|
||||
import { Gesture } from "react-native-gesture-handler";
|
||||
|
||||
/** Uses native hover recognition without React Native's optional pointer-event flags. */
|
||||
export function useHoverGesture(disabled = false) {
|
||||
const [hovered, setHovered] = useState(false);
|
||||
const hoverGesture = useMemo(
|
||||
() =>
|
||||
Gesture.Hover()
|
||||
.manualActivation(true)
|
||||
.enabled(!disabled)
|
||||
// Observe hover without competing with row taps, scrolling, or swipe actions.
|
||||
.cancelsTouchesInView(false)
|
||||
.runOnJS(true)
|
||||
.onBegin(() => {
|
||||
setHovered(true);
|
||||
})
|
||||
.onFinalize(() => {
|
||||
setHovered(false);
|
||||
}),
|
||||
[disabled],
|
||||
);
|
||||
return { hovered: !disabled && hovered, hoverGesture };
|
||||
}
|
||||
@@ -33,6 +33,7 @@ import {
|
||||
resolveComposerControlledEventCount,
|
||||
type ComposerNativeEventSnapshot,
|
||||
} from "./composerEditorRevision";
|
||||
import { DEFAULT_COMPOSER_ENTER_BEHAVIOR } from "../lib/composerEnterBehavior";
|
||||
import type { ComposerEditorProps, ComposerEditorSelection } from "./T3ComposerEditor.types";
|
||||
|
||||
const NATIVE_MODULE_NAME = "T3ComposerEditor";
|
||||
@@ -79,6 +80,7 @@ interface NativeComposerEditorProps extends ViewProps {
|
||||
readonly contentInsetVertical: number;
|
||||
readonly editable: boolean;
|
||||
readonly readOnly: boolean;
|
||||
readonly enterBehavior: string;
|
||||
readonly scrollEnabled: boolean;
|
||||
readonly autoFocus: boolean;
|
||||
readonly autoCorrect: boolean;
|
||||
@@ -291,6 +293,7 @@ export function ComposerEditor({
|
||||
contentInsetVertical={contentInsetVertical}
|
||||
editable={props.editable ?? true}
|
||||
readOnly={props.readOnly ?? false}
|
||||
enterBehavior={props.enterBehavior ?? DEFAULT_COMPOSER_ENTER_BEHAVIOR}
|
||||
scrollEnabled={props.scrollEnabled ?? true}
|
||||
autoFocus={props.autoFocus ?? false}
|
||||
autoCorrect={props.autoCorrect ?? true}
|
||||
|
||||
@@ -17,6 +17,7 @@ export function ComposerEditor({
|
||||
textStyle,
|
||||
contentInsetVertical = 0,
|
||||
singleLineCentered: _singleLineCentered,
|
||||
enterBehavior: _enterBehavior,
|
||||
readOnly = false,
|
||||
...props
|
||||
}: ComposerEditorProps) {
|
||||
|
||||
@@ -2,6 +2,10 @@ import type { OrchestrationMessageContext, ServerProviderSkill } from "@t3tools/
|
||||
import type { Ref } from "react";
|
||||
import type { StyleProp, TextStyle, ViewStyle } from "react-native";
|
||||
|
||||
import type { ComposerEnterBehavior } from "../lib/composerEnterBehavior";
|
||||
|
||||
export type { ComposerEnterBehavior };
|
||||
|
||||
export type ComposerEditorSelection = {
|
||||
readonly start: number;
|
||||
readonly end: number;
|
||||
@@ -61,6 +65,11 @@ export interface ComposerEditorProps {
|
||||
readonly onPasteText?: (paste: ComposerTextPaste) => void;
|
||||
readonly onFocus?: () => void;
|
||||
readonly onBlur?: () => void;
|
||||
/** Invoked by the native editor when Command-Return is pressed on a hardware keyboard. */
|
||||
/**
|
||||
* Hardware-keyboard Return behavior on iOS. No-op on Android, which has no
|
||||
* hardware Return handling.
|
||||
*/
|
||||
readonly enterBehavior?: ComposerEnterBehavior;
|
||||
/** Hardware keyboard submission: Command-Return, or Return when `enterBehavior` is "send". */
|
||||
readonly onSubmit?: () => void;
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import * as Ref from "effect/Ref";
|
||||
import * as Schema from "effect/Schema";
|
||||
import * as Semaphore from "effect/Semaphore";
|
||||
import type { SidebarProjectGroupingMode } from "@t3tools/contracts";
|
||||
import type { ComposerEnterBehavior } from "../lib/composerEnterBehavior";
|
||||
import { MOBILE_THEME_IDS, type MobileThemeId, type MobileThemeMode } from "../lib/mobileTheme";
|
||||
|
||||
import * as MobileDatabase from "./mobile-database";
|
||||
@@ -29,6 +30,8 @@ export interface Preferences {
|
||||
readonly codeWordBreak?: boolean;
|
||||
readonly connectOnboardingOptOutAccounts?: ReadonlyArray<string>;
|
||||
readonly collapsedProjectGroups?: readonly string[];
|
||||
/** What the Return key does in the composer on a hardware keyboard. iOS only. */
|
||||
readonly composerEnterBehavior?: ComposerEnterBehavior;
|
||||
/** @deprecated Kept temporarily so older OTA bundles retain the selected mode. */
|
||||
readonly projectGroupingEnabled?: boolean;
|
||||
readonly projectGroupingMode?: SidebarProjectGroupingMode;
|
||||
@@ -99,6 +102,7 @@ function sanitizePreferences(parsed: Preferences): Preferences {
|
||||
codeWordBreak?: boolean;
|
||||
connectOnboardingOptOutAccounts?: ReadonlyArray<string>;
|
||||
collapsedProjectGroups?: readonly string[];
|
||||
composerEnterBehavior?: ComposerEnterBehavior;
|
||||
projectGroupingEnabled?: boolean;
|
||||
projectGroupingMode?: SidebarProjectGroupingMode;
|
||||
legacyThreadListEnabled?: boolean;
|
||||
@@ -159,6 +163,9 @@ function sanitizePreferences(parsed: Preferences): Preferences {
|
||||
(key): key is string => typeof key === "string",
|
||||
);
|
||||
}
|
||||
if (parsed.composerEnterBehavior === "send" || parsed.composerEnterBehavior === "newline") {
|
||||
preferences.composerEnterBehavior = parsed.composerEnterBehavior;
|
||||
}
|
||||
if (typeof parsed.projectGroupingEnabled === "boolean") {
|
||||
preferences.projectGroupingEnabled = parsed.projectGroupingEnabled;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,19 @@ to copy its URL and `mod+shift+k` to copy its number with a `#` prefix.
|
||||
Both shortcuts can be changed in Settings. Search for “Copy Link or Thread ID”
|
||||
or “Copy Number”. They copy the selected PR and leave terminal input alone.
|
||||
|
||||
## iPad
|
||||
|
||||
With a hardware keyboard, use `Cmd+1` through `Cmd+9` to open the first nine
|
||||
displayed threads. The shortcuts follow the current list filters and order.
|
||||
`Cmd+K` opens the command palette to search commands, projects, and threads.
|
||||
Use the arrow keys and Return to choose a result, or `Cmd+1` through `Cmd+9` to
|
||||
choose directly. Escape or `Cmd+K` closes the palette. Start a search with `>`
|
||||
to show only actions.
|
||||
|
||||
In the composer, Return sends and `Shift+Return` inserts a new line. `Cmd+Return`
|
||||
also sends. To make Return insert a new line instead, change the Return key
|
||||
behavior in Settings → Keyboard.
|
||||
|
||||
## Edit the configuration file
|
||||
|
||||
Keybindings live on the environment's machine, in
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
diff --git a/apple/Handlers/RNHoverHandler.m b/apple/Handlers/RNHoverHandler.m
|
||||
index 320cb8cb2652bfcfe1ecc65ebd81a8d208e4260f..a88ac5f04a9663fd7a62ee89e42d85ec41dcaf55 100644
|
||||
--- a/apple/Handlers/RNHoverHandler.m
|
||||
+++ b/apple/Handlers/RNHoverHandler.m
|
||||
@@ -132,8 +132,10 @@ - (void)unbindFromView
|
||||
{
|
||||
#if CHECK_TARGET(13_4)
|
||||
if (@available(iOS 13.4, *)) {
|
||||
+ // The superclass detaches the recognizer, clearing recognizer.view. Remove
|
||||
+ // the interaction from its own view before it can be recycled by Fabric.
|
||||
+ [_pointerInteraction.view removeInteraction:_pointerInteraction];
|
||||
[super unbindFromView];
|
||||
- [self.recognizer.view removeInteraction:_pointerInteraction];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
diff --git a/lib/commonjs/components/ReanimatedSwipeable/ReanimatedSwipeable.js b/lib/commonjs/components/ReanimatedSwipeable/ReanimatedSwipeable.js
|
||||
index 551ab92bf58db0b79d428dcd2f2df898ef686493..13db26d88bff975bc5d46bb6432cbf9fda3d489a 100644
|
||||
--- a/lib/commonjs/components/ReanimatedSwipeable/ReanimatedSwipeable.js
|
||||
@@ -97,7 +113,7 @@ index a2835d5416ffd5cf9a04e98774516b9e6569691e..055afce410d6eb655532e7a09371dfc2
|
||||
const animatedStyle = useAnimatedStyle(() => ({
|
||||
transform: [{
|
||||
diff --git a/lib/typescript/components/ReanimatedSwipeable/ReanimatedSwipeableProps.d.ts b/lib/typescript/components/ReanimatedSwipeable/ReanimatedSwipeableProps.d.ts
|
||||
index ac8b76830d468edfbc29052b452a36221323c3de..6985d54d9d359e825a5a0e6078bb113204e2807b 100644
|
||||
index ac8b76830d468edfbc29052b452a36221323c3de..cac72ebaafaf746af7640783a16e99c93ecad2a4 100644
|
||||
--- a/lib/typescript/components/ReanimatedSwipeable/ReanimatedSwipeableProps.d.ts
|
||||
+++ b/lib/typescript/components/ReanimatedSwipeable/ReanimatedSwipeableProps.d.ts
|
||||
@@ -64,6 +64,13 @@ export interface SwipeableProps {
|
||||
|
||||
Generated
+3
-3
@@ -99,7 +99,7 @@ patchedDependencies:
|
||||
[email protected]: fa9a3e0442ed395d4071bb406e08c3a471c9a84700bdfa0b9ad7ff144c96041a
|
||||
[email protected]: 8d2e3b10eb3f52036a9a086800180ec6cebf3b75bccc5b1775117a7244d4ac45
|
||||
[email protected]: 319a9ded5db49c5b5215c511a138b33f44c7ea2972eb418192e8d5342fe75ce6
|
||||
[email protected]: 96573c000f7fe56b5abfa13e2e5f0d065907e674cb8e2300155226d7c9874398
|
||||
[email protected]: 0579f8e4dad02bf3183d95b02620358412983c36f9bda7425dc8bcb9643b5ce2
|
||||
[email protected]: 6e4339347bc5bb3c9ea67d85ff5c814058b211c5750f247aba59d07869a2e787
|
||||
[email protected]: 825622aae63a8fb5b904f3c77908a0e216261d727ea171709f2c0b6088422675
|
||||
[email protected]: a23baea5d82cbf1254720110aef6671e39d57a425f8be446756f91ab806eb72c
|
||||
@@ -426,7 +426,7 @@ importers:
|
||||
version: 0.86.3(@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected])
|
||||
react-native-gesture-handler:
|
||||
specifier: ~2.32.0
|
||||
version: 2.32.0(patch_hash=96573c000f7fe56b5abfa13e2e5f0d065907e674cb8e2300155226d7c9874398)([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected])
|
||||
version: 2.32.0(patch_hash=0579f8e4dad02bf3183d95b02620358412983c36f9bda7425dc8bcb9643b5ce2)([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected])
|
||||
react-native-image-viewing:
|
||||
specifier: ^0.2.2
|
||||
version: 0.2.2([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected])
|
||||
@@ -20977,7 +20977,7 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
[email protected](patch_hash=96573c000f7fe56b5abfa13e2e5f0d065907e674cb8e2300155226d7c9874398)([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected]):
|
||||
[email protected](patch_hash=0579f8e4dad02bf3183d95b02620358412983c36f9bda7425dc8bcb9643b5ce2)([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected]):
|
||||
dependencies:
|
||||
'@egjs/hammerjs': 2.0.17
|
||||
'@types/react-test-renderer': 19.1.0
|
||||
|
||||
Reference in new issue
Block a user