| 51 | } |
| 52 | |
| 53 | export function deriveShellRoute(pathname: string): { |
| 54 | selectedChannelId: string | null; |
| 55 | selectedView: AppView; |
| 56 | } { |
| 57 | if (pathname.startsWith("/channels/")) { |
| 58 | const [, , rawChannelId] = pathname.split("/"); |
| 59 | return { |
| 60 | selectedChannelId: rawChannelId ? decodeURIComponent(rawChannelId) : null, |
| 61 | selectedView: "channel", |
| 62 | }; |
| 63 | } |
| 64 | |
| 65 | if (pathname === "/agents") { |
| 66 | return { |
| 67 | selectedChannelId: null, |
| 68 | selectedView: "agents", |
| 69 | }; |
| 70 | } |
| 71 | |
| 72 | if (pathname === "/workflows" || pathname.startsWith("/workflows/")) { |
| 73 | return { |
| 74 | selectedChannelId: null, |
| 75 | selectedView: "workflows", |
| 76 | }; |
| 77 | } |
| 78 | |
| 79 | if (pathname === "/projects" || pathname.startsWith("/projects/")) { |
| 80 | return { |
| 81 | selectedChannelId: null, |
| 82 | selectedView: "projects", |
| 83 | }; |
| 84 | } |
| 85 | |
| 86 | if (pathname === "/pulse") { |
| 87 | return { |
| 88 | selectedChannelId: null, |
| 89 | selectedView: "pulse", |
| 90 | }; |
| 91 | } |
| 92 | |
| 93 | return { |
| 94 | selectedChannelId: null, |
| 95 | selectedView: "home", |
| 96 | }; |
| 97 | } |