GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — sync(upstream): merge upstream/main a20923ce4 into fork/dev · patroza/t3code@3cbce35

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps
    • mobile/src
      • features/threads
        • NewTaskDraftScreen.tsx
        • ThreadComposer.tsx
        • ThreadSettingsSheet.tsx
        • new-task-flow-provider.tsx
        • thread-settings-sheet-state.test.ts
        • thread-settings-sheet-state.ts
        • use-thread-settings-sheet-presentation.ts
      • lib
        • modelOptions.test.ts
        • modelOptions.ts
        • providerOptions.test.ts
        • providerOptions.ts
    • server/src
      • auth
        • RpcAuthorization.ts
      • server.test.ts
      • server.ts
      • usage
        • UsageService.ts
        • usageAggregation.test.ts
        • usageAggregation.ts
        • usagePricing.ts
        • usageScanCache.test.ts
        • usageScanCache.ts
        • usageTranscriptReader.ts
        • usageTranscripts.test.ts
        • usageTranscripts.ts
      • ws.ts
    • web/src
      • components
        • sidebar
          • SidebarChrome.tsx
        • usage
          • UsagePage.tsx
          • UsageProviderChart.test.ts
          • UsageProviderChart.tsx
          • usageProviders.ts
      • routeTree.gen.ts
      • routes
        • usage.tsx
      • state
        • usage.ts
      • usage
        • usageFormat.ts
        • usageMerge.test.ts
        • usageMerge.ts
  • packages
    • client-runtime/src/state
      • server.ts
    • contracts/src
      • index.ts
      • rpc.ts
      • usage.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/mobile/src/features/threads/NewTaskDraftScreen.tsx‎

Copy file name to clipboardExpand all lines: apps/mobile/src/features/threads/NewTaskDraftScreen.tsx
+56-117Lines changed: 56 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,12 @@ import { ComposerAttachmentStrip } from "../../components/ComposerAttachmentStri
2525
import { ControlPill, ControlPillMenu } from "../../components/ControlPill";
2626
import { ProviderIcon } from "../../components/ProviderIcon";
2727
import { ComposerSurface } from "./ThreadComposer";
28+
import { ThreadSettingsSheet, threadSettingsSummaryLabel } from "./ThreadSettingsSheet";
29+
import { useThreadSettingsSheetPresentation } from "./use-thread-settings-sheet-presentation";
2830

