* Empty-state when no session is pinned. * * Two shapes: * * 1. Workspace has 0 sessions → fall back to the original single-CTA * spawn UI. Same copy as before to avoid regressing users who use * the keyboard. * * 2. Workspace has 1+ sessions → render them as inline resume/continue
(props: {
sessions: readonly SessionRecord[];
onResume: (sessionId: string) => void;
onSelectSession: (sessionId: string) => void;
onSpawn: () => void;
})
| 146 | * is enough; users read the timestamps. |
| 147 | */ |
| 148 | function EmptyState(props: { |
| 149 | sessions: readonly SessionRecord[]; |
| 150 | onResume: (sessionId: string) => void; |
| 151 | onSelectSession: (sessionId: string) => void; |
| 152 | onSpawn: () => void; |
| 153 | }): ReactElement { |
| 154 | if (props.sessions.length === 0) { |
| 155 | return ( |
| 156 | <div className="workspace-cta"> |
| 157 | <p className="workspace-cta-text"> |
| 158 | No session yet — start one to begin a conversation in this workspace. |
| 159 | </p> |
| 160 | <button type="button" className="workspace-cta-btn" onClick={props.onSpawn}> |
| 161 | Start a new session |
| 162 | </button> |
| 163 | <p className="workspace-cta-hint"> |
| 164 | <kbd>⌘T</kbd> works too. |
| 165 | </p> |
| 166 | </div> |
| 167 | ); |
| 168 | } |
| 169 | |
| 170 | // Sort newest-first by lastActiveAt; defensive against ISO parse failures. |
| 171 | const ordered = [...props.sessions].sort((a, b) => { |
| 172 | const at = new Date(a.lastActiveAt).getTime(); |
| 173 | const bt = new Date(b.lastActiveAt).getTime(); |
| 174 | return (Number.isFinite(bt) ? bt : 0) - (Number.isFinite(at) ? at : 0); |
| 175 | }); |
| 176 | |
| 177 | return ( |
| 178 | <div className="workspace-empty-state"> |
| 179 | <h2 className="workspace-empty-heading">Pick up where you left off</h2> |
| 180 | <ul className="workspace-empty-list"> |
| 181 | {ordered.map((s) => ( |
| 182 | <SessionCard |
| 183 | key={s.id} |
| 184 | record={s} |
| 185 | onClick={() => { |
| 186 | if (s.state === 'paused') props.onResume(s.id); |
| 187 | else props.onSelectSession(s.id); |
| 188 | }} |
| 189 | /> |
| 190 | ))} |
| 191 | </ul> |
| 192 | <div className="workspace-empty-divider"> |
| 193 | <span>or</span> |
| 194 | </div> |
| 195 | <button |
| 196 | type="button" |
| 197 | className="workspace-empty-secondary-btn" |
| 198 | onClick={props.onSpawn} |
| 199 | > |
| 200 | + Start a new session |
| 201 | </button> |
| 202 | <p className="workspace-cta-hint"> |
| 203 | <kbd>⌘T</kbd> works too. |
| 204 | </p> |
| 205 | </div> |
nothing calls this directly
no outgoing calls
no test coverage detected