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:
chengyongru authored and GitHub committed 2026-11-05 17:09:20 +08:00
1 parent 2b44088413
commit 519ed81132
132 files changed
+4673 -1159

No files matched your search

+20 -6
View File
@@ -28,6 +28,12 @@ from nanobot.session.display_history import (
HistoryFact,
HistoryReader,
)
from nanobot.session.history_graph import (
decode_graph,
decode_snapshot,
graph_decoding,
graph_size_adjustment,
)
from nanobot.session.history_visibility import is_hidden_history_message
from nanobot.session.manager import Session, SessionManager
from nanobot.session.sqlite_store import SessionConflictError
@@ -233,7 +239,7 @@ def _record_json_line(record: dict[str, Any]) -> str:
def _records_bytes(records: list[dict[str, Any]]) -> int:
total = 0
for record in records:
total += len(_record_json_line(record).encode("utf-8")) + 1
total += len(_record_json_line(record).encode("utf-8")) + graph_size_adjustment(record) + 1
return total
@@ -581,9 +587,6 @@ class WebUITranscriptRecorder:
for event in events:
try:
fact = fact_from_record(_record_for_append(event))
if len(events) > 1:
# An invalid member must not roll back otherwise valid activity.
fact.encode()
facts.append(fact)
except (ValueError, TypeError) as exc:
self._log.warning("history append failed for {}: {}", chat_id, exc)
@@ -591,8 +594,12 @@ class WebUITranscriptRecorder:
if not facts:
return False
try:
await self.sessions.state.append_history(webui_session_key(chat_id), facts,
expected_generation=generation)
errors = await self.sessions.state.append_history(webui_session_key(chat_id), facts,
expected_generation=generation,
skip_invalid=len(events) > 1)
for error in errors:
self._log.warning("history append failed for {}: {}", chat_id, error)
valid = valid and not errors
except (OSError, ValueError, TypeError, sqlite3.Error, SessionConflictError, SessionOperationQueueFullError) as exc:
self._log.warning("history append failed for {}: {}", chat_id, exc)
return False
@@ -1510,6 +1517,8 @@ def _client_projection_event(
"compaction_id": compaction_id,
"phase": phase,
}
if (snapshot := decode_snapshot(record.get("context_snapshot"))) is not None:
projected["context_snapshot"] = snapshot
reason = record.get("reason")
if isinstance(reason, str) and reason in {"idle", "context_pressure", "manual", "provider_native"}:
projected["reason"] = reason
@@ -1528,6 +1537,10 @@ def _client_projection_event(
):
return None
projected.update(request_id=request_id, run_id=run_id, sequence=sequence, phase=phase)
if "request_usage" in record:
projected["request_usage"] = _sanitize_turn_usage(record["request_usage"]) or None
if (graph := decode_graph(record.get("context_graph"))) is not None:
projected["context_graph"] = graph
latency_ms = record.get("latency_ms")
if isinstance(latency_ms, int | float) and latency_ms >= 0:
projected["latency_ms"] = int(latency_ms)
@@ -1757,6 +1770,7 @@ def build_session_thread_response(
"active_turn_id": turn_id if active else None}
@graph_decoding()
def build_webui_thread_response(
session_key: str,
*,