fix(7736): #N in a body links to the record it names, not to a tag
CI & Build / TypeScript typecheck (push) Successful in 35s
CI & Build / Python lint (push) Successful in 2s
CI & Build / Plugin hooks (push) Successful in 14s
CI & Build / Python tests (push) Failing after 1m37s
CI & Build / integration (push) Successful in 2m11s
CI & Build / Build & push image (push) Skipped
CI & Build / TypeScript typecheck (push) Successful in 35s
CI & Build / Python lint (push) Successful in 2s
CI & Build / Plugin hooks (push) Successful in 14s
CI & Build / Python tests (push) Failing after 1m37s
CI & Build / integration (push) Successful in 2m11s
CI & Build / Build & push image (push) Skipped
A purely numeric #N is a record reference everywhere now. The tag patterns (frontend utils/tags.ts, the editor decoration, the first-line tag strip, tag autocomplete, backend utils/tags.py) leave digits alone, so #3127 is no longer drawn as a tag chip linking to /notes?tag=3127. - utils/recordRefs.ts links #N, milestone N and rule N in rendered markdown, with the same patterns and other-numbering word list as services/record_refs.py. A drift test reads the TS source and fails when the two differ. - v-record-refs (directives/recordRefs.ts) asks POST /api/notes/resolve-refs once per body for what each id is. A link gets the route for its kind (task, lesson, snippet, note, milestone, rule) and its kind and title on hover. One the reader cannot open is drawn as a dead reference, and missing vs not shared read the same. Applied on every surface that renders markdown. - /milestones/:id finds the project and opens its board at that milestone (?milestone= expands it, scrolls to it and focuses it). - Backlinks include records that cite #N in a body or a work log, through readable_notes_clause instead of an owner-only filter, and route by kind. The graph draws #N citations as dashed reference edges. - create_note, create_task and add_task_log say which forms link. There were no numeric tags to clean up: tags are stored only from the explicit field, and none of the 200 most used is numeric. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,7 @@ import { drag } from "d3-drag";
|
||||
import { select } from "d3-selection";
|
||||
import { apiGet } from "@/api/client";
|
||||
import { renderMarkdown } from "@/utils/markdown";
|
||||
import { vRecordRefs } from "@/directives/recordRefs";
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
@@ -26,7 +27,8 @@ interface GraphNode extends SimulationNodeDatum {
|
||||
interface GraphEdge {
|
||||
source: number | string | GraphNode;
|
||||
target: number | string | GraphNode;
|
||||
type: "wikilink" | "tag";
|
||||
/** wikilink: `[[title]]`; reference: a `#N` citation; tag: a shared tag. */
|
||||
type: "wikilink" | "reference" | "tag";
|
||||
}
|
||||
|
||||
interface Project {
|
||||
@@ -237,12 +239,14 @@ function initGraph() {
|
||||
.append("line")
|
||||
.attr("class", "graph-edge")
|
||||
.attr("stroke", (d: any) =>
|
||||
d.type === "wikilink" ? "var(--fs-accent)" : "var(--fs-text-tertiary)"
|
||||
d.type === "tag" ? "var(--fs-text-tertiary)" : "var(--fs-accent)"
|
||||
)
|
||||
.attr("stroke-opacity", (d: any) => (d.type === "wikilink" ? 0.5 : 0.4))
|
||||
.attr("stroke-dasharray", null)
|
||||
.attr("stroke-width", (d: any) => (d.type === "wikilink" ? 1.5 : 1))
|
||||
.attr("marker-end", (d: any) => (d.type === "wikilink" ? "url(#arrow)" : null));
|
||||
.attr("stroke-opacity", (d: any) => (d.type === "tag" ? 0.4 : 0.5))
|
||||
// A citation is a looser link than a wikilink: same colour and direction,
|
||||
// drawn dashed so the two read apart.
|
||||
.attr("stroke-dasharray", (d: any) => (d.type === "reference" ? "4 3" : null))
|
||||
.attr("stroke-width", (d: any) => (d.type === "tag" ? 1 : 1.5))
|
||||
.attr("marker-end", (d: any) => (d.type === "tag" ? null : "url(#arrow)"));
|
||||
|
||||
// Node groups
|
||||
const nodeSel = zoomG
|
||||
@@ -559,7 +563,7 @@ onUnmounted(() => {
|
||||
<div
|
||||
v-else-if="peekBody"
|
||||
class="prose peek-prose"
|
||||
v-html="renderMarkdown(peekBody)"
|
||||
v-html="renderMarkdown(peekBody)" v-record-refs
|
||||
/>
|
||||
<div v-else class="peek-empty">No content.</div>
|
||||
</div>
|
||||
|
||||
@@ -40,6 +40,7 @@ import UsageBadge from "@/components/UsageBadge.vue";
|
||||
import { DEAD_WEIGHT_ADVICE } from "@/utils/deadWeight";
|
||||
import { useToastStore } from "@/stores/toast";
|
||||
import { renderMarkdown } from "@/utils/markdown";
|
||||
import { vRecordRefs } from "@/directives/recordRefs";
|
||||
import { canWriteRecord } from "@/utils/permission";
|
||||
import { recordHref } from "@/utils/recordHref";
|
||||
|
||||
@@ -171,7 +172,7 @@ onMounted(load);
|
||||
<div
|
||||
v-if="insightHtml"
|
||||
class="ld-insight markdown-body"
|
||||
v-html="insightHtml"
|
||||
v-html="insightHtml" v-record-refs
|
||||
/>
|
||||
<p v-else class="ld-muted ld-empty">
|
||||
No detail was recorded — the claim above is the whole lesson.
|
||||
|
||||
@@ -5,6 +5,7 @@ import type { NoteType } from "@/types/note";
|
||||
import { useNotesStore } from "@/stores/notes";
|
||||
import { useToastStore } from "@/stores/toast";
|
||||
import { renderMarkdown } from "@/utils/markdown";
|
||||
import { vRecordRefs } from "@/directives/recordRefs";
|
||||
import { useAssist, type NoteDraft } from "@/composables/useAssist";
|
||||
import { useAutoSave } from "@/composables/useAutoSave";
|
||||
import { useEditorGuards } from "@/composables/useEditorGuards";
|
||||
@@ -439,7 +440,7 @@ onUnmounted(() => assist.clearSelection());
|
||||
<div
|
||||
v-else
|
||||
class="preview-pane prose"
|
||||
v-html="renderedPreview"
|
||||
v-html="renderedPreview" v-record-refs
|
||||
/>
|
||||
</Transition>
|
||||
</template>
|
||||
|
||||
@@ -3,6 +3,8 @@ import { onMounted, computed, ref, watch } from "vue";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import { useNotesStore } from "@/stores/notes";
|
||||
import { renderMarkdown } from "@/utils/markdown";
|
||||
import { vRecordRefs } from "@/directives/recordRefs";
|
||||
import { recordHref } from "@/utils/recordHref";
|
||||
import { relativeTime } from "@/composables/useRelativeTime";
|
||||
import { apiPost, apiGet, apiPatch } from "@/api/client";
|
||||
import type { Note } from "@/types/note";
|
||||
@@ -14,7 +16,12 @@ import { Clock, Pencil, Link as LinkIcon } from "lucide-vue-next";
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const store = useNotesStore();
|
||||
const backlinks = ref<{ type: string; id: number; title: string }[]>([]);
|
||||
/** What links here, and how: a `[[title]]` wikilink or a `#N` reference in a
|
||||
* body or work log. */
|
||||
const backlinks = ref<{
|
||||
type: string; id: number; title: string;
|
||||
is_task?: boolean; note_type?: string; via?: "wikilink" | "reference";
|
||||
}[]>([]);
|
||||
const converting = ref(false);
|
||||
const showShare = ref(false);
|
||||
|
||||
@@ -259,7 +266,7 @@ async function convertToTask() {
|
||||
<div
|
||||
class="body prose"
|
||||
:class="{ 'prose--checklist': isListNote }"
|
||||
v-html="renderedBody"
|
||||
v-html="renderedBody" v-record-refs
|
||||
@click="onBodyClick"
|
||||
@change="onBodyChange"
|
||||
></div>
|
||||
@@ -274,7 +281,8 @@ async function convertToTask() {
|
||||
<router-link
|
||||
v-for="link in backlinks"
|
||||
:key="`${link.type}-${link.id}`"
|
||||
:to="`/${link.type === 'note' ? 'notes' : 'tasks'}/${link.id}`"
|
||||
:to="recordHref({ id: link.id, is_task: link.is_task ?? link.type === 'task', note_type: link.note_type })"
|
||||
:title="link.via === 'reference' ? `Cites #${noteId} in its text` : `Links here by title`"
|
||||
class="backlink-card"
|
||||
>
|
||||
<span :class="['backlink-type-badge', `badge-${link.type}`]">{{ link.type }}</span>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted, watch } from "vue";
|
||||
import { ref, computed, onMounted, watch, nextTick } from "vue";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import { apiGet, apiPatch, apiDelete, apiPost, apiPut, apiErrorMessage } from "@/api/client";
|
||||
import { useAuthStore } from "@/stores/auth";
|
||||
@@ -7,6 +7,7 @@ import { useToastStore } from "@/stores/toast";
|
||||
import { useTasksStore } from "@/stores/tasks";
|
||||
import { relativeTime } from "@/composables/useRelativeTime";
|
||||
import { renderMarkdown } from "@/utils/markdown";
|
||||
import { vRecordRefs } from "@/directives/recordRefs";
|
||||
import ShareDialog from "@/components/ShareDialog.vue";
|
||||
import KindBadge from "@/components/KindBadge.vue";
|
||||
import ProjectStatusBadge from "@/components/ProjectStatusBadge.vue";
|
||||
@@ -585,8 +586,27 @@ async function saveForgePin() {
|
||||
}
|
||||
}
|
||||
|
||||
/** `?milestone=N` opens the board at that milestone: the Tasks tab, the
|
||||
* milestone expanded and scrolled into view, its header focused. This is
|
||||
* where a `milestone N` reference in any body leads. */
|
||||
async function focusMilestoneFromRoute() {
|
||||
const id = Number(route.query.milestone);
|
||||
if (!id || !milestones.value.some((m) => m.id === id)) return;
|
||||
activeTab.value = "tasks";
|
||||
collapsedMilestones.value.delete(id);
|
||||
await nextTick();
|
||||
const header = document.querySelector<HTMLElement>(
|
||||
`[data-milestone-id="${id}"] .milestone-header`,
|
||||
);
|
||||
header?.scrollIntoView({ block: "start", behavior: "smooth" });
|
||||
header?.focus({ preventScroll: true });
|
||||
}
|
||||
|
||||
watch(() => route.query.milestone, () => void focusMilestoneFromRoute());
|
||||
|
||||
onMounted(async () => {
|
||||
await loadProject();
|
||||
void focusMilestoneFromRoute();
|
||||
loadTasks();
|
||||
loadNotes();
|
||||
loadDesignSystems();
|
||||
@@ -985,9 +1005,15 @@ async function confirmDelete() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-for="group in milestoneGroups" :key="group.milestone?.id ?? 'unassigned'" class="milestone-group">
|
||||
<div
|
||||
v-for="group in milestoneGroups"
|
||||
:key="group.milestone?.id ?? 'unassigned'"
|
||||
class="milestone-group"
|
||||
:data-milestone-id="group.milestone?.id"
|
||||
>
|
||||
<div
|
||||
class="milestone-header"
|
||||
tabindex="-1"
|
||||
:class="{ clickable: renamingMilestoneId !== group.milestone?.id }"
|
||||
:aria-expanded="!collapsedMilestones.has(groupKey(group))"
|
||||
@click="renamingMilestoneId !== group.milestone?.id && toggleMilestoneCollapse(groupKey(group))"
|
||||
@@ -1050,7 +1076,7 @@ async function confirmDelete() {
|
||||
:class="['ms-plan-rendered', 'markdown-body',
|
||||
{ 'ms-plan-clamped': isPlanClamped(group.milestone) }]"
|
||||
@click="startEditPlan(group.milestone.id, group.milestone.body)"
|
||||
v-html="renderMarkdown(group.milestone.body || '')"
|
||||
v-html="renderMarkdown(group.milestone.body || '')" v-record-refs
|
||||
></div>
|
||||
<button
|
||||
v-if="isPlanLong(group.milestone)"
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
import { useToastStore } from "@/stores/toast";
|
||||
import ConfirmDialog from "@/components/ConfirmDialog.vue";
|
||||
import { renderMarkdown } from "@/utils/markdown";
|
||||
import { vRecordRefs } from "@/directives/recordRefs";
|
||||
import { canWriteRecord } from "@/utils/permission";
|
||||
|
||||
const route = useRoute();
|
||||
@@ -185,7 +186,7 @@ async function confirmDelete() {
|
||||
|
||||
<section v-if="snippet.snippet.notes" class="notes">
|
||||
<h2 class="notes-heading">Notes</h2>
|
||||
<div class="prose" v-html="renderMarkdown(snippet.snippet.notes)" />
|
||||
<div class="prose" v-html="renderMarkdown(snippet.snippet.notes)" v-record-refs />
|
||||
</section>
|
||||
|
||||
<div v-if="snippet.tags.length" class="tag-row">
|
||||
|
||||
@@ -5,6 +5,7 @@ import { useTasksStore } from "@/stores/tasks";
|
||||
import { useNotesStore } from "@/stores/notes";
|
||||
import { useToastStore } from "@/stores/toast";
|
||||
import { renderMarkdown } from "@/utils/markdown";
|
||||
import { vRecordRefs } from "@/directives/recordRefs";
|
||||
import { useAssist } from "@/composables/useAssist";
|
||||
import { useAutoSave } from "@/composables/useAutoSave";
|
||||
import { useEditorGuards } from "@/composables/useEditorGuards";
|
||||
@@ -538,7 +539,7 @@ useEditorGuards(dirty, save);
|
||||
<div
|
||||
v-show="showPreview"
|
||||
class="preview-pane prose"
|
||||
v-html="renderedPreview"
|
||||
v-html="renderedPreview" v-record-refs
|
||||
/>
|
||||
</template>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user