Skip to content

Commit bb9d9b0

Browse files
klopez4212npub13fn4ahfnvaa2qwylvegdgeajqs0mph6v4qsw4jcqnw4mjh3hzh2quuucm5
andauthored
feat(desktop): add conversation-style DM composer (#1768)
Signed-off-by: npub13fn4ahfnvaa2qwylvegdgeajqs0mph6v4qsw4jcqnw4mjh3hzh2quuucm5 <8a675edd33677aa0389f6650d467b2041fb0df4ca820eacb009babb95e3715d4@sprout-oss.stage.blox.sqprod.co> Signed-off-by: Fizz <8a675edd33677aa0389f6650d467b2041fb0df4ca820eacb009babb95e3715d4@sprout-oss.stage.blox.sqprod.co> Co-authored-by: npub13fn4ahfnvaa2qwylvegdgeajqs0mph6v4qsw4jcqnw4mjh3hzh2quuucm5 <8a675edd33677aa0389f6650d467b2041fb0df4ca820eacb009babb95e3715d4@sprout-oss.stage.blox.sqprod.co>
1 parent 1c00682 commit bb9d9b0

36 files changed

Lines changed: 3273 additions & 1089 deletions

‎desktop/playwright.config.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export default defineConfig({
4545
"**/edit-agent.spec.ts",
4646
"**/doctor-cta-screenshots.spec.ts",
4747
"**/pubkey-display-screenshots.spec.ts",
48+
"**/dm-new-message-screenshots.spec.ts",
4849
"**/file-attachment.spec.ts",
4950
"**/image-attachment-gallery.spec.ts",
5051
"**/composer-image-draw.spec.ts",

‎desktop/src/app/AppShell.helpers.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { SearchHit } from "@/shared/api/types";
55
export type AppView =
66
| "home"
77
| "channel"
8+
| "messages"
89
| "agents"
910
| "workflows"
1011
| "pulse"
@@ -117,6 +118,13 @@ export function deriveShellRoute(pathname: string): {
117118
};
118119
}
119120

121+
if (pathname === "/messages/new") {
122+
return {
123+
selectedChannelId: null,
124+
selectedView: "messages",
125+
};
126+
}
127+
120128
if (pathname === "/agents") {
121129
return {
122130
selectedChannelId: null,

‎desktop/src/app/AppShell.tsx‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ export function AppShell() {
109109
const [searchFocusRequest, setSearchFocusRequest] = React.useState(0);
110110
const [browseDialogType, setBrowseDialogType] =
111111
React.useState<BrowseDialogType>(null);
112-
const [isNewDmOpen, setIsNewDmOpen] = React.useState(false);
113112
const [isCreateChannelOpen, setIsCreateChannelOpen] = React.useState(false);
114113
const [isHuddleDrawerOpen, setIsHuddleDrawerOpen] = React.useState(false);
115114
const mainInsetRef = React.useRef<HTMLElement>(null);
@@ -119,6 +118,7 @@ export function AppShell() {
119118
goAgents,
120119
goChannel,
121120
goHome,
121+
goNewMessage,
122122
goProjects,
123123
goPulse,
124124
goSettings,
@@ -547,7 +547,10 @@ export function AppShell() {
547547
// Dispatch `buzz://message` deep links into the router.
548548
useMessageDeepLinks();
549549

550-
const handleOpenNewDm = React.useCallback(() => setIsNewDmOpen(true), []);
550+
const handleOpenNewDm = React.useCallback(
551+
() => void goNewMessage(),
552+
[goNewMessage],
553+
);
551554
const handleOpenCreateChannel = React.useCallback(
552555
() => setIsCreateChannelOpen(true),
553556
[],
@@ -754,16 +757,14 @@ export function AppShell() {
754757
isCreatingChannel={createChannelMutation.isPending}
755758
isCreatingForum={createForumMutation.isPending}
756759
isLoading={channelsQuery.isLoading}
757-
isOpeningDm={openDmMutation.isPending}
758-
isNewDmOpen={isNewDmOpen}
759760
isCreateChannelOpen={isCreateChannelOpen}
760761
isPresencePending={presenceSession.isPending}
761762
onAddWorkspace={(workspace) => {
762763
const id = workspacesHook.addWorkspace(workspace);
763764
handleSwitchWorkspace(id);
764765
}}
765766
onAddWorkspaceOpenChange={setIsAddWorkspaceOpen}
766-
onNewDmOpenChange={setIsNewDmOpen}
767+
onNewMessage={handleOpenNewDm}
767768
onCreateChannelOpenChange={setIsCreateChannelOpen}
768769
onOpenAddWorkspace={() => setIsAddWorkspaceOpen(true)}
769770
onUpdateWorkspace={workspacesHook.updateWorkspace}

‎desktop/src/app/navigation/useAppNavigation.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,17 @@ export function useAppNavigation() {
185185
[commitNavigation],
186186
);
187187

188+
const goNewMessage = React.useCallback(
189+
(behavior?: NavigationBehavior) =>
190+
commitNavigation(
191+
{
192+
to: "/messages/new",
193+
},
194+
behavior,
195+
),
196+
[commitNavigation],
197+
);
198+
188199
const goForumPost = React.useCallback(
189200
(
190201
channelId: string,
@@ -284,6 +295,7 @@ export function useAppNavigation() {
284295
goChannel,
285296
goForumPost,
286297
goHome,
298+
goNewMessage,
287299
goProject,
288300
goProjects,
289301
goPulse,

‎desktop/src/app/routeTree.gen.ts‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { Route as agentsRouteImport } from "./routes/agents";
1414
import { Route as indexRouteImport } from "./routes/index";
1515
import { Route as workflowsDotworkflowIdRouteImport } from "./routes/workflows.$workflowId";
1616
import { Route as projectsDotprojectIdRouteImport } from "./routes/projects.$projectId";
17+
import { Route as messagesDotnewRouteImport } from "./routes/messages.new";
1718
import { Route as channelsDotchannelIdRouteImport } from "./routes/channels.$channelId";
1819
import { Route as channelsDotchannelIdDotpostsDotpostIdRouteImport } from "./routes/channels.$channelId.posts.$postId";
1920

@@ -62,6 +63,11 @@ const projectsDotprojectIdRoute = projectsDotprojectIdRouteImport.update({
6263
path: "/projects/$projectId",
6364
getParentRoute: () => rootRouteImport,
6465
} as any);
66+
const messagesDotnewRoute = messagesDotnewRouteImport.update({
67+
id: "/messages/new",
68+
path: "/messages/new",
69+
getParentRoute: () => rootRouteImport,
70+
} as any);
6571
const channelsDotchannelIdRoute = channelsDotchannelIdRouteImport.update({
6672
id: "/channels/$channelId",
6773
path: "/channels/$channelId",
@@ -83,6 +89,7 @@ export interface FileRoutesByFullPath {
8389
"/settings": typeof settingsRoute;
8490
"/workflows": typeof workflowsRoute;
8591
"/channels/$channelId": typeof channelsDotchannelIdRoute;
92+
"/messages/new": typeof messagesDotnewRoute;
8693
"/projects/$projectId": typeof projectsDotprojectIdRoute;
8794
"/workflows/$workflowId": typeof workflowsDotworkflowIdRoute;
8895
"/channels/$channelId/posts/$postId": typeof channelsDotchannelIdDotpostsDotpostIdRoute;
@@ -96,6 +103,7 @@ export interface FileRoutesByTo {
96103
"/settings": typeof settingsRoute;
97104
"/workflows": typeof workflowsRoute;
98105
"/channels/$channelId": typeof channelsDotchannelIdRoute;
106+
"/messages/new": typeof messagesDotnewRoute;
99107
"/projects/$projectId": typeof projectsDotprojectIdRoute;
100108
"/workflows/$workflowId": typeof workflowsDotworkflowIdRoute;
101109
"/channels/$channelId/posts/$postId": typeof channelsDotchannelIdDotpostsDotpostIdRoute;
@@ -110,6 +118,7 @@ export interface FileRoutesById {
110118
"/settings": typeof settingsRoute;
111119
"/workflows": typeof workflowsRoute;
112120
"/channels/$channelId": typeof channelsDotchannelIdRoute;
121+
"/messages/new": typeof messagesDotnewRoute;
113122
"/projects/$projectId": typeof projectsDotprojectIdRoute;
114123
"/workflows/$workflowId": typeof workflowsDotworkflowIdRoute;
115124
"/channels/$channelId/posts/$postId": typeof channelsDotchannelIdDotpostsDotpostIdRoute;
@@ -125,6 +134,7 @@ export interface FileRouteTypes {
125134
| "/settings"
126135
| "/workflows"
127136
| "/channels/$channelId"
137+
| "/messages/new"
128138
| "/projects/$projectId"
129139
| "/workflows/$workflowId"
130140
| "/channels/$channelId/posts/$postId";
@@ -138,6 +148,7 @@ export interface FileRouteTypes {
138148
| "/settings"
139149
| "/workflows"
140150
| "/channels/$channelId"
151+
| "/messages/new"
141152
| "/projects/$projectId"
142153
| "/workflows/$workflowId"
143154
| "/channels/$channelId/posts/$postId";
@@ -151,6 +162,7 @@ export interface FileRouteTypes {
151162
| "/settings"
152163
| "/workflows"
153164
| "/channels/$channelId"
165+
| "/messages/new"
154166
| "/projects/$projectId"
155167
| "/workflows/$workflowId"
156168
| "/channels/$channelId/posts/$postId";
@@ -165,6 +177,7 @@ export interface RootRouteChildren {
165177
settingsRoute: typeof settingsRoute;
166178
workflowsRoute: typeof workflowsRoute;
167179
channelsDotchannelIdRoute: typeof channelsDotchannelIdRoute;
180+
messagesDotnewRoute: typeof messagesDotnewRoute;
168181
projectsDotprojectIdRoute: typeof projectsDotprojectIdRoute;
169182
workflowsDotworkflowIdRoute: typeof workflowsDotworkflowIdRoute;
170183
channelsDotchannelIdDotpostsDotpostIdRoute: typeof channelsDotchannelIdDotpostsDotpostIdRoute;
@@ -235,6 +248,13 @@ declare module "@tanstack/react-router" {
235248
preLoaderRoute: typeof projectsDotprojectIdRouteImport;
236249
parentRoute: typeof rootRouteImport;
237250
};
251+
"/messages/new": {
252+
id: "/messages/new";
253+
path: "/messages/new";
254+
fullPath: "/messages/new";
255+
preLoaderRoute: typeof messagesDotnewRouteImport;
256+
parentRoute: typeof rootRouteImport;
257+
};
238258
"/channels/$channelId": {
239259
id: "/channels/$channelId";
240260
path: "/channels/$channelId";
@@ -261,6 +281,7 @@ const rootRouteChildren: RootRouteChildren = {
261281
settingsRoute: settingsRoute,
262282
workflowsRoute: workflowsRoute,
263283
channelsDotchannelIdRoute: channelsDotchannelIdRoute,
284+
messagesDotnewRoute: messagesDotnewRoute,
264285
projectsDotprojectIdRoute: projectsDotprojectIdRoute,
265286
workflowsDotworkflowIdRoute: workflowsDotworkflowIdRoute,
266287
channelsDotchannelIdDotpostsDotpostIdRoute:

‎desktop/src/app/routes.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export const routes = rootRoute("root.tsx", [
1010
route("/workflows/$workflowId", "workflows.$workflowId.tsx"),
1111
route("/projects", "projects.tsx"),
1212
route("/projects/$projectId", "projects.$projectId.tsx"),
13+
route("/messages/new", "messages.new.tsx"),
1314
route("/channels/$channelId", "channels.$channelId.tsx"),
1415
route(
1516
"/channels/$channelId/posts/$postId",
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { createFileRoute } from "@tanstack/react-router";
2+
3+
import { NewMessageScreen } from "@/features/messages/ui/NewMessageScreen";
4+
5+
export const Route = createFileRoute("/messages/new")({
6+
component: NewMessageScreen,
7+
});

‎desktop/src/features/agents/channelAgents.ts‎

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ export type CreateChannelManagedAgentResult =
8484
runtimeId: string;
8585
};
8686

87+
export type ProvisionChannelManagedAgentResult = {
88+
agent: ManagedAgent;
89+
created: boolean;
90+
runtimeId: string;
91+
};
92+
8793
export type CreateChannelManagedAgentBatchFailure = {
8894
kind: "generic" | "persona";
8995
name: string;
@@ -238,16 +244,13 @@ export async function ensureChannelAgentPresetInChannel(
238244
};
239245
}
240246

241-
export async function createChannelManagedAgent(
242-
channelId: string,
247+
export async function provisionChannelManagedAgent(
243248
input: CreateChannelManagedAgentInput,
244249
context?: {
245250
managedAgents?: ManagedAgent[];
246251
channelMemberPubkeys?: ReadonlySet<string>;
247252
},
248-
): Promise<CreateChannelManagedAgentResult> {
249-
const role = input.role ?? "bot";
250-
const ensureRunning = input.ensureRunning ?? true;
253+
): Promise<ProvisionChannelManagedAgentResult> {
251254
const trimmedName = input.name.trim();
252255

253256
if (trimmedName.length === 0) {
@@ -285,13 +288,8 @@ export async function createChannelManagedAgent(
285288
).agent
286289
: reusable;
287290

288-
const attached = await attachManagedAgentToChannel(channelId, {
289-
agent: updatedAgent,
290-
role,
291-
ensureRunning,
292-
});
293291
return {
294-
...attached,
292+
agent: updatedAgent,
295293
created: false,
296294
runtimeId: input.runtime.id,
297295
};
@@ -328,13 +326,8 @@ export async function createChannelManagedAgent(
328326
).agent
329327
: reusable;
330328

331-
const attached = await attachManagedAgentToChannel(channelId, {
332-
agent: updatedAgent,
333-
role,
334-
ensureRunning,
335-
});
336329
return {
337-
...attached,
330+
agent: updatedAgent,
338331
created: false,
339332
runtimeId: input.runtime.id,
340333
};
@@ -373,16 +366,32 @@ export async function createChannelManagedAgent(
373366
throw new Error(created.spawnError);
374367
}
375368

376-
const attached = await attachManagedAgentToChannel(channelId, {
369+
return {
377370
agent: created.agent,
378-
role,
379-
ensureRunning,
371+
created: true,
372+
runtimeId: input.runtime.id,
373+
};
374+
}
375+
376+
export async function createChannelManagedAgent(
377+
channelId: string,
378+
input: CreateChannelManagedAgentInput,
379+
context?: {
380+
managedAgents?: ManagedAgent[];
381+
channelMemberPubkeys?: ReadonlySet<string>;
382+
},
383+
): Promise<CreateChannelManagedAgentResult> {
384+
const provisioned = await provisionChannelManagedAgent(input, context);
385+
const attached = await attachManagedAgentToChannel(channelId, {
386+
agent: provisioned.agent,
387+
role: input.role ?? "bot",
388+
ensureRunning: input.ensureRunning ?? true,
380389
});
381390

382391
return {
383392
...attached,
384-
created: true,
385-
runtimeId: input.runtime.id,
393+
created: provisioned.created,
394+
runtimeId: provisioned.runtimeId,
386395
};
387396
}
388397

0 commit comments

Comments
 (0)