Korrigiere IMAP-Ordner, MIME-Ansicht und die gemeinsamen Leser, damit große Postfächer, Notizen und verspätete Quellenantworten zuverlässig bleiben.
Deploy Development / deploy (push) Successful in 39s
Test Suite / pytest-backend (push) Successful in 2m29s
Test Suite / smoke-dev (push) Successful in 0s
Test Suite / frontend-build (push) Successful in 20s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-10-20 08:47:24 +02:00
1 parent 34c4084a7c
commit c29bd29f34
29 files changed
+2562 -410

No files matched your search

+10 -107
View File
@@ -1,9 +1,8 @@
import { useContext, useEffect, useRef, useState } from "react";
import { SessionContext } from "../session.js";
import { documentToText, downloadMailPart, fetchExternal, fetchFile, fetchMailPart, isDirty, markDirty, textToDocument, api } from "../api.js";
import { MarkdownView } from "../markdown.jsx";
import { NoteEditor } from "../notes.jsx";
import { SourceAssignment, noteEditor, representationOf } from "../sources/registry.jsx";
import { SourceAssignment, representationOf, stageFor } from "../sources/registry.jsx";
import "../sources/builtin-views.jsx";
import { ErrorNote } from "./widgets.jsx";
import { UnitDetail } from "./correspondence.jsx";
import { dateCaption, DateField, DirectionChoice, DirectionColumn, directionValue, directionWord, formatDate, mailFacts, sourceLabel } from "./content.jsx";
@@ -132,14 +131,14 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
useEffect(() => {
if (!element) return undefined;
const kind = representationOf(element);
if (kind === "note" || kind === "mail") setPhase("ready");
if (stageFor(kind) || kind === "note" || kind === "mail") setPhase("ready");
else if (kind === "locked" || kind === "unassigned" || !element.preview?.available) setPhase("missing");
setError("");
return undefined;
}, [element?.id, element?.kind, element?.external?.source, element?.external?.resolution, element?.file?.protection_profile, element?.preview?.available]);
useEffect(() => {
if (!element || representationOf(element) === "note" || representationOf(element) === "mail" || representationOf(element) === "locked" || representationOf(element) === "unassigned" || !element.preview?.available) return undefined;
if (!element || stageFor(representationOf(element)) || representationOf(element) === "locked" || representationOf(element) === "unassigned" || !element.preview?.available) return undefined;
let alive = true;
let url = "";
setPage(1);
@@ -206,7 +205,7 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
}, [element?.id, element?.kind, element?.external?.source, element?.external?.resolution, element?.file?.protection_profile, element?.preview?.available, context?.kind, context?.id]);
useEffect(() => {
if (!element || representationOf(element) !== "mail") return undefined;
if (!element || stageFor("mail") || representationOf(element) !== "mail") return undefined;
if (shownIndex === null) {
setPhase("ready");
setPdf(null);
@@ -275,7 +274,7 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
}, [element?.id, element?.external?.source, shownIndex, letter, context?.kind, context?.id]);
useEffect(() => {
if (!element || representationOf(element) !== "mail") return undefined;
if (!element || stageFor("mail") || representationOf(element) !== "mail") return undefined;
let alive = true;
const params = new URLSearchParams();
if (context?.kind && context?.id) {
@@ -366,52 +365,8 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
}
}
async function saveNote(event) {
event.preventDefault();
setError("");
try {
const updated = await noteEditor.save({
api,
element,
context,
document: textToDocument(text),
});
pendingNote.current = text;
editingRef.current = false;
setEditingNote(false);
markDirty(false);
setNotice(updated.notice || "Der gemeinsame Text ist gespeichert.");
onReload();
} catch (err) {
if (err.status === 409) {
setError("Der Stand hat sich geändert. Der eingegebene Text bleibt stehen. Bitte neu laden.");
return;
}
setError(err.message);
}
}
function beginNote() {
pendingNote.current = "";
editingRef.current = true;
setText(documentToText(element.document));
setNoteSession((current) => current + 1);
setEditingNote(true);
setError("");
setNotice("");
}
function cancelNote() {
pendingNote.current = "";
editingRef.current = false;
setText(documentToText(element.document));
setEditingNote(false);
markDirty(false);
setError("");
}
function requestClose() {
if (editingRef.current && isDirty() && !window.confirm("Ungespeicherte Eingaben verwerfen?")) return;
if (isDirty() && !window.confirm("Ungespeicherte Eingaben verwerfen?")) return;
markDirty(false);
onClose();
}
@@ -538,6 +493,7 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
const communication = binding.communication || {};
const shownDirection = communication.direction || null;
const kind = representationOf(element);
const Stage = stageFor(kind);
const isMail = kind === "mail";
const locked = kind === "locked";
const unassigned = kind === "unassigned";
@@ -589,61 +545,8 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
onDetach={() => {}}
onUnfold={() => {}}
/>
{isMail ? (
<article className="mail-letter">
<p className="mail-letter__way"><DirectionColumn direction={shownDirection} />{directionWord(shownDirection) ? <span>{directionWord(shownDirection)}</span> : null}</p>
<p><span>Von</span> {mailDetail.message_from || "Ohne Absender"}</p>
<p><span>An</span> {mailDetail.message_to || "Ohne Empfänger"}</p>
{mailDetail.message_cc ? <p><span>Kopie</span> {mailDetail.message_cc}</p> : null}
{letter?.complete ? (
<>
<MailAttachments files={letter.attachments} current={shownIndex} onOpen={(file) => {
setError("");
setShownFor((current) => (
current?.elementId === element.id && current.index === file.index ? null : { elementId: element.id, index: file.index }
));
}} />
{shownFile ? <p className="mail-attachment__caption">Anlage: {shownFile.filename}</p> : null}
{shownFile && phase === "loading" ? <p className="muted">Die Anlage wird geladen …</p> : null}
{media === "image" && blobUrl ? (
<img className="reader-image" alt={shownFile?.filename || element.title} src={blobUrl} style={{ width: `${Math.round(scale * 100)}%` }} />
) : null}
{media === "pdf" && pdf ? <canvas ref={canvasRef} className="reader-canvas" /> : null}
{media === "pdf-frame" && blobUrl ? <iframe className="reader-frame" title={shownFile?.filename || element.title} src={blobUrl} /> : null}
{media === "other" && blobUrl ? (
<div className="reader-pane__state">
<p>Diese Anlage lässt sich hier nicht als Seite zeigen.</p>
<a href={blobUrl} target="_blank" rel="noreferrer">Anlage öffnen</a>
</div>
) : null}
{letter.text ? <pre className="mail-letter__body">{letter.text}</pre> : (
<p className="muted">Diese Nachricht hat keinen lesbaren Text. Die vollständige E-Mail bleibt abrufbar.</p>
)}
<button type="button" onClick={() => openMailPart("original", "nachricht.eml")}>Vollständige E-Mail</button>
</>
) : (
<p className="muted">{error ? "Die vollständige Nachricht konnte nicht geladen werden." : "Die vollständige Nachricht wird geladen …"}</p>
)}
</article>
) : null}
{element.kind === "note" && noteEditor.available ? (
editingNote && binding.rights.edit ? (
<form className="reader-note" onSubmit={saveNote}>
<NoteEditor key={noteSession} value={text} onChange={(value) => { setText(value); markDirty(true); }} />
<p className="muted">Diese Änderung betrifft den gemeinsamen Inhalt der Notiz, nicht die hiesige Anmerkung. Gespeichert wird Markdown.</p>
{notice ? <p className="notice">{notice}</p> : null}
<div className="row">
<button type="submit">Text speichern</button>
<button type="button" className="quiet" onClick={cancelNote}>Abbrechen</button>
</div>
</form>
) : (
<div className="reader-note">
{text.trim() ? <MarkdownView text={text} /> : <p className="muted">Die Notiz ist leer.</p>}
{notice ? <p className="notice">{notice}</p> : null}
{binding.rights.edit ? <button type="button" onClick={beginNote}>Bearbeiten</button> : <p className="muted">In diesem Kontext nur lesbar.</p>}
</div>
)
{Stage ? (
<Stage element={element} context={context} binding={binding} onReload={onReload} shownDirection={shownDirection} />
) : null}
<form className="stack reader-direction" onSubmit={(event) => event.preventDefault()}>
<DirectionChoice