feat(webui): inspect file context in a live graph sidebar (#6562)
* feat(webui): inspect file context in a live graph sidebar * refactor(webui): place preview controls in the shared sidebar header * fix(webui): synchronize npm lockfile for graph dependencies * fix(webui): preserve compacted context and refine graph inspection * fix(context): harden provenance, request usage, and drawer lifecycle * fix(webui): align source skeleton and browser fixtures * perf(context): reuse source analysis and capture request graphs once * perf(webui): compact graph history and render graph motion on canvas * fix(webui): remove redundant context sidebar header * style(webui): clarify context replay icon * perf(webui): pace context replay on an adaptive timeline * feat(webui): briefly reveal labels for new context nodes * fix(webui): reveal new labels only for loaded context files * fix(webui): restart graph animation clock after idle * fix(webui): reveal labels when replay reverses node exit * refactor(context): project file-use facts without retention tracking * refactor(context): observe file reads outside agent execution * fix(webui): animate context sidebar closing * refactor(context): remove unused graph and usage panel code * refactor(context): isolate prompt observation from execution metadata * fix(webui): clarify cache rate and show context token usage * fix(webui): abbreviate context token counts in thousands * fix(webui): omit token unit from context usage details * fix(webui): restore large source preview highlighting and panel elevation * fix(webui): distinguish modifier scrolling from keyboard focus * fix(webui): align preview tab and panel corner radii * fix(webui): attach file tabs to the header divider * fix(webui): use one action to toggle file preview mode * fix(webui): use hover hint for context replay * fix(webui): share composer layout between graph and file sidebars * fix(webui): align sidebar bottom with composer surface * fix(webui): restore mobile graph drawing and touch file details * test(webui): align legacy cache assertions with current label * perf(context): retain source analysis and bound graph animation work * style(webui): add light elevation to user messages * test(webui): await lazy graph scene before replay assertions * fix(webui): align preview skeleton and browser contracts
This commit is contained in:
1 parent
2b44088413
commit
519ed81132
132 files changed
+4673
-1159
No files matched your search
@@ -12,6 +12,7 @@ from typing import Any, TypeVar, cast
|
||||
|
||||
from nanobot.providers.base import ProviderConversationState
|
||||
from nanobot.session.display_history import HistoryFact, HistoryKind, HistoryReader
|
||||
from nanobot.session.history_graph import history_record_size
|
||||
from nanobot.session.history_visibility import is_hidden_history_message
|
||||
from nanobot.session.manager import (
|
||||
Session,
|
||||
@@ -428,8 +429,25 @@ class SqliteSessionStore:
|
||||
|
||||
def append_history(
|
||||
self, key: str, facts: list[HistoryFact], *, expected_generation: str | None,
|
||||
) -> None:
|
||||
encoded = [(fact, fact.encode()) for fact in facts]
|
||||
skip_invalid: bool = False,
|
||||
) -> list[str]:
|
||||
encoded: list[tuple[HistoryKind, int, str, str]] = []
|
||||
errors: list[str] = []
|
||||
for fact in facts:
|
||||
try:
|
||||
record = fact.encode()
|
||||
# Freeze all transaction inputs from the encoded snapshot; never
|
||||
# revisit mutable content after serialization has completed.
|
||||
preview = ""
|
||||
if fact.kind in {HistoryKind.INPUT, HistoryKind.ANSWER, HistoryKind.ANSWER_SEGMENT}:
|
||||
preview = message_preview_text({"content": json.loads(record)["content"].get("text", "")})
|
||||
encoded.append((fact.kind, fact.created_at_ms, record, preview))
|
||||
except (ValueError, TypeError) as exc:
|
||||
if not skip_invalid:
|
||||
raise
|
||||
errors.append(str(exc))
|
||||
if not encoded and errors:
|
||||
return errors
|
||||
with self.transaction() as db:
|
||||
row = db.execute("SELECT generation FROM sessions WHERE key=?", (key,)).fetchone()
|
||||
if row is None or (expected_generation is not None and row[0] != expected_generation):
|
||||
@@ -441,7 +459,7 @@ class SqliteSessionStore:
|
||||
).fetchone()
|
||||
ordinal, position = (int(tail[0]), int(tail[1])) if tail is not None else (0, 0)
|
||||
completed = tail is not None and bool(tail[2])
|
||||
for fact, record in encoded:
|
||||
for kind, created_at_ms, record, preview in encoded:
|
||||
if completed:
|
||||
ordinal, position = ordinal + 1, 0
|
||||
if position == 0:
|
||||
@@ -449,25 +467,24 @@ class SqliteSessionStore:
|
||||
"INSERT INTO history_turns VALUES (?, ?, 0, 0, 0, 0)", (key, ordinal),
|
||||
)
|
||||
db.execute("INSERT INTO history_entries VALUES (?, ?, ?, ?, ?)", (
|
||||
key, ordinal, position, fact.kind.value, record,
|
||||
key, ordinal, position, kind.value, record,
|
||||
))
|
||||
completed = fact.kind is HistoryKind.COMPLETION
|
||||
completed = kind is HistoryKind.COMPLETION
|
||||
db.execute(
|
||||
"""UPDATE history_turns SET record_count=record_count+1, byte_count=byte_count+?,
|
||||
user_count=user_count+?, completed=? WHERE session_key=? AND ordinal=?""",
|
||||
(len(record.encode("utf-8")), int(fact.kind is HistoryKind.INPUT),
|
||||
(history_record_size(record), int(kind is HistoryKind.INPUT),
|
||||
int(completed), key, ordinal),
|
||||
)
|
||||
position += 1
|
||||
if fact.kind in {HistoryKind.INPUT, HistoryKind.ANSWER, HistoryKind.ANSWER_SEGMENT}:
|
||||
preview = message_preview_text({"content": fact.content.get("text", "")})
|
||||
if preview:
|
||||
field = "user_preview" if fact.kind is HistoryKind.INPUT else "preview"
|
||||
db.execute(f"UPDATE history_heads SET {field}=? WHERE session_key=? AND {field}=''", (preview, key))
|
||||
if preview:
|
||||
field = "user_preview" if kind is HistoryKind.INPUT else "preview"
|
||||
db.execute(f"UPDATE history_heads SET {field}=? WHERE session_key=? AND {field}=''", (preview, key))
|
||||
db.execute("UPDATE history_heads SET updated_at_ms=max(updated_at_ms, ?) WHERE session_key=?",
|
||||
(fact.created_at_ms, key))
|
||||
(created_at_ms, key))
|
||||
if encoded:
|
||||
db.execute("UPDATE history_heads SET revision=revision+1 WHERE session_key=?", (key,))
|
||||
return errors
|
||||
|
||||
def copy_history_prefix(self, source_key: str, target: Session, before_input: int) -> bool:
|
||||
"""Copy a display prefix alongside its canonical fork, in the caller's transaction."""
|
||||
|
||||
Reference in new issue
Block a user