2931
import { makeTurnCommandMetadata } from "../../lib/commandMetadata";
3032
import { convertPastedImagesToAttachments, pickComposerImages } from "../../lib/composerImages";
31-
import {
32-
applyProviderOptionMenuEvent,
33-
buildProviderOptionMenuActions,
34-
providerOptionsConfigurationLabel,
35-
resolveProviderOptionDescriptors,
36-
} from "../../lib/providerOptions";
33+
import { resolveProviderOptionDescriptors } from "../../lib/providerOptions";
3734
import { useScaledTextRole } from "../settings/appearance/useScaledTextRole";
3835
import {
3936
clearComposerDraftContent,
@@ -45,7 +42,7 @@ import {
4542
type ComposerDraftWorkspaceSelection,
4643
} from "../../state/use-composer-drafts";
4744
import { useEnvironmentServerConfig, useProjects } from "../../state/entities";
48-
import { buildModelMenuActions, resolveSelectableModelSelection } from "../../lib/modelOptions";
45+
import { resolveSelectableModelSelection } from "../../lib/modelOptions";
4946
import { deriveThreadTitleFromPrompt } from "../../lib/projectThreadStartTurn";
5047
import { armAgentAwarenessLiveActivityForLocalWork } from "../agent-awareness/remoteRegistration";
5148
import { enqueueThreadOutboxMessage, removeThreadOutboxMessage } from "../../state/thread-outbox";
@@ -103,6 +100,10 @@ export function NewTaskDraftScreen(props: {
103100
const promptInputRef = useRef<ComposerEditorHandle>(null);
104101
const loadedBranchesProjectKeyRef = useRef<string | null>(null);
105102
const [isComposerFocused, setIsComposerFocused] = useState(false);
103+
const settingsSheetPresentation = useThreadSettingsSheetPresentation({
104+
editorRef: promptInputRef,
105+
isEditorFocused: isComposerFocused,
106+
});
106107
const [importingShareKey, setImportingShareKey] = useState<string | null>(null);
107108
const [isCancellingShareImport, setIsCancellingShareImport] = useState(false);
108109
const [cancelledIncomingShareId, setCancelledIncomingShareId] = useState<string | null>(null);
@@ -548,7 +549,15 @@ export function NewTaskDraftScreen(props: {
548549

549550
let focusFrame: ReturnType<typeof requestAnimationFrame> | null = null;
550551
const interaction = InteractionManager.runAfterInteractions(() => {
551-
focusFrame = requestAnimationFrame(() => promptInputRef.current?.focus());
552+
focusFrame = requestAnimationFrame(() => {
553+
// The delayed focus can land after the settings sheet opened, which
554+
// would pop the keyboard underneath its modal.
555+
if (!settingsSheetPresentation.isActiveRef.current) {
556+
promptInputRef.current?.focus();
557+
} else {
558+
settingsSheetPresentation.restoreFocusAfterSave();
559+
}
560+
});
552561
});
553562

554563
return () => {
@@ -557,7 +566,11 @@ export function NewTaskDraftScreen(props: {
557566
cancelAnimationFrame(focusFrame);
558567
}
559568
};
560-
}, [selectedProject]);
569+
}, [
570+
selectedProject,
571+
settingsSheetPresentation.isActiveRef,
572+
settingsSheetPresentation.restoreFocusAfterSave,
573+
]);
561574

562575
const environmentMenuActions = useMemo(
563576
() =>
@@ -571,10 +584,6 @@ export function NewTaskDraftScreen(props: {
571584
[flow.environments, flow.selectedEnvironmentId, isIncomingShareTransferPending],
572585
);
573586

574-
const modelMenuActions = useMemo(
575-
() => buildModelMenuActions(flow.providerGroups, flow.selectedModel),
576-
[flow.providerGroups, flow.selectedModel],
577-
);
578587
const providerOptionDescriptors = useMemo(
579588
() =>
580589
resolveProviderOptionDescriptors({
@@ -584,54 +593,6 @@ export function NewTaskDraftScreen(props: {
584593
[flow.selectedModel?.options, flow.selectedModelOption?.capabilities],
585594
);
586595

587-
const optionsMenuActions = useMemo(
588-
() => [
589-
...buildProviderOptionMenuActions(providerOptionDescriptors),
590-
{
591-
id: "options-runtime",
592-
title: "Runtime",
593-
subtitle:
594-
flow.runtimeMode === "approval-required"
595-
? "Approve actions"
596-
: flow.runtimeMode === "auto-accept-edits"
597-
? "Auto-accept edits"
598-
: flow.runtimeMode === "auto"
599-
? "Auto"
600-
: "Full access",
601-
subactions: [
602-
{ id: "options:runtime:approval-required", title: "Approve actions" },
603-
{ id: "options:runtime:auto-accept-edits", title: "Auto-accept edits" },
604-
{ id: "options:runtime:auto", title: "Auto" },
605-
{ id: "options:runtime:full-access", title: "Full access" },
606-
].map((option) => {
607-
const value = option.id.replace("options:runtime:", "");
608-
return {
609-
id: option.id,
610-
title: option.title,
611-
state: flow.runtimeMode === value ? ("on" as const) : undefined,
612-
};
613-
}),
614-
},
615-
{
616-
id: "options-interaction",
617-
title: "Interaction",
618-
subtitle: flow.interactionMode === "plan" ? "Plan" : "Default",
619-
subactions: [
620-
{ id: "options:interaction:default", title: "Default" },
621-
{ id: "options:interaction:plan", title: "Plan" },
622-
].map((option) => {
623-
const value = option.id.replace("options:interaction:", "");
624-
return {
625-
id: option.id,
626-
title: option.title,
627-
state: flow.interactionMode === value ? ("on" as const) : undefined,
628-
};
629-
}),
630-
},
631-
],
632-
[flow.interactionMode, flow.runtimeMode, providerOptionDescriptors],
633-
);
634-
635596
const workspaceMenuActions = useMemo(() => {
636597
const branchActions =
637598
flow.availableBranches.length === 0
@@ -702,10 +663,12 @@ export function NewTaskDraftScreen(props: {
702663
flow.availableBranches.find((branch) => branch.current)?.name ??
703664
flow.availableBranches.find((branch) => branch.isDefault)?.name ??
704665
null;
705-
const configurationLabel = useMemo(
706-
() => providerOptionsConfigurationLabel(providerOptionDescriptors),
707-
[providerOptionDescriptors],
708-
);
666+
const settingsSummaryLabel = threadSettingsSummaryLabel({
667+
modelLabel: flow.selectedModelOption?.label ?? "Model",
668+
optionDescriptors: providerOptionDescriptors,
669+
runtimeMode: flow.runtimeMode,
670+
interactionMode: flow.interactionMode,
671+
});
709672
const workspaceLabel = useMemo(
710673
() =>
711674
formatWorkspaceLabel({
@@ -715,42 +678,13 @@ export function NewTaskDraftScreen(props: {
715678
}),
716679
[currentBranchName, flow.selectedBranchName, flow.workspaceMode],
717680
);
718-
function handleModelMenuAction(event: string) {
719-
if (isIncomingShareTransferPending || !event.startsWith("model:")) {
720-
return;
721-
}
722-
flow.setSelectedModelKey(event.slice("model:".length));
723-
}
724-
725681
function handleEnvironmentMenuAction(event: string) {
726682
if (isIncomingShareTransferPending || !event.startsWith("environment:")) {
727683
return;
728684
}
729685
flow.selectEnvironment(EnvironmentId.make(event.slice("environment:".length)));
730686
}
731687

732-
function handleOptionsMenuAction(event: string) {
733-
if (isIncomingShareTransferPending) {
734-
return;
735-
}
736-
const providerOptions = applyProviderOptionMenuEvent(providerOptionDescriptors, event);
737-
if (providerOptions) {
738-
flow.setSelectedModelOptions(providerOptions);
739-
return;
740-
}
741-
if (event.startsWith("options:runtime:")) {
742-
flow.setRuntimeMode(
743-
event.slice("options:runtime:".length) as Parameters<typeof flow.setRuntimeMode>[0],
744-
);
745-
return;
746-
}
747-
if (event.startsWith("options:interaction:")) {
748-
flow.setInteractionMode(
749-
event.slice("options:interaction:".length) as Parameters<typeof flow.setInteractionMode>[0],
750-
);
751-
}
752-
}
753-
754688
function handleWorkspaceMenuAction(event: string) {
755689
if (isIncomingShareTransferPending) {
756690
return;
@@ -947,7 +881,9 @@ export function NewTaskDraftScreen(props: {
947881
const isDarkMode = colorScheme === "dark";
948882
// Android expansion follows native editor focus so relayout cannot race
949883
// the touch gesture that opens the keyboard.
950-
const isExpanded = !isAndroid || isComposerFocused;
884+
// The settings sheet dismisses the keyboard, so its flag keeps the Android
885+
// draft composer expanded through the blur (mirrors ThreadComposer).
886+
const isExpanded = !isAndroid || isComposerFocused || settingsSheetPresentation.isActive;
951887
const canStart =
952888
Boolean(flow.selectedProject) &&
953889
Boolean(flow.selectedModel) &&
@@ -1001,28 +937,14 @@ export function NewTaskDraftScreen(props: {
1001937
showChevron={false}
1002938
disabled={isIncomingShareTransferPending}
1003939
/>
1004-
<ControlPillMenu
1005-
actions={modelMenuActions}
1006-
onPressAction={({ nativeEvent }) => handleModelMenuAction(nativeEvent.event)}
1007-
>
1008-
<ComposerToolbarTrigger
1009-
accessibilityLabel="Model"
1010-
disabled={isIncomingShareTransferPending}
1011-
iconNode={<ProviderIcon provider={flow.selectedModelOption?.providerDriver} size={16} />}
1012-
label={flow.selectedModelOption?.label ?? "Model"}
1013-
/>
1014-
</ControlPillMenu>
1015-
<ControlPillMenu
1016-
actions={optionsMenuActions}
1017-
onPressAction={({ nativeEvent }) => handleOptionsMenuAction(nativeEvent.event)}
1018-
>
1019-
<ComposerToolbarTrigger
1020-
accessibilityLabel="Configuration"
1021-
disabled={isIncomingShareTransferPending}
1022-
icon="slider.horizontal.3"
1023-
label={configurationLabel}
1024-
/>
1025-
</ControlPillMenu>
940+
<ComposerToolbarTrigger
941+
accessibilityLabel="Thread settings"
942+
disabled={isIncomingShareTransferPending}
943+
iconNode={<ProviderIcon provider={flow.selectedModelOption?.providerDriver} size={16} />}
944+
label={settingsSummaryLabel}
945+
maxWidth={320}
946+
onPress={settingsSheetPresentation.open}
947+
/>
1026948
<ControlPillMenu
1027949
actions={environmentMenuActions}
1028950
onPressAction={({ nativeEvent }) => handleEnvironmentMenuAction(nativeEvent.event)}
@@ -1048,6 +970,21 @@ export function NewTaskDraftScreen(props: {
1048970
</>
1049971
);
1050972

973+
const settingsSheet = (
974+
<ThreadSettingsSheet
975+
visible={settingsSheetPresentation.isVisible}
976+
onClose={settingsSheetPresentation.close}
977+
onDismissed={settingsSheetPresentation.onDismissed}
978+
providerGroups={flow.providerGroups}
979+
selectedModel={flow.selectedModel}
980+
onSelectModel={(option) => flow.setSelectedModelKey(option.key, option.selection.options)}
981+
optionDescriptors={providerOptionDescriptors}
982+
onUpdateOptionSelections={flow.setSelectedModelOptions}
983+
runtimeMode={flow.runtimeMode}
984+
onUpdateRuntimeMode={flow.setRuntimeMode}
985+
/>
986+
);
987+
1051988
const startButton = (
1052989
<ComposerToolbarButton
1053990
accessibilityLabel={
@@ -1137,6 +1074,7 @@ export function NewTaskDraftScreen(props: {
11371074
) : null}
11381075
</View>
11391076
</KeyboardAvoidingView>
1077+
{settingsSheet}
11401078
</View>
11411079
);
11421080
}
@@ -1170,6 +1108,7 @@ export function NewTaskDraftScreen(props: {
11701108
</ComposerToolbarRow>
11711109
</View>
11721110
</KeyboardAvoidingView>
1111+
{settingsSheet}
11731112
</View>
11741113
);
11751114
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.