|
5 | 5 | import { appMeta, AppWithMocks, type AppStory } from "./meta.js"; |
6 | 6 | import { |
7 | 7 | NOW, |
| 8 | + STABLE_TIMESTAMP, |
8 | 9 | createWorkspace, |
9 | 10 | createSSHWorkspace, |
| 11 | + createLocalWorkspace, |
| 12 | + createUserMessage, |
| 13 | + createStreamingChatHandler, |
10 | 14 | groupWorkspacesByProject, |
11 | 15 | createMockAPI, |
12 | 16 | installMockAPI, |
13 | 17 | type GitStatusFixture, |
14 | 18 | } from "./mockFactory"; |
| 19 | +import { expandProjects } from "./storyHelpers"; |
15 | 20 |
|
16 | 21 | export default { |
17 | 22 | ...appMeta, |
@@ -175,3 +180,121 @@ export const GitStatusVariations: AppStory = { |
175 | 180 | /> |
176 | 181 | ), |
177 | 182 | }; |
| 183 | + |
| 184 | +/** |
| 185 | + * All runtime badge variations showing different runtime types. |
| 186 | + * Each type has distinct colors: |
| 187 | + * - SSH: blue theme |
| 188 | + * - Worktree: purple theme |
| 189 | + * - Local: gray theme |
| 190 | + * |
| 191 | + * The streaming workspaces show the "working" state with pulse animation. |
| 192 | + */ |
| 193 | +export const RuntimeBadgeVariations: AppStory = { |
| 194 | + render: () => ( |
| 195 | + <AppWithMocks |
| 196 | + setup={() => { |
| 197 | + // Idle workspaces (one of each type) |
| 198 | + const sshIdle = createSSHWorkspace({ |
| 199 | + id: "ws-ssh-idle", |
| 200 | + name: "ssh-idle", |
| 201 | + projectName: "runtime-demo", |
| 202 | + host: "dev.example.com", |
| 203 | + createdAt: new Date(NOW - 3600000).toISOString(), |
| 204 | + }); |
| 205 | + const worktreeIdle = createWorkspace({ |
| 206 | + id: "ws-worktree-idle", |
| 207 | + name: "worktree-idle", |
| 208 | + projectName: "runtime-demo", |
| 209 | + createdAt: new Date(NOW - 7200000).toISOString(), |
| 210 | + }); |
| 211 | + const localIdle = createLocalWorkspace({ |
| 212 | + id: "ws-local-idle", |
| 213 | + name: "local-idle", |
| 214 | + projectName: "runtime-demo", |
| 215 | + createdAt: new Date(NOW - 10800000).toISOString(), |
| 216 | + }); |
| 217 | + |
| 218 | + // Working workspaces (streaming - shows pulse animation) |
| 219 | + const sshWorking = createSSHWorkspace({ |
| 220 | + id: "ws-ssh-working", |
| 221 | + name: "ssh-working", |
| 222 | + projectName: "runtime-demo", |
| 223 | + host: "prod.example.com", |
| 224 | + createdAt: new Date(NOW - 1800000).toISOString(), |
| 225 | + }); |
| 226 | + const worktreeWorking = createWorkspace({ |
| 227 | + id: "ws-worktree-working", |
| 228 | + name: "worktree-working", |
| 229 | + projectName: "runtime-demo", |
| 230 | + createdAt: new Date(NOW - 900000).toISOString(), |
| 231 | + }); |
| 232 | + const localWorking = createLocalWorkspace({ |
| 233 | + id: "ws-local-working", |
| 234 | + name: "local-working", |
| 235 | + projectName: "runtime-demo", |
| 236 | + createdAt: new Date(NOW - 300000).toISOString(), |
| 237 | + }); |
| 238 | + |
| 239 | + const workspaces = [ |
| 240 | + sshIdle, |
| 241 | + worktreeIdle, |
| 242 | + localIdle, |
| 243 | + sshWorking, |
| 244 | + worktreeWorking, |
| 245 | + localWorking, |
| 246 | + ]; |
| 247 | + |
| 248 | + // Create streaming handlers for working workspaces |
| 249 | + const workingMessage = createUserMessage("msg-1", "Working on task...", { |
| 250 | + historySequence: 1, |
| 251 | + timestamp: STABLE_TIMESTAMP, |
| 252 | + }); |
| 253 | + |
| 254 | + const chatHandlers = new Map([ |
| 255 | + [ |
| 256 | + "ws-ssh-working", |
| 257 | + createStreamingChatHandler({ |
| 258 | + messages: [workingMessage], |
| 259 | + streamingMessageId: "stream-ssh", |
| 260 | + model: "claude-sonnet-4-20250514", |
| 261 | + historySequence: 2, |
| 262 | + streamText: "Processing SSH task...", |
| 263 | + }), |
| 264 | + ], |
| 265 | + [ |
| 266 | + "ws-worktree-working", |
| 267 | + createStreamingChatHandler({ |
| 268 | + messages: [workingMessage], |
| 269 | + streamingMessageId: "stream-worktree", |
| 270 | + model: "claude-sonnet-4-20250514", |
| 271 | + historySequence: 2, |
| 272 | + streamText: "Processing worktree task...", |
| 273 | + }), |
| 274 | + ], |
| 275 | + [ |
| 276 | + "ws-local-working", |
| 277 | + createStreamingChatHandler({ |
| 278 | + messages: [workingMessage], |
| 279 | + streamingMessageId: "stream-local", |
| 280 | + model: "claude-sonnet-4-20250514", |
| 281 | + historySequence: 2, |
| 282 | + streamText: "Processing local task...", |
| 283 | + }), |
| 284 | + ], |
| 285 | + ]); |
| 286 | + |
| 287 | + installMockAPI( |
| 288 | + createMockAPI({ |
| 289 | + projects: groupWorkspacesByProject(workspaces), |
| 290 | + workspaces, |
| 291 | + chatHandlers, |
| 292 | + }) |
| 293 | + ); |
| 294 | + |
| 295 | + // Expand the project so badges are visible |
| 296 | + expandProjects(["/home/user/projects/runtime-demo"]); |
| 297 | + }} |
| 298 | + /> |
| 299 | + ), |
| 300 | +}; |
0 commit comments