Commit fb49197
authored
feat: Optimistically render conversation items before subscription confirms (#1209)
Adds a generic optimisticItems mechanism to the session store so any conversation item type can be displayed immediately before the real event arrives from the main process. Currently used for user messages, but the OptimisticItem union is designed to be extended for future use cases.
1. Add OptimisticItem type and optimisticItems array to AgentSession store
2. Append an optimistic user message when a prompt is sent, before the server round-trip
3. Clear optimistic items when the real session/prompt event arrives or on error
4. Merge optimistic items into the conversation view between confirmed items and queued messages
5. Add useOptimisticItemsForTask hook and store setters (appendOptimisticItem, clearOptimisticItems, appendEventAndClearOptimisticItems)1 parent 83bb341 commit fb49197
5 files changed
Lines changed: 87 additions & 11 deletions
File tree
- apps/code/src/renderer/features/sessions
- components
- hooks
- service
- stores
Lines changed: 9 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
| 72 | + | |
71 | 73 | | |
72 | 74 | | |
73 | 75 | | |
| |||
79 | 81 | | |
80 | 82 | | |
81 | 83 | | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
89 | 91 | | |
90 | 92 | | |
91 | 93 | | |
| |||
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
98 | 99 | | |
99 | 100 | | |
100 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
101 | 113 | | |
102 | 114 | | |
103 | 115 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
53 | 56 | | |
54 | 57 | | |
55 | 58 | | |
| |||
205 | 208 | | |
206 | 209 | | |
207 | 210 | | |
| 211 | + | |
208 | 212 | | |
209 | 213 | | |
210 | 214 | | |
| |||
Lines changed: 21 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
819 | 819 | | |
820 | 820 | | |
821 | 821 | | |
822 | | - | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
823 | 831 | | |
824 | 832 | | |
825 | 833 | | |
| |||
997 | 1005 | | |
998 | 1006 | | |
999 | 1007 | | |
1000 | | - | |
| 1008 | + | |
1001 | 1009 | | |
1002 | 1010 | | |
1003 | 1011 | | |
| |||
1044 | 1052 | | |
1045 | 1053 | | |
1046 | 1054 | | |
1047 | | - | |
| 1055 | + | |
1048 | 1056 | | |
1049 | 1057 | | |
1050 | 1058 | | |
| |||
1059 | 1067 | | |
1060 | 1068 | | |
1061 | 1069 | | |
| 1070 | + | |
1062 | 1071 | | |
1063 | 1072 | | |
1064 | 1073 | | |
1065 | 1074 | | |
1066 | 1075 | | |
1067 | 1076 | | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
1068 | 1083 | | |
1069 | 1084 | | |
1070 | 1085 | | |
1071 | 1086 | | |
1072 | 1087 | | |
1073 | | - | |
1074 | 1088 | | |
1075 | 1089 | | |
1076 | 1090 | | |
| |||
1082 | 1096 | | |
1083 | 1097 | | |
1084 | 1098 | | |
| 1099 | + | |
| 1100 | + | |
1085 | 1101 | | |
1086 | 1102 | | |
1087 | 1103 | | |
| |||
2144 | 2160 | | |
2145 | 2161 | | |
2146 | 2162 | | |
| 2163 | + | |
2147 | 2164 | | |
2148 | 2165 | | |
2149 | 2166 | | |
| |||
Lines changed: 41 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
31 | 38 | | |
32 | 39 | | |
33 | 40 | | |
| |||
63 | 70 | | |
64 | 71 | | |
65 | 72 | | |
| 73 | + | |
66 | 74 | | |
67 | 75 | | |
68 | 76 | | |
| |||
191 | 199 | | |
192 | 200 | | |
193 | 201 | | |
| 202 | + | |
194 | 203 | | |
195 | 204 | | |
196 | 205 | | |
| |||
334 | 343 | | |
335 | 344 | | |
336 | 345 | | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
337 | 378 | | |
338 | 379 | | |
339 | 380 | | |
| |||
0 commit comments