Coach: Admin-Karte als Setup-Assistent, sichtbarer Einstieg im Plan, Doku-Kapitel auf der Website
Solange der Coach aus ist, zeigt die Admin-Karte einen sauberen Pitch mit einem Knopf statt halb ausgegrauter Regler; danach ein echter Assistent: nur der naechste offene Schritt ist aufgeklappt, ein Fortschrittsbalken zaehlt mit, fertige Schritte falten sich zur Quittung. Arbeitende Knoepfe sind getoent statt grau (List models, Replace key), der deaktivierte Test-Knopf erklaert, welcher Schritt noch fehlt, Provider-Chips haben einen klaren gewaehlt-Zustand. Der Coach-Einstieg im Plan ist eine deutliche Karte mit Farbverlauf statt einer Settings-Zeile. Website: das #coach-Kapitel erklaert Pipeline, Provider, den komplett lokalen Betrieb inkl. "jedes Modell, das du pullen kannst, kannst du nutzen" und ehrlicher RAM-/Tempo-Beratung; docs/AI_COACH.md ergaenzt Modellwahl und Performance auf kleinen Boxen.
This commit is contained in:
1 parent
e134914026
commit
ae9d6785ac
7 files changed
+220
-48
No files matched your search
@@ -110,3 +110,34 @@
|
||||
}
|
||||
.adm-iconbtn{width:44px;height:44px;border-radius:12px;font-size:17px}
|
||||
.adm-empty{color:var(--label-3);font-size:13.5px;padding:10px 2px}
|
||||
|
||||
/* ---------- the Coach before setup: a pitch, not a form ---------- */
|
||||
.adm-hero{display:flex;flex-direction:column;align-items:flex-start;gap:4px;padding:6px 2px 2px}
|
||||
.adm-hero-av{
|
||||
width:52px;height:52px;border-radius:16px;display:grid;place-items:center;font-size:26px;
|
||||
background:linear-gradient(135deg,var(--acc),color-mix(in srgb,var(--acc) 55%,var(--teal)));
|
||||
color:var(--on-acc);margin-bottom:8px;box-shadow:0 8px 24px -8px color-mix(in srgb,var(--acc) 55%,transparent)
|
||||
}
|
||||
.adm-hero h2{margin:0 0 4px;font-size:22px;letter-spacing:-.022em}
|
||||
.adm-hero p{margin:0 0 14px;font-size:14px;line-height:1.5;color:var(--label-2)}
|
||||
.adm-hero-feats{display:grid;gap:10px;margin-bottom:18px}
|
||||
.adm-hero-feats>div{display:flex;gap:11px;align-items:flex-start}
|
||||
.adm-hero-feats .icn{color:var(--acc);font-size:18px;flex:none;margin-top:2px}
|
||||
.adm-hero-feats span{font-size:13.5px;line-height:1.45;color:var(--label-2)}
|
||||
.adm-hero-feats b{color:var(--label);font-weight:600}
|
||||
.adm-hero .btn{width:100%}
|
||||
|
||||
/* ---------- setup progress ---------- */
|
||||
.adm-progress{height:5px;border-radius:99px;background:var(--surface-2);overflow:hidden;margin:0 0 10px}
|
||||
.adm-progress i{display:block;height:100%;border-radius:99px;background:var(--acc);transition:width var(--med) var(--ease)}
|
||||
|
||||
/* ---------- provider chips: clearly idle vs. clearly chosen ---------- */
|
||||
.adm-chips .chip{
|
||||
background:var(--surface-2);border:1.5px solid transparent;color:var(--label);
|
||||
font-weight:500;text-transform:none
|
||||
}
|
||||
.adm-chips .chip.on{background:var(--acc-soft);border-color:var(--acc);color:var(--acc);font-weight:600}
|
||||
.adm-chips .chip:active{transform:scale(.97)}
|
||||
|
||||
/* a finished step's summary reads as a receipt, not a control */
|
||||
.adm-step.done>summary .adm-step-t span{color:var(--acc)}
|
||||
@@ -990,3 +990,21 @@ h4.sec{
|
||||
.exmedia img{height:380px}
|
||||
.hm-wrap{display:flex;flex-direction:column;align-items:center}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------- the Coach entry on Plan -- */
|
||||
.coach-cta{
|
||||
display:flex;align-items:center;gap:13px;width:100%;text-align:left;
|
||||
margin-bottom:12px;padding:14px 16px;border-radius:var(--r-card);
|
||||
background:linear-gradient(135deg,var(--acc-soft),color-mix(in srgb,var(--acc) 6%,var(--surface)));
|
||||
border:1px solid color-mix(in srgb,var(--acc) 35%,transparent);
|
||||
transition:transform var(--fast),filter var(--fast)
|
||||
}
|
||||
.coach-cta:active{transform:scale(.985);filter:brightness(1.06)}
|
||||
.coach-cta-av{
|
||||
width:42px;height:42px;border-radius:13px;flex:none;display:grid;place-items:center;font-size:21px;
|
||||
background:var(--acc);color:var(--on-acc);box-shadow:0 6px 18px -6px color-mix(in srgb,var(--acc) 60%,transparent)
|
||||
}
|
||||
.coach-cta-t{flex:1;min-width:0;display:flex;flex-direction:column;gap:1px}
|
||||
.coach-cta-t b{font-size:17px;font-weight:600;letter-spacing:-.015em;color:var(--label)}
|
||||
.coach-cta-t span{font-size:13px;color:var(--label-2);line-height:1.35}
|
||||
.coach-cta-chev{color:var(--acc);font-size:15px;flex:none}
|
||||
@@ -110,9 +110,30 @@ export default function AdminCoach() {
|
||||
const step3Done = authed
|
||||
const step4Done = !!d.model
|
||||
const step5Done = !!testResult?.ok || !!d.lastSuccess
|
||||
// Step numbers only count the steps this provider actually shows.
|
||||
// Step numbers only count the steps this provider actually shows — and like any wizard,
|
||||
// only the first unfinished step stands open; everything done folds to its summary line.
|
||||
const flags = [step1Done, ...(needsEndpoint ? [step2Done] : []), ...(hasCredentialStep ? [step3Done] : []), step4Done, step5Done]
|
||||
const doneCount = flags.filter(Boolean).length
|
||||
const firstTodo = flags.indexOf(false)
|
||||
let n = 1
|
||||
let idx = 0
|
||||
const num = () => n++
|
||||
const stepAt = () => { const i = idx++; return { open: i === (firstTodo === -1 ? -1 : firstTodo), key: i + ':' + (i === firstTodo) } }
|
||||
|
||||
// Off = a quiet, optional feature: one clean pitch and one button, no half-dimmed controls.
|
||||
if (!d.enabled) return <div className="card">
|
||||
<div className="adm-hero">
|
||||
<div className="adm-hero-av"><Icon name="sparkles" /></div>
|
||||
<h2>AI Coach</h2>
|
||||
<p>An optional coach that designs training plans and reviews what people actually log. Off right now — nobody sees it anywhere in the app.</p>
|
||||
<div className="adm-hero-feats">
|
||||
<div><Icon name="clipboard" /><span><b>Bring any AI.</b> An API key from Anthropic, OpenAI or Gemini — or a free local model via Ollama.</span></div>
|
||||
<div><Icon name="shield" /><span><b>Private by design.</b> A strict allowlist decides what leaves; every change needs the user's yes and can be undone.</span></div>
|
||||
<div><Icon name="person" /><span><b>Each user decides.</b> Turning it on only makes the Coach available; every person consents for themselves.</span></div>
|
||||
</div>
|
||||
<Button variant="primary" icon="sparkles" disabled={busy} onClick={() => patch({ enabled: true })}>Set up the Coach</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
return <div className="card" style={{ borderColor: live ? 'var(--acc)' : undefined }}>
|
||||
<div className="row between" style={{ marginBottom: 2 }}>
|
||||
@@ -120,16 +141,18 @@ export default function AdminCoach() {
|
||||
<Switch checked={!!d.enabled} disabled={busy} onChange={v => patch({ enabled: v })} />
|
||||
</div>
|
||||
<div className="adm-status">
|
||||
<span className={'adm-pill ' + (!d.enabled ? '' : live ? 'ok' : 'warn')}>{!d.enabled ? 'off' : live ? 'ready' : 'not ready'}</span>
|
||||
<span className={'adm-pill ' + (live ? 'ok' : 'warn')}>{live ? 'ready' : 'not ready'}</span>
|
||||
<span>{status}</span>
|
||||
</div>
|
||||
{!live && <div className="adm-progress" aria-hidden="true"><i style={{ width: Math.round(doneCount / flags.length * 100) + '%' }} /></div>}
|
||||
<div className="adm-lead">
|
||||
The Coach designs a training plan and adjusts it from what people log. This switch is the only place it can be turned off for everyone — users decide for themselves whether to use it, but cannot disable it.
|
||||
{live ? 'Users find the Coach under Plan → Coach. This switch is the only place it can be turned off for everyone.'
|
||||
: `${doneCount} of ${flags.length} steps done — finish the open step and the next one unfolds.`}
|
||||
</div>
|
||||
|
||||
{d.enabled && <>
|
||||
{/* ---------- provider ---------- */}
|
||||
<Step n={num()} title="Provider" hint={meta.label || 'Which AI answers the Coach'} done={step1Done} open={!step1Done}>
|
||||
<Step n={num()} title="Provider" hint={meta.label || 'Which AI answers the Coach'} done={step1Done} {...stepAt()}>
|
||||
<div className="adm-hint">Pick who answers. A key or token you save stays with its provider, so you can switch back and forth without pasting it again.</div>
|
||||
{groups.map(g => !!g.items.length && <div key={g.title} className="adm-group">
|
||||
<div className="adm-group-t">{g.title}</div>
|
||||
@@ -144,7 +167,7 @@ export default function AdminCoach() {
|
||||
</Step>
|
||||
|
||||
{/* ---------- endpoint (compatible only) ---------- */}
|
||||
{needsEndpoint && <Step n={num()} title="Endpoint" hint={d.baseUrl || 'Where the model runs'} done={step2Done} open={!step2Done}>
|
||||
{needsEndpoint && <Step n={num()} title="Endpoint" hint={d.baseUrl || 'Where the model runs'} done={step2Done} {...stepAt()}>
|
||||
<div className="adm-hint">The address of any server that speaks OpenAI's chat API: <b>Ollama</b>, <b>LM Studio</b>, <b>vLLM</b>, <b>OpenRouter</b>, or a gateway of your own. Just the base — no <code>/v1</code>, no key in the URL.</div>
|
||||
<div className="adm-field">
|
||||
<label>Base URL</label>
|
||||
@@ -155,14 +178,14 @@ export default function AdminCoach() {
|
||||
</Step>}
|
||||
|
||||
{/* ---------- credential ---------- */}
|
||||
{hasCredentialStep && <Step n={num()} title="Credential" hint={credentialHint(d.auth, meta)} done={step3Done} open={!step3Done}>
|
||||
{hasCredentialStep && <Step n={num()} title="Credential" hint={credentialHint(d.auth, meta)} done={step3Done} {...stepAt()}>
|
||||
<div className="row" style={{ gap: 8, flexWrap: 'wrap', marginBottom: 8 }}>
|
||||
<CredentialPill auth={d.auth} />
|
||||
</div>
|
||||
{authState === 'connected' ? <>
|
||||
<div className="adm-hint">Connected{d.auth.account ? ' as ' + d.auth.account : ''} via {credentialLabel(d.auth.type)}{d.auth.connectedAt ? ' · added ' + rel(d.auth.connectedAt) : ''}. The key is stored encrypted and is never shown again.</div>
|
||||
<div className="adm-actions">
|
||||
{meta.apiKey && <Button size="sm" icon="lock" disabled={busy}
|
||||
{meta.apiKey && <Button size="sm" variant="tinted" icon="lock" disabled={busy}
|
||||
onClick={() => openSheet(close => <ApiKeySheet close={close} onDone={load} label={meta.label} placeholder={meta.keyPlaceholder} optional={meta.keyOptional} />)}>Replace key</Button>}
|
||||
<Button size="sm" danger disabled={busy} onClick={disconnect}>Remove</Button>
|
||||
</div>
|
||||
@@ -185,7 +208,7 @@ export default function AdminCoach() {
|
||||
</Step>}
|
||||
|
||||
{/* ---------- model ---------- */}
|
||||
<Step n={num()} title="Model" hint={d.model || (meta.defaultModel ? 'default: ' + meta.defaultModel : 'not chosen yet')} done={step4Done} open={!step4Done}>
|
||||
<Step n={num()} title="Model" hint={d.model || (meta.defaultModel ? 'default: ' + meta.defaultModel : 'not chosen yet')} done={step4Done} {...stepAt()}>
|
||||
<div className="adm-hint">{meta.http
|
||||
? 'Which model the provider should use. "List models" asks the provider for its current list, so nothing here goes stale.'
|
||||
: 'Optional. Leave it empty to use the runtime\'s own default.'}</div>
|
||||
@@ -201,17 +224,20 @@ export default function AdminCoach() {
|
||||
onBlur={e => e.target.value !== (d.models?.[d.provider] || '') && patch({ model: e.target.value })} />}
|
||||
</div>
|
||||
{meta.http && <div className="adm-actions">
|
||||
<Button size="sm" disabled={busy} onClick={loadModels}>{models ? 'Refresh list' : 'List models'}</Button>
|
||||
<Button size="sm" variant="tinted" icon="reset" disabled={busy} onClick={loadModels}>{models ? 'Refresh list' : 'List models'}</Button>
|
||||
{models && models.length ? <span className="dim small" style={{ alignSelf: 'center' }}>{models.length} served by the provider</span> : null}
|
||||
</div>}
|
||||
</Step>
|
||||
|
||||
{/* ---------- test ---------- */}
|
||||
<Step n={num()} title="Test" hint={step5Done ? 'passed' : 'one real round trip, no user data'} done={step5Done} open={!step5Done || !!testResult}>
|
||||
<Step n={num()} title="Test" hint={step5Done ? 'passed' : 'one real round trip, no user data'} done={step5Done} {...stepAt()} forceOpen={!!testResult}>
|
||||
<div className="adm-hint">Sends one tiny question to the provider and checks the answer. No training data is involved. Do this after every change above.</div>
|
||||
<div className="adm-actions">
|
||||
<Button size="sm" variant="primary" icon="check" disabled={busy || !authed || !hasEndpoint} onClick={test}>Test the Coach</Button>
|
||||
</div>
|
||||
{(!authed || !hasEndpoint) && <div className="adm-hint" style={{ margin: '6px 0 0' }}>
|
||||
{!hasEndpoint ? 'Finish the Endpoint step first.' : 'Finish the Credential step first.'}
|
||||
</div>}
|
||||
{testResult && <div className={'adm-result ' + (testResult.pending ? '' : testResult.ok ? 'ok' : 'bad')}>
|
||||
{testResult.pending ? 'Asking the provider…'
|
||||
: testResult.ok ? <><b>Passed</b>{testResult.version ? 'Provider: ' + testResult.version : 'The provider answered as expected.'}</>
|
||||
@@ -294,8 +320,9 @@ export default function AdminCoach() {
|
||||
|
||||
/* ---------------------------------- pieces ---------------------------------- */
|
||||
|
||||
function Step({ n, title, hint, done, open, children }) {
|
||||
return <details className={'adm-step ' + (done ? 'done' : 'todo')} open={open}>
|
||||
function Step({ n, title, hint, done, open, forceOpen, children }) {
|
||||
// `key` remounts the <details> when the wizard advances, so the next step unfolds itself.
|
||||
return <details className={'adm-step ' + (done ? 'done' : 'todo')} open={open || forceOpen}>
|
||||
<summary>
|
||||
<span className="adm-num">{done ? <Icon name="check" /> : n}</span>
|
||||
<span className="adm-step-t"><b>{title}</b><span>{hint}</span></span>
|
||||
@@ -329,7 +356,7 @@ const credentialLabel = type => ({
|
||||
|
||||
// The failure classes jobs.js emits, in words an operator can act on.
|
||||
const failureTitle = cls => ({
|
||||
timeout: 'The provider took too long (over 5 minutes)',
|
||||
timeout: 'The provider took longer than the job budget (COACH_JOB_TIMEOUT_MS, default 5 minutes)',
|
||||
missing: 'The provider runtime or key is missing',
|
||||
auth: 'The provider rejected the credential',
|
||||
provider: 'The provider returned an error',
|
||||
|
||||
@@ -35,12 +35,14 @@ export default function Plan() {
|
||||
<div><h1>{t('Plan')}</h1><div className="sub">{t('Your weekly routine')}</div></div>
|
||||
<button className="iconbtn" onClick={planToolsSheet} aria-label={t('Share your plan')} title={t('Share your plan')}><Icon name="upload" /></button>
|
||||
</div>
|
||||
{showCoach && <div className="list" style={{ marginBottom: 10 }}>
|
||||
<Row icon="sparkles" iconTint="var(--acc)" accessory="chevron"
|
||||
title={t('Coach')}
|
||||
subtitle={t('Plan design and reviews, from your own training')}
|
||||
onClick={() => nav('/coach')} />
|
||||
</div>}
|
||||
{showCoach && <button className="coach-cta" onClick={() => nav('/coach')}>
|
||||
<span className="coach-cta-av"><Icon name="sparkles" /></span>
|
||||
<span className="coach-cta-t">
|
||||
<b>{t('Coach')}</b>
|
||||
<span>{t('Plan design and reviews, from your own training')}</span>
|
||||
</span>
|
||||
<Icon name="chevronRight" className="coach-cta-chev" />
|
||||
</button>}
|
||||
|
||||
<div className="cols"><div>
|
||||
<h4 className="sec">{t('Week schedule')}</h4>
|
||||
|
||||
Reference in new issue
Block a user