feat: OpenMesh 基础平台与 MD/PDF 转换技能
- 后端: coworker 智能体框架, WS API, 文件上传, 附件处理 - 前端: Open WebUI, 文件全量走 upload API (含 MD/TXT/JSON 等文本类) - 技能: md-to-office (pandoc + wkhtmltopdf) - 修复: 上传文件路径丢失, Agent 搜索浪费, 输出文件跑到 uploads/ - 打包: PyInstaller one-dir, 预打包 pandoc/wkhtmltopdf/chromium
This commit is contained in:
74
tests/test_session_persona.py
Normal file
74
tests/test_session_persona.py
Normal file
@@ -0,0 +1,74 @@
|
||||
"""Phase 1 gate — a session is born from exactly one persona; pin + rename persist.
|
||||
|
||||
The persona binding rides on the existing ``SessionRecord.agent`` column (immutable in
|
||||
practice — ``get_engine`` always rebuilds from it). Pin = ``pinned`` flag; rename = ``title``.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from coworker.conversations import ConversationStore
|
||||
from coworker.sessions import SessionRecord
|
||||
|
||||
|
||||
def _store(tmp_path) -> ConversationStore:
|
||||
return ConversationStore(tmp_path)
|
||||
|
||||
|
||||
def test_session_records_its_persona(tmp_path):
|
||||
store = _store(tmp_path)
|
||||
store.save(
|
||||
SessionRecord(
|
||||
session_id="s1",
|
||||
workspace=str(tmp_path),
|
||||
model="gpt-5.5",
|
||||
mode="interactive",
|
||||
agent="ops",
|
||||
)
|
||||
)
|
||||
loaded = store.load("s1")
|
||||
assert loaded is not None and loaded.agent == "ops"
|
||||
|
||||
|
||||
def test_persona_binding_is_stable_across_reload(tmp_path):
|
||||
store = _store(tmp_path)
|
||||
store.save(
|
||||
SessionRecord(
|
||||
session_id="s2",
|
||||
workspace=str(tmp_path),
|
||||
model="gpt-5.5",
|
||||
mode="interactive",
|
||||
agent="code",
|
||||
)
|
||||
)
|
||||
# A fresh store instance over the same dir still sees the original persona.
|
||||
assert _store(tmp_path).load("s2").agent == "code"
|
||||
|
||||
|
||||
def test_pin_persists(tmp_path):
|
||||
store = _store(tmp_path)
|
||||
store.save(
|
||||
SessionRecord(
|
||||
session_id="s3",
|
||||
workspace=str(tmp_path),
|
||||
model="gpt-5.5",
|
||||
mode="interactive",
|
||||
agent="ops",
|
||||
)
|
||||
)
|
||||
assert store.set_flags("s3", pinned=True)
|
||||
assert store.load("s3").pinned is True
|
||||
|
||||
|
||||
def test_rename_persists(tmp_path):
|
||||
store = _store(tmp_path)
|
||||
store.save(
|
||||
SessionRecord(
|
||||
session_id="s4",
|
||||
workspace=str(tmp_path),
|
||||
model="gpt-5.5",
|
||||
mode="interactive",
|
||||
agent="ops",
|
||||
)
|
||||
)
|
||||
assert store.rename("s4", "Release Captain")
|
||||
assert store.load("s4").title == "Release Captain"
|
||||
Reference in New Issue
Block a user