|
| 1 | +<script lang="ts"> |
| 2 | + // The relevance brief — the operator's standing intent, per workspace |
| 3 | + // client: the topical scope ("what's relevant") and the people policy |
| 4 | + // ("who from a team page is worth ingesting"). Every didi crawl loads it |
| 5 | + // server-side; this panel is the view/edit door. State-Inspector ethos: |
| 6 | + // what the agent believes should be visible and editable. |
| 7 | + // Per context-v/specs/Augment-From-DB-Flow.md §v1.2. |
| 8 | +
|
| 9 | + import { fetchBrief, saveBrief } from './lib/org-client'; |
| 10 | +
|
| 11 | + let { client }: { client: string } = $props(); |
| 12 | +
|
| 13 | + let open = $state(false); |
| 14 | + let text = $state(''); |
| 15 | + let loadedFor = $state<string | null>(null); |
| 16 | + let updatedAt = $state<string | null>(null); |
| 17 | + let busy = $state(false); |
| 18 | + let saved = $state(false); |
| 19 | + let error = $state<string | null>(null); |
| 20 | +
|
| 21 | + async function load(c: string) { |
| 22 | + busy = true; |
| 23 | + error = null; |
| 24 | + try { |
| 25 | + const r = await fetchBrief(c); |
| 26 | + text = r.brief ?? ''; |
| 27 | + updatedAt = r.updated_at; |
| 28 | + loadedFor = c; |
| 29 | + } catch (err) { |
| 30 | + error = err instanceof Error ? err.message : String(err); |
| 31 | + } finally { |
| 32 | + busy = false; |
| 33 | + } |
| 34 | + } |
| 35 | +
|
| 36 | + $effect(() => { |
| 37 | + if (open && loadedFor !== client) void load(client); |
| 38 | + }); |
| 39 | +
|
| 40 | + async function save() { |
| 41 | + busy = true; |
| 42 | + error = null; |
| 43 | + try { |
| 44 | + await saveBrief(client, text); |
| 45 | + saved = true; |
| 46 | + setTimeout(() => (saved = false), 2000); |
| 47 | + } catch (err) { |
| 48 | + error = err instanceof Error ? err.message : String(err); |
| 49 | + } finally { |
| 50 | + busy = false; |
| 51 | + } |
| 52 | + } |
| 53 | +</script> |
| 54 | + |
| 55 | +<div class="ow-brief"> |
| 56 | + <button type="button" class="ow-add-go" onclick={() => (open = !open)}> |
| 57 | + {open ? '× Relevance brief' : '📋 Relevance brief'} |
| 58 | + </button> |
| 59 | + {#if open} |
| 60 | + <div class="ow-brief-panel"> |
| 61 | + <p class="ow-brief-hint"> |
| 62 | + didi loads this into every crawl for <strong>{client}</strong> — topical scope (what's |
| 63 | + relevant) and the people policy (who from a team page is worth ingesting). |
| 64 | + {#if updatedAt}<span class="ow-brief-date">last saved {updatedAt.slice(0, 10)}</span>{/if} |
| 65 | + </p> |
| 66 | + <textarea |
| 67 | + class="ow-brief-text" |
| 68 | + rows="6" |
| 69 | + placeholder="e.g. Relevant: US higher-education and workforce-development funders, their education-adjacent publication streams. People policy: all major leadership, plus all team members covering Education & Workforce Development and related strategies/topics." |
| 70 | + bind:value={text} |
| 71 | + disabled={busy} |
| 72 | + ></textarea> |
| 73 | + <span class="ow-addperson-actions"> |
| 74 | + {#if saved}<span class="ow-added">saved ✓</span>{/if} |
| 75 | + <button type="button" class="ow-add-go" onclick={save} disabled={busy}> |
| 76 | + {busy ? '…' : 'Save brief'} |
| 77 | + </button> |
| 78 | + </span> |
| 79 | + {#if error}<div class="ow-error">{error}</div>{/if} |
| 80 | + </div> |
| 81 | + {/if} |
| 82 | +</div> |
0 commit comments