feat(family): platforms declared at inception and detected from bound repos (milestone 463 step 2, #4988)
CI & Build / Python lint (push) Successful in 4s
CI & Build / Plugin hooks (push) Successful in 21s
CI & Build / TypeScript typecheck (push) Successful in 1m10s
CI & Build / integration (push) Successful in 1m48s
CI & Build / Python tests (push) Successful in 2m40s
CI & Build / Build & push image (push) Failing after 44s
CI & Build / Python lint (push) Successful in 4s
CI & Build / Plugin hooks (push) Successful in 21s
CI & Build / TypeScript typecheck (push) Successful in 1m10s
CI & Build / integration (push) Successful in 1m48s
CI & Build / Python tests (push) Successful in 2m40s
CI & Build / Build & push image (push) Failing after 44s
A project's platforms decide which family ideas reach it. This step makes membership answerable from every door: - services/platforms.py: the global catalog (writes are admin-only and duplicate-gated by slug); pure marker detection; and membership reads and writes. Detection only ADDS, and only where nobody has answered. It never overrides a declared or rejected row and never removes one. - coverage: the archive scan now carries every path, and the refresh runs detection fail-open. - inception: a platforms choice (slugs, or null for unanswered). The list is the whole answer: members left out of it become rejected. - MCP: list_platforms and set_project_platforms; enter_project and get_project carry the project's platforms. - REST: /api/platforms (admin writes) and /api/projects/<id>/platforms. - UI: a platforms checklist on the inception card, a Family tab on ProjectView, and a Platforms admin tab in Settings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,10 +6,16 @@
|
||||
* second step and only emits the choices (the project does not exist yet);
|
||||
* mode="decide" sits on ProjectView for an undecided project, loads that
|
||||
* project's current defaults, and records the decision itself.
|
||||
*
|
||||
* Platforms (milestone 463) start UNANSWERED (null). Ticking any box makes
|
||||
* the list the whole answer; in decide mode the boxes start from what
|
||||
* detection already found, so recording confirms it.
|
||||
*/
|
||||
import { computed, onMounted, ref, watch } from "vue";
|
||||
import { apiErrorMessage } from "@/api/client";
|
||||
import { fetchDesignSystems } from "@/api/designSystems";
|
||||
import { MEMBER_STATES } from "@/api/platforms";
|
||||
import { usePlatformsStore } from "@/stores/platforms";
|
||||
import {
|
||||
decideInception, emptyChoices, fetchInceptionDefaults,
|
||||
type InceptionChoices, type InceptionDecision, type InceptionDefaults,
|
||||
@@ -29,6 +35,9 @@ const emit = defineEmits<{
|
||||
const local = ref<InceptionChoices>(props.choices ? { ...props.choices } : emptyChoices());
|
||||
const designSystems = ref<{ id: number; title: string }[]>([]);
|
||||
const systemsCount = ref(0);
|
||||
const platforms = ref<{ slug: string; name: string }[]>([]);
|
||||
const detected = ref<Set<string>>(new Set());
|
||||
const platformsStore = usePlatformsStore();
|
||||
const loading = ref(true);
|
||||
const saving = ref(false);
|
||||
const error = ref("");
|
||||
@@ -46,11 +55,25 @@ async function load() {
|
||||
const d: InceptionDefaults = await fetchInceptionDefaults(props.projectId);
|
||||
designSystems.value = d.design_systems;
|
||||
systemsCount.value = d.systems;
|
||||
platforms.value = d.platforms;
|
||||
const members = d.project_platforms
|
||||
.filter((p) => MEMBER_STATES.includes(p.state))
|
||||
.map((p) => p.slug);
|
||||
detected.value = new Set(
|
||||
d.project_platforms.filter((p) => p.state === "detected").map((p) => p.slug),
|
||||
);
|
||||
// Start from what stands today, so "record" without changes keeps it.
|
||||
local.value = { design_system_id: d.design_system_id, seed_systems: false };
|
||||
local.value = {
|
||||
design_system_id: d.design_system_id,
|
||||
seed_systems: false,
|
||||
platforms: members.length ? members : null,
|
||||
};
|
||||
} else {
|
||||
const ds = await fetchDesignSystems();
|
||||
const [ds, catalog] = await Promise.all([
|
||||
fetchDesignSystems(), platformsStore.fetchCatalog(),
|
||||
]);
|
||||
designSystems.value = ds.design_systems.map((d) => ({ id: d.id, title: d.title }));
|
||||
platforms.value = catalog.map((p) => ({ slug: p.slug, name: p.name }));
|
||||
}
|
||||
} catch (e: unknown) {
|
||||
error.value = apiErrorMessage(e, "Could not load what this project could inherit");
|
||||
@@ -61,6 +84,22 @@ async function load() {
|
||||
|
||||
const nothingToDecide = computed(() => !designSystems.value.length);
|
||||
|
||||
function isChecked(slug: string): boolean {
|
||||
return (local.value.platforms ?? []).includes(slug);
|
||||
}
|
||||
|
||||
function togglePlatform(slug: string, on: boolean) {
|
||||
const current = new Set(local.value.platforms ?? []);
|
||||
if (on) current.add(slug);
|
||||
else current.delete(slug);
|
||||
local.value.platforms = [...current].sort();
|
||||
}
|
||||
|
||||
/** Back to "not answered" — distinct from an empty list, which says "none". */
|
||||
function clearPlatforms() {
|
||||
local.value.platforms = null;
|
||||
}
|
||||
|
||||
async function record() {
|
||||
if (!props.projectId) return;
|
||||
saving.value = true;
|
||||
@@ -105,6 +144,31 @@ onMounted(load);
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
<div v-if="platforms.length" class="inception-group">
|
||||
<h4>Platforms</h4>
|
||||
<p class="inception-muted">
|
||||
What it is built on or ships as. Ideas the family has proven for a
|
||||
platform reach every project that is one.
|
||||
<template v-if="local.platforms === null"> Not answered yet.</template>
|
||||
<template v-else>
|
||||
Anything left unticked is recorded as "not this project".
|
||||
<button type="button" class="btn-ghost btn-sm" @click="clearPlatforms">Leave unanswered</button>
|
||||
</template>
|
||||
</p>
|
||||
<div class="inception-platforms">
|
||||
<label v-for="p in platforms" :key="p.slug" class="inception-choice">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="isChecked(p.slug)"
|
||||
@change="togglePlatform(p.slug, ($event.target as HTMLInputElement).checked)"
|
||||
/>
|
||||
<span>
|
||||
{{ p.name }}
|
||||
<em v-if="detected.has(p.slug)" class="inception-muted"> — detected</em>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<p v-if="nothingToDecide" class="inception-muted">
|
||||
No design systems on this install yet — recording still settles the question.
|
||||
</p>
|
||||
@@ -132,6 +196,11 @@ onMounted(load);
|
||||
.inception-group h4 { margin: 0 0 0.35rem; font-size: 0.9rem; font-weight: 500; }
|
||||
.inception-choice { display: flex; align-items: flex-start; gap: 0.5rem; font-size: 0.9rem; margin: 0.25rem 0; }
|
||||
.inception-choice input { margin-top: 0.2rem; accent-color: var(--fs-accent); }
|
||||
.inception-platforms {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
|
||||
gap: 0 1rem;
|
||||
}
|
||||
.inception-select {
|
||||
padding: 0.45rem 0.7rem;
|
||||
border: 1px solid var(--fs-border-color);
|
||||
|
||||
@@ -0,0 +1,200 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* A project's place in the family (milestone 463): which platforms it is.
|
||||
*
|
||||
* Membership is what makes "does this family idea reach this project?" a
|
||||
* lookup rather than a judgment — an idea is for some platforms, and it
|
||||
* reaches every project that is one of them. So the answers here matter, and
|
||||
* each kind of answer is shown as what it is:
|
||||
*
|
||||
* - Yes — a person said so.
|
||||
* - Detected — a marker file in a bound repo said so. Detection only adds,
|
||||
* and only where nobody has answered; it never overrides a Yes or a No.
|
||||
* - No — a person said this project is NOT that platform. Kept as a row, so
|
||||
* the next coverage refresh cannot detect it straight back.
|
||||
* - No answer — detection may decide on the next refresh.
|
||||
*
|
||||
* Each change is saved as it is made: one platform, one request, applied
|
||||
* whole or refused whole.
|
||||
*/
|
||||
import { computed, onMounted, ref, watch } from "vue";
|
||||
import { apiErrorMessage } from "@/api/client";
|
||||
import {
|
||||
fetchProjectPlatforms, setProjectPlatforms,
|
||||
type PlatformState, type ProjectPlatform, type SettablePlatformState,
|
||||
} from "@/api/platforms";
|
||||
import { usePlatformsStore } from "@/stores/platforms";
|
||||
|
||||
const props = defineProps<{ projectId: number; canWrite: boolean }>();
|
||||
|
||||
const platformsStore = usePlatformsStore();
|
||||
const answers = ref<ProjectPlatform[]>([]);
|
||||
const loading = ref(false);
|
||||
const failed = ref(false);
|
||||
const saving = ref<string | null>(null);
|
||||
const error = ref("");
|
||||
|
||||
const LABELS: Record<PlatformState, string> = {
|
||||
declared: "Yes",
|
||||
detected: "Detected",
|
||||
rejected: "No",
|
||||
};
|
||||
|
||||
async function load() {
|
||||
loading.value = true;
|
||||
failed.value = false;
|
||||
try {
|
||||
const [, rows] = await Promise.all([
|
||||
platformsStore.fetchCatalog(),
|
||||
fetchProjectPlatforms(props.projectId),
|
||||
]);
|
||||
answers.value = rows;
|
||||
} catch {
|
||||
// Said out loud: "couldn't load" must not read as "no platforms".
|
||||
failed.value = true;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
const stateBySlug = computed(() => {
|
||||
const out: Record<string, PlatformState> = {};
|
||||
for (const a of answers.value) out[a.slug] = a.state;
|
||||
return out;
|
||||
});
|
||||
|
||||
const rows = computed(() =>
|
||||
platformsStore.catalog.map((p) => ({
|
||||
...p,
|
||||
state: stateBySlug.value[p.slug] ?? null,
|
||||
})),
|
||||
);
|
||||
|
||||
const memberCount = computed(
|
||||
() => answers.value.filter((a) => a.state !== "rejected").length,
|
||||
);
|
||||
|
||||
async function answer(slug: string, value: string) {
|
||||
const state: SettablePlatformState = value === "" ? null : (value as SettablePlatformState);
|
||||
saving.value = slug;
|
||||
error.value = "";
|
||||
try {
|
||||
answers.value = await setProjectPlatforms(props.projectId, { [slug]: state });
|
||||
} catch (e: unknown) {
|
||||
error.value = apiErrorMessage(e, "Could not save that answer");
|
||||
} finally {
|
||||
saving.value = null;
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(load);
|
||||
watch(() => props.projectId, load);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="pft">
|
||||
<header class="pft-head">
|
||||
<h3 class="pft-title">Platforms</h3>
|
||||
<p class="pft-muted">
|
||||
What this project is built on or ships as. Ideas the family has proven
|
||||
for a platform reach every project that is one, and each project
|
||||
answers them — adopts, varies with a reason, or owes the work.
|
||||
</p>
|
||||
</header>
|
||||
|
||||
<p v-if="loading" class="pft-muted">Loading…</p>
|
||||
|
||||
<div v-else-if="failed" class="pft-note">
|
||||
<strong>The platforms couldn't load.</strong>
|
||||
<p>Nothing is known either way — this is a failure, not an empty answer.</p>
|
||||
<button class="btn-secondary btn-sm" @click="load">Try again</button>
|
||||
</div>
|
||||
|
||||
<p v-else-if="!rows.length" class="pft-muted">
|
||||
This install has no platforms in its catalog yet. An administrator adds
|
||||
them in Settings.
|
||||
</p>
|
||||
|
||||
<template v-else>
|
||||
<p class="pft-summary">
|
||||
<template v-if="memberCount">
|
||||
A member of {{ memberCount }} platform{{ memberCount === 1 ? "" : "s" }}.
|
||||
</template>
|
||||
<template v-else>
|
||||
Not a member of any platform yet — bind a repo and refresh coverage
|
||||
to detect them, or answer below.
|
||||
</template>
|
||||
</p>
|
||||
<p v-if="error" class="error-msg">{{ error }}</p>
|
||||
<ul class="pft-list">
|
||||
<li v-for="p in rows" :key="p.id" class="pft-row">
|
||||
<div class="pft-name">
|
||||
<span>{{ p.name }}</span>
|
||||
<span v-if="p.state" :class="['pft-tag', `pft-${p.state}`]">{{ LABELS[p.state] }}</span>
|
||||
<span v-if="p.description" class="pft-desc">{{ p.description }}</span>
|
||||
</div>
|
||||
<select
|
||||
v-if="canWrite"
|
||||
class="pft-select"
|
||||
:value="p.state === 'detected' ? 'detected' : (p.state ?? '')"
|
||||
:disabled="saving === p.slug"
|
||||
:aria-label="`Is this project ${p.name}?`"
|
||||
@change="answer(p.slug, ($event.target as HTMLSelectElement).value)"
|
||||
>
|
||||
<option v-if="p.state === 'detected'" value="detected" disabled>Detected</option>
|
||||
<option value="declared">Yes</option>
|
||||
<option value="rejected">No</option>
|
||||
<option value="">No answer</option>
|
||||
</select>
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.pft { padding: 0.25rem 0; }
|
||||
.pft-head { margin-bottom: 1rem; }
|
||||
.pft-title { margin: 0 0 0.35rem; font-size: 1rem; }
|
||||
.pft-muted { color: var(--fs-text-tertiary); font-size: 0.875rem; margin: 0; }
|
||||
.pft-summary { color: var(--fs-text-secondary); font-size: 0.9rem; margin: 0 0 0.75rem; }
|
||||
.pft-note {
|
||||
background: var(--fs-surface-raised);
|
||||
border: 1px solid var(--fs-border-color);
|
||||
border-radius: var(--fs-radius-md);
|
||||
padding: 0.85rem 1rem;
|
||||
}
|
||||
.pft-note p { margin: 0.35rem 0 0.6rem; color: var(--fs-text-secondary); font-size: 0.875rem; }
|
||||
.pft-list { list-style: none; margin: 0; padding: 0; }
|
||||
.pft-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
padding: 0.6rem 0;
|
||||
border-bottom: 1px solid var(--fs-border-color);
|
||||
}
|
||||
.pft-name { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 0.5rem; min-width: 0; }
|
||||
.pft-desc { flex-basis: 100%; color: var(--fs-text-tertiary); font-size: 0.8rem; }
|
||||
.pft-tag {
|
||||
font-size: 0.75rem;
|
||||
padding: 0.05rem 0.45rem;
|
||||
border-radius: var(--fs-radius-sm);
|
||||
border: 1px solid var(--fs-border-color);
|
||||
color: var(--fs-text-secondary);
|
||||
}
|
||||
.pft-declared { color: var(--fs-text-primary); }
|
||||
.pft-rejected { color: var(--fs-text-tertiary); text-decoration: line-through; }
|
||||
.pft-select {
|
||||
padding: 0.35rem 0.6rem;
|
||||
border: 1px solid var(--fs-border-color);
|
||||
border-radius: var(--fs-radius-sm);
|
||||
background: var(--fs-surface-page);
|
||||
color: var(--fs-text-primary);
|
||||
font-size: 0.85rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
@media (max-width: 640px) {
|
||||
.pft-row { flex-direction: column; align-items: stretch; }
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user