Skip to content

Commit c5a929e

Browse files
t3dotggclaude
andauthored
fix(web): Woke dismiss syncs, preview mute is back, and subscription retries back off (#15034)
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
1 parent 798e945 commit c5a929e

11 files changed

Lines changed: 306 additions & 193 deletions

File tree

‎apps/web/src/components/ChatView.tsx‎

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ import {
8585
import { readPastedComposerContext } from "./composerInlineTokenPaste";
8686
import { isPasteAsTextShortcut } from "@t3tools/client-runtime/text-paste";
8787
import { effectiveSnoozed, threadWokeAt } from "@t3tools/client-runtime/state/thread-settled";
88-
import { useThreadActions } from "../hooks/useThreadActions";
88+
import { useAcknowledgeThreadWoke, useThreadActions } from "../hooks/useThreadActions";
8989
import {
9090
deriveProviderSubagentStatus,
9191
deriveReportedModelSelection,
@@ -251,6 +251,7 @@ import {
251251
useThreadPreviewState,
252252
} from "../previewStateStore";
253253
import { BrowserSettingsReadError } from "../browser/openFileInPreview";
254+
import { previewRuntimeTabId } from "../browser/previewRuntimeTabId";
254255
import { addBrowserSurface } from "./preview/addBrowserSurface";
255256
import { closePreviewSession } from "./preview/closePreviewSession";
256257
import { ThreadPreviewMiniPlayer } from "./preview/ThreadPreviewMiniPlayer";
@@ -2234,6 +2235,14 @@ export default function ChatView(props: ChatViewProps) {
22342235
selectActiveRightPanelSurface(state.byThreadKey, activeThreadRef),
22352236
);
22362237
const activePreviewState = useThreadPreviewState(activeThreadRef);
2238+
const activePreviewServerEpoch = activePreviewState.serverEpoch;
2239+
const resolvePreviewRuntimeTabId = useMemo(
2240+
() =>
2241+
activeThreadRef
2242+
? (tabId: string) => previewRuntimeTabId(activeThreadRef, activePreviewServerEpoch, tabId)
2243+
: undefined,
2244+
[activeThreadRef, activePreviewServerEpoch],
2245+
);
22372246
const activePreviewMiniPlayer = usePreviewMiniPlayerStore((state) =>
22382247
selectThreadPreviewMiniPlayer(state.byThreadKey, activeThreadRef),
22392248
);
@@ -6634,14 +6643,20 @@ export default function ChatView(props: ChatViewProps) {
66346643
activeThreadShell !== null && supportsSnooze
66356644
? threadWokeAt(activeThreadShell, { now: new Date().toISOString() })
66366645
: null;
6646+
const acknowledgeThreadWoke = useAcknowledgeThreadWoke();
66376647
const acknowledgeActiveThreadWoke = useCallback(() => {
66386648
if (activeThreadRef === null || activeThreadWokeAt === null) return;
6639-
markThreadVisited(scopedThreadKey(activeThreadRef), activeThreadWokeAt);
6640-
}, [activeThreadRef, activeThreadWokeAt, markThreadVisited]);
6641-
// Mirror of the sidebar's Woke pill for the open thread.
6642-
const activeThreadLastVisitedAt = useUiStateStore((store) =>
6649+
acknowledgeThreadWoke(activeThreadRef, activeThreadWokeAt);
6650+
}, [acknowledgeThreadWoke, activeThreadRef, activeThreadWokeAt]);
6651+
// Mirror of the sidebar's Woke pill for the open thread. Same watermark as
6652+
// the sidebar, so an acknowledgement from any device hides it.
6653+
const activeThreadLocalVisitedAt = useUiStateStore((store) =>
66436654
activeThreadKey === null ? undefined : store.threadLastVisitedAtById[activeThreadKey],
66446655
);
6656+
const activeThreadLastVisitedAt = resolveThreadLastVisitedAt(
6657+
activeThreadShell?.lastVisitedAt,
6658+
activeThreadLocalVisitedAt,
6659+
);
66456660
const activeThreadWokeVisible = useMemo(() => {
66466661
if (activeThreadWokeAt === null) return false;
66476662
if (activeThreadShell?.settledOverride === "settled") return false;
@@ -6651,7 +6666,7 @@ export default function ChatView(props: ChatViewProps) {
66516666
// above stamps it); folding that floor in here keeps a completion-
66526667
// triggered wake from flashing a banner for one frame before the stamp
66536668
// lands. An unparseable stored visit counts as never-visited: corrupt
6654-
// local data must not eat the wake signal.
6669+
// data must not eat the wake signal.
66556670
const storedVisitMs = activeThreadLastVisitedAt ? Date.parse(activeThreadLastVisitedAt) : NaN;
66566671
const completedAtMs = activeLatestRun?.completedAt
66576672
? Date.parse(activeLatestRun.completedAt)
@@ -11168,6 +11183,7 @@ export default function ChatView(props: ChatViewProps) {
1116811183
pendingSurfaceIds={pendingFileSurfaceIds}
1116911184
previewSessions={activePreviewState.sessions}
1117011185
desktopByTabId={activePreviewState.desktopByTabId}
11186+
previewRuntimeTabId={resolvePreviewRuntimeTabId}
1117111187
terminalLabelsById={activeTerminalLabelsById}
1117211188
onActivate={activateRightPanelSurface}
1117311189
onCloseSurface={closeRightPanelSurface}
@@ -11222,6 +11238,7 @@ export default function ChatView(props: ChatViewProps) {
1122211238
pendingSurfaceIds={pendingFileSurfaceIds}
1122311239
previewSessions={activePreviewState.sessions}
1122411240
desktopByTabId={activePreviewState.desktopByTabId}
11241+
previewRuntimeTabId={resolvePreviewRuntimeTabId}
1122511242
terminalLabelsById={activeTerminalLabelsById}
1122611243
onActivate={activateRightPanelSurface}
1122711244
onCloseSurface={closeRightPanelSurface}

‎apps/web/src/components/Sidebar.tsx‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ import {
130130
getThreadKeysToDeselectAfterDelete,
131131
useThreadSelectionStore,
132132
} from "../threadSelectionStore";
133-
import { useThreadActions } from "../hooks/useThreadActions";
133+
import { useAcknowledgeThreadWoke, useThreadActions } from "../hooks/useThreadActions";
134134
import { useHandleNewThread } from "../hooks/useHandleNewThread";
135135
import { useTerminalFocus } from "../hooks/useTerminalFocus";
136136
import { isCommandPaletteOpen, openCommandPalette } from "../commandPaletteBus";
@@ -2381,13 +2381,7 @@ export default function Sidebar() {
23812381
const setSelectionAnchor = useThreadSelectionStore((s) => s.setAnchor);
23822382
const toggleThreadSelection = useThreadSelectionStore((s) => s.toggleThread);
23832383
const rangeSelectTo = useThreadSelectionStore((s) => s.rangeSelectTo);
2384-
const markThreadVisited = useUiStateStore((s) => s.markThreadVisited);
2385-
const acknowledgeWoke = useCallback(
2386-
(threadRef: ScopedThreadRef, visitedAt: string) => {
2387-
markThreadVisited(scopedThreadKey(threadRef), visitedAt);
2388-
},
2389-
[markThreadVisited],
2390-
);
2384+
const acknowledgeWoke = useAcknowledgeThreadWoke();
23912385
const routeTarget = useParams({
23922386
strict: false,
23932387
select: (params) => resolveThreadRouteTarget(params),

‎apps/web/src/components/settings/SettingsPanels.tsx‎

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import {
4444
type ResponseStreamingMode,
4545
MIN_TERMINAL_FONT_SIZE,
4646
type QuitConfirmationMode,
47+
SidebarProjectSortOrder,
4748
} from "@t3tools/contracts/settings";
4849
import { resolveServerBackgroundActivitySettings } from "@t3tools/shared/backgroundActivitySettings";
4950
import { createModelSelection } from "@t3tools/shared/model";
@@ -87,6 +88,7 @@ import { useDesktopUpdateState } from "../../state/desktopUpdate";
8788
import {
8889
getCustomModelOptionsByInstance,
8990
resolveAppModelSelectionState,
91+
selectsPlanAgent,
9092
} from "../../modelSelection";
9193
import {
9294
applyProviderInstanceSettings,
@@ -181,6 +183,13 @@ const RESPONSE_STREAMING_MODE_DESCRIPTIONS: Record<ResponseStreamingMode, string
181183
paragraph: "Each paragraph or code block appears as soon as it is complete.",
182184
};
183185

186+
const SIDEBAR_PROJECT_SORT_ORDER_LABELS: Record<SidebarProjectSortOrder, string> = {
187+
updated_at: "Last user message",
188+
created_at: "Created at",
189+
manual: "Manual",
190+
};
191+
const isSidebarProjectSortOrder = Schema.is(SidebarProjectSortOrder);
192+
184193
const TIMESTAMP_FORMAT_LABELS = {
185194
locale: "System default",
186195
"12-hour": "12-hour",
@@ -552,6 +561,9 @@ export function useSettingsRestore(onRestored?: () => void) {
552561
DEFAULT_UNIFIED_SETTINGS.sidebarProjectGroupingMode
553562
? ["Project Grouping"]
554563
: []),
564+
...(settings.sidebarProjectSortOrder !== DEFAULT_UNIFIED_SETTINGS.sidebarProjectSortOrder
565+
? ["Project order"]
566+
: []),
555567
...(settings.sidebarWorkingShelfEnabled !==
556568
DEFAULT_UNIFIED_SETTINGS.sidebarWorkingShelfEnabled
557569
? ["Working section"]
@@ -690,6 +702,7 @@ export function useSettingsRestore(onRestored?: () => void) {
690702
settings.autoResumeLimitedThreads,
691703
settings.snoozeLimitedThreads,
692704
settings.sidebarProjectGroupingMode,
705+
settings.sidebarProjectSortOrder,
693706
settings.sidebarWorkingShelfEnabled,
694707
settings.sidebarThreadPreviewCount,
695708
settings.showSkillsInSlashMenu,
@@ -789,6 +802,7 @@ export function useSettingsRestore(onRestored?: () => void) {
789802
panelAnimationDurationMs: DEFAULT_UNIFIED_SETTINGS.panelAnimationDurationMs,
790803
sidebarThreadPreviewCount: DEFAULT_UNIFIED_SETTINGS.sidebarThreadPreviewCount,
791804
sidebarProjectGroupingMode: DEFAULT_UNIFIED_SETTINGS.sidebarProjectGroupingMode,
805+
sidebarProjectSortOrder: DEFAULT_UNIFIED_SETTINGS.sidebarProjectSortOrder,
792806
sidebarWorkingShelfEnabled: DEFAULT_UNIFIED_SETTINGS.sidebarWorkingShelfEnabled,
793807
sidebarAutoSettleAfterDays: DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleAfterDays,
794808
sidebarAutoSettleOnMerge: DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleOnMerge,
@@ -2270,6 +2284,46 @@ export function GeneralSettingsPanel() {
22702284
/>
22712285
}
22722286
/>
2287+
<SettingsRow
2288+
{...searchableSetting("project-order")}
2289+
description="Order of projects in the sidebar project picker and command palette."
2290+
resetAction={
2291+
settings.sidebarProjectSortOrder !==
2292+
DEFAULT_UNIFIED_SETTINGS.sidebarProjectSortOrder ? (
2293+
<SettingResetButton
2294+
label="project order"
2295+
onClick={() =>
2296+
updateSettings({
2297+
sidebarProjectSortOrder: DEFAULT_UNIFIED_SETTINGS.sidebarProjectSortOrder,
2298+
})
2299+
}
2300+
/>
2301+
) : null
2302+
}
2303+
control={
2304+
<Select
2305+
value={settings.sidebarProjectSortOrder}
2306+
onValueChange={(value) => {
2307+
if (isSidebarProjectSortOrder(value)) {
2308+
updateSettings({ sidebarProjectSortOrder: value });
2309+
}
2310+
}}
2311+
>
2312+
<SelectTrigger size="sm" className="w-full sm:w-44" aria-label="Project order">
2313+
<SelectValue>
2314+
{SIDEBAR_PROJECT_SORT_ORDER_LABELS[settings.sidebarProjectSortOrder]}
2315+
</SelectValue>
2316+
</SelectTrigger>
2317+
<SelectPopup align="end" alignItemWithTrigger={false}>
2318+
{SidebarProjectSortOrder.literals.map((sortOrder) => (
2319+
<SelectItem hideIndicator key={sortOrder} value={sortOrder}>
2320+
{SIDEBAR_PROJECT_SORT_ORDER_LABELS[sortOrder]}
2321+
</SelectItem>
2322+
))}
2323+
</SelectPopup>
2324+
</Select>
2325+
}
2326+
/>
22732327

22742328
<SettingsRow
22752329
serverScoped
@@ -3244,7 +3298,9 @@ export function GeneralSettingsPanel() {
32443298
onPromptChange={() => {}}
32453299
modelOptions={textGenModelOptions}
32463300
allowPromptInjectedEffort={false}
3247-
planModeEnabled={settings.planModeEnabled}
3301+
planModeEnabled={
3302+
settings.planModeEnabled || selectsPlanAgent(textGenModelOptions)
3303+
}
32483304
triggerClassName={SETTINGS_PICKER_TRIGGER_CLASSNAME}
32493305
onModelOptionsChange={(nextOptions) => {
32503306
updateSettings({

‎apps/web/src/components/settings/settingsSearch.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,12 @@ export const SETTINGS_SEARCH_ITEMS = [
280280
to: "/settings/general",
281281
searchTerms: ["combine matching repositories environments sidebar"],
282282
},
283+
{
284+
id: "project-order",
285+
title: "Project order",
286+
to: "/settings/general",
287+
searchTerms: ["sort projects sidebar manual created recent"],
288+
},
283289
{
284290
id: "snooze-limited-threads",
285291
title: "Snooze limited threads",

‎apps/web/src/hooks/useThreadActions.ts‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,30 @@ function useMarkThreadUnread() {
219219
);
220220
}
221221

222+
/**
223+
* Clears a thread's Woke marker by recording a visit at the wake time.
224+
* Servers with visited tracking own the watermark (thread.visit keeps the
225+
* later of the stored and supplied values, so this syncs to every device);
226+
* older servers keep the browser-local watermark.
227+
*/
228+
export function useAcknowledgeThreadWoke() {
229+
const visitThreadMutation = useAtomCommand(threadEnvironment.visit, { reportFailure: false });
230+
const markThreadVisited = useUiStateStore((state) => state.markThreadVisited);
231+
return useCallback(
232+
(target: ScopedThreadRef, wokeAt: string) => {
233+
if (readEnvironmentSupportsVisitedTracking(target.environmentId)) {
234+
void visitThreadMutation({
235+
environmentId: target.environmentId,
236+
input: { threadId: target.threadId, visitedAt: wokeAt },
237+
});
238+
return;
239+
}
240+
markThreadVisited(scopedThreadKey(target), wokeAt);
241+
},
242+
[markThreadVisited, visitThreadMutation],
243+
);
244+
}
245+
222246
export function useThreadActions() {
223247
const closeTerminal = useAtomCommand(terminalEnvironment.close);
224248
const archiveThreadMutation = useAtomCommand(threadEnvironment.archive, {

‎apps/web/src/modelSelection.test.ts‎

Lines changed: 35 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ import {
1515
getAppModelOptionsForInstance,
1616
resolveAppModelSelectionForInstance,
1717
resolveAppModelSelectionState,
18-
resolvePlanAgentHealPatch,
19-
withoutPlanAgentSelection,
2018
} from "./modelSelection";
2119

2220
function provider(input: {
@@ -865,81 +863,44 @@ describe("instance-scoped model selection", () => {
865863
});
866864
});
867865

868-
describe("withoutPlanAgentSelection", () => {
869-
const instance = ProviderInstanceId.make("opencode");
866+
describe("resolveAppModelSelectionState with the opencode plan agent", () => {
867+
const instanceId = ProviderInstanceId.make("opencode");
870868
const model = "opencode/gpt-5.4";
871-
872-
it("drops a stored plan agent option", () => {
873-
const selection = createModelSelection(instance, model, [
874-
{ id: "variant", value: "high" },
869+
const opencode: ServerProvider = {
870+
...provider({ provider: ProviderDriverKind.make("opencode"), instanceId: "opencode" }),
871+
models: [
872+
{
873+
slug: model,
874+
name: model,
875+
isCustom: false,
876+
capabilities: {
877+
optionDescriptors: [
878+
{
879+
id: "agent",
880+
label: "Agent",
881+
type: "select",
882+
options: [
883+
{ id: "build", label: "Build", isDefault: true },
884+
{ id: "plan", label: "Plan" },
885+
],
886+
currentValue: "build",
887+
},
888+
],
889+
},
890+
},
891+
],
892+
};
893+
const settings: UnifiedSettings = {
894+
...DEFAULT_UNIFIED_SETTINGS,
895+
planModeEnabled: false,
896+
textGenerationModelSelection: createModelSelection(instanceId, model, [
875897
{ id: "agent", value: "plan" },
876-
]);
877-
expect(withoutPlanAgentSelection(selection)).toEqual(
878-
createModelSelection(instance, model, [{ id: "variant", value: "high" }]),
879-
);
880-
});
881-
882-
it("keeps non-plan agent options", () => {
883-
const selection = createModelSelection(instance, model, [{ id: "agent", value: "build" }]);
884-
expect(withoutPlanAgentSelection(selection)).toBe(selection);
885-
});
886-
887-
it("omits options entirely when plan was the only stored option", () => {
888-
const selection = createModelSelection(instance, model, [{ id: "agent", value: "plan" }]);
889-
expect(withoutPlanAgentSelection(selection)).toEqual({ instanceId: instance, model });
890-
});
891-
892-
it("returns null and undefined selections unchanged", () => {
893-
expect(withoutPlanAgentSelection(null)).toBeNull();
894-
expect(withoutPlanAgentSelection(undefined)).toBeUndefined();
895-
});
896-
});
897-
898-
describe("resolvePlanAgentHealPatch", () => {
899-
const instance = ProviderInstanceId.make("opencode");
900-
const model = "opencode/gpt-5.4";
901-
const healed = createModelSelection(instance, model, [{ id: "variant", value: "high" }]);
902-
const storedPlan = createModelSelection(instance, model, [
903-
{ id: "variant", value: "high" },
904-
{ id: "agent", value: "plan" },
905-
]);
906-
const nullPatch = {
907-
planModeEnabled: true,
908-
textGenerationModelSelection: storedPlan,
909-
sourceControlWriterModelSelection: null,
898+
]),
910899
};
911900

912-
it("returns null when plan mode is on", () => {
913-
expect(resolvePlanAgentHealPatch(nullPatch)).toBeNull();
914-
});
915-
916-
it("returns null when nothing needs healing", () => {
917-
expect(
918-
resolvePlanAgentHealPatch({
919-
planModeEnabled: false,
920-
textGenerationModelSelection: healed,
921-
sourceControlWriterModelSelection: null,
922-
}),
923-
).toBeNull();
924-
});
925-
926-
it("patches the stored text generation selection to drop the plan agent", () => {
927-
expect(
928-
resolvePlanAgentHealPatch({
929-
planModeEnabled: false,
930-
textGenerationModelSelection: storedPlan,
931-
sourceControlWriterModelSelection: null,
932-
}),
933-
).toEqual({ textGenerationModelSelection: healed });
934-
});
935-
936-
it("patches a stored source control writer selection that uses the plan agent", () => {
937-
expect(
938-
resolvePlanAgentHealPatch({
939-
planModeEnabled: false,
940-
textGenerationModelSelection: healed,
941-
sourceControlWriterModelSelection: storedPlan,
942-
}),
943-
).toEqual({ sourceControlWriterModelSelection: healed });
901+
it("keeps a stored plan agent this device did not pick", () => {
902+
expect(resolveAppModelSelectionState(settings, [opencode])).toEqual(
903+
createModelSelection(instanceId, model, [{ id: "agent", value: "plan" }]),
904+
);
944905
});
945906
});

0 commit comments

Comments
 (0)