diff --git a/backend/app/api/routes.py b/backend/app/api/routes.py
index d2bbf49..0ac6cba 100644
--- a/backend/app/api/routes.py
+++ b/backend/app/api/routes.py
@@ -1027,7 +1027,7 @@ def post_file(
settings.media_root,
settings.upload_max_bytes,
request.state.cleanup_files,
- communication_direction if communication_direction in {"in", "out"} else None,
+ communication_direction if communication_direction in {"in", "out", "local"} else None,
)
return _created(f"/api/v1/elements/{element['id']}", {"id": str(element["id"]), "title": element["title"]})
diff --git a/backend/app/api/schemas.py b/backend/app/api/schemas.py
index d499741..df58f25 100644
--- a/backend/app/api/schemas.py
+++ b/backend/app/api/schemas.py
@@ -119,7 +119,7 @@ class MatterMoveIn(APIModel):
class CommunicationIn(APIModel):
expected_version: int = Field(ge=1)
- direction: Literal["in", "out"] | None = None
+ direction: Literal["in", "out", "local"] | None = None
context: ContextIn | None = None
@@ -176,7 +176,7 @@ class NoteIn(APIModel):
placement: ContextIn | None = None
chapter_id: UUID | None = None
dates: DatesIn | None = None
- communication_direction: Literal["in", "out"] | None = None
+ communication_direction: Literal["in", "out", "local"] | None = None
class ContentOrderIn(APIModel):
diff --git a/backend/app/ops.py b/backend/app/ops.py
index 67994e8..7019157 100644
--- a/backend/app/ops.py
+++ b/backend/app/ops.py
@@ -665,10 +665,14 @@ def record_dates(conn, actor: UUID, scope_id: UUID, element_id: UUID, context: C
audit(conn, actor, scope_id, "correspondence_recorded", "element", element_id, context)
+def chosen_direction(value: str | None) -> str | None:
+ return value if value in ("in", "out", "local") else None
+
+
def store_direction(conn, binding_id: UUID, direction: str | None, explicit: bool) -> None:
if not explicit:
return
- if direction not in (None, "in", "out"):
+ if direction not in (None, "in", "out", "local"):
raise unprocessable("Die Richtung ist ungültig.")
conn.execute(
"""
@@ -703,7 +707,8 @@ def create_note(
(element["id"], Json(document)),
)
binding = insert_binding(conn, element["id"], target.kind, target.id, chapter_id, actor)
- store_direction(conn, binding["id"], communication_direction, communication_direction in ("in", "out"))
+ chosen = chosen_direction(communication_direction)
+ store_direction(conn, binding["id"], chosen, chosen is not None)
audit(conn, actor, scope_id, "note_created", "element", element["id"], rights_context or target)
if document_on is not None or sent_on is not None or received_on is not None:
record_dates(conn, actor, scope_id, element["id"], rights_context or target, document_on, sent_on, received_on)
@@ -792,8 +797,8 @@ def create_external(conn, actor: UUID, scope_id: UUID, title: str, source: str,
)
binding = insert_binding(conn, element["id"], target.kind, target.id, chapter_id, actor)
adopted = (detail or {}).get("direction") if source == "imap" else None
- chosen = communication_direction if communication_direction in ("in", "out") else adopted if adopted in ("in", "out") else None
- store_direction(conn, binding["id"], chosen, chosen in ("in", "out"))
+ chosen = chosen_direction(communication_direction) or (adopted if adopted in ("in", "out") else None)
+ store_direction(conn, binding["id"], chosen, chosen is not None)
record_dates(conn, actor, scope_id, element["id"], rights_context or target, document_on, sent_on, received_on)
audit(conn, actor, scope_id, "external_ref_added", "element", element["id"], rights_context or target)
return element | {"binding_id": binding["id"]}
@@ -837,7 +842,8 @@ def create_file(conn, actor: UUID, scope_id: UUID, title: str, filename: str, da
(element["id"], asset_id),
)
binding = insert_binding(conn, element["id"], target.kind, target.id, chapter_id, actor)
- store_direction(conn, binding["id"], communication_direction, communication_direction in ("in", "out"))
+ chosen = chosen_direction(communication_direction)
+ store_direction(conn, binding["id"], chosen, chosen is not None)
record_dates(conn, actor, scope_id, element["id"], rights_context or target, document_on, sent_on, received_on)
audit(conn, actor, scope_id, "file_added", "element", element["id"], rights_context or target)
return element | {"binding_id": binding["id"], "asset_id": asset_id}
diff --git a/backend/app/present.py b/backend/app/present.py
index beb6a87..7ab2bbc 100644
--- a/backend/app/present.py
+++ b/backend/app/present.py
@@ -198,7 +198,7 @@ def _exception(conn, kind: str, resource_id: UUID, context: Ctx | None) -> dict
def communication_from_row(conn, binding: dict, element: dict) -> dict:
"""Explicit binding direction wins. An adopted mailbox direction may prefill. Dates never do."""
stored = binding.get("communication_direction")
- stored = stored if stored in ("in", "out") else None
+ stored = stored if stored in ("in", "out", "local") else None
if binding.get("direction_explicit"):
return {"direction": stored, "explicit": True}
source = None
diff --git a/backend/migrations/20261017T193000Z_communication_local.sql b/backend/migrations/20261017T193000Z_communication_local.sql
new file mode 100644
index 0000000..021c508
--- /dev/null
+++ b/backend/migrations/20261017T193000Z_communication_local.sql
@@ -0,0 +1,5 @@
+ALTER TABLE bindings DROP CONSTRAINT bindings_communication_direction;
+
+ALTER TABLE bindings
+ ADD CONSTRAINT bindings_communication_direction
+ CHECK (communication_direction IS NULL OR communication_direction IN ('in', 'out', 'local'));
diff --git a/backend/tests/test_direction.py b/backend/tests/test_direction.py
index f88818f..d5051de 100644
--- a/backend/tests/test_direction.py
+++ b/backend/tests/test_direction.py
@@ -194,3 +194,65 @@ def test_chapter_and_matter_can_be_renamed_and_moved(client, db):
json={"expected_version": ada.request("GET", f"/api/v1/cases/{case['id']}")["version"]},
)
ada.request("GET", f"/api/v1/cases/{case['id']}", status=404)
+
+
+def test_one_beleg_does_not_classify_the_chapter(client, db):
+ ada = Actor(client, "ada-kapitel@example.test", "Ada Kapitel")
+ register(db, ada.email, ada.name)
+ ada.login()
+ matter = matter_of(ada, "Schriftverkehr")
+ chapter = ada.request(
+ "POST",
+ f"/api/v1/matters/{matter['id']}/chapters",
+ json={"title": "Belege"},
+ status=201,
+ )
+ for title, external_id in (("Eingangsschreiben", "pl-1"), ("Antwortschreiben", "pl-2"), ("Rechnung", "pl-3")):
+ ada.request(
+ "POST",
+ "/api/v1/external-refs",
+ json={
+ "title": title,
+ "source": "paperless",
+ "external_id": external_id,
+ "context": {"kind": "matter", "id": matter["id"]},
+ "chapter_id": chapter["id"],
+ "dates": {"document_on": "2026-10-01"},
+ },
+ status=201,
+ )
+ detail = _matter(ada, matter["id"])
+ incoming = _binding(detail, "Eingangsschreiben")
+ reply = _binding(detail, "Antwortschreiben")
+ invoice = _binding(detail, "Rechnung")
+ ada.request(
+ "POST",
+ f"/api/v1/elements/{reply['element']['id']}/references",
+ json={"refers_to_element_id": incoming["element"]["id"], "context": {"kind": "matter", "id": matter["id"]}},
+ status=204,
+ )
+ ada.request(
+ "PATCH",
+ f"/api/v1/bindings/{incoming['id']}/communication",
+ json={"expected_version": incoming["element"]["version"], "direction": "in", "context": {"kind": "matter", "id": matter["id"]}},
+ )
+ shown = _matter(ada, matter["id"])
+ assert _binding(shown, "Eingangsschreiben")["communication"] == {"direction": "in", "explicit": True}
+ assert _binding(shown, "Antwortschreiben")["communication"]["direction"] is None
+ assert _binding(shown, "Rechnung")["communication"]["direction"] is None
+ assert _binding(shown, "Antwortschreiben")["element"]["refers_to"][0]["direction"] == "in"
+ ada.request(
+ "PATCH",
+ f"/api/v1/bindings/{reply['id']}/communication",
+ json={"expected_version": reply["element"]["version"], "direction": "out", "context": {"kind": "matter", "id": matter["id"]}},
+ )
+ ada.request(
+ "PATCH",
+ f"/api/v1/bindings/{invoice['id']}/communication",
+ json={"expected_version": invoice["element"]["version"], "direction": "local", "context": {"kind": "matter", "id": matter["id"]}},
+ )
+ final = _matter(ada, matter["id"])
+ assert _binding(final, "Eingangsschreiben")["communication"]["direction"] == "in"
+ assert _binding(final, "Antwortschreiben")["communication"]["direction"] == "out"
+ assert _binding(final, "Rechnung")["communication"] == {"direction": "local", "explicit": True}
+ assert all(item["chapter_id"] == chapter["id"] for item in final["bindings"])
diff --git a/docs/architecture/TSUMUGU_TECHNICAL_SPEC.md b/docs/architecture/TSUMUGU_TECHNICAL_SPEC.md
index 7e184fa..5dc1a08 100644
--- a/docs/architecture/TSUMUGU_TECHNICAL_SPEC.md
+++ b/docs/architecture/TSUMUGU_TECHNICAL_SPEC.md
@@ -196,7 +196,7 @@ Gemeinsame Spalten der fachlichen Ankerobjekte `cases`, `matters`, `elements`, `
| `elements` | `kind` `note`, `correspondence`, `file` oder `external_ref` | Gemeinsamer Inhaltsträger. Rechnungen verweisen auf ein Element, sind aber eigene Finanzobjekte. |
| `note_bodies` | `element_id`, `document_json`, `version` | Ein Text je Notiz. Begrenzter Renderbaum aus dem Datei-Blueprint, keine freie HTML-Ablage. |
| `correspondence_dates` | `element_id`, `document_on`, `sent_on`, `received_on` | Vier getrennte Datumssachen. `recorded_at` ist `elements.created_at`. |
-| `bindings` | `element_id`, `context_kind`, `context_id`, `chapter_id` null, `position`, `release_state`, `communication_direction` null, `direction_explicit` | Kontext ist Akte, Vorgang oder Zusammenstellung. `release_state` `visible` oder `pending` für noch nicht freigegebene neue Zusammenstellungsinhalte. `communication_direction` ist `in`, `out` oder leer und gilt nur für diese Einbindung. `direction_explicit` wahr hält eine bewusste Wahl oder ein bewusstes Leeren; sonst darf nur eine übernommene IMAP-Richtung `in` oder `out` vorgefüllt werden. Versand- und Zugangsdatum sind keine Richtung. |
+| `bindings` | `element_id`, `context_kind`, `context_id`, `chapter_id` null, `position`, `release_state`, `communication_direction` null, `direction_explicit` | Kontext ist Akte, Vorgang oder Zusammenstellung. `release_state` `visible` oder `pending` für noch nicht freigegebene neue Zusammenstellungsinhalte. `communication_direction` ist `in`, `out`, `local` oder leer und gilt nur für diese Einbindung. `local` ist eine bewusste lokale Unterlage ohne Ein- oder Ausgang. `direction_explicit` wahr hält eine bewusste Wahl oder ein bewusstes Leeren; sonst darf nur eine übernommene IMAP-Richtung `in` oder `out` vorgefüllt werden. Versand- und Zugangsdatum sind keine Richtung. |
| `context_annotations` | `binding_id`, `body`, `author_subject_id` | Gehört zur Einbindung, nicht zum gemeinsamen Text. |
| `access_grants` | `grantee_subject_id`, `resource_kind`, `resource_id`, `context_kind`, `context_id`, `can_read`, `can_edit`, `can_share`, `can_delete` | Explizite Grants. Vererbung wird berechnet und nur bei Abweichung materialisiert. |
| `compilations` | Ankerfelder | Virtuelle Zusammenstellung. |
diff --git a/docs/product/TSUMUGU_PRODUCT_SPEC.md b/docs/product/TSUMUGU_PRODUCT_SPEC.md
index bbb742f..c8a4ce8 100644
--- a/docs/product/TSUMUGU_PRODUCT_SPEC.md
+++ b/docs/product/TSUMUGU_PRODUCT_SPEC.md
@@ -472,4 +472,6 @@ Der Nutzer nennt folgende tatsächlich genutzte Felder. Schreibweisen sind als G
17.10.2026, Arbeitsstand 0.33: Sichtprüfung zu F-06e bestätigt Blatt statt Sprechblase bei Notizen und zu kleine Richtungspfeile. Paket 1.3 liefert gefüllte Dreiecke; Auftrag 1.1 verlangt führende Richtungsspalte, tatsächlichen Austausch der Notizdateien und Prüfung der ausgelieferten Inhalte. Fachliche Exportplanung aus 0.32 erhalten. Keine Anwendungscodeänderung oder Deployment durch diese Fortschreibung.
+17.10.2026, Arbeitsstand 0.35: Richtung bleibt an der einzelnen Einbindung. Ein Beleg im Kapitel, auch mit Bezug auf einen anderen Beleg, ändert die Richtung der übrigen Einträge nicht. In der Übersicht sind Eingang, Ausgang und Lokal direkt wählbar. Lokal ist eine bewusste Unterlage ohne Ein- oder Ausgang und trägt kein Richtungsdreieck. Keine Angabe bleibt der unbestimmte Zustand.
+
Nach jeder Entscheidung diese Datei mit kurzer Begründung und Auswirkungen auf Fachmodell/MVP aktualisieren. Die historische Baseline bleibt unverändert. Keine Implementierung ohne ausdrückliche Freigabe; technische Umsetzung später anhand der dann freigegebenen Jinkendo-Blueprints.
diff --git a/frontend/src/pages/Cases.jsx b/frontend/src/pages/Cases.jsx
index b3b71dc..a7597bf 100644
--- a/frontend/src/pages/Cases.jsx
+++ b/frontend/src/pages/Cases.jsx
@@ -956,7 +956,7 @@ export function FileForm({ context, placement, chapters = [], initialChapter = "
if (documentOn) form.set("document_on", documentOn);
if (sentOn) form.set("sent_on", sentOn);
if (receivedOn) form.set("received_on", receivedOn);
- if (direction === "in" || direction === "out") form.set("communication_direction", direction);
+ if (direction === "in" || direction === "out" || direction === "local") form.set("communication_direction", direction);
setError("");
try {
await api("/api/v1/files", { method: "POST", form });
diff --git a/frontend/src/pages/ReadingPane.jsx b/frontend/src/pages/ReadingPane.jsx
index e7bb5fc..58bab16 100644
--- a/frontend/src/pages/ReadingPane.jsx
+++ b/frontend/src/pages/ReadingPane.jsx
@@ -1,7 +1,7 @@
import { useEffect, useRef, useState } from "react";
import { documentToText, downloadMailPart, fetchFile, fetchMailPart, fetchPaperless, markDirty, textToDocument, api } from "../api.js";
import { ErrorNote } from "./widgets.jsx";
-import { dateCaption, DirectionChoice, DirectionColumn, directionWord, formatDate, mailFacts, MarkdownEditor, sourceLabel } from "./content.jsx";
+import { dateCaption, DirectionChoice, DirectionColumn, directionValue, directionWord, formatDate, mailFacts, MarkdownEditor, sourceLabel } from "./content.jsx";
import { NavIcon } from "./icons.jsx";
import workerSrc from "pdfjs-dist/build/pdf.worker.min.mjs?url";
@@ -22,7 +22,7 @@ function MailAttachments({ files, current, onOpen }) {
{files.map((file) => (
{onOpen && Number.isInteger(file.index) ? (
-
+
) : file.filename}
))}
@@ -30,7 +30,7 @@ function MailAttachments({ files, current, onOpen }) {
);
}
-function Correspondence({ element, onOpenRelated }) {
+function Correspondence({ element, direction, onOpenRelated }) {
const refers = element.refers_to || [];
const replies = element.referred_by || [];
if (!refers.length && !replies.length) return null;
@@ -38,7 +38,7 @@ function Correspondence({ element, onOpenRelated }) {
id: element.id,
title: element.title,
document_on: element.dates?.document_on || null,
- direction: element.external?.detail?.direction || (element.dates?.sent_on && !element.dates?.received_on ? "out" : element.dates?.received_on && !element.dates?.sent_on ? "in" : null),
+ direction: direction || null,
current: true,
};
const seen = new Set();
@@ -90,7 +90,8 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
const [notice, setNotice] = useState("");
const [annotate, setAnnotate] = useState(false);
const [letter, setLetter] = useState(null);
- const [shownIndex, setShownIndex] = useState(null);
+ const [shownFor, setShownFor] = useState(null);
+ const shownIndex = shownFor?.elementId === element?.id ? shownFor.index : null;
const canvasRef = useRef(null);
const objectUrl = useRef("");
const closeRef = useRef(null);
@@ -106,28 +107,33 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
setSentOn(element.dates?.sent_on || "");
setReceivedOn(element.dates?.received_on || "");
setSummary(element.summary || "");
- setError("");
setNotice("");
- setPage(1);
- setPdf(null);
- setPages(0);
- setMedia("");
- setLetter(null);
- setShownIndex(null);
- if (objectUrl.current) {
- URL.revokeObjectURL(objectUrl.current);
- objectUrl.current = "";
- }
- setBlobUrl("");
- const mail = element.external?.source === "imap";
- setPhase(element.kind === "note" || mail ? "ready" : element.preview?.available ? "loading" : "missing");
return undefined;
- }, [element?.id, element?.version]);
+ }, [element?.id, element?.version, element?.summary, element?.document, element?.dates?.document_on, element?.dates?.sent_on, element?.dates?.received_on]);
+
+ useEffect(() => {
+ if (!element) return undefined;
+ const mail = element.external?.source === "imap";
+ if (element.kind === "note" || mail) setPhase("ready");
+ else if (!element.preview?.available) setPhase("missing");
+ setError("");
+ return undefined;
+ }, [element?.id, element?.kind, element?.external?.source, element?.preview?.available]);
useEffect(() => {
if (!element || element.kind === "note" || element.external?.source === "imap" || !element.preview?.available) return undefined;
let alive = true;
let url = "";
+ setPage(1);
+ setPdf(null);
+ setPages(0);
+ setMedia("");
+ setLetter(null);
+ if (objectUrl.current) {
+ URL.revokeObjectURL(objectUrl.current);
+ objectUrl.current = "";
+ }
+ setBlobUrl("");
setPhase("loading");
const load = element.external?.source === "paperless" ? fetchPaperless(element.id, context) : fetchFile(element.id, context);
load.then(async (blob) => {
@@ -175,15 +181,20 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
}, [element?.id, element?.kind, element?.external?.source, element?.preview?.available, context?.kind, context?.id]);
useEffect(() => {
- if (!letter?.complete) return undefined;
- const files = letter.attachments || [];
- const viewable = files.findIndex((file) => previewKind(file.content_type, file.filename) !== "other");
- setShownIndex(viewable >= 0 ? files[viewable].index : (files[0] ? files[0].index : null));
- return undefined;
- }, [letter]);
-
- useEffect(() => {
- if (!element || element.external?.source !== "imap" || shownIndex === null) return undefined;
+ if (!element || element.external?.source !== "imap") return undefined;
+ if (shownIndex === null) {
+ setPhase("ready");
+ setPdf(null);
+ setPages(0);
+ setPage(1);
+ setMedia("");
+ if (objectUrl.current) {
+ URL.revokeObjectURL(objectUrl.current);
+ objectUrl.current = "";
+ }
+ setBlobUrl("");
+ return undefined;
+ }
const file = (letter?.attachments || []).find((item) => item.index === shownIndex);
if (!file) return undefined;
let alive = true;
@@ -473,7 +484,7 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
-
+
{isMail ? (
{directionWord(shownDirection) ? {directionWord(shownDirection)} : null}
@@ -482,7 +493,12 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
{mailDetail.message_cc ? Kopie {mailDetail.message_cc}
: null}
{letter?.complete ? (
<>
- { setError(""); setShownIndex(file.index); }} />
+ {
+ setError("");
+ setShownFor((current) => (
+ current?.elementId === element.id && current.index === file.index ? null : { elementId: element.id, index: file.index }
+ ));
+ }} />
{shownFile ? Anlage: {shownFile.filename}
: null}
{shownFile && phase === "loading" ? Die Anlage wird geladen …
: null}
{media === "image" && blobUrl ? (
@@ -516,7 +532,7 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
) : null}