The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { useGT } from "gt-react"; |
| 2 | import { useRef } from "react"; |
| 3 | |
| 4 | import { Textarea } from "../ui/textarea"; |
| 5 | import { SettingsRow, SettingResetButton } from "./settingsLayout"; |
| 6 | import { useSettingsScope } from "./SettingsScopeContext"; |
| 7 | import { useSearchableSetting } from "./settingsSearch"; |
| 8 | import { |
| 9 | useScopedSettings, |
| 10 | useScopedSettingsMixed, |
| 11 | useUpdateScopedSettings, |
| 12 | } from "./useScopedSettings"; |
| 13 | |
| 14 | export function ThreadTitleInstructionsSettings() { |
| 15 | const gt = useGT(); |
| 16 | const searchableSetting = useSearchableSetting(); |
| 17 | const settings = useScopedSettings(); |
| 18 | const { targets } = useSettingsScope(); |
| 19 | const scopeKey = targets.map((target) => `${target.environmentId}:${target.projectId}`).join(","); |
| 20 | const edited = useRef(false); |
| 21 | const updateSettings = useUpdateScopedSettings(); |
| 22 | const mixed = useScopedSettingsMixed(["threadTitleInstructions"]); |
| 23 | |
| 24 | return ( |
| 25 | <SettingsRow |
| 26 | serverScoped |
| 27 | settingKeys={["threadTitleInstructions"]} |
| 28 | {...searchableSetting("thread-title-instructions")} |
| 29 | description={gt("Appended to the prompt for new and regenerated thread titles.")} |
| 30 | resetAction={ |
| 31 | mixed || settings.threadTitleInstructions !== "" ? ( |
| 32 | <SettingResetButton |
| 33 | ariaLabel={gt("Reset thread title instructions to default")} |
| 34 | onClick={() => updateSettings({ threadTitleInstructions: "" })} |
| 35 | /> |
| 36 | ) : null |
| 37 | } |
| 38 | > |
| 39 | <div className="mt-3 max-w-2xl pb-3.5"> |
| 40 | <Textarea |
| 41 | key={`${scopeKey}:${mixed}:${settings.threadTitleInstructions}`} |
| 42 | aria-label={gt("Thread title instructions")} |
| 43 | onChange={() => { |
| 44 | edited.current = true; |
| 45 | }} |
| 46 | rows={4} |
| 47 | defaultValue={mixed ? "" : settings.threadTitleInstructions} |
| 48 | placeholder={ |
| 49 | mixed |
| 50 | ? gt("Mixed. Enter instructions to apply to all selected targets.") |
| 51 | : gt("Keep titles to a few words. Lead with the main subject.") |
| 52 | } |
| 53 | onBlur={(event) => { |
| 54 | const value = event.target.value.trim(); |
| 55 | if (edited.current && (mixed || value !== settings.threadTitleInstructions)) |
| 56 | updateSettings({ threadTitleInstructions: value }); |
| 57 | edited.current = false; |
| 58 | }} |
| 59 | /> |
| 60 | </div> |
| 61 | </SettingsRow> |
| 62 | ); |
| 63 | } |