feat(rules)!: retire rulebook subscriptions and per-project suppressions (#4052)
CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 13s
CI & Build / integration (push) Successful in 49s
CI & Build / TypeScript typecheck (push) Successful in 57s
CI & Build / Python tests (push) Failing after 1m3s
CI & Build / Build & push image (push) Skipped
CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 13s
CI & Build / integration (push) Successful in 49s
CI & Build / TypeScript typecheck (push) Successful in 57s
CI & Build / Python tests (push) Failing after 1m3s
CI & Build / Build & push image (push) Skipped
A rule's home is its scope now: a rule in a rulebook topic is global, a rule on a project applies to that project, and retrieval reads that directly (#4074). A subscription had stopped changing anything a session received; a suppression muted rules from a subscription. Operator, 2026-09-15: "we have global and project scoped rules, we don't need the subscriptions now." What goes, whole (rule 22): - Migration 0101 drops project_rulebook_subscriptions, project_rule_suppressions and project_topic_suppressions, and strips subscribe_rulebooks (and 394's leftover exclude_always_on_rulebooks) from stored inception choices. - Service, MCP and REST: subscribe/unsubscribe and the four suppress/unsuppress operations. The Subscribers checklist, the subscribe chips, the skip buttons and the Suppressed section in the rules UI. - Inception asks two questions (design system, seed Systems). create_project and decide_project_inception lose subscribe_rulebooks. - Backup v15 stops exporting the three sections; older archives still restore, the keys simply unread. Trash no longer hard-deletes suppression rows. What changes meaning: - get_applicable_rules is a project's LISTING: its own rules, plus the global rules tagged to an area it works in. Untagged global rules apply everywhere and arrive by retrieval, so they are not listed. A co_surfaces partner on a different project is not dragged in. - list_rules(project_id) lists that project's own rules. - rules_payload drops subscribed_rulebooks and suppressed_*; the handshake's brief form is project_rules alone. - using-scribe's "Where a new rule goes" and inception sections, tool docstrings and docs say global vs project. Plugin 2026.09.15.1620. Milestone 414 step 2. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01821k5B3Ysecp9fNYs92Kuy
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
import { apiGet, apiPost } from "@/api/client";
|
||||
|
||||
export interface InceptionChoices {
|
||||
subscribe_rulebooks: number[];
|
||||
design_system_id: number | null;
|
||||
seed_systems: boolean;
|
||||
}
|
||||
@@ -15,8 +14,6 @@ export interface InceptionRecord {
|
||||
}
|
||||
|
||||
export interface InceptionDefaults {
|
||||
rulebooks: { id: number; title: string }[];
|
||||
subscribed_rulebooks: { id: number; title: string }[];
|
||||
design_system_id: number | null;
|
||||
design_systems: { id: number; title: string }[];
|
||||
systems: number;
|
||||
@@ -25,11 +22,11 @@ export interface InceptionDefaults {
|
||||
export interface InceptionDecision {
|
||||
project_id: number;
|
||||
inception: InceptionRecord;
|
||||
effects: { excluded: number[]; subscribed: number[]; design_system_id: number | null; systems_seeded: string[] };
|
||||
effects: { design_system_id: number | null; systems_seeded: string[] };
|
||||
}
|
||||
|
||||
export const emptyChoices = (): InceptionChoices => ({
|
||||
subscribe_rulebooks: [], design_system_id: null, seed_systems: false,
|
||||
design_system_id: null, seed_systems: false,
|
||||
});
|
||||
|
||||
export const fetchInceptionDefaults = (projectId: number) =>
|
||||
|
||||
@@ -108,23 +108,7 @@ export interface ApplicableRules {
|
||||
rulebook_title: string;
|
||||
})[];
|
||||
project_rules: RuleHeader[];
|
||||
suppressed_rules: {
|
||||
id: number;
|
||||
title: string;
|
||||
topic_id: number;
|
||||
topic_title: string;
|
||||
rulebook_id: number;
|
||||
rulebook_title: string;
|
||||
}[];
|
||||
suppressed_topics: {
|
||||
id: number;
|
||||
title: string;
|
||||
rulebook_id: number;
|
||||
rulebook_title: string;
|
||||
}[];
|
||||
truncated: boolean;
|
||||
subscribed_rulebooks: { id: number; title: string }[];
|
||||
/** Always-on rulebooks this project opted out of at inception (milestone 297). */
|
||||
}
|
||||
|
||||
// ── Rulebooks ───────────────────────────────────────────────────────
|
||||
@@ -272,15 +256,7 @@ export async function deleteRule(id: number): Promise<void> {
|
||||
return apiDelete(`/api/rules/${id}`);
|
||||
}
|
||||
|
||||
// ── Subscriptions ──────────────────────────────────────────────────
|
||||
|
||||
export async function subscribeProject(projectId: number, rulebookId: number): Promise<void> {
|
||||
await apiPost(`/api/projects/${projectId}/rulebook-subscriptions`, { rulebook_id: rulebookId });
|
||||
}
|
||||
|
||||
export async function unsubscribeProject(projectId: number, rulebookId: number): Promise<void> {
|
||||
return apiDelete(`/api/projects/${projectId}/rulebook-subscriptions/${rulebookId}`);
|
||||
}
|
||||
// ── A project's rules ──────────────────────────────────────────────
|
||||
|
||||
export async function getProjectApplicableRules(projectId: number): Promise<ApplicableRules> {
|
||||
return apiGet(`/api/projects/${projectId}/rules`);
|
||||
@@ -293,24 +269,6 @@ export async function createProjectRule(
|
||||
return apiPost(`/api/projects/${projectId}/rules`, data);
|
||||
}
|
||||
|
||||
// ── Suppressions ───────────────────────────────────────────────────
|
||||
|
||||
export async function suppressRuleForProject(projectId: number, ruleId: number): Promise<void> {
|
||||
await apiPost(`/api/projects/${projectId}/suppressions/rules/${ruleId}`, {});
|
||||
}
|
||||
|
||||
export async function unsuppressRuleForProject(projectId: number, ruleId: number): Promise<void> {
|
||||
return apiDelete(`/api/projects/${projectId}/suppressions/rules/${ruleId}`);
|
||||
}
|
||||
|
||||
export async function suppressTopicForProject(projectId: number, topicId: number): Promise<void> {
|
||||
await apiPost(`/api/projects/${projectId}/suppressions/topics/${topicId}`, {});
|
||||
}
|
||||
|
||||
export async function unsuppressTopicForProject(projectId: number, topicId: number): Promise<void> {
|
||||
return apiDelete(`/api/projects/${projectId}/suppressions/topics/${topicId}`);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* One row of the staleness sweep. Unlike RuleHeader this carries the CHECK
|
||||
@@ -337,9 +295,9 @@ export interface RuleVerificationRow {
|
||||
* first, never-checked at the top. Rules without a check never appear:
|
||||
* they are decisions, and there is nothing to go and check.
|
||||
*
|
||||
* Not filterable by project — a project reaches rules through project
|
||||
* scope, subscriptions, always-on rulebooks and exclusions, and a filter
|
||||
* missing one of those paths would under-report.
|
||||
* Not filterable by project — a project is bound by its own rules and by
|
||||
* every global rule, and a filter that dropped the global ones would
|
||||
* under-report.
|
||||
*/
|
||||
export async function listRulesDueForVerification(opts: {
|
||||
olderThanDays?: number;
|
||||
|
||||
@@ -14,7 +14,6 @@ import {
|
||||
decideInception, emptyChoices, fetchInceptionDefaults,
|
||||
type InceptionChoices, type InceptionDecision, type InceptionDefaults,
|
||||
} from "@/api/inception";
|
||||
import { listRulebooks } from "@/api/rulebooks";
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
mode: "create" | "decide";
|
||||
@@ -28,7 +27,6 @@ const emit = defineEmits<{
|
||||
}>();
|
||||
|
||||
const local = ref<InceptionChoices>(props.choices ? { ...props.choices } : emptyChoices());
|
||||
const others = ref<{ id: number; title: string }[]>([]);
|
||||
const designSystems = ref<{ id: number; title: string }[]>([]);
|
||||
const systemsCount = ref(0);
|
||||
const loading = ref(true);
|
||||
@@ -46,18 +44,12 @@ async function load() {
|
||||
try {
|
||||
if (props.mode === "decide" && props.projectId) {
|
||||
const d: InceptionDefaults = await fetchInceptionDefaults(props.projectId);
|
||||
others.value = d.rulebooks;
|
||||
designSystems.value = d.design_systems;
|
||||
systemsCount.value = d.systems;
|
||||
// Start from what stands today so "record" without changes is a true inherit-all.
|
||||
local.value = {
|
||||
subscribe_rulebooks: d.subscribed_rulebooks.map((r) => r.id),
|
||||
design_system_id: d.design_system_id,
|
||||
seed_systems: false,
|
||||
};
|
||||
// Start from what stands today, so "record" without changes keeps it.
|
||||
local.value = { design_system_id: d.design_system_id, seed_systems: false };
|
||||
} else {
|
||||
const [rulebooks, ds] = await Promise.all([listRulebooks(), fetchDesignSystems()]);
|
||||
others.value = rulebooks.map((r) => ({ id: r.id, title: r.title }));
|
||||
const ds = await fetchDesignSystems();
|
||||
designSystems.value = ds.design_systems.map((d) => ({ id: d.id, title: d.title }));
|
||||
}
|
||||
} catch (e: unknown) {
|
||||
@@ -67,17 +59,7 @@ async function load() {
|
||||
}
|
||||
}
|
||||
|
||||
function subscribed(id: number): boolean {
|
||||
return local.value.subscribe_rulebooks.includes(id);
|
||||
}
|
||||
function toggleSubscribe(id: number) {
|
||||
const list = local.value.subscribe_rulebooks;
|
||||
local.value.subscribe_rulebooks = list.includes(id) ? list.filter((x) => x !== id) : [...list, id];
|
||||
}
|
||||
|
||||
const nothingToDecide = computed(
|
||||
() => !others.value.length && !designSystems.value.length,
|
||||
);
|
||||
const nothingToDecide = computed(() => !designSystems.value.length);
|
||||
|
||||
async function record() {
|
||||
if (!props.projectId) return;
|
||||
@@ -101,22 +83,12 @@ onMounted(load);
|
||||
<h3 id="inception-title" class="inception-title">What does this project inherit?</h3>
|
||||
<p class="inception-lede">
|
||||
A project's inheritance is a decision, not a default. Until it is recorded,
|
||||
every always-on rulebook binds, nothing is subscribed, and there is no design
|
||||
system or Systems.
|
||||
there is no design system and no Systems. Rules aren't part of this: global
|
||||
rules apply to every project, and a project's own rules are added on it.
|
||||
</p>
|
||||
<p v-if="loading" class="inception-muted">Loading…</p>
|
||||
<p v-else-if="error" class="error-msg">{{ error }}</p>
|
||||
<template v-else>
|
||||
<div v-if="others.length" class="inception-group">
|
||||
<h4>Subscribe to rulebooks</h4>
|
||||
<p class="inception-muted">
|
||||
A rulebook binds this project only if it is subscribed — nothing is inherited automatically.
|
||||
</p>
|
||||
<label v-for="rb in others" :key="rb.id" class="inception-choice">
|
||||
<input type="checkbox" :checked="subscribed(rb.id)" @change="toggleSubscribe(rb.id)" />
|
||||
<span>{{ rb.title }}</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="inception-group">
|
||||
<h4>Design system</h4>
|
||||
<select v-model="local.design_system_id" class="inception-select" aria-label="Design system">
|
||||
@@ -134,7 +106,7 @@ onMounted(load);
|
||||
</label>
|
||||
</div>
|
||||
<p v-if="nothingToDecide" class="inception-muted">
|
||||
Nothing to inherit yet on this install — recording still settles the question.
|
||||
No design systems on this install yet — recording still settles the question.
|
||||
</p>
|
||||
<div v-if="mode === 'decide'" class="inception-actions">
|
||||
<button class="btn-primary" :disabled="saving" @click="record">
|
||||
|
||||
@@ -3,24 +3,26 @@ import { ref, onMounted, watch } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import {
|
||||
getProjectApplicableRules,
|
||||
subscribeProject,
|
||||
unsubscribeProject,
|
||||
listRulebooks,
|
||||
getRule,
|
||||
createProjectRule,
|
||||
deleteRule,
|
||||
suppressRuleForProject,
|
||||
unsuppressRuleForProject,
|
||||
suppressTopicForProject,
|
||||
unsuppressTopicForProject,
|
||||
} from "@/api/rulebooks";
|
||||
import type { ApplicableRules, Rulebook } from "@/api/rulebooks";
|
||||
import type { ApplicableRules } from "@/api/rulebooks";
|
||||
|
||||
/**
|
||||
* A project's view of its rules (milestone 414). A rule's home is its reach:
|
||||
* the project's own rules apply here and nowhere else, and every global rule
|
||||
* (one in a rulebook) applies here too. There is no subscribing this project
|
||||
* to a rulebook and no skipping a global rule for it — a project that departs
|
||||
* from one writes its own rule and links it with an `overrides` relation.
|
||||
*
|
||||
* The second list is the global rules TAGGED to an area this project works in,
|
||||
* not every global rule: those arrive by retrieval when the work matches them,
|
||||
* and listing them all under every project would say nothing.
|
||||
*/
|
||||
const props = defineProps<{ projectId: number }>();
|
||||
const router = useRouter();
|
||||
const applicable = ref<ApplicableRules | null>(null);
|
||||
const allRulebooks = ref<Rulebook[]>([]);
|
||||
const showPicker = ref(false);
|
||||
const expandedRuleIds = ref<Set<number>>(new Set());
|
||||
|
||||
const ruleDetails = ref<Record<number, {
|
||||
@@ -38,22 +40,6 @@ async function load() {
|
||||
applicable.value = await getProjectApplicableRules(props.projectId);
|
||||
}
|
||||
|
||||
async function loadAllRulebooks() {
|
||||
allRulebooks.value = await listRulebooks();
|
||||
}
|
||||
|
||||
async function subscribe(rulebookId: number) {
|
||||
await subscribeProject(props.projectId, rulebookId);
|
||||
showPicker.value = false;
|
||||
await load();
|
||||
}
|
||||
|
||||
async function unsubscribe(rulebookId: number) {
|
||||
if (!confirm("Unsubscribe from this rulebook for this project?")) return;
|
||||
await unsubscribeProject(props.projectId, rulebookId);
|
||||
await load();
|
||||
}
|
||||
|
||||
async function toggleRuleExpand(ruleId: number) {
|
||||
if (expandedRuleIds.value.has(ruleId)) {
|
||||
expandedRuleIds.value.delete(ruleId);
|
||||
@@ -143,66 +129,13 @@ async function removeProjectRule(ruleId: number) {
|
||||
await load();
|
||||
}
|
||||
|
||||
const showSuppressed = ref(false);
|
||||
|
||||
async function suppressRule(ruleId: number) {
|
||||
await suppressRuleForProject(props.projectId, ruleId);
|
||||
await load();
|
||||
}
|
||||
|
||||
async function unsuppressRule(ruleId: number) {
|
||||
await unsuppressRuleForProject(props.projectId, ruleId);
|
||||
await load();
|
||||
}
|
||||
|
||||
async function suppressTopic(topicId: number) {
|
||||
await suppressTopicForProject(props.projectId, topicId);
|
||||
await load();
|
||||
}
|
||||
|
||||
async function unsuppressTopic(topicId: number) {
|
||||
await unsuppressTopicForProject(props.projectId, topicId);
|
||||
await load();
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await load();
|
||||
await loadAllRulebooks();
|
||||
});
|
||||
onMounted(load);
|
||||
|
||||
watch(() => props.projectId, load);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="rules-tab" v-if="applicable">
|
||||
<section class="subscribed">
|
||||
<h3>Subscribed rulebooks</h3>
|
||||
<div class="chips">
|
||||
<span
|
||||
v-for="rb in applicable.subscribed_rulebooks"
|
||||
:key="rb.id"
|
||||
class="chip"
|
||||
>
|
||||
<a @click="openInRulesView(rb.id)">{{ rb.title }}</a>
|
||||
<button class="chip-remove" @click="unsubscribe(rb.id)" aria-label="Unsubscribe">×</button>
|
||||
</span>
|
||||
<button v-if="!showPicker" class="add" @click="showPicker = true">+ Subscribe</button>
|
||||
<select
|
||||
v-else
|
||||
@change="subscribe(Number(($event.target as HTMLSelectElement).value))"
|
||||
>
|
||||
<option value="">Choose a rulebook…</option>
|
||||
<option
|
||||
v-for="rb in allRulebooks.filter((rb) => !applicable!.subscribed_rulebooks.some((s) => s.id === rb.id))"
|
||||
:key="rb.id"
|
||||
:value="rb.id"
|
||||
>
|
||||
{{ rb.title }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="project-rules">
|
||||
<div class="section-head">
|
||||
<h3>Project rules</h3>
|
||||
@@ -286,9 +219,13 @@ watch(() => props.projectId, load);
|
||||
</section>
|
||||
|
||||
<section class="applicable">
|
||||
<h3>Applicable rules</h3>
|
||||
<h3>Global rules for this project's areas</h3>
|
||||
<p class="applicable-note">
|
||||
Every global rule applies to this project and arrives when the work matches it.
|
||||
These are the ones tagged to an area this project works in.
|
||||
</p>
|
||||
<p v-if="applicable.rules.length === 0" class="empty">
|
||||
No rules yet — subscribe to a rulebook above, or create one at
|
||||
None tagged to this project's areas. Global rules live in
|
||||
<a @click="router.push('/rules')">Rulebooks</a>.
|
||||
</p>
|
||||
<div
|
||||
@@ -298,26 +235,12 @@ watch(() => props.projectId, load);
|
||||
>
|
||||
<h4>{{ rb.rulebook_title }}</h4>
|
||||
<div v-for="topic in rb.topics" :key="topic.topic_id" class="topic-group">
|
||||
<h5>
|
||||
<span>{{ topic.topic_title }}</span>
|
||||
<button
|
||||
class="skip-btn"
|
||||
:title="`Skip the entire ${topic.topic_title} topic for this project`"
|
||||
@click="suppressTopic(topic.topic_id)"
|
||||
>× skip topic</button>
|
||||
</h5>
|
||||
<h5>{{ topic.topic_title }}</h5>
|
||||
<ul>
|
||||
<li v-for="r in topic.rules" :key="r.id" class="rule">
|
||||
<div class="rule-head">
|
||||
<div class="rule-head-text" @click="toggleRuleExpand(r.id)">
|
||||
<span class="rule-title">{{ r.title }}</span>
|
||||
<span class="rule-statement">{{ r.statement }}</span>
|
||||
</div>
|
||||
<button
|
||||
class="skip-btn"
|
||||
title="Skip this rule for this project"
|
||||
@click.stop="suppressRule(r.id)"
|
||||
>× skip</button>
|
||||
<div class="rule-head" @click="toggleRuleExpand(r.id)">
|
||||
<span class="rule-title">{{ r.title }}</span>
|
||||
<span class="rule-statement">{{ r.statement }}</span>
|
||||
</div>
|
||||
<div v-if="expandedRuleIds.has(r.id) && ruleDetails[r.id]" class="rule-detail">
|
||||
<div v-if="ruleDetails[r.id].why">
|
||||
@@ -349,64 +272,25 @@ watch(() => props.projectId, load);
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<section
|
||||
v-if="applicable.suppressed_rules.length + applicable.suppressed_topics.length > 0"
|
||||
class="suppressed"
|
||||
>
|
||||
<button class="suppressed-toggle" @click="showSuppressed = !showSuppressed">
|
||||
<span>Suppressed ({{ applicable.suppressed_rules.length + applicable.suppressed_topics.length }})</span>
|
||||
<span class="caret">{{ showSuppressed ? "▾" : "▸" }}</span>
|
||||
</button>
|
||||
<div v-if="showSuppressed" class="suppressed-body">
|
||||
<ul v-if="applicable.suppressed_topics.length > 0" class="suppressed-list">
|
||||
<li v-for="t in applicable.suppressed_topics" :key="`topic-${t.id}`">
|
||||
<span class="suppressed-kind">topic</span>
|
||||
<span class="suppressed-path">{{ t.rulebook_title }} → {{ t.title }}</span>
|
||||
<button class="reenable-btn" @click="unsuppressTopic(t.id)">↻ re-enable</button>
|
||||
</li>
|
||||
</ul>
|
||||
<ul v-if="applicable.suppressed_rules.length > 0" class="suppressed-list">
|
||||
<li v-for="r in applicable.suppressed_rules" :key="`rule-${r.id}`">
|
||||
<span class="suppressed-kind">rule</span>
|
||||
<span class="suppressed-path">{{ r.rulebook_title }} → {{ r.topic_title }} → {{ r.title }}</span>
|
||||
<button class="reenable-btn" @click="unsuppressRule(r.id)">↻ re-enable</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.trigger-hint { flex: 1; min-width: 12rem; font-size: 0.75rem; color: var(--fs-text-tertiary); }
|
||||
|
||||
.excluded-note { margin: 0 0 0.5rem; color: var(--fs-text-tertiary); font-size: 0.85rem; }
|
||||
.rules-tab { padding: 1rem; }
|
||||
h3 {
|
||||
font-size: 0.9em; opacity: 0.7; text-transform: uppercase; letter-spacing: 0.05em;
|
||||
margin-top: 0;
|
||||
}
|
||||
.chips { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
|
||||
.chip {
|
||||
display: inline-flex; align-items: center; gap: 0.25rem;
|
||||
background: var(--fs-accent-soft);
|
||||
padding: 0.25rem 0.5rem; border-radius: 999px;
|
||||
}
|
||||
.chip a { cursor: pointer; }
|
||||
.chip-remove { background: none; border: none; cursor: pointer; opacity: 0.5; font-size: 1.1em; }
|
||||
.chip-remove:hover { opacity: 1; }
|
||||
.add {
|
||||
background: none;
|
||||
border: 1px dashed var(--fs-border-color);
|
||||
padding: 0.25rem 0.75rem; border-radius: 999px; cursor: pointer;
|
||||
color: inherit;
|
||||
}
|
||||
select {
|
||||
background: var(--fs-surface-page); color: inherit;
|
||||
border: 1px solid var(--fs-border-color); border-radius: 6px;
|
||||
padding: 0.25rem 0.5rem;
|
||||
}
|
||||
.applicable { margin-top: 2rem; }
|
||||
.applicable-note { margin: 0 0 0.75rem; color: var(--fs-text-tertiary); font-size: 0.85rem; }
|
||||
.rb-group { margin-bottom: 1.5rem; }
|
||||
.rb-group h4 { font-family: Fraunces, serif; font-style: italic; margin-bottom: 0.5rem; }
|
||||
/* `.topic-group` is deliberately bare — a namespace for the two h5 rules (this
|
||||
@@ -441,7 +325,7 @@ ul { list-style: none; padding: 0; margin: 0; }
|
||||
}
|
||||
.empty, .truncated { opacity: 0.7; font-style: italic; }
|
||||
.empty a { cursor: pointer; text-decoration: underline; }
|
||||
.project-rules { margin-top: 1.5rem; }
|
||||
.project-rules { margin-top: 0; }
|
||||
.section-head { display: flex; justify-content: space-between; align-items: center; }
|
||||
.new-rule-form {
|
||||
display: flex; flex-direction: column; gap: 0.5rem;
|
||||
@@ -459,49 +343,4 @@ ul { list-style: none; padding: 0; margin: 0; }
|
||||
background: none; border: none; cursor: pointer;
|
||||
color: var(--fs-destructive); padding: 0.5rem 0 0 0;
|
||||
}
|
||||
/* Per-rule / per-topic suppress affordance — quiet by default, reveal on hover */
|
||||
.topic-group h5 {
|
||||
display: flex; justify-content: space-between; align-items: center; gap: 0.5rem;
|
||||
}
|
||||
.rule-head {
|
||||
display: flex; justify-content: space-between; align-items: flex-start; gap: 0.5rem;
|
||||
}
|
||||
.rule-head-text { flex: 1; cursor: pointer; }
|
||||
.skip-btn {
|
||||
background: none; border: none; cursor: pointer;
|
||||
color: var(--fs-text-tertiary); font-size: 0.75rem;
|
||||
padding: 0.1rem 0.4rem; opacity: 0; transition: opacity 0.15s;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.topic-group h5:hover .skip-btn,
|
||||
.rule:hover .skip-btn,
|
||||
.skip-btn:focus { opacity: 1; }
|
||||
.skip-btn:hover { color: var(--fs-destructive); }
|
||||
/* Suppressed section */
|
||||
.suppressed { margin-top: 1.5rem; }
|
||||
.suppressed-toggle {
|
||||
display: flex; align-items: center; gap: 0.4rem;
|
||||
background: none; border: none; cursor: pointer;
|
||||
font-size: 0.85rem; opacity: 0.7; padding: 0.25rem 0; color: inherit;
|
||||
}
|
||||
.suppressed-toggle:hover { opacity: 1; }
|
||||
.suppressed-toggle .caret { font-size: 0.7em; }
|
||||
.suppressed-body { margin-top: 0.5rem; }
|
||||
.suppressed-list { padding-left: 0; }
|
||||
.suppressed-list li {
|
||||
display: flex; align-items: center; gap: 0.5rem;
|
||||
padding: 0.25rem 0; opacity: 0.75;
|
||||
}
|
||||
.suppressed-kind {
|
||||
font-size: 0.7em; text-transform: uppercase; letter-spacing: 0.05em;
|
||||
padding: 0.1rem 0.4rem; border-radius: 3px;
|
||||
background: var(--fs-surface-page);
|
||||
border: 1px solid var(--fs-border-color);
|
||||
}
|
||||
.suppressed-path { flex: 1; }
|
||||
.reenable-btn {
|
||||
background: none; border: none; cursor: pointer;
|
||||
color: var(--fs-accent); font-size: 0.85em;
|
||||
}
|
||||
.reenable-btn:hover { text-decoration: underline; }
|
||||
</style>
|
||||
|
||||
@@ -221,7 +221,7 @@ watch(() => props.ruleId, load);
|
||||
</ul>
|
||||
<p class="field-note">
|
||||
Rules that <em>fail together</em> are linked, never merged — a merged rule cannot be
|
||||
cited, surfaced or suppressed a clause at a time.
|
||||
cited or surfaced a clause at a time.
|
||||
</p>
|
||||
</section>
|
||||
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, watch } from "vue";
|
||||
import { ref } from "vue";
|
||||
import { useRulebooksStore } from "@/stores/rulebooks";
|
||||
import { apiGet } from "@/api/client";
|
||||
import {
|
||||
subscribeProject, unsubscribeProject, getProjectApplicableRules,
|
||||
} from "@/api/rulebooks";
|
||||
import type { RulebookTopic } from "@/api/rulebooks";
|
||||
|
||||
// A rulebook's rules are global — they apply to every project — so this pane
|
||||
// lists topics and nothing else. It carried a "Subscribers" checklist of
|
||||
// projects until milestone 414 retired subscriptions.
|
||||
const props = defineProps<{
|
||||
rulebookId: number;
|
||||
topics: RulebookTopic[];
|
||||
@@ -18,42 +17,6 @@ const store = useRulebooksStore();
|
||||
const isCreating = ref(false);
|
||||
const newTitle = ref("");
|
||||
|
||||
|
||||
interface ProjectLite { id: number; title: string }
|
||||
const projects = ref<ProjectLite[]>([]);
|
||||
// Map<project_id, Set<rulebook_id>>
|
||||
const subscribedRulebookIds = ref<Map<number, Set<number>>>(new Map());
|
||||
|
||||
async function loadProjects() {
|
||||
const data = await apiGet<{ projects: ProjectLite[] }>("/api/projects");
|
||||
projects.value = data.projects;
|
||||
for (const p of projects.value) {
|
||||
const result = await getProjectApplicableRules(p.id);
|
||||
subscribedRulebookIds.value.set(
|
||||
p.id,
|
||||
new Set(result.subscribed_rulebooks.map((rb) => rb.id)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function isSubscribed(projectId: number): boolean {
|
||||
return subscribedRulebookIds.value.get(projectId)?.has(props.rulebookId) ?? false;
|
||||
}
|
||||
|
||||
async function toggleSubscription(projectId: number, checked: boolean) {
|
||||
if (checked) {
|
||||
await subscribeProject(projectId, props.rulebookId);
|
||||
const set = subscribedRulebookIds.value.get(projectId) || new Set<number>();
|
||||
set.add(props.rulebookId);
|
||||
subscribedRulebookIds.value.set(projectId, set);
|
||||
} else {
|
||||
await unsubscribeProject(projectId, props.rulebookId);
|
||||
subscribedRulebookIds.value.get(projectId)?.delete(props.rulebookId);
|
||||
}
|
||||
// trigger reactivity on Map mutation
|
||||
subscribedRulebookIds.value = new Map(subscribedRulebookIds.value);
|
||||
}
|
||||
|
||||
async function submitNew() {
|
||||
const title = newTitle.value.trim();
|
||||
if (!title) return;
|
||||
@@ -63,8 +26,6 @@ async function submitNew() {
|
||||
emit("select-topic", topic.id);
|
||||
}
|
||||
|
||||
onMounted(loadProjects);
|
||||
watch(() => props.rulebookId, () => {/* re-render of isSubscribed from existing map */});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -92,21 +53,6 @@ watch(() => props.rulebookId, () => {/* re-render of isSubscribed from existing
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="subscriptions">
|
||||
<h3>Subscribers</h3>
|
||||
<ul class="sub-list">
|
||||
<li v-for="p in projects" :key="p.id">
|
||||
<label>
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="isSubscribed(p.id)"
|
||||
@change="toggleSubscription(p.id, ($event.target as HTMLInputElement).checked)"
|
||||
/>
|
||||
{{ p.title }}
|
||||
</label>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
@@ -117,24 +63,13 @@ ul { list-style: none; padding: 0; margin: 1rem 0; }
|
||||
li { padding: 0.5rem; cursor: pointer; border-radius: 6px; }
|
||||
li.active { background: var(--fs-accent-soft); }
|
||||
li:hover { background: var(--fs-surface-hover); }
|
||||
/* `.new-topic` and `.sub-list` are deliberately bare (#2444). The first wraps a
|
||||
button-or-form whose children style themselves; the second is a `<ul>`, and
|
||||
the bare `ul` rule above already gives it list-style, padding and margin —
|
||||
a base a class-name check cannot see, since it comes from an element
|
||||
selector. Both namespace descendant rules and assume nothing about layout. */
|
||||
/* `.new-topic` is deliberately bare (#2444): it wraps a button-or-form whose
|
||||
children style themselves, and namespaces the descendant rule below. */
|
||||
.new-topic input {
|
||||
width: 100%; margin-bottom: 0.5rem;
|
||||
background: var(--fs-surface-page); color: inherit;
|
||||
border: 1px solid var(--fs-border-color); border-radius: 6px;
|
||||
padding: 0.5rem;
|
||||
}
|
||||
.subscriptions {
|
||||
margin-top: 2rem;
|
||||
border-top: 1px solid var(--fs-border-color);
|
||||
padding-top: 1rem;
|
||||
}
|
||||
.subscriptions h3 { font-size: 0.9em; opacity: 0.7; text-transform: uppercase; letter-spacing: 0.05em; }
|
||||
.sub-list li { cursor: default; }
|
||||
.sub-list label { display: flex; gap: 0.5rem; align-items: center; cursor: pointer; }
|
||||
button { cursor: pointer; }
|
||||
</style>
|
||||
|
||||
@@ -24,7 +24,6 @@ export interface StartPlanningResult {
|
||||
topic_title: string;
|
||||
rulebook_title: string;
|
||||
}[];
|
||||
subscribed_rulebooks: { id: number; title: string }[];
|
||||
applicable_rules_truncated: boolean;
|
||||
project_goal: string;
|
||||
open_task_count: number;
|
||||
|
||||
@@ -716,9 +716,6 @@ async function confirmDelete() {
|
||||
/>
|
||||
<p v-else-if="project.inception" class="inception-line">
|
||||
Inheritance decided {{ fmtDate(project.inception.decided_at) }} via {{ project.inception.via }}
|
||||
<template v-if="project.inception.choices.subscribe_rulebooks.length">
|
||||
· subscribes {{ project.inception.choices.subscribe_rulebooks.length }}
|
||||
</template>
|
||||
· design system {{ project.inception.choices.design_system_id ? "#" + project.inception.choices.design_system_id : "none" }}
|
||||
<template v-if="project.inception.choices.seed_systems"> · Systems seeded</template>
|
||||
</p>
|
||||
|
||||
Reference in New Issue
Block a user