forked from retoor/devplacepy
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5f956d12f6 | ||
|
|
bfafe8c99d |
File diff suppressed because one or more lines are too long
@@ -1,7 +1,6 @@
|
|||||||
# retoor <retoor@molodetz.nl>
|
# retoor <retoor@molodetz.nl>
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Annotated
|
from typing import Annotated
|
||||||
|
|
||||||
@@ -65,7 +64,6 @@ def _targets() -> list[dict]:
|
|||||||
def _dashboard(can_download: bool) -> dict:
|
def _dashboard(can_download: bool) -> dict:
|
||||||
backups = [_backup_payload(row, can_download) for row in store.list_backups()]
|
backups = [_backup_payload(row, can_download) for row in store.list_backups()]
|
||||||
schedules = store.list_schedules()
|
schedules = store.list_schedules()
|
||||||
threshold = int(os.environ.get("DISK_WARNING_PERCENT", "85"))
|
|
||||||
return {
|
return {
|
||||||
"storage": store.compute_storage_stats(),
|
"storage": store.compute_storage_stats(),
|
||||||
"backups": backups,
|
"backups": backups,
|
||||||
@@ -74,8 +72,6 @@ def _dashboard(can_download: bool) -> dict:
|
|||||||
"metrics": _metrics(backups),
|
"metrics": _metrics(backups),
|
||||||
"generated_at": store.now_iso(),
|
"generated_at": store.now_iso(),
|
||||||
"can_download_backups": can_download,
|
"can_download_backups": can_download,
|
||||||
"disk_warnings": store.get_disk_warnings(threshold),
|
|
||||||
"disk_warning_threshold": threshold,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@router.get("/backups", response_class=HTMLResponse)
|
@router.get("/backups", response_class=HTMLResponse)
|
||||||
|
|||||||
@@ -53,13 +53,6 @@ class BackupJobOut(_Out):
|
|||||||
completed_at: Optional[str] = None
|
completed_at: Optional[str] = None
|
||||||
|
|
||||||
|
|
||||||
class DiskWarningOut(_Out):
|
|
||||||
path: str = ""
|
|
||||||
used_pct: float = 0.0
|
|
||||||
total_gb: float = 0.0
|
|
||||||
used_gb: float = 0.0
|
|
||||||
|
|
||||||
|
|
||||||
class BackupScheduleOut(_Out):
|
class BackupScheduleOut(_Out):
|
||||||
uid: str = ""
|
uid: str = ""
|
||||||
name: str = ""
|
name: str = ""
|
||||||
@@ -85,5 +78,3 @@ class BackupDashboardOut(_Out):
|
|||||||
generated_at: Optional[str] = None
|
generated_at: Optional[str] = None
|
||||||
can_download_backups: bool = False
|
can_download_backups: bool = False
|
||||||
admin_section: Optional[str] = None
|
admin_section: Optional[str] = None
|
||||||
disk_warnings: list[DiskWarningOut] = []
|
|
||||||
disk_warning_threshold: int = 85
|
|
||||||
|
|||||||
@@ -34,10 +34,6 @@ class BackupService(JobService):
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(name="backup", interval_seconds=15)
|
super().__init__(name="backup", interval_seconds=15)
|
||||||
try:
|
|
||||||
store.seed_default_schedule()
|
|
||||||
except Exception as exc:
|
|
||||||
logger.warning("failed to seed default backup schedule: %s", exc)
|
|
||||||
|
|
||||||
async def run_once(self) -> None:
|
async def run_once(self) -> None:
|
||||||
await super().run_once()
|
await super().run_once()
|
||||||
@@ -125,15 +121,6 @@ class BackupService(JobService):
|
|||||||
summary=f"backup {target} completed ({_human_bytes(stats['bytes_out'])})",
|
summary=f"backup {target} completed ({_human_bytes(stats['bytes_out'])})",
|
||||||
links=[audit.job(job_uid)],
|
links=[audit.job(job_uid)],
|
||||||
)
|
)
|
||||||
if schedule_uid:
|
|
||||||
try:
|
|
||||||
store.check_disk_and_alert()
|
|
||||||
except Exception as exc:
|
|
||||||
logger.warning("disk alert check failed: %s", exc)
|
|
||||||
try:
|
|
||||||
store.check_db_growth()
|
|
||||||
except Exception as exc:
|
|
||||||
logger.warning("db growth check failed: %s", exc)
|
|
||||||
return {
|
return {
|
||||||
"backup_uid": backup_uid,
|
"backup_uid": backup_uid,
|
||||||
"target": target,
|
"target": target,
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
# retoor <retoor@molodetz.nl>
|
# retoor <retoor@molodetz.nl>
|
||||||
|
|
||||||
import json
|
|
||||||
import logging
|
|
||||||
import shutil
|
import shutil
|
||||||
import time
|
import time
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
@@ -11,8 +9,6 @@ from devplacepy import config
|
|||||||
from devplacepy.database import _index, db, get_table
|
from devplacepy.database import _index, db, get_table
|
||||||
from devplacepy.utils import generate_uid
|
from devplacepy.utils import generate_uid
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
BACKUP_TARGETS: dict[str, dict] = {
|
BACKUP_TARGETS: dict[str, dict] = {
|
||||||
"database": {
|
"database": {
|
||||||
"label": "Database",
|
"label": "Database",
|
||||||
@@ -379,58 +375,6 @@ def _storage_paths() -> list[tuple[str, str, Path]]:
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def seed_default_schedule() -> None:
|
|
||||||
if "backup_schedules" not in db.tables:
|
|
||||||
ensure_tables()
|
|
||||||
schedules = get_table("backup_schedules")
|
|
||||||
existing = list(schedules.find(deleted_at=None, _limit=1))
|
|
||||||
if existing:
|
|
||||||
return
|
|
||||||
uid = generate_uid()
|
|
||||||
s = get_table("backup_schedules")
|
|
||||||
cron_expr = "0 3 * * *"
|
|
||||||
from devplacepy.services.devii.tasks.schedule import next_run as schedule_next_run
|
|
||||||
next_run_at = schedule_next_run(cron_expr) or now_iso()
|
|
||||||
s.insert(
|
|
||||||
{
|
|
||||||
"uid": uid,
|
|
||||||
"name": "Daily database backup",
|
|
||||||
"target": "database",
|
|
||||||
"kind": "cron",
|
|
||||||
"every_seconds": 0,
|
|
||||||
"cron": cron_expr,
|
|
||||||
"enabled": 1,
|
|
||||||
"keep_last": 14,
|
|
||||||
"next_run_at": next_run_at,
|
|
||||||
"last_run_at": "",
|
|
||||||
"last_job_uid": "",
|
|
||||||
"run_count": 0,
|
|
||||||
"created_by": "system",
|
|
||||||
"created_at": now_iso(),
|
|
||||||
"updated_at": now_iso(),
|
|
||||||
"deleted_at": None,
|
|
||||||
"deleted_by": None,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def get_disk_warnings(threshold: int = 85) -> list[dict]:
|
|
||||||
stats = compute_storage_stats()
|
|
||||||
disk = stats.get("disk", {})
|
|
||||||
used_pct = disk.get("used_percent", 0.0)
|
|
||||||
warnings = []
|
|
||||||
if used_pct >= threshold:
|
|
||||||
warnings.append(
|
|
||||||
{
|
|
||||||
"path": stats.get("data_dir", {}).get("path", str(config.DATA_DIR)),
|
|
||||||
"used_pct": used_pct,
|
|
||||||
"total_gb": round(disk.get("total_bytes", 0) / (1024**3), 1),
|
|
||||||
"used_gb": round(disk.get("used_bytes", 0) / (1024**3), 1),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
return warnings
|
|
||||||
|
|
||||||
|
|
||||||
def compute_storage_stats() -> dict:
|
def compute_storage_stats() -> dict:
|
||||||
now = time.monotonic()
|
now = time.monotonic()
|
||||||
if (
|
if (
|
||||||
@@ -491,131 +435,3 @@ def compute_storage_stats() -> dict:
|
|||||||
_storage_cache["data"] = data
|
_storage_cache["data"] = data
|
||||||
_storage_cache["at"] = now
|
_storage_cache["at"] = now
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
DB_GROWTH_HISTORY_FILE = None
|
|
||||||
|
|
||||||
|
|
||||||
def _db_growth_path() -> Path:
|
|
||||||
global DB_GROWTH_HISTORY_FILE
|
|
||||||
if DB_GROWTH_HISTORY_FILE is None:
|
|
||||||
DB_GROWTH_HISTORY_FILE = config.BACKUPS_DIR / "db_growth_history.json"
|
|
||||||
return DB_GROWTH_HISTORY_FILE
|
|
||||||
|
|
||||||
|
|
||||||
def _load_db_sizes() -> list[dict]:
|
|
||||||
path = _db_growth_path()
|
|
||||||
if not path.exists():
|
|
||||||
return []
|
|
||||||
try:
|
|
||||||
return json.loads(path.read_text())
|
|
||||||
except (ValueError, OSError):
|
|
||||||
return []
|
|
||||||
|
|
||||||
|
|
||||||
def _save_db_sizes(sizes: list[dict]) -> None:
|
|
||||||
path = _db_growth_path()
|
|
||||||
try:
|
|
||||||
path.parent.mkdir(parents=True, exist_ok=True)
|
|
||||||
path.write_text(json.dumps(sizes))
|
|
||||||
except OSError as exc:
|
|
||||||
logger.warning("failed to write db growth history: %s", exc)
|
|
||||||
|
|
||||||
|
|
||||||
def _database_file_size() -> int:
|
|
||||||
database_file = Path(str(config.DATABASE_URL).replace("sqlite:///", ""))
|
|
||||||
try:
|
|
||||||
return database_file.stat().st_size if database_file.exists() else 0
|
|
||||||
except OSError:
|
|
||||||
return 0
|
|
||||||
|
|
||||||
|
|
||||||
def check_db_growth() -> None:
|
|
||||||
from devplacepy.services.audit import record as audit
|
|
||||||
|
|
||||||
current = _database_file_size()
|
|
||||||
if current <= 0:
|
|
||||||
return
|
|
||||||
|
|
||||||
sizes = _load_db_sizes()
|
|
||||||
last_entry = sizes[-1] if sizes else None
|
|
||||||
now = now_iso()
|
|
||||||
|
|
||||||
sizes.append({"at": now, "size_bytes": current})
|
|
||||||
_save_db_sizes(sizes)
|
|
||||||
|
|
||||||
if last_entry and last_entry.get("size_bytes", 0) > 0:
|
|
||||||
try:
|
|
||||||
last_at = datetime.fromisoformat(last_entry["at"])
|
|
||||||
current_at = datetime.fromisoformat(now)
|
|
||||||
days = (current_at - last_at).total_seconds() / 86400
|
|
||||||
if days > 0:
|
|
||||||
growth_pct = (current - last_entry["size_bytes"]) / last_entry["size_bytes"]
|
|
||||||
daily_pct = growth_pct / days
|
|
||||||
if daily_pct > 0.10:
|
|
||||||
logger.warning(
|
|
||||||
"database growth %.1f%%/day (%.0f MB -> %.0f MB over %.1f days)",
|
|
||||||
daily_pct * 100,
|
|
||||||
last_entry["size_bytes"] / (1024 * 1024),
|
|
||||||
current / (1024 * 1024),
|
|
||||||
days,
|
|
||||||
)
|
|
||||||
try:
|
|
||||||
audit.record_system(
|
|
||||||
"backup.db_growth_high",
|
|
||||||
actor_kind="service",
|
|
||||||
origin="scheduler",
|
|
||||||
target_type="system",
|
|
||||||
metadata={
|
|
||||||
"size_bytes": current,
|
|
||||||
"previous_size_bytes": last_entry["size_bytes"],
|
|
||||||
"daily_growth_pct": round(daily_pct * 100, 1),
|
|
||||||
"span_days": round(days, 2),
|
|
||||||
},
|
|
||||||
summary=(
|
|
||||||
f"database growth {daily_pct * 100:.1f}%/day "
|
|
||||||
f"({human_bytes(last_entry['size_bytes'])} -> {human_bytes(current)})"
|
|
||||||
),
|
|
||||||
)
|
|
||||||
except Exception as exc:
|
|
||||||
logger.warning("db growth audit failed: %s", exc)
|
|
||||||
except (ValueError, TypeError) as exc:
|
|
||||||
logger.warning("failed to parse db growth dates: %s", exc)
|
|
||||||
|
|
||||||
|
|
||||||
DISK_ALERT_THRESHOLD = 85
|
|
||||||
|
|
||||||
|
|
||||||
def check_disk_and_alert() -> None:
|
|
||||||
from devplacepy.services.audit import record as audit
|
|
||||||
|
|
||||||
stats = compute_storage_stats()
|
|
||||||
disk = stats.get("disk", {})
|
|
||||||
used_pct = disk.get("used_percent", 0.0)
|
|
||||||
if used_pct < DISK_ALERT_THRESHOLD:
|
|
||||||
return
|
|
||||||
logger.warning(
|
|
||||||
"disk usage at %.1f%% (threshold %d%%)",
|
|
||||||
used_pct,
|
|
||||||
DISK_ALERT_THRESHOLD,
|
|
||||||
)
|
|
||||||
try:
|
|
||||||
audit.record_system(
|
|
||||||
"backup.disk.critical",
|
|
||||||
actor_kind="service",
|
|
||||||
origin="scheduler",
|
|
||||||
target_type="system",
|
|
||||||
metadata={
|
|
||||||
"used_percent": used_pct,
|
|
||||||
"used_bytes": disk.get("used_bytes", 0),
|
|
||||||
"total_bytes": disk.get("total_bytes", 0),
|
|
||||||
"free_bytes": disk.get("free_bytes", 0),
|
|
||||||
},
|
|
||||||
summary=(
|
|
||||||
f"disk usage at {used_pct:.1f}% "
|
|
||||||
f"({human_bytes(disk.get('used_bytes', 0))} / "
|
|
||||||
f"{human_bytes(disk.get('total_bytes', 0))})"
|
|
||||||
),
|
|
||||||
)
|
|
||||||
except Exception as exc:
|
|
||||||
logger.warning("disk alert audit failed: %s", exc)
|
|
||||||
|
|||||||
@@ -81,7 +81,6 @@ class ContainerService(BaseService):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(name="containers", interval_seconds=5)
|
super().__init__(name="containers", interval_seconds=5)
|
||||||
self._metric_tick = 0
|
self._metric_tick = 0
|
||||||
self._orphan_sweep_tick = 0
|
|
||||||
self._booted = False
|
self._booted = False
|
||||||
self._last_sync_at = 0.0
|
self._last_sync_at = 0.0
|
||||||
|
|
||||||
@@ -108,6 +107,19 @@ class ContainerService(BaseService):
|
|||||||
|
|
||||||
await self._periodic_sync(instances, by_uid)
|
await self._periodic_sync(instances, by_uid)
|
||||||
|
|
||||||
|
for uid, row in by_uid.items():
|
||||||
|
if uid not in known:
|
||||||
|
try:
|
||||||
|
await backend.rm(row.container_id, force=True)
|
||||||
|
self.log(f"reaped orphan container {row.name}")
|
||||||
|
_audit_reconcile(
|
||||||
|
{"uid": uid, "name": row.name},
|
||||||
|
"orphan_reap",
|
||||||
|
f"reconciler reaped orphan container {row.name}",
|
||||||
|
)
|
||||||
|
except Exception as exc:
|
||||||
|
self.log(f"orphan rm failed for {row.name}: {exc}")
|
||||||
|
|
||||||
for inst in instances:
|
for inst in instances:
|
||||||
try:
|
try:
|
||||||
await self._reconcile(backend, inst, by_uid.get(inst["uid"]))
|
await self._reconcile(backend, inst, by_uid.get(inst["uid"]))
|
||||||
@@ -116,16 +128,6 @@ class ContainerService(BaseService):
|
|||||||
|
|
||||||
await self._fire_schedules()
|
await self._fire_schedules()
|
||||||
|
|
||||||
try:
|
|
||||||
await self._sweep_orphaned_containers(backend, by_uid, known)
|
|
||||||
except Exception as exc:
|
|
||||||
self.log(f"orphan sweep failed: {exc}")
|
|
||||||
|
|
||||||
try:
|
|
||||||
await self._cleanup_stale_workspaces(backend)
|
|
||||||
except Exception as exc:
|
|
||||||
self.log(f"workspace cleanup failed: {exc}")
|
|
||||||
|
|
||||||
self._metric_tick += 1
|
self._metric_tick += 1
|
||||||
if (
|
if (
|
||||||
self._metric_tick
|
self._metric_tick
|
||||||
@@ -134,49 +136,6 @@ class ContainerService(BaseService):
|
|||||||
):
|
):
|
||||||
await self._sample_metrics(backend, by_uid)
|
await self._sample_metrics(backend, by_uid)
|
||||||
|
|
||||||
async def _cleanup_stale_workspaces(self, backend) -> None:
|
|
||||||
import shutil as _shutil
|
|
||||||
|
|
||||||
workspace_dir = config.CONTAINER_WORKSPACES_DIR
|
|
||||||
if not workspace_dir.is_dir():
|
|
||||||
return
|
|
||||||
instances = store.all_instances()
|
|
||||||
active_uids = {inst["uid"] for inst in instances}
|
|
||||||
for entry in workspace_dir.iterdir():
|
|
||||||
if not entry.is_dir():
|
|
||||||
continue
|
|
||||||
uid = entry.name
|
|
||||||
if uid in active_uids:
|
|
||||||
continue
|
|
||||||
try:
|
|
||||||
_shutil.rmtree(entry)
|
|
||||||
self.log(f"removed stale workspace {uid}")
|
|
||||||
except Exception as exc:
|
|
||||||
self.log(f"failed to remove workspace {uid}: {exc}")
|
|
||||||
await backend.image_prune()
|
|
||||||
|
|
||||||
async def _sweep_orphaned_containers(self, backend, by_uid: dict, known: set) -> None:
|
|
||||||
if self._orphan_sweep_tick % 60 != 0:
|
|
||||||
self._orphan_sweep_tick += 1
|
|
||||||
return
|
|
||||||
self._orphan_sweep_tick += 1
|
|
||||||
for uid, row in by_uid.items():
|
|
||||||
if uid not in known:
|
|
||||||
try:
|
|
||||||
await backend.stop(row.container_id, timeout=10)
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
await backend.rm(row.container_id, force=True)
|
|
||||||
self.log(f"removed orphan container {row.name}")
|
|
||||||
_audit_reconcile(
|
|
||||||
{"uid": uid, "name": row.name},
|
|
||||||
"orphan_reap",
|
|
||||||
f"sweeper removed orphan container {row.name}",
|
|
||||||
)
|
|
||||||
except Exception as exc:
|
|
||||||
self.log(f"orphan rm failed for {row.name}: {exc}")
|
|
||||||
|
|
||||||
async def _reconcile(self, backend, inst, ps) -> None:
|
async def _reconcile(self, backend, inst, ps) -> None:
|
||||||
uid = inst["uid"]
|
uid = inst["uid"]
|
||||||
desired = inst["desired_state"]
|
desired = inst["desired_state"]
|
||||||
|
|||||||
@@ -236,6 +236,12 @@ dp-chat[mode="embed"] {
|
|||||||
border-bottom-right-radius: 4px;
|
border-bottom-right-radius: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.message-bubble.mine a,
|
||||||
|
.message-bubble.mine .rendered-content a {
|
||||||
|
color: var(--white);
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
.message-bubble.theirs {
|
.message-bubble.theirs {
|
||||||
align-self: flex-start;
|
align-self: flex-start;
|
||||||
background: var(--bg-card-hover);
|
background: var(--bg-card-hover);
|
||||||
|
|||||||
@@ -0,0 +1,525 @@
|
|||||||
|
// retoor <retoor@molodetz.nl>
|
||||||
|
|
||||||
|
import { MessagesSocket } from "./MessagesSocket.js";
|
||||||
|
import { contentRenderer } from "./ContentRenderer.js";
|
||||||
|
|
||||||
|
const TYPING_THROTTLE_MS = 1500;
|
||||||
|
const TYPING_HIDE_MS = 4000;
|
||||||
|
const AUTO_SCROLL_MARGIN_PX = 100;
|
||||||
|
const STABILIZE_MAX_FRAMES = 300;
|
||||||
|
|
||||||
|
export class MessagesLayout {
|
||||||
|
constructor() {
|
||||||
|
this.layout = document.querySelector(".messages-layout");
|
||||||
|
if (!this.layout) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.thread = document.querySelector(".messages-thread");
|
||||||
|
this.form = document.querySelector(".messages-input-area");
|
||||||
|
this.input = this.form ? this.form.querySelector('input[name="content"]') : null;
|
||||||
|
this.upload = this.form ? this.form.querySelector("dp-upload") : null;
|
||||||
|
this.sendBtn = this.form ? this.form.querySelector(".messages-send-btn") : null;
|
||||||
|
this._uploading = false;
|
||||||
|
this._pendingSends = new Set();
|
||||||
|
this.typingEl = document.getElementById("typing-indicator");
|
||||||
|
|
||||||
|
this.selfUid = this.layout.dataset.selfUid || "";
|
||||||
|
this.otherUid = this.layout.dataset.otherUid || "";
|
||||||
|
|
||||||
|
this._lastTypingSent = 0;
|
||||||
|
this._typingHideTimer = null;
|
||||||
|
this._socketReady = false;
|
||||||
|
this._userAtBottom = true;
|
||||||
|
this._stabilizeFrames = 0;
|
||||||
|
this._stabilizePending = false;
|
||||||
|
|
||||||
|
// Expose for diagnostics
|
||||||
|
window.__messagesLayout = this;
|
||||||
|
|
||||||
|
this.scrollThreadToEnd();
|
||||||
|
if (this.input) {
|
||||||
|
this.input.focus({ preventScroll: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
this.connect();
|
||||||
|
this.bindForm();
|
||||||
|
this.bindTyping();
|
||||||
|
this.bindViewport();
|
||||||
|
this.bindAutoScroll();
|
||||||
|
this._startScrollWatcher();
|
||||||
|
this.markRead();
|
||||||
|
}
|
||||||
|
|
||||||
|
_startScrollWatcher() {
|
||||||
|
if (!this.thread) return;
|
||||||
|
|
||||||
|
const onAnyChange = () => {
|
||||||
|
if (!this._userAtBottom) return;
|
||||||
|
if (this._stabilizePending) return;
|
||||||
|
this._stabilizePending = true;
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
this._stabilizePending = false;
|
||||||
|
this._stabilizeScroll();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
this._scrollWatcher = new MutationObserver(onAnyChange);
|
||||||
|
this._scrollWatcher.observe(this.thread, {
|
||||||
|
childList: true,
|
||||||
|
subtree: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
this.thread.addEventListener("load", (e) => {
|
||||||
|
if (e.target.tagName === "IMG" && this._userAtBottom) {
|
||||||
|
onAnyChange();
|
||||||
|
}
|
||||||
|
}, true);
|
||||||
|
|
||||||
|
// Kick initial stabilization
|
||||||
|
onAnyChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
_stabilizeScroll() {
|
||||||
|
if (!this.thread) {
|
||||||
|
this._stabilizeFrames = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!this._userAtBottom) {
|
||||||
|
this._stabilizeFrames = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this._stabilizeFrames >= STABILIZE_MAX_FRAMES) {
|
||||||
|
this._stabilizeFrames = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this._stabilizeFrames++;
|
||||||
|
this.thread.scrollTop = this.thread.scrollHeight;
|
||||||
|
const atBottom = this.thread.scrollHeight
|
||||||
|
- this.thread.scrollTop
|
||||||
|
- this.thread.clientHeight < 10;
|
||||||
|
if (!atBottom) {
|
||||||
|
this._stabilizePending = true;
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
this._stabilizePending = false;
|
||||||
|
this._stabilizeScroll();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this._stabilizeFrames = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bindAutoScroll() {
|
||||||
|
if (!this.thread) return;
|
||||||
|
this.thread.addEventListener("scroll", () => {
|
||||||
|
if (this._stabilizePending) return;
|
||||||
|
const atBottom = this.thread.scrollHeight
|
||||||
|
- this.thread.scrollTop
|
||||||
|
- this.thread.clientHeight < AUTO_SCROLL_MARGIN_PX;
|
||||||
|
this._userAtBottom = atBottom;
|
||||||
|
if (atBottom) {
|
||||||
|
this._stabilizeScroll();
|
||||||
|
}
|
||||||
|
}, { passive: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
bindViewport() {
|
||||||
|
const page = document.querySelector(".page-messages");
|
||||||
|
if (!page || !this.input || !this.form) return;
|
||||||
|
|
||||||
|
const viewport = window.visualViewport;
|
||||||
|
|
||||||
|
const ensureInputVisible = () => {
|
||||||
|
const vh = viewport ? viewport.height : window.innerHeight;
|
||||||
|
const formRect = this.form.getBoundingClientRect();
|
||||||
|
const currentInset = parseInt(page.style.getPropertyValue("--kb-inset")) || 0;
|
||||||
|
const delta = formRect.bottom - vh;
|
||||||
|
const newInset = Math.max(0, currentInset + delta);
|
||||||
|
|
||||||
|
if (newInset !== currentInset) {
|
||||||
|
page.style.setProperty("--kb-inset", `${Math.round(newInset)}px`);
|
||||||
|
this._userAtBottom = true;
|
||||||
|
this.scrollThreadToEnd();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (viewport) {
|
||||||
|
let insetTimer = null;
|
||||||
|
const onViewportChange = () => {
|
||||||
|
cancelAnimationFrame(insetTimer);
|
||||||
|
insetTimer = requestAnimationFrame(ensureInputVisible);
|
||||||
|
};
|
||||||
|
viewport.addEventListener("resize", onViewportChange);
|
||||||
|
viewport.addEventListener("scroll", onViewportChange);
|
||||||
|
}
|
||||||
|
|
||||||
|
const ro = new ResizeObserver(() => ensureInputVisible());
|
||||||
|
ro.observe(page);
|
||||||
|
if (this.layout) ro.observe(this.layout);
|
||||||
|
|
||||||
|
if (this.form) {
|
||||||
|
const io = new IntersectionObserver((entries) => {
|
||||||
|
for (const entry of entries) {
|
||||||
|
if (!entry.isIntersecting) ensureInputVisible();
|
||||||
|
}
|
||||||
|
}, { root: null, threshold: [0, 0.5, 1] });
|
||||||
|
io.observe(this.form);
|
||||||
|
this._viewportIO = io;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.input.addEventListener("keydown", (event) => {
|
||||||
|
if (event.key === "Enter" && !event.shiftKey) {
|
||||||
|
event.preventDefault();
|
||||||
|
this.form.requestSubmit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.input.addEventListener("input", () => {
|
||||||
|
this.input.style.height = "auto";
|
||||||
|
this.input.style.height = Math.min(this.input.scrollHeight, 160) + "px";
|
||||||
|
});
|
||||||
|
|
||||||
|
this.input.addEventListener("focus", () => {
|
||||||
|
this._userAtBottom = true;
|
||||||
|
const doScroll = () => {
|
||||||
|
this.scrollThreadToEnd();
|
||||||
|
if (window.innerWidth < 768) {
|
||||||
|
const retry = (delay) => setTimeout(() => {
|
||||||
|
ensureInputVisible();
|
||||||
|
this.scrollThreadToEnd();
|
||||||
|
}, delay);
|
||||||
|
retry(100);
|
||||||
|
retry(350);
|
||||||
|
retry(600);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
requestAnimationFrame(doScroll);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.input.addEventListener("blur", () => {
|
||||||
|
page.style.setProperty("--kb-inset", "0px");
|
||||||
|
});
|
||||||
|
|
||||||
|
ensureInputVisible();
|
||||||
|
}
|
||||||
|
|
||||||
|
connect() {
|
||||||
|
this.socket = new MessagesSocket({
|
||||||
|
onReady: () => this.onReady(),
|
||||||
|
onMessage: (frame) => this.onFrame(frame),
|
||||||
|
onClose: () => { this._socketReady = false; },
|
||||||
|
});
|
||||||
|
this.socket.connect();
|
||||||
|
}
|
||||||
|
|
||||||
|
onReady() {
|
||||||
|
this._socketReady = true;
|
||||||
|
if (this.otherUid) {
|
||||||
|
this.markRead();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onFrame(frame) {
|
||||||
|
switch (frame.type) {
|
||||||
|
case "message":
|
||||||
|
this.handleIncoming(frame);
|
||||||
|
break;
|
||||||
|
case "typing":
|
||||||
|
if (frame.from_uid === this.otherUid) this.showTyping();
|
||||||
|
break;
|
||||||
|
case "read":
|
||||||
|
if (frame.by_uid === this.otherUid) this.markReceipts();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bindForm() {
|
||||||
|
if (!this.form || !this.input) return;
|
||||||
|
this.form.addEventListener("submit", (event) => {
|
||||||
|
if (!this._socketReady || !this.socket.isOpen()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
event.preventDefault();
|
||||||
|
this.sendViaSocket();
|
||||||
|
});
|
||||||
|
if (this.upload) {
|
||||||
|
this.upload.addEventListener("dp-upload:busy", (event) => {
|
||||||
|
this._uploading = !!(event.detail && event.detail.busy);
|
||||||
|
this.refreshSendButton();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
refreshSendButton() {
|
||||||
|
if (!this.sendBtn) return;
|
||||||
|
const busy = this._uploading || this._pendingSends.size > 0;
|
||||||
|
this.sendBtn.disabled = busy;
|
||||||
|
this.sendBtn.classList.toggle("is-sending", busy);
|
||||||
|
}
|
||||||
|
|
||||||
|
sendViaSocket() {
|
||||||
|
const content = (this.input.value || "").trim();
|
||||||
|
const attachmentUids = this.collectAttachments();
|
||||||
|
if (!content && attachmentUids.length === 0) return;
|
||||||
|
const clientId = "c" + Date.now() + Math.random().toString(36).slice(2, 8);
|
||||||
|
this.appendOptimistic(content, clientId, attachmentUids.length);
|
||||||
|
const ok = this.socket.send({
|
||||||
|
type: "send",
|
||||||
|
receiver_uid: this.otherUid,
|
||||||
|
content,
|
||||||
|
attachment_uids: attachmentUids,
|
||||||
|
client_id: clientId,
|
||||||
|
});
|
||||||
|
if (!ok) {
|
||||||
|
this.form.submit();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this._pendingSends.add(clientId);
|
||||||
|
this.refreshSendButton();
|
||||||
|
window.setTimeout(() => this.clearPendingSend(clientId), 8000);
|
||||||
|
this.input.value = "";
|
||||||
|
if (this.upload && typeof this.upload.clear === "function") {
|
||||||
|
this.upload.clear();
|
||||||
|
}
|
||||||
|
this.input.focus({ preventScroll: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
clearPendingSend(clientId) {
|
||||||
|
if (this._pendingSends.delete(clientId)) {
|
||||||
|
this.refreshSendButton();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
collectAttachments() {
|
||||||
|
const hidden = this.form.querySelector('input[name="attachment_uids"]');
|
||||||
|
if (!hidden || !hidden.value) return [];
|
||||||
|
return hidden.value.split(",").map((v) => v.trim()).filter(Boolean);
|
||||||
|
}
|
||||||
|
|
||||||
|
bindTyping() {
|
||||||
|
if (!this.input) return;
|
||||||
|
this.input.addEventListener("input", () => {
|
||||||
|
if (!this._socketReady || !this.otherUid) return;
|
||||||
|
const now = Date.now();
|
||||||
|
if (now - this._lastTypingSent < TYPING_THROTTLE_MS) return;
|
||||||
|
this._lastTypingSent = now;
|
||||||
|
this.socket.send({ type: "typing", receiver_uid: this.otherUid });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
appendOptimistic(content, clientId, attachmentCount) {
|
||||||
|
const bubble = this.buildBubble({
|
||||||
|
content,
|
||||||
|
mine: true,
|
||||||
|
clientId,
|
||||||
|
time: "now",
|
||||||
|
iso: new Date().toISOString(),
|
||||||
|
attachmentCount,
|
||||||
|
});
|
||||||
|
bubble.classList.add("pending");
|
||||||
|
this.insertBubble(bubble);
|
||||||
|
}
|
||||||
|
|
||||||
|
handleIncoming(frame) {
|
||||||
|
if (frame.uid && this.thread &&
|
||||||
|
this.thread.querySelector(`.message-bubble[data-msg-uid="${frame.uid}"]`)) {
|
||||||
|
if (frame.client_id) this.clearPendingSend(frame.client_id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (frame.sender_uid === this.selfUid && frame.client_id) {
|
||||||
|
this.clearPendingSend(frame.client_id);
|
||||||
|
const pending = this.thread.querySelector(`.message-bubble[data-client-id="${frame.client_id}"]`);
|
||||||
|
if (pending) {
|
||||||
|
pending.classList.remove("pending");
|
||||||
|
pending.dataset.msgUid = frame.uid;
|
||||||
|
const oldBody = pending.querySelector(".rendered-content");
|
||||||
|
if (oldBody && frame.content !== undefined) {
|
||||||
|
const content = document.createElement("dp-content");
|
||||||
|
content.setAttribute("no-copy", "");
|
||||||
|
if (frame.sender_role === "Admin") content.setAttribute("data-author-admin", "");
|
||||||
|
content.textContent = frame.content || "";
|
||||||
|
oldBody.replaceWith(content);
|
||||||
|
}
|
||||||
|
const time = pending.querySelector(".message-time");
|
||||||
|
if (time && frame.created_at) {
|
||||||
|
time.setAttribute("datetime", frame.created_at);
|
||||||
|
time.dataset.dt = "";
|
||||||
|
time.dataset.dtMode = "ago";
|
||||||
|
if (window.app && window.app.localTime) window.app.localTime.apply(time);
|
||||||
|
else time.textContent = frame.time_ago;
|
||||||
|
} else if (time) {
|
||||||
|
time.textContent = frame.time_ago;
|
||||||
|
}
|
||||||
|
const placeholder = pending.querySelector(".attachment-pending");
|
||||||
|
if (placeholder) placeholder.remove();
|
||||||
|
const gallery = this.renderAttachments(frame.attachments);
|
||||||
|
if (gallery) pending.insertBefore(gallery, time || null);
|
||||||
|
this.bumpConversation(frame, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const partnerUid = frame.sender_uid === this.selfUid ? frame.receiver_uid : frame.sender_uid;
|
||||||
|
const inThisThread = this.otherUid && partnerUid === this.otherUid;
|
||||||
|
|
||||||
|
if (inThisThread) {
|
||||||
|
const mine = frame.sender_uid === this.selfUid;
|
||||||
|
const bubble = this.buildBubble({
|
||||||
|
content: frame.content,
|
||||||
|
mine,
|
||||||
|
time: frame.time_ago,
|
||||||
|
iso: frame.created_at,
|
||||||
|
uid: frame.uid,
|
||||||
|
senderRole: frame.sender_role,
|
||||||
|
attachments: frame.attachments,
|
||||||
|
});
|
||||||
|
this.insertBubble(bubble);
|
||||||
|
if (!mine && this._socketReady) {
|
||||||
|
this.socket.send({ type: "read", with_uid: this.otherUid });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.bumpConversation(frame, frame.sender_uid === this.selfUid);
|
||||||
|
}
|
||||||
|
|
||||||
|
buildBubble({ content, mine, time, iso, uid, clientId, senderRole, attachments, attachmentCount }) {
|
||||||
|
const bubble = document.createElement("div");
|
||||||
|
bubble.className = "message-bubble " + (mine ? "mine" : "theirs");
|
||||||
|
if (uid) bubble.dataset.msgUid = uid;
|
||||||
|
if (clientId) bubble.dataset.clientId = clientId;
|
||||||
|
|
||||||
|
const el = document.createElement("dp-content");
|
||||||
|
el.setAttribute("no-copy", "");
|
||||||
|
if (senderRole === "Admin") el.setAttribute("data-author-admin", "");
|
||||||
|
el.textContent = content || "";
|
||||||
|
bubble.appendChild(el);
|
||||||
|
|
||||||
|
const gallery = this.renderAttachments(attachments);
|
||||||
|
if (gallery) {
|
||||||
|
bubble.appendChild(gallery);
|
||||||
|
} else if (attachmentCount > 0) {
|
||||||
|
const placeholder = document.createElement("div");
|
||||||
|
placeholder.className = "attachment-pending";
|
||||||
|
placeholder.textContent = attachmentCount === 1
|
||||||
|
? "Uploading attachment..."
|
||||||
|
: `Uploading ${attachmentCount} attachments...`;
|
||||||
|
bubble.appendChild(placeholder);
|
||||||
|
}
|
||||||
|
|
||||||
|
const timeEl = document.createElement(iso ? "time" : "span");
|
||||||
|
timeEl.className = "message-time";
|
||||||
|
if (iso) {
|
||||||
|
timeEl.setAttribute("datetime", iso);
|
||||||
|
timeEl.dataset.dt = "";
|
||||||
|
timeEl.dataset.dtMode = "ago";
|
||||||
|
if (window.app && window.app.localTime) window.app.localTime.apply(timeEl);
|
||||||
|
else timeEl.textContent = time || "";
|
||||||
|
} else {
|
||||||
|
timeEl.textContent = time || "";
|
||||||
|
}
|
||||||
|
bubble.appendChild(timeEl);
|
||||||
|
|
||||||
|
if (mine) {
|
||||||
|
const receipt = document.createElement("span");
|
||||||
|
receipt.className = "message-receipt";
|
||||||
|
receipt.hidden = true;
|
||||||
|
receipt.innerHTML = "✓✓";
|
||||||
|
bubble.appendChild(receipt);
|
||||||
|
}
|
||||||
|
|
||||||
|
return bubble;
|
||||||
|
}
|
||||||
|
|
||||||
|
renderAttachments(attachments) {
|
||||||
|
if (!attachments || !attachments.length) return null;
|
||||||
|
const gallery = document.createElement("div");
|
||||||
|
gallery.className = "attachment-gallery";
|
||||||
|
for (const att of attachments) {
|
||||||
|
const item = document.createElement("div");
|
||||||
|
item.className = "attachment-gallery-item";
|
||||||
|
if (att.is_image) {
|
||||||
|
const img = document.createElement("img");
|
||||||
|
img.src = att.thumbnail_url || att.url;
|
||||||
|
img.alt = att.original_filename || "";
|
||||||
|
img.loading = "lazy";
|
||||||
|
img.className = "gallery-thumb";
|
||||||
|
img.dataset.lightbox = "";
|
||||||
|
img.dataset.full = att.url;
|
||||||
|
if (att.mime_type) img.dataset.mime = att.mime_type;
|
||||||
|
item.appendChild(img);
|
||||||
|
} else if (att.is_video) {
|
||||||
|
const video = document.createElement("video");
|
||||||
|
video.src = att.url;
|
||||||
|
video.controls = true;
|
||||||
|
video.preload = "metadata";
|
||||||
|
video.className = "gallery-video";
|
||||||
|
item.appendChild(video);
|
||||||
|
} else {
|
||||||
|
const link = document.createElement("a");
|
||||||
|
link.href = att.url;
|
||||||
|
link.target = "_blank";
|
||||||
|
link.rel = "noopener";
|
||||||
|
link.className = "non-image";
|
||||||
|
link.download = att.original_filename || "file";
|
||||||
|
link.textContent = att.original_filename || "file";
|
||||||
|
item.appendChild(link);
|
||||||
|
}
|
||||||
|
gallery.appendChild(item);
|
||||||
|
}
|
||||||
|
return gallery;
|
||||||
|
}
|
||||||
|
|
||||||
|
insertBubble(bubble) {
|
||||||
|
if (!this.thread) return;
|
||||||
|
if (this.typingEl && this.typingEl.parentElement === this.thread) {
|
||||||
|
this.thread.insertBefore(bubble, this.typingEl);
|
||||||
|
} else {
|
||||||
|
this.thread.appendChild(bubble);
|
||||||
|
}
|
||||||
|
this.scrollThreadToEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
markReceipts() {
|
||||||
|
this.thread.querySelectorAll(".message-bubble.mine .message-receipt").forEach((el) => {
|
||||||
|
el.hidden = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
markRead() {
|
||||||
|
if (this._socketReady && this.otherUid) {
|
||||||
|
this.socket.send({ type: "read", with_uid: this.otherUid });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
showTyping() {
|
||||||
|
if (!this.typingEl) return;
|
||||||
|
this.typingEl.hidden = false;
|
||||||
|
this.scrollThreadToEnd();
|
||||||
|
clearTimeout(this._typingHideTimer);
|
||||||
|
this._typingHideTimer = setTimeout(() => {
|
||||||
|
this.typingEl.hidden = true;
|
||||||
|
}, TYPING_HIDE_MS);
|
||||||
|
}
|
||||||
|
|
||||||
|
bumpConversation(frame, mine) {
|
||||||
|
const partnerUid = mine ? frame.receiver_uid : frame.sender_uid;
|
||||||
|
const item = document.querySelector(`.conversation-item[data-conv-uid="${partnerUid}"]`);
|
||||||
|
if (!item) return;
|
||||||
|
const preview = item.querySelector(".conversation-preview");
|
||||||
|
if (preview) preview.textContent = contentRenderer.preview(frame.content, 60);
|
||||||
|
const dot = item.querySelector(".conversation-unread-dot");
|
||||||
|
if (dot) {
|
||||||
|
dot.hidden = mine || partnerUid === this.otherUid;
|
||||||
|
}
|
||||||
|
const list = item.parentElement;
|
||||||
|
if (list && list.firstElementChild !== item) {
|
||||||
|
list.insertBefore(item, list.firstElementChild);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
scrollThreadToEnd() {
|
||||||
|
if (!this.thread) return;
|
||||||
|
if (!this._userAtBottom) return;
|
||||||
|
this.thread.scrollTop = this.thread.scrollHeight;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,7 +13,7 @@ export class AppContent extends Component {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!contentRenderer.emojiLoaded) {
|
if (!contentRenderer.emojiLoaded) {
|
||||||
contentRenderer.ready.then(() => this.connectedCallback());
|
contentRenderer.ready.then(() => this.connectedCallback()).catch(console.error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._rendered = true;
|
this._rendered = true;
|
||||||
|
|||||||
@@ -3,34 +3,8 @@
|
|||||||
{{ super() }}
|
{{ super() }}
|
||||||
<link rel="stylesheet" href="{{ static_url('/static/css/services.css') }}">
|
<link rel="stylesheet" href="{{ static_url('/static/css/services.css') }}">
|
||||||
<link rel="stylesheet" href="{{ static_url('/static/css/backups.css') }}">
|
<link rel="stylesheet" href="{{ static_url('/static/css/backups.css') }}">
|
||||||
<style>
|
|
||||||
.disk-warning {
|
|
||||||
background: #fff3cd;
|
|
||||||
border: 1px solid #ffc107;
|
|
||||||
border-radius: 6px;
|
|
||||||
padding: 12px 16px;
|
|
||||||
margin-bottom: 16px;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 10px;
|
|
||||||
color: #856404;
|
|
||||||
}
|
|
||||||
.disk-warning .icon {
|
|
||||||
font-size: 1.4em;
|
|
||||||
flex-shrink: 0;
|
|
||||||
}
|
|
||||||
.disk-warning strong {
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block admin_content %}
|
{% block admin_content %}
|
||||||
{% for w in disk_warnings %}
|
|
||||||
<div class="disk-warning" role="alert">
|
|
||||||
<span class="icon">⚠</span>
|
|
||||||
<span>Disk usage on <strong>{{ w.path }}</strong> is <strong>{{ w.used_pct }}%</strong> ({{ w.used_gb }} GB / {{ w.total_gb }} GB) - above {{ disk_warning_threshold }}% threshold. Consider cleaning up old data or increasing disk capacity.</span>
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
<div class="admin-toolbar">
|
<div class="admin-toolbar">
|
||||||
<h2>Backups</h2>
|
<h2>Backups</h2>
|
||||||
<div class="backup-controls">
|
<div class="backup-controls">
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
2026-07-19T09:01:55 INFO logging initialised at /workspace/repo/dpc.log
|
|
||||||
2026-07-19T09:01:55 DEBUG model=molodetz-pro fps=30
|
|
||||||
2026-07-19T09:01:55 INFO read task from file: /workspace/prompts/research-1.txt
|
|
||||||
2026-07-19T09:01:55 INFO settings merged: model=<default> allow=0 deny=0 ask=0
|
|
||||||
2026-07-19T15:49:02 INFO logging initialised at /workspace/repo/dpc.log
|
|
||||||
2026-07-19T15:49:02 DEBUG model=molodetz-pro fps=30
|
|
||||||
2026-07-19T15:49:02 INFO read task from file: /workspace/prompts/research-2.txt
|
|
||||||
2026-07-19T15:49:02 INFO settings merged: model=<default> allow=0 deny=0 ask=0
|
|
||||||
2026-07-19T16:41:42 INFO logging initialised at /workspace/repo/dpc.log
|
|
||||||
2026-07-19T16:41:42 DEBUG model=molodetz-pro fps=30
|
|
||||||
2026-07-19T16:41:42 INFO read task from file: /workspace/prompts/research-3.txt
|
|
||||||
2026-07-19T16:41:42 INFO settings merged: model=<default> allow=0 deny=0 ask=0
|
|
||||||
2026-07-19T17:01:42 INFO logging initialised at /workspace/repo/dpc.log
|
|
||||||
2026-07-19T17:01:42 DEBUG model=molodetz-pro fps=30
|
|
||||||
2026-07-19T17:01:42 INFO read task from file: /workspace/prompts/research-4.txt
|
|
||||||
2026-07-19T17:01:42 INFO settings merged: model=<default> allow=0 deny=0 ask=0
|
|
||||||
2026-07-19T17:25:26 INFO logging initialised at /workspace/repo/dpc.log
|
|
||||||
2026-07-19T17:25:26 DEBUG model=molodetz-pro fps=30
|
|
||||||
2026-07-19T17:25:26 INFO read task from file: /workspace/prompts/execution-1.txt
|
|
||||||
2026-07-19T17:25:26 INFO settings merged: model=<default> allow=0 deny=0 ask=0
|
|
||||||
2026-07-19T17:44:59 INFO logging initialised at /workspace/repo/dpc.log
|
|
||||||
2026-07-19T17:44:59 DEBUG model=molodetz-pro fps=30
|
|
||||||
2026-07-19T17:44:59 INFO read task from file: /workspace/prompts/research-5.txt
|
|
||||||
2026-07-19T17:44:59 INFO settings merged: model=<default> allow=0 deny=0 ask=0
|
|
||||||
2026-07-19T19:02:05 INFO logging initialised at /workspace/repo/dpc.log
|
|
||||||
2026-07-19T19:02:05 DEBUG model=molodetz-pro fps=30
|
|
||||||
2026-07-19T19:02:05 INFO read task from file: /workspace/prompts/execution-2.txt
|
|
||||||
2026-07-19T19:02:05 INFO settings merged: model=<default> allow=0 deny=0 ask=0
|
|
||||||
2026-07-23T01:50:04 INFO logging initialised at /workspace/repo/dpc.log
|
|
||||||
2026-07-23T01:50:04 DEBUG model=molodetz-pro fps=30
|
|
||||||
2026-07-23T01:50:04 INFO read task from file: /workspace/prompts/execution-2.txt
|
|
||||||
2026-07-23T01:50:04 INFO settings merged: model=<default> allow=0 deny=0 ask=0
|
|
||||||
@@ -263,3 +263,43 @@ def test_xss_legitimate_link_survives_audit():
|
|||||||
out = str(render_content("see https://example.com/page ok"))
|
out = str(render_content("see https://example.com/page ok"))
|
||||||
assert 'href="https://example.com/page"' in out
|
assert 'href="https://example.com/page"' in out
|
||||||
assert_no_executable_html(out)
|
assert_no_executable_html(out)
|
||||||
|
|
||||||
|
|
||||||
|
def test_url_inside_fenced_code_block_is_not_embedded():
|
||||||
|
out = str(render_content("```\nhttps://example.com/video.mp4\n```"))
|
||||||
|
assert "<pre" in out
|
||||||
|
assert "<video" not in out
|
||||||
|
assert "<iframe" not in out
|
||||||
|
assert "example.com/video.mp4" in out
|
||||||
|
|
||||||
|
|
||||||
|
def test_mention_does_not_match_email_address():
|
||||||
|
out = str(render_content("contact me at user@domain.com for info"))
|
||||||
|
assert "mention-link" not in out
|
||||||
|
assert "domain.com" in out
|
||||||
|
|
||||||
|
|
||||||
|
def test_bold_inside_inline_code_is_plain():
|
||||||
|
out = str(render_content("use `**not bold**` here"))
|
||||||
|
assert "<code>" in out
|
||||||
|
assert "<strong>" not in out
|
||||||
|
|
||||||
|
|
||||||
|
def test_consecutive_line_breaks_preserve_paragraphs():
|
||||||
|
out = str(render_content("line one\n\nline two\n\n\nline three"))
|
||||||
|
assert "<p>line one</p>" in out
|
||||||
|
assert "<p>line two</p>" in out
|
||||||
|
assert "<p>line three</p>" in out
|
||||||
|
|
||||||
|
|
||||||
|
def test_table_with_inline_links_renders_correctly():
|
||||||
|
out = str(render_content(
|
||||||
|
"| Name | Link |\n"
|
||||||
|
"|------|------|\n"
|
||||||
|
"| Dev | https://dev.place |\n"
|
||||||
|
"| Docs | https://docs.place |\n"
|
||||||
|
))
|
||||||
|
assert "<table>" in out
|
||||||
|
assert 'href="https://dev.place"' in out
|
||||||
|
assert 'href="https://docs.place"' in out
|
||||||
|
assert "<th" in out
|
||||||
|
|||||||
Reference in New Issue
Block a user