create-feltkit 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/create.js +3 -3
- package/package.json +4 -4
- package/scaffold.d.ts +1 -1
- package/scaffold.js +8 -5
- package/template/README.md +72 -177
- package/template/_gitignore +4 -0
- package/template/agent/agent.ts +28 -0
- package/template/agent/channels/eve.ts +6 -0
- package/template/agent/instructions.md +24 -0
- package/template/agent/lib/deterministic.ts +46 -0
- package/template/agent/lib/feltkit-capabilities.json +294 -0
- package/template/agent/tools/crew_artifacts_create.ts +4 -0
- package/template/agent/tools/crew_context_read.ts +4 -0
- package/template/agent/tools/crew_context_record.ts +4 -0
- package/template/agent/tools/crew_context_search.ts +4 -0
- package/template/agent/tools/crew_decisions_propose.ts +4 -0
- package/template/agent/tools/crew_tasks_add.ts +6 -0
- package/template/agent/tools/crew_tasks_list.ts +4 -0
- package/template/agent/tools/crew_tasks_note.ts +4 -0
- package/template/agent/tools/crew_workspace_overview.ts +4 -0
- package/template/agent/tools/crew_workstreams_update.ts +6 -0
- package/template/agent/tools/web_fetch.ts +1 -0
- package/template/agent/tools/web_search.ts +3 -0
- package/template/feltkit/_generated/api.ts +8 -4
- package/template/feltkit/activity.ts +26 -0
- package/template/feltkit/app.ts +147 -54
- package/template/feltkit/boards.ts +10 -0
- package/template/feltkit/decisions.ts +99 -0
- package/template/feltkit/knowledge.ts +119 -0
- package/template/feltkit/model.ts +96 -0
- package/template/feltkit/work.ts +45 -0
- package/template/feltkit/workspace.ts +171 -0
- package/template/index.html +1 -1
- package/template/native/App.tsx +249 -0
- package/template/package.json +11 -5
- package/template/shared/rules.ts +23 -0
- package/template/src/App.tsx +177 -528
- package/template/src/screens/activity.tsx +66 -0
- package/template/src/screens/agent.tsx +188 -0
- package/template/src/screens/context.tsx +71 -0
- package/template/src/screens/decisions.tsx +89 -0
- package/template/src/screens/home.tsx +140 -0
- package/template/src/screens/team.tsx +13 -0
- package/template/src/screens/work.tsx +149 -0
- package/template/src/styles.css +201 -118
- package/template/src/ui.tsx +179 -0
- package/template/tests/crew.test.ts +111 -0
- package/template/tsconfig.json +18 -3
- package/template-managed/Dockerfile +2 -2
- package/template-managed/README.md +1 -1
- package/template-managed/package.json +3 -3
- package/template-tasks/README.md +383 -0
- package/template-tasks/_gitignore +12 -0
- package/template-tasks/feltkit/_generated/api.ts +10 -0
- package/template-tasks/feltkit/app.ts +73 -0
- package/template-tasks/index.html +17 -0
- package/template-tasks/native/App.tsx +220 -0
- package/template-tasks/native/native.json +5 -0
- package/template-tasks/package.json +30 -0
- package/template-tasks/public/apple-touch-icon.png +0 -0
- package/template-tasks/public/favicon.png +0 -0
- package/template-tasks/public/theme.js +7 -0
- package/template-tasks/shared/rules.ts +18 -0
- package/template-tasks/src/App.tsx +557 -0
- package/template-tasks/src/main.tsx +17 -0
- package/template-tasks/src/styles.css +134 -0
- package/template-tasks/src/theme.tsx +58 -0
- package/template-tasks/tsconfig.json +16 -0
- package/template-tasks/vite.config.ts +6 -0
- /package/{template → template-tasks}/feltkit/inbox.ts +0 -0
- /package/{template → template-tasks}/feltkit/projects.ts +0 -0
- /package/{template → template-tasks}/feltkit/tasks.ts +0 -0
- /package/{template → template-tasks}/public/feltkit-mark.png +0 -0
- /package/{template → template-tasks}/tests/tasks.test.ts +0 -0
package/template/src/App.tsx
CHANGED
|
@@ -1,569 +1,218 @@
|
|
|
1
|
-
import { useEffect, useMemo,
|
|
2
|
-
import { useConnectionState, useFeltKit, useMutation, useQueryState,
|
|
1
|
+
import { useEffect, useMemo, useState } from "react";
|
|
2
|
+
import { AcceptInvitation, SignIn, TenantSwitcher, useAuth, useAuthRedirect, useConnectionState, useFeltKit, useMutation, useQueryState, useTenant } from "@feltdb/feltkit/react";
|
|
3
3
|
import { api } from "../feltkit/_generated/api";
|
|
4
4
|
import { ThemeToggle } from "./theme";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function describe(error: unknown): string {
|
|
14
|
-
const e = error as FeltKitClientError;
|
|
15
|
-
if (e?.code === "FORBIDDEN") return `Not allowed: ${e.message}. Switch to a member to make changes.`;
|
|
16
|
-
if (e?.code === "UNAUTHORIZED") return "Sign in to continue.";
|
|
17
|
-
if (e?.code === "CONFLICT") return e.message;
|
|
18
|
-
return e?.message ?? String(error);
|
|
19
|
-
}
|
|
5
|
+
import { Failure, Loading, useRun, type Screen } from "./ui";
|
|
6
|
+
import { Home } from "./screens/home";
|
|
7
|
+
import { Work } from "./screens/work";
|
|
8
|
+
import { ContextScreen } from "./screens/context";
|
|
9
|
+
import { Decisions } from "./screens/decisions";
|
|
10
|
+
import { Agent, useAgentSessions } from "./screens/agent";
|
|
11
|
+
import { Activity } from "./screens/activity";
|
|
12
|
+
import { Team } from "./screens/team";
|
|
20
13
|
|
|
21
14
|
export function App() {
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const tried = useRef(false);
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
if (session && !principal && session.devUsers.length && !tried.current) {
|
|
34
|
-
tried.current = true;
|
|
35
|
-
void signInAsDevUser(session.devUsers[0]!.id);
|
|
36
|
-
}
|
|
37
|
-
}, [session, principal, signInAsDevUser]);
|
|
38
|
-
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
if (!notice) return;
|
|
41
|
-
const timer = setTimeout(() => setNotice(null), 6000);
|
|
42
|
-
return () => clearTimeout(timer);
|
|
43
|
-
}, [notice]);
|
|
44
|
-
|
|
45
|
-
const report = (error: unknown) => setNotice({ tone: "error", text: describe(error) });
|
|
46
|
-
|
|
47
|
-
// A link back into the app: a provider sign-in, a password reset, or an e-mail verification.
|
|
48
|
-
const client = useFeltKit();
|
|
49
|
-
const [resetToken, setResetToken] = useState<string | null>(null);
|
|
50
|
-
useEffect(() => {
|
|
51
|
-
void client.handleRedirect().then((r) => {
|
|
52
|
-
if (r?.kind === "reset") setResetToken(r.token);
|
|
53
|
-
else if (r?.kind === "verified") setNotice({ tone: "info", text: `${r.email} is verified.` });
|
|
54
|
-
else if (r?.kind === "error" || r?.kind === "verify-failed") setNotice({ tone: "error", text: r.message });
|
|
55
|
-
});
|
|
56
|
-
}, [client]);
|
|
57
|
-
|
|
58
|
-
return (
|
|
59
|
-
<div className="shell">
|
|
60
|
-
<header className="topbar">
|
|
61
|
-
<div className="brand">
|
|
62
|
-
<img className="mark" src="/feltkit-mark.png" width="30" height="30" alt="" />
|
|
63
|
-
<span className="brand-name">Tasks</span>
|
|
64
|
-
{session && !session.environment.production && <span className="env">{session.environment.name}</span>}
|
|
65
|
-
</div>
|
|
66
|
-
<div className="topbar-right">
|
|
67
|
-
<span className={`live ${live ? "on" : ""}`} title={live ? "Live: changes from anyone appear here immediately" : "Connecting to the change stream…"}>
|
|
68
|
-
<span className="dot" /> {live ? "Live" : "Connecting"}
|
|
69
|
-
</span>
|
|
70
|
-
{session && session.devUsers.length > 0 && (
|
|
71
|
-
<label className="identity">
|
|
72
|
-
<span className="sr-only">Signed in as</span>
|
|
73
|
-
<select
|
|
74
|
-
value={principal?.id ?? ""}
|
|
75
|
-
onChange={(e) => (e.target.value ? signInAsDevUser(e.target.value).catch(report) : signOut())}
|
|
76
|
-
aria-label="Signed in as"
|
|
77
|
-
>
|
|
78
|
-
<option value="">Signed out</option>
|
|
79
|
-
{session.devUsers.map((u) => (
|
|
80
|
-
<option key={u.id} value={u.id}>
|
|
81
|
-
{u.name} · {u.roles.join(", ")}
|
|
82
|
-
</option>
|
|
83
|
-
))}
|
|
84
|
-
</select>
|
|
85
|
-
</label>
|
|
86
|
-
)}
|
|
87
|
-
{principal && !session?.devUsers.length && (
|
|
88
|
-
<button className="ghost signout" onClick={() => void signOut().catch(report)} title={principal.displayName ?? principal.id}>
|
|
89
|
-
Sign out
|
|
90
|
-
</button>
|
|
91
|
-
)}
|
|
92
|
-
<ThemeToggle />
|
|
93
|
-
{session?.dashboard && (
|
|
94
|
-
<a className="dashboard-link" href={session.dashboard} target="_blank" rel="noreferrer">
|
|
95
|
-
Dashboard ↗
|
|
96
|
-
</a>
|
|
97
|
-
)}
|
|
98
|
-
</div>
|
|
99
|
-
</header>
|
|
100
|
-
|
|
101
|
-
{notice && (
|
|
102
|
-
<div className={`notice ${notice.tone}`} role="status">
|
|
103
|
-
{notice.text}
|
|
104
|
-
<button className="ghost" onClick={() => setNotice(null)} aria-label="Dismiss">
|
|
105
|
-
×
|
|
106
|
-
</button>
|
|
107
|
-
</div>
|
|
108
|
-
)}
|
|
109
|
-
|
|
110
|
-
{!session ? (
|
|
111
|
-
<div className="center muted">Connecting…</div>
|
|
112
|
-
) : resetToken ? (
|
|
113
|
-
<div className="center">
|
|
114
|
-
<div className="card narrow">
|
|
115
|
-
<ResetForm token={resetToken} onDone={() => (setResetToken(null), setNotice({ tone: "info", text: "Your password is set. Other sessions were signed out." }))} />
|
|
116
|
-
</div>
|
|
15
|
+
const auth = useAuth();
|
|
16
|
+
const { redirect } = useAuthRedirect();
|
|
17
|
+
if (auth.loading) return <Loading label="Opening Crew" />;
|
|
18
|
+
if (!auth.user) {
|
|
19
|
+
// An invitation link asks for sign-in itself (as the invited address), so it is the only form shown.
|
|
20
|
+
return (
|
|
21
|
+
<div className="center">
|
|
22
|
+
<div className="welcome">
|
|
23
|
+
{redirect?.kind === "invitation" ? <AcceptInvitation brand={{ name: "Crew" }} /> : <SignIn brand={{ name: "Crew" }} title="Sign in to Crew" />}
|
|
117
24
|
</div>
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
onSignIn={signIn}
|
|
124
|
-
onSignUp={signUp}
|
|
125
|
-
/>
|
|
126
|
-
) : (
|
|
127
|
-
<Workspace canWrite={canWrite} canComplete={canComplete} role={principal.roles.join(", ")} onError={report} />
|
|
128
|
-
)}
|
|
129
|
-
|
|
130
|
-
{session && !session.environment.production && (
|
|
131
|
-
<footer className="footer">
|
|
132
|
-
Every project, task, and note lives in this app’s single FeltDB instance. Changes made by other people, agents (through AppPort), and services appear here live.
|
|
133
|
-
</footer>
|
|
134
|
-
)}
|
|
135
|
-
</div>
|
|
136
|
-
);
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
if (!auth.tenant) return <ChooseWorkspace />;
|
|
29
|
+
return <Workspace key={auth.tenant.id} />;
|
|
137
30
|
}
|
|
138
31
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
onSignUp: (input: { email: string; password: string; name?: string }) => Promise<void>;
|
|
145
|
-
}) {
|
|
32
|
+
/** Signed in, working in no workspace yet: accept an invitation, open one of yours, or start one. */
|
|
33
|
+
function ChooseWorkspace() {
|
|
34
|
+
const tenant = useTenant();
|
|
35
|
+
const [name, setName] = useState("Launch a Business");
|
|
36
|
+
const { busy, error, run } = useRun();
|
|
146
37
|
return (
|
|
147
38
|
<div className="center">
|
|
148
|
-
<div className="
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
39
|
+
<div className="welcome">
|
|
40
|
+
<div>
|
|
41
|
+
<div className="eyebrow">Crew</div>
|
|
42
|
+
<h1>Where people and agents get things done together</h1>
|
|
43
|
+
<p className="muted" style={{ marginTop: 8 }}>A workspace holds one mission: the people working on it, the plan, what you have learned and decided, and an agent that works beside you.</p>
|
|
44
|
+
</div>
|
|
45
|
+
<AcceptInvitation brand={{ name: "Crew" }} />
|
|
46
|
+
{tenant.tenants.length ? (
|
|
47
|
+
<div className="panel">
|
|
48
|
+
<div className="panel-head"><h2>Your workspaces</h2></div>
|
|
49
|
+
<div className="list">
|
|
50
|
+
{tenant.tenants.map((t) => (
|
|
51
|
+
<button key={t.id} className="item click" onClick={() => run(() => tenant.switchTo(t.id))}>
|
|
52
|
+
<div className="grow"><div style={{ fontWeight: 600 }}>{t.name}</div><div className="small muted">{t.role}</div></div>
|
|
53
|
+
<span className="btn small">Open</span>
|
|
157
54
|
</button>
|
|
158
55
|
))}
|
|
159
56
|
</div>
|
|
160
|
-
|
|
161
|
-
) :
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
<
|
|
165
|
-
|
|
57
|
+
</div>
|
|
58
|
+
) : null}
|
|
59
|
+
<form className="panel panel-pad stack" onSubmit={(e) => { e.preventDefault(); void run(() => tenant.create(name.trim())); }}>
|
|
60
|
+
<h2>Start a workspace</h2>
|
|
61
|
+
<div className="field">
|
|
62
|
+
<label htmlFor="ws-name">Workspace name</label>
|
|
63
|
+
<input id="ws-name" className="input" value={name} onChange={(e) => setName(e.target.value)} required maxLength={80} />
|
|
64
|
+
</div>
|
|
65
|
+
<Failure error={error ?? tenant.error} />
|
|
66
|
+
<div><button className="btn primary" disabled={busy || !name.trim()}>Create workspace</button></div>
|
|
67
|
+
</form>
|
|
166
68
|
</div>
|
|
167
69
|
</div>
|
|
168
70
|
);
|
|
169
71
|
}
|
|
170
72
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
setBusy(true);
|
|
185
|
-
try {
|
|
186
|
-
client.setToken(token.trim());
|
|
187
|
-
const session = await client.session();
|
|
188
|
-
if (!session.principal) {
|
|
189
|
-
client.setToken(null);
|
|
190
|
-
setError("That session isn't valid, or it has expired or been revoked. Ask your operator for a new one.");
|
|
191
|
-
}
|
|
192
|
-
} catch (err) {
|
|
193
|
-
client.setToken(null);
|
|
194
|
-
setError(describe(err));
|
|
195
|
-
} finally {
|
|
196
|
-
setBusy(false);
|
|
197
|
-
}
|
|
198
|
-
};
|
|
199
|
-
return (
|
|
200
|
-
<form className="stack" onSubmit={submit}>
|
|
201
|
-
<h1>Sign in</h1>
|
|
202
|
-
<p className="muted">Access to this app is given by its operator. Paste the session they issued you.</p>
|
|
203
|
-
<label className="field">
|
|
204
|
-
<span>Session</span>
|
|
205
|
-
<input type="password" autoComplete="off" spellCheck={false} value={token} onChange={(e) => setToken(e.target.value)} placeholder="abs_…" required autoFocus />
|
|
206
|
-
</label>
|
|
207
|
-
{error && <p className="error-text" role="alert">{error}</p>}
|
|
208
|
-
<button className="wide" type="submit" disabled={busy || !token.trim()}>{busy ? "Signing in…" : "Sign in"}</button>
|
|
209
|
-
</form>
|
|
210
|
-
);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
/** Sign in to an existing account, or create one (auth.accounts in feltkit/app.ts). */
|
|
214
|
-
function AccountForm(props: {
|
|
215
|
-
signUpOpen: boolean;
|
|
216
|
-
/** The app sends account e-mail (auth.accounts.email): offer "forgot password". */
|
|
217
|
-
email: boolean;
|
|
218
|
-
providers: Array<{ id: string; name: string }>;
|
|
219
|
-
onSignIn: (input: { email: string; password: string }) => Promise<void>;
|
|
220
|
-
onSignUp: (input: { email: string; password: string; name?: string }) => Promise<void>;
|
|
221
|
-
}) {
|
|
222
|
-
const client = useFeltKit();
|
|
223
|
-
const [mode, setMode] = useState<"signin" | "signup" | "forgot">("signin");
|
|
224
|
-
const [name, setName] = useState("");
|
|
225
|
-
const [email, setEmail] = useState("");
|
|
226
|
-
const [password, setPassword] = useState("");
|
|
227
|
-
const [error, setError] = useState<string | null>(null);
|
|
228
|
-
const [info, setInfo] = useState<string | null>(null);
|
|
229
|
-
const [busy, setBusy] = useState(false);
|
|
230
|
-
const creating = mode === "signup";
|
|
231
|
-
const forgot = mode === "forgot";
|
|
232
|
-
const go = (next: typeof mode) => (setMode(next), setError(null), setInfo(null));
|
|
233
|
-
const submit = async (e: FormEvent) => {
|
|
234
|
-
e.preventDefault();
|
|
235
|
-
setError(null);
|
|
236
|
-
setInfo(null);
|
|
237
|
-
setBusy(true);
|
|
238
|
-
try {
|
|
239
|
-
if (forgot) setInfo((await client.requestPasswordReset(email)).message);
|
|
240
|
-
else if (creating) {
|
|
241
|
-
await props.onSignUp({ email, password, ...(name.trim() ? { name: name.trim() } : {}) });
|
|
242
|
-
if (!client.tokens.get()) setInfo("Check your e-mail: open the link we sent to verify your address, then sign in.");
|
|
243
|
-
} else await props.onSignIn({ email, password });
|
|
244
|
-
} catch (err) {
|
|
245
|
-
setError(describe(err));
|
|
246
|
-
} finally {
|
|
247
|
-
setBusy(false);
|
|
248
|
-
}
|
|
249
|
-
};
|
|
250
|
-
return (
|
|
251
|
-
<form className="stack" onSubmit={submit}>
|
|
252
|
-
<h1>{forgot ? "Reset your password" : creating ? "Create your account" : "Sign in"}</h1>
|
|
253
|
-
{!forgot &&
|
|
254
|
-
props.providers.map((p) => (
|
|
255
|
-
<button key={p.id} type="button" className="secondary wide" onClick={() => client.signInWith(p.id)}>
|
|
256
|
-
Continue with {p.name}
|
|
257
|
-
</button>
|
|
258
|
-
))}
|
|
259
|
-
{!forgot && props.providers.length > 0 && <p className="muted small-text">or with your e-mail address</p>}
|
|
260
|
-
{creating && <input value={name} onChange={(e) => setName(e.target.value)} placeholder="Name" aria-label="Name" autoComplete="name" />}
|
|
261
|
-
<input type="email" value={email} onChange={(e) => setEmail(e.target.value)} placeholder="E-mail" aria-label="E-mail" autoComplete="email" required />
|
|
262
|
-
{!forgot && (
|
|
263
|
-
<input
|
|
264
|
-
type="password"
|
|
265
|
-
value={password}
|
|
266
|
-
onChange={(e) => setPassword(e.target.value)}
|
|
267
|
-
placeholder={creating ? "Password (12+ characters)" : "Password"}
|
|
268
|
-
aria-label="Password"
|
|
269
|
-
autoComplete={creating ? "new-password" : "current-password"}
|
|
270
|
-
minLength={creating ? 12 : undefined}
|
|
271
|
-
required
|
|
272
|
-
/>
|
|
273
|
-
)}
|
|
274
|
-
{error && <p className="error-text">{error}</p>}
|
|
275
|
-
{info && <p className="muted">{info}</p>}
|
|
276
|
-
<button type="submit" disabled={busy || !email || (!forgot && !password)}>
|
|
277
|
-
{busy ? "One moment…" : forgot ? "Send reset link" : creating ? "Create account" : "Sign in"}
|
|
278
|
-
</button>
|
|
279
|
-
{mode === "signin" && props.email && (
|
|
280
|
-
<p className="muted small-text">
|
|
281
|
-
<button type="button" className="link" onClick={() => go("forgot")}>
|
|
282
|
-
Forgot your password?
|
|
283
|
-
</button>
|
|
284
|
-
</p>
|
|
285
|
-
)}
|
|
286
|
-
{(props.signUpOpen || forgot) && (
|
|
287
|
-
<p className="muted small-text">
|
|
288
|
-
{forgot ? "Remembered it? " : creating ? "Already have an account? " : "New here? "}
|
|
289
|
-
<button type="button" className="link" onClick={() => go(creating || forgot ? "signin" : "signup")}>
|
|
290
|
-
{creating || forgot ? "Sign in" : "Create an account"}
|
|
291
|
-
</button>
|
|
292
|
-
</p>
|
|
293
|
-
)}
|
|
294
|
-
</form>
|
|
295
|
-
);
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
/** A password reset link opened: choose a new password. */
|
|
299
|
-
function ResetForm({ token, onDone }: { token: string; onDone: () => void }) {
|
|
300
|
-
const client = useFeltKit();
|
|
301
|
-
const [password, setPassword] = useState("");
|
|
302
|
-
const [error, setError] = useState<string | null>(null);
|
|
303
|
-
const [busy, setBusy] = useState(false);
|
|
304
|
-
const submit = async (e: FormEvent) => {
|
|
305
|
-
e.preventDefault();
|
|
306
|
-
setError(null);
|
|
307
|
-
setBusy(true);
|
|
308
|
-
try {
|
|
309
|
-
await client.resetPassword(token, password);
|
|
310
|
-
onDone();
|
|
311
|
-
} catch (err) {
|
|
312
|
-
setError(describe(err));
|
|
313
|
-
} finally {
|
|
314
|
-
setBusy(false);
|
|
315
|
-
}
|
|
316
|
-
};
|
|
317
|
-
return (
|
|
318
|
-
<form className="stack" onSubmit={submit}>
|
|
319
|
-
<h1>Choose a new password</h1>
|
|
320
|
-
<input type="password" value={password} onChange={(e) => setPassword(e.target.value)} placeholder="New password (12+ characters)" aria-label="New password" autoComplete="new-password" minLength={12} required />
|
|
321
|
-
{error && <p className="error-text">{error}</p>}
|
|
322
|
-
<button type="submit" disabled={busy || !password}>
|
|
323
|
-
{busy ? "One moment…" : "Set password and sign in"}
|
|
324
|
-
</button>
|
|
325
|
-
</form>
|
|
326
|
-
);
|
|
73
|
+
const NAV: Array<{ id: Screen; label: string; icon: string }> = [
|
|
74
|
+
{ id: "home", label: "Home", icon: "◎" },
|
|
75
|
+
{ id: "work", label: "Work", icon: "☰" },
|
|
76
|
+
{ id: "context", label: "Context", icon: "❏" },
|
|
77
|
+
{ id: "decisions", label: "Decisions", icon: "◆" },
|
|
78
|
+
{ id: "agent", label: "Agent", icon: "✦" },
|
|
79
|
+
{ id: "activity", label: "Activity", icon: "↻" },
|
|
80
|
+
{ id: "team", label: "Team", icon: "☺" },
|
|
81
|
+
];
|
|
82
|
+
|
|
83
|
+
function screenFromHash(): Screen {
|
|
84
|
+
const id = location.hash.replace(/^#\/?/, "").split("/")[0] as Screen;
|
|
85
|
+
return NAV.some((n) => n.id === id) ? id : "home";
|
|
327
86
|
}
|
|
328
87
|
|
|
329
|
-
function Workspace(
|
|
330
|
-
const
|
|
331
|
-
const
|
|
332
|
-
const
|
|
333
|
-
const [
|
|
334
|
-
|
|
335
|
-
const
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
onError(error);
|
|
347
|
-
}
|
|
88
|
+
function Workspace() {
|
|
89
|
+
const auth = useAuth();
|
|
90
|
+
const overview = useQueryState(api.workspace.overview);
|
|
91
|
+
const [screen, setScreenState] = useState<Screen>(screenFromHash);
|
|
92
|
+
const [agentPrompt, setAgentPrompt] = useState<string | null>(null);
|
|
93
|
+
const connection = useConnectionState();
|
|
94
|
+
const sessions = useAgentSessions();
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
const on = () => setScreenState(screenFromHash());
|
|
97
|
+
addEventListener("hashchange", on);
|
|
98
|
+
return () => removeEventListener("hashchange", on);
|
|
99
|
+
}, []);
|
|
100
|
+
const go = (next: Screen, prompt?: string) => {
|
|
101
|
+
if (prompt) setAgentPrompt(prompt);
|
|
102
|
+
location.hash = `/${next}`;
|
|
103
|
+
setScreenState(next);
|
|
104
|
+
scrollTo({ top: 0 });
|
|
348
105
|
};
|
|
349
|
-
|
|
350
|
-
if (
|
|
351
|
-
if (
|
|
352
|
-
|
|
106
|
+
const o = overview.data as any;
|
|
107
|
+
if (overview.error) return <div className="center"><Failure error={overview.error} /></div>;
|
|
108
|
+
if (!o) return <Loading label="Opening the workspace" />;
|
|
109
|
+
if (!o.setup) return <Setup canManage={auth.can("crew.manage")} />;
|
|
110
|
+
const waiting = sessions.waiting;
|
|
111
|
+
const pendingDecisions = o.attention.decisions.length;
|
|
112
|
+
const counts: Partial<Record<Screen, number>> = { agent: waiting, decisions: pendingDecisions };
|
|
113
|
+
const live = connection;
|
|
353
114
|
return (
|
|
354
|
-
<div className="
|
|
355
|
-
<aside className="
|
|
356
|
-
<div className="
|
|
357
|
-
<
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
<span
|
|
362
|
-
|
|
363
|
-
</span>
|
|
115
|
+
<div className="shell">
|
|
116
|
+
<aside className="side" aria-label="Workspace">
|
|
117
|
+
<div className="brand"><span className="brand-mark">C</span>Crew</div>
|
|
118
|
+
<TenantSwitcher allowCreate />
|
|
119
|
+
<nav className="nav">
|
|
120
|
+
{NAV.map((n) => (
|
|
121
|
+
<button key={n.id} aria-current={screen === n.id ? "page" : undefined} onClick={() => go(n.id)}>
|
|
122
|
+
<span aria-hidden>{n.icon}</span>{n.label}
|
|
123
|
+
{counts[n.id] ? <span className="count" aria-label={`${counts[n.id]} waiting`}>{counts[n.id]}</span> : null}
|
|
364
124
|
</button>
|
|
365
125
|
))}
|
|
366
126
|
</nav>
|
|
367
|
-
|
|
368
|
-
<
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
127
|
+
<div className="side-foot">
|
|
128
|
+
<span className={`live ${live ? "" : "off"}`}>{live ? "Live" : "Reconnecting"}</span>
|
|
129
|
+
<div className="spread small">
|
|
130
|
+
<span className="clip">{auth.user?.displayName ?? auth.user?.id}</span>
|
|
131
|
+
<button className="btn ghost small" onClick={() => void auth.signOut()}>Sign out</button>
|
|
132
|
+
</div>
|
|
133
|
+
<ThemeToggle />
|
|
134
|
+
</div>
|
|
373
135
|
</aside>
|
|
374
136
|
<main className="main">
|
|
375
|
-
|
|
376
|
-
<
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
</button>
|
|
387
|
-
</form>
|
|
388
|
-
)}
|
|
389
|
-
</div>
|
|
390
|
-
)}
|
|
137
|
+
<div className="mobile-head">
|
|
138
|
+
<div className="brand"><span className="brand-mark">C</span>{auth.tenant?.name}</div>
|
|
139
|
+
<div className="row"><span className={`live ${live ? "" : "off"}`}>{live ? "Live" : "Reconnecting"}</span><button className="btn small" onClick={() => go("team")}>Team</button></div>
|
|
140
|
+
</div>
|
|
141
|
+
{screen === "home" && <Home o={o} go={go} sessions={sessions} />}
|
|
142
|
+
{screen === "work" && <Work workstreams={o.workstreams} />}
|
|
143
|
+
{screen === "context" && <ContextScreen workstreams={o.workstreams} />}
|
|
144
|
+
{screen === "decisions" && <Decisions workstreams={o.workstreams} />}
|
|
145
|
+
{screen === "agent" && <Agent sessions={sessions} prompt={agentPrompt} onPromptUsed={() => setAgentPrompt(null)} />}
|
|
146
|
+
{screen === "activity" && <Activity />}
|
|
147
|
+
{screen === "team" && <Team />}
|
|
391
148
|
</main>
|
|
149
|
+
<nav className="tabs" aria-label="Workspace">
|
|
150
|
+
{NAV.filter((n) => n.id !== "team").map((n) => (
|
|
151
|
+
<button key={n.id} aria-current={screen === n.id ? "page" : undefined} onClick={() => go(n.id)}>
|
|
152
|
+
<span aria-hidden style={{ fontSize: 17 }}>{n.icon}</span>{n.label}
|
|
153
|
+
{counts[n.id] ? <span className="dot" /> : null}
|
|
154
|
+
</button>
|
|
155
|
+
))}
|
|
156
|
+
</nav>
|
|
392
157
|
</div>
|
|
393
158
|
);
|
|
394
159
|
}
|
|
395
160
|
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
const
|
|
404
|
-
|
|
405
|
-
const
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
onError(error);
|
|
414
|
-
} finally {
|
|
415
|
-
setBusy(false);
|
|
416
|
-
}
|
|
161
|
+
const TEMPLATE = {
|
|
162
|
+
title: "Launch a Business",
|
|
163
|
+
outcome: "Validate and launch a viable business by identifying a real customer problem, validating demand, defining an offer, establishing operational readiness, and executing a launch.",
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
/** The workspace's first minutes: what it is trying to accomplish, and how to start. */
|
|
167
|
+
function Setup({ canManage }: { canManage: boolean }) {
|
|
168
|
+
const auth = useAuth();
|
|
169
|
+
const setup = useMutation(api.workspace.setup);
|
|
170
|
+
const [template, setTemplate] = useState<"launch-a-business" | "blank">("launch-a-business");
|
|
171
|
+
const [title, setTitle] = useState(TEMPLATE.title);
|
|
172
|
+
const [outcome, setOutcome] = useState(TEMPLATE.outcome);
|
|
173
|
+
const { busy, error, run } = useRun();
|
|
174
|
+
const pick = (next: "launch-a-business" | "blank") => {
|
|
175
|
+
setTemplate(next);
|
|
176
|
+
if (next === "blank") { if (title === TEMPLATE.title) setTitle(auth.tenant?.name ?? ""); if (outcome === TEMPLATE.outcome) setOutcome(""); }
|
|
177
|
+
else { setTitle(TEMPLATE.title); setOutcome(TEMPLATE.outcome); }
|
|
417
178
|
};
|
|
418
|
-
|
|
419
|
-
const items = tasks.data ?? [];
|
|
420
|
-
const open = items.filter((t) => !t.done).length;
|
|
179
|
+
if (!canManage) return <div className="center"><div className="welcome panel panel-pad"><h2>{auth.tenant?.name}</h2><p className="muted">An owner or admin is setting this workspace up. It will open here as soon as they do.</p></div></div>;
|
|
421
180
|
return (
|
|
422
|
-
<
|
|
423
|
-
<
|
|
424
|
-
<
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
</span>
|
|
428
|
-
</div>
|
|
429
|
-
{canWrite && (
|
|
430
|
-
<form onSubmit={add} className="add-task">
|
|
431
|
-
<input value={title} onChange={(e) => setTitle(e.target.value)} placeholder="Add a task and press Enter" aria-label="New task" maxLength={200} disabled={busy} />
|
|
432
|
-
</form>
|
|
433
|
-
)}
|
|
434
|
-
{tasks.isLoading && !tasks.data ? (
|
|
435
|
-
<p className="muted pad">Loading tasks…</p>
|
|
436
|
-
) : items.length === 0 ? (
|
|
437
|
-
<div className="empty small">
|
|
438
|
-
<p>No tasks yet.</p>
|
|
439
|
-
<p className="muted">{canWrite ? "Add one above." : "A member can add tasks."}</p>
|
|
181
|
+
<div className="center">
|
|
182
|
+
<form className="welcome" onSubmit={(e) => { e.preventDefault(); void run(() => setup({ title: title.trim(), outcome: outcome.trim(), template })); }}>
|
|
183
|
+
<div>
|
|
184
|
+
<div className="eyebrow">Step 1 of 3 · {auth.tenant?.name}</div>
|
|
185
|
+
<h1>What is this workspace trying to accomplish?</h1>
|
|
440
186
|
</div>
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
<
|
|
445
|
-
))}
|
|
446
|
-
</ul>
|
|
447
|
-
)}
|
|
448
|
-
</section>
|
|
449
|
-
);
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
type Task = { id: string; title: string; details?: string; done: boolean; createdBy: string; completedBy?: string };
|
|
453
|
-
|
|
454
|
-
function TaskRow({ task, canWrite, canComplete, open, onToggleOpen, onError }: { task: Task; canWrite: boolean; canComplete: boolean; open: boolean; onToggleOpen: () => void; onError: (e: unknown) => void }) {
|
|
455
|
-
const setDone = useMutation(api.tasks.setDone);
|
|
456
|
-
const update = useMutation(api.tasks.update);
|
|
457
|
-
const remove = useMutation(api.tasks.remove);
|
|
458
|
-
const [editing, setEditing] = useState(false);
|
|
459
|
-
const [draft, setDraft] = useState(task.title);
|
|
460
|
-
const [details, setDetails] = useState(task.details ?? "");
|
|
461
|
-
|
|
462
|
-
useEffect(() => setDraft(task.title), [task.title]);
|
|
463
|
-
useEffect(() => setDetails(task.details ?? ""), [task.details]);
|
|
464
|
-
|
|
465
|
-
const save = async () => {
|
|
466
|
-
setEditing(false);
|
|
467
|
-
if (draft.trim() && draft.trim() !== task.title) await update({ id: task.id, title: draft }).catch(onError);
|
|
468
|
-
else setDraft(task.title);
|
|
469
|
-
};
|
|
470
|
-
|
|
471
|
-
return (
|
|
472
|
-
<li className={`task ${task.done ? "done" : ""} ${open ? "open" : ""}`}>
|
|
473
|
-
<div className="task-row">
|
|
474
|
-
<input type="checkbox" checked={task.done} disabled={!canComplete} onChange={(e) => setDone({ id: task.id, done: e.target.checked }).catch(onError)} aria-label={task.done ? "Reopen task" : "Complete task"} />
|
|
475
|
-
{editing ? (
|
|
476
|
-
<input
|
|
477
|
-
className="title-input"
|
|
478
|
-
value={draft}
|
|
479
|
-
autoFocus
|
|
480
|
-
onChange={(e) => setDraft(e.target.value)}
|
|
481
|
-
onBlur={save}
|
|
482
|
-
onKeyDown={(e) => {
|
|
483
|
-
if (e.key === "Enter") void save();
|
|
484
|
-
if (e.key === "Escape") {
|
|
485
|
-
setDraft(task.title);
|
|
486
|
-
setEditing(false);
|
|
487
|
-
}
|
|
488
|
-
}}
|
|
489
|
-
aria-label="Task title"
|
|
490
|
-
/>
|
|
491
|
-
) : (
|
|
492
|
-
<button className="title" onClick={onToggleOpen} onDoubleClick={() => canWrite && setEditing(true)} aria-expanded={open}>
|
|
493
|
-
{task.title}
|
|
187
|
+
<div className="choice" role="group" aria-label="Start from">
|
|
188
|
+
<button type="button" aria-pressed={template === "launch-a-business"} onClick={() => pick("launch-a-business")}>
|
|
189
|
+
<strong>Launch a Business</strong>
|
|
190
|
+
<span className="small muted">Five workstreams from customer discovery to go-to-market, with starter tasks and hypotheses to test.</span>
|
|
494
191
|
</button>
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
<button className="ghost icon" onClick={() => setEditing(true)} aria-label="Rename task" title="Rename">
|
|
499
|
-
✎
|
|
192
|
+
<button type="button" aria-pressed={template === "blank"} onClick={() => pick("blank")}>
|
|
193
|
+
<strong>Start blank</strong>
|
|
194
|
+
<span className="small muted">Your own mission and one workstream. Add the rest as you go.</span>
|
|
500
195
|
</button>
|
|
501
|
-
)}
|
|
502
|
-
</div>
|
|
503
|
-
{open && (
|
|
504
|
-
<div className="task-detail">
|
|
505
|
-
<label className="field">
|
|
506
|
-
<span>Details</span>
|
|
507
|
-
<textarea
|
|
508
|
-
value={details}
|
|
509
|
-
onChange={(e) => setDetails(e.target.value)}
|
|
510
|
-
onBlur={() => details !== (task.details ?? "") && update({ id: task.id, details }).catch(onError)}
|
|
511
|
-
placeholder={canWrite ? "Add details…" : "No details"}
|
|
512
|
-
readOnly={!canWrite}
|
|
513
|
-
rows={3}
|
|
514
|
-
maxLength={4000}
|
|
515
|
-
/>
|
|
516
|
-
</label>
|
|
517
|
-
<Notes taskId={task.id} canWrite={canWrite} onError={onError} />
|
|
518
|
-
{canWrite && (
|
|
519
|
-
<div className="row-end">
|
|
520
|
-
<button className="danger-link" onClick={() => remove({ id: task.id }).catch(onError)}>
|
|
521
|
-
Delete task
|
|
522
|
-
</button>
|
|
523
|
-
</div>
|
|
524
|
-
)}
|
|
525
196
|
</div>
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
const notes = useQueryState(api.tasks.notes, { taskId });
|
|
533
|
-
const addNote = useMutation(api.tasks.addNote);
|
|
534
|
-
const [text, setText] = useState("");
|
|
535
|
-
const submit = async (event: FormEvent) => {
|
|
536
|
-
event.preventDefault();
|
|
537
|
-
if (!text.trim()) return;
|
|
538
|
-
try {
|
|
539
|
-
await addNote({ taskId, text });
|
|
540
|
-
setText("");
|
|
541
|
-
} catch (error) {
|
|
542
|
-
onError(error);
|
|
543
|
-
}
|
|
544
|
-
};
|
|
545
|
-
return (
|
|
546
|
-
<div className="notes">
|
|
547
|
-
<div className="notes-title">
|
|
548
|
-
Notes <span className="muted">· stored by AppPort Services Files</span>
|
|
549
|
-
</div>
|
|
550
|
-
{(notes.data ?? []).map((n) => (
|
|
551
|
-
<div className="note" key={n.id}>
|
|
552
|
-
<div className="note-meta muted">
|
|
553
|
-
{n.author} · {new Date(n.createdAt).toLocaleString()}
|
|
554
|
-
</div>
|
|
555
|
-
<div className="note-text">{n.text}</div>
|
|
197
|
+
<div className="panel panel-pad stack">
|
|
198
|
+
<div className="field"><label htmlFor="m-title">Mission</label><input id="m-title" className="input" value={title} onChange={(e) => setTitle(e.target.value)} required maxLength={120} /></div>
|
|
199
|
+
<div className="field"><label htmlFor="m-outcome">Desired outcome</label><textarea id="m-outcome" className="textarea" value={outcome} onChange={(e) => setOutcome(e.target.value)} required maxLength={2000} placeholder="What will be true when this succeeds?" /></div>
|
|
200
|
+
{template === "launch-a-business" ? <p className="small muted">Starter content is marked as hypotheses and examples. Nothing in it counts as evidence until someone verifies what they found.</p> : null}
|
|
201
|
+
<Failure error={error} />
|
|
202
|
+
<div className="row"><button className="btn primary" disabled={busy || !title.trim() || !outcome.trim()}>{busy ? "Setting up…" : "Set up the workspace"}</button><span className="small muted">Next: invite people and activate the agent.</span></div>
|
|
556
203
|
</div>
|
|
557
|
-
|
|
558
|
-
{notes.data?.length === 0 && <p className="muted small-text">No notes yet.</p>}
|
|
559
|
-
{canWrite && (
|
|
560
|
-
<form onSubmit={submit} className="note-form">
|
|
561
|
-
<input value={text} onChange={(e) => setText(e.target.value)} placeholder="Leave a note" aria-label="New note" maxLength={8000} />
|
|
562
|
-
<button className="secondary" type="submit" disabled={!text.trim()}>
|
|
563
|
-
Add
|
|
564
|
-
</button>
|
|
565
|
-
</form>
|
|
566
|
-
)}
|
|
204
|
+
</form>
|
|
567
205
|
</div>
|
|
568
206
|
);
|
|
569
207
|
}
|
|
208
|
+
|
|
209
|
+
export function useMembers(): Map<string, string> {
|
|
210
|
+
const client = useFeltKit();
|
|
211
|
+
const [names, setNames] = useState(new Map<string, string>());
|
|
212
|
+
useEffect(() => {
|
|
213
|
+
let live = true;
|
|
214
|
+
client.members().then((m) => live && setNames(new Map(m.map((x: any) => [x.principalId, x.displayName ?? x.email ?? x.principalId])))).catch(() => undefined);
|
|
215
|
+
return () => { live = false; };
|
|
216
|
+
}, [client]);
|
|
217
|
+
return useMemo(() => names, [names]);
|
|
218
|
+
}
|