Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/server/src/guide/topics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ The project name in "What's next in …?" on the new-thread screen opens the lis

A repository can already have worktrees that Threadlines did not make (git worktree add, or another app). Right after such a repository is added as a project, the new-thread screen lists them under the message box with a checkbox each, and "Add N threads" makes a thread for every ticked one, named from its branch; nothing runs until you send a message there. After that the screen shows only a count beside the recent threads ("4 worktrees"); opening it lists them with Work here, which points the thread you are about to start at that worktree, Add as threads…, and Hide for this project. The Workspace picker under the message box lists the same worktrees under Existing worktree, and the command palette has Add existing worktrees as threads…, which also brings a hidden count back. A thread in one of these is a guest: no setup script runs, the branch is not renamed, deleting the thread never offers to delete the folder, and undoing a turn only undoes that thread's own edits. Worktrees a thread already works in are left out. The computer's server needs to be on a version that has this; with an older one none of it shows.

The agent and model a new thread starts with is {place:threads.agent}. You can switch model or agent at any time from the model button in the composer, which also holds the agent's effort. Beside it sit Build or Plan (one click switches, as does Shift+Tab in the message box) and the access level; on a narrow window they show just their icons, and on phones both live in the model button's panel instead.
The agent and model a new thread starts with is {place:threads.agent}. You can switch model or agent at any time from the model button in the composer, which also holds the agent's effort. Beside it sit Build or Plan (one click switches, as does Shift+Tab in the message box; default {place:threads.mode}) and the access level (default {place:threads.access}); on a narrow window they show just their icons, and on phones both live in the model button's panel instead.

While an agent works, {place:general.followUpDelivery} sets how a message goes by default (Steer now adds it to the reply in progress, Send when done holds it for the next one), and the arrow beside the send button overrides it for the current thread. Enter sends that way; Cmd+Enter (Ctrl+Enter on Windows and Linux) sends that one message the other way.

Expand All @@ -74,7 +74,7 @@ When Threadlines quits, updates or crashes while an agent works on something the
id: "access-levels",
title: "Access levels",
keywords: ["access", "permissions", "approval", "sandbox", "full access", "auto", "supervised"],
body: `Each thread runs at an access level, picked from the access button beside the model button in the composer (on phones, in the model button's panel):
body: `Each thread runs at an access level, picked from the access button beside the model button in the composer (on phones, in the model button's panel). {place:threads.access} sets the default for new threads:

- Supervised: asks before commands and file changes.
- Auto-accept edits: edits run without asking; other actions ask.
Expand Down
2 changes: 2 additions & 0 deletions apps/web/src/commands/projectCommands.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
startNewThreadFromContext,
startNewThreadInProjectFromContext,
} from "../lib/chatThreadActions";
import { readComputerConfig } from "../newThreadDefaults";
import { projectBriefLocation, useProjectBriefSupport } from "../projectBrief";
import { deriveProviderInstanceEntries } from "../providerInstances";
import { useServerProviders } from "../rpc/serverState";
Expand Down Expand Up @@ -215,6 +216,7 @@ export function useProjectCommands(): void {
runtimeMode:
openThreadRuntimeMode ??
activeDraftThread?.runtimeMode ??
readComputerConfig(currentProject.environmentId)?.settings.newThreadRuntimeMode ??
DEFAULT_NEW_THREAD_RUNTIME_MODE,
returnFocus: focusComposer,
});
Expand Down
14 changes: 10 additions & 4 deletions apps/web/src/components/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1558,6 +1558,7 @@ export default function ChatView(props: ChatViewProps) {
sendCtx.selectedModelSelection.options,
),
runtimeMode,
interactionMode,
});
} catch (error) {
toastManager.add(failureNotice({ title: "Couldn't add the threads", error }));
Expand All @@ -1571,6 +1572,7 @@ export default function ChatView(props: ChatViewProps) {
draftProjectId,
draftWorktreePath,
environmentId,
interactionMode,
isGeneralChatThread,
isLocalDraftThread,
pickupProjectCwd,
Expand Down Expand Up @@ -4613,14 +4615,15 @@ export default function ChatView(props: ChatViewProps) {
// for more changes, and focus moving to the prompt would close it.
const handleRuntimeModeChange = useCallback(
(mode: RuntimeMode, options?: { focusComposer?: boolean }) => {
if (mode === runtimeMode) return;
if (mode === runtimeMode && (!isLocalDraftThread || composerRuntimeMode === mode)) return;
setComposerDraftRuntimeMode(composerDraftTarget, mode);
if (isLocalDraftThread) {
if (isLocalDraftThread && mode !== runtimeMode) {
setDraftThreadContext(composerDraftTarget, { runtimeMode: mode });
}
if (options?.focusComposer !== false) scheduleComposerFocus();
},
[
composerRuntimeMode,
isLocalDraftThread,
runtimeMode,
scheduleComposerFocus,
Expand All @@ -4632,14 +4635,17 @@ export default function ChatView(props: ChatViewProps) {

const handleInteractionModeChange = useCallback(
(mode: ProviderInteractionMode, options?: { focusComposer?: boolean }) => {
if (mode === interactionMode) return;
if (mode === interactionMode && (!isLocalDraftThread || composerInteractionMode === mode)) {
return;
}
setComposerDraftInteractionMode(composerDraftTarget, mode);
if (isLocalDraftThread) {
if (isLocalDraftThread && mode !== interactionMode) {
setDraftThreadContext(composerDraftTarget, { interactionMode: mode });
}
if (options?.focusComposer !== false) scheduleComposerFocus();
},
[
composerInteractionMode,
interactionMode,
isLocalDraftThread,
scheduleComposerFocus,
Expand Down
6 changes: 4 additions & 2 deletions apps/web/src/components/chat/ChatComposer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1873,7 +1873,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
options: accessLevel.options,
// The row's menu returns the cursor itself once it has closed.
onChange: (mode) => handleRuntimeModeChange(mode, { focusComposer: false }),
planning: interactionMode === "plan",
planning: composerProviderControls.showInteractionModeToggle && interactionMode === "plan",
});
const settingsModeControl = runControlsOnRow ? null : modeControl;
const settingsAccessControl = runControlsOnRow ? null : accessControl;
Expand Down Expand Up @@ -3943,7 +3943,9 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
data-glass-surface="composer"
className={cn(
"group rounded-[13px] p-px transition-[background-color,box-shadow] duration-200",
interactionMode === "plan" && "plan-mode-frame",
composerProviderControls.showInteractionModeToggle &&
interactionMode === "plan" &&
"plan-mode-frame",
composerProviderState.composerFrameClassName,
)}
onDragEnter={onComposerDragEnter}
Expand Down
16 changes: 16 additions & 0 deletions apps/web/src/components/settings/SettingsPanels.browser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4608,6 +4608,22 @@ describe("ThreadsSettingsPanel new thread defaults", () => {
.toBeInTheDocument();
await expect.element(page.getByRole("button", { name: "Add agent" })).toBeDisabled();
});

it("changes and resets default mode and access level", async () => {
const updateSettings = await mountWith({});

await page.getByRole("combobox", { name: "Default build or plan mode" }).click();
await page.getByRole("option", { name: /Plan/ }).click();
await vi.waitFor(() => {
expect(updateSettings).toHaveBeenCalledWith({ newThreadInteractionMode: "plan" });
});

await page.getByRole("combobox", { name: "Default access level" }).click();
await page.getByRole("option", { name: /Full access/ }).click();
await vi.waitFor(() => {
expect(updateSettings).toHaveBeenCalledWith({ newThreadRuntimeMode: "full-access" });
});
});
});

describe("Agent Instructions", () => {
Expand Down
10 changes: 10 additions & 0 deletions apps/web/src/components/settings/SettingsPanels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,12 @@ export function useSettingsRestore(onRestored?: () => void) {
: []),
...(settings.newThreadModelSelection !== null ? ["New thread agent"] : []),
...(settings.newThreadRoomAgents.length > 0 ? ["New thread room"] : []),
...(settings.newThreadInteractionMode !== DEFAULT_UNIFIED_SETTINGS.newThreadInteractionMode
? ["Build or Plan"]
: []),
...(settings.newThreadRuntimeMode !== DEFAULT_UNIFIED_SETTINGS.newThreadRuntimeMode
? ["New thread access"]
: []),
...(settings.openLinksIn !== DEFAULT_UNIFIED_SETTINGS.openLinksIn ? ["Open links in"] : []),
...(settings.browserNewTabSize !== null ? ["Browser page size"] : []),
...(settings.browserSearchEngine !== DEFAULT_UNIFIED_SETTINGS.browserSearchEngine
Expand Down Expand Up @@ -590,6 +596,8 @@ export function useSettingsRestore(onRestored?: () => void) {
settings.wrapUpThreadsOnPullRequestSettled,
settings.newThreadModelSelection,
settings.newThreadRoomAgents,
settings.newThreadInteractionMode,
settings.newThreadRuntimeMode,
settings.enableRooms,
settings.enableAgentPages,
settings.enableClaudeArtifacts,
Expand Down Expand Up @@ -669,6 +677,8 @@ export function useSettingsRestore(onRestored?: () => void) {
wrapUpThreadsOnPullRequestSettled: DEFAULT_UNIFIED_SETTINGS.wrapUpThreadsOnPullRequestSettled,
newThreadModelSelection: DEFAULT_UNIFIED_SETTINGS.newThreadModelSelection,
newThreadRoomAgents: DEFAULT_UNIFIED_SETTINGS.newThreadRoomAgents,
newThreadInteractionMode: DEFAULT_UNIFIED_SETTINGS.newThreadInteractionMode,
newThreadRuntimeMode: DEFAULT_UNIFIED_SETTINGS.newThreadRuntimeMode,
openLinksIn: DEFAULT_UNIFIED_SETTINGS.openLinksIn,
browserNewTabSize: DEFAULT_UNIFIED_SETTINGS.browserNewTabSize,
browserSearchEngine: DEFAULT_UNIFIED_SETTINGS.browserSearchEngine,
Expand Down
130 changes: 130 additions & 0 deletions apps/web/src/components/settings/ThreadsSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ import {
type NewWorktreeBaseFrom,
ProviderDriverKind,
ProviderInstanceId,
type ProviderInteractionMode,
ROOM_AGENT_ROLE_MAX_LENGTH,
RUNTIME_MODES,
type RuntimeMode,
} from "@threadlines/contracts";
import { DEFAULT_UNIFIED_SETTINGS } from "@threadlines/contracts/settings";
import {
AGENT_INVITES_LABELS,
AGENT_THREADS_LABELS,
GENERAL_CHATS_PLACEMENT_LABELS,
INTERACTION_MODE_LABELS,
NEW_WORKTREE_BASE_LABELS,
THREAD_ENV_MODE_LABELS,
} from "@threadlines/shared/appPlaces";
Expand All @@ -27,6 +31,8 @@ import { useState } from "react";

import { useSettings, useUpdateSettings } from "../../hooks/useSettings";
import { roomsEnabledFor } from "../../hooks/useRoomsEnabled";
import { interactionModeConfig, interactionModeOptions } from "../../interactionModeOptions";
import { cn } from "../../lib/utils";
import {
getCustomModelOptionsByInstance,
resolveAppModelSelectionState,
Expand All @@ -36,6 +42,8 @@ import {
import { canRunOnComputer } from "../../newThreadDefaults";
import { deriveDisplayProviderInstanceEntries } from "../../providerInstances";
import { useServerProviders } from "../../rpc/serverState";
import { runtimeModeConfig } from "../../runtimeModeOptions";
import { AccessOptionContent } from "../chat/ComposerRunControls";
import { ProviderModelPicker } from "../chat/ProviderModelPicker";
import { Button } from "../ui/button";
import { DraftInput } from "../ui/draft-input";
Expand Down Expand Up @@ -73,6 +81,8 @@ export function ThreadsSettingsPanel({ surface = "full" }: { surface?: "full" |
<SettingsSection place="threads.newThreads" description={computerNote}>
<NewThreadAgentRow />
<NewThreadRoomRow />
<NewThreadModeRow />
<NewThreadAccessRow />
<DefaultThreadEnvModeRow />
<NewWorktreeBaseRow />
<AgentThreadsRow />
Expand Down Expand Up @@ -325,6 +335,126 @@ export function NewThreadRoomRow() {
);
}

export function NewThreadModeRow() {
const settings = useSettings();
const { updateSettings } = useUpdateSettings();
const mode = settings.newThreadInteractionMode;
const current = interactionModeConfig[mode];
const CurrentIcon = current.icon;
return (
<SettingsRow
place="threads.mode"
resetAction={
mode !== DEFAULT_UNIFIED_SETTINGS.newThreadInteractionMode ? (
<SettingResetButton
label="build or plan"
onClick={() =>
updateSettings({
newThreadInteractionMode: DEFAULT_UNIFIED_SETTINGS.newThreadInteractionMode,
})
}
/>
) : null
}
control={
<Select
value={mode}
onValueChange={(value) => {
if (value === "default" || value === "plan") {
updateSettings({ newThreadInteractionMode: value satisfies ProviderInteractionMode });
}
}}
>
<SelectTrigger className="w-full sm:w-44" aria-label="Default build or plan mode">
<span className="inline-flex min-w-0 items-center gap-1.5">
<CurrentIcon aria-hidden="true" className="size-3.5 shrink-0 text-muted-foreground" />
<SelectValue>{INTERACTION_MODE_LABELS[mode]}</SelectValue>
</span>
</SelectTrigger>
<SelectPopup align="end" alignItemWithTrigger={false} matchTriggerWidth={false}>
{interactionModeOptions.map((option) => {
const Icon = option.icon;
return (
<SelectItem key={option.mode} value={option.mode} className="min-w-60 py-2">
<div className="grid min-w-0 gap-0.5">
<span className="inline-flex items-center gap-1.5 font-medium">
<Icon
aria-hidden="true"
className="size-3.5 shrink-0 text-muted-foreground"
/>
{INTERACTION_MODE_LABELS[option.mode]}
</span>
<span className="text-muted-foreground text-xs leading-4">
{option.description}
</span>
</div>
</SelectItem>
);
})}
</SelectPopup>
</Select>
}
/>
);
}

export function NewThreadAccessRow() {
const settings = useSettings();
const { updateSettings } = useUpdateSettings();
const mode = settings.newThreadRuntimeMode;
const current = runtimeModeConfig[mode];
const CurrentIcon = current.icon;
return (
<SettingsRow
place="threads.access"
resetAction={
mode !== DEFAULT_UNIFIED_SETTINGS.newThreadRuntimeMode ? (
<SettingResetButton
label="new thread access"
onClick={() =>
updateSettings({
newThreadRuntimeMode: DEFAULT_UNIFIED_SETTINGS.newThreadRuntimeMode,
})
}
/>
) : null
}
control={
<Select
value={mode}
onValueChange={(value) => {
if (RUNTIME_MODES.includes(value as RuntimeMode)) {
updateSettings({ newThreadRuntimeMode: value as RuntimeMode });
}
}}
>
<SelectTrigger className="w-full sm:w-auto sm:min-w-44" aria-label="Default access level">
<span className="inline-flex min-w-0 items-center gap-1.5">
<CurrentIcon
aria-hidden="true"
className={cn(
"size-3.5 shrink-0",
mode === "full-access" ? "text-warning-foreground" : "text-muted-foreground",
)}
/>
<SelectValue>{current.label}</SelectValue>
</span>
</SelectTrigger>
<SelectPopup align="end" alignItemWithTrigger={false} matchTriggerWidth={false}>
{RUNTIME_MODES.map((candidate) => (
<SelectItem key={candidate} value={candidate} className="min-w-64 py-2">
<AccessOptionContent
option={{ mode: candidate, ...runtimeModeConfig[candidate] }}
/>
</SelectItem>
))}
</SelectPopup>
</Select>
}
/>
);
}

export function DefaultThreadEnvModeRow() {
const settings = useSettings();
const { updateSettings } = useUpdateSettings();
Expand Down
4 changes: 4 additions & 0 deletions apps/web/src/components/settings/settingsRowRegistry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ import {
ContinueAfterRestartRow,
DefaultThreadEnvModeRow,
GeneralChatsPlacementRow,
NewThreadAccessRow,
NewThreadAgentRow,
NewThreadModeRow,
NewThreadRoomRow,
NewWorktreeBaseRow,
RoomsRow,
Expand Down Expand Up @@ -144,6 +146,8 @@ export const SETTINGS_ROWS = {
// Threads
"threads.agent": live(NewThreadAgentRow),
"threads.room": live(NewThreadRoomRow),
"threads.mode": live(NewThreadModeRow),
"threads.access": live(NewThreadAccessRow),
"threads.startIn": live(DefaultThreadEnvModeRow),
"threads.worktreesFrom": live(NewWorktreeBaseRow),
"threads.agentThreads": live(AgentThreadsRow),
Expand Down
Loading
Loading