feat: Enhance session management by adding session ID handling and re…#33
Conversation
…storing current session content
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThis pull request implements session restoration and tracking by deferring recorder creation until the first user message, adding Changes
Sequence DiagramsequenceDiagram
participant Client as Client (Browser)
participant App as App.vue
participant Store as Chat Store
participant Server as Backend Server
participant Storage as Session File
Client->>App: onMounted
App->>Store: fetchHealth()
Store->>Server: GET /api/health
Server-->>Store: {status, session_id, running, ...}
Store->>Store: sync currentSessionId, isRunning
App->>Store: restoreCurrentSession()
alt Session exists
Store->>Server: api.session(currentSessionId)
Server->>Storage: load session file
Storage-->>Server: session entries
Server-->>Store: entries
Store->>Store: rebuild timeline items
Store->>Store: match tool results to calls
Store->>Store: finalize tool calls
Store-->>Client: restored chat UI
else No session or agent running
Store-->>Client: skip restoration
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related PRs
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…us runs (#118) * fix(agent): harden tools, compaction, and prompt for long-horizon runs Audit of jcode vs Claude Code and codex (32 findings, tracked with per-case status in internal-doc/tooling-audit.md); all confirmed cases fixed with TDD across four waves: Tools - execute: head+tail truncation with dropped-bytes marker, full output spilled to ~/.jcode/tasks and the path returned to the model - exec lifecycle: process-group kill via new internal/procutil (Setpgid + Kill(-pid)), WaitDelay=2s with ErrWaitDelay folded to success, SSH SIGTERM->SIGKILL grace, Docker in-container pidfile tree kill - read: 200KB output budget with offset continuation + 2000-byte per-line truncation (UTF-8 safe) - glob: find -name replaced with cd+rg --files --glob --sortr=modified (fixes silently-broken ** recursion, adds deterministic mtime order) - grep: global (not per-file) content limit via streaming early-stop, honest capped footer, output_mode enum validation - edit/write: read-before-edit enforced (ConflictNeverRead; FileTracker now actually wired in NewEnv), atomic writes (temp+fsync+rename, SSH base64+mv -f), multi-edit overlap/ambiguity guards + per-op replace_all, item schemas for edits/todos arrays - background tasks: head+tail truncation, task log always written and its path surfaced to the model - errors: Fatal/IsFatal layer aborts runs on dead container/SSH, subagent safe middleware (panic recovery + error folding + parent propagation, async panic no longer crashes the process), ToolError hints on high-frequency failures Compaction - occupancy reminder now uses last-call total (GetLastTotal) instead of the cumulative ledger — fixes permanently >100% "wrap up" pressure after any compaction - crude 500-char threshold strategy demoted to fallback-only behind the eino summarizer; compact failure fuse (3 strikes, fail-open) - output-reserve headroom (EffectiveContextLimit) for trigger math - compaction persists the kept tail; TUI resume no longer loses it - reduction config single-sourced (BuildReductionConfig) across TUI/ACP/Web, calibrated token estimator (ASCII/3.6 + CJK-aware + EMA self-calibration from provider usage) replaces len/4, per-turn aggregate tool-result budget (150k chars, copy-on-write) Prompt - env/git drift re-collected every 5 iterations and injected as a diff (includes date rollover); AGENTS.md hot-reloaded on mtime+hash change; externally-modified files reported with a re-read instruction - system.md: parallel tool-call batching directive + Verification discipline section Verified by ~90 new TDD tests (red first), full-repo go test -count=1, -race on tools/agent, GOOS=windows build, and a new agent-eval ACP e2e (robust_huge_output: seq 1 200000 truncated to marker+tail, session survives, oracle-checked answer) passing against a live model. Generated with Jack AI bot * chore: resolve golangci-lint findings in new code errcheck on discarded Count returns, De Morgan simplification, embedded-field selector cleanup, and two unparam removals (execLocal constant timeout, buildRgArgs unused maxResults). Generated with Jack AI bot * fix(git): scrub inherited GIT_* env from every git subprocess git exports an absolute GIT_DIR to hook subprocesses when pushing from a linked worktree. jcode's git calls (envinfo, web git API, session baseline/diff stats) and the web test helper inherited it, silently operating on the outer repository instead of the -C/cwd-selected one — the web suite's `git init` in a temp dir re-initialized the pushing repo as bare when run under the pre-push hook. Add util.ScrubbedGitEnv() (drops GIT_DIR/GIT_WORK_TREE/GIT_INDEX_FILE/ GIT_COMMON_DIR and friends), apply it at all production git call sites, and pin GIT_DIR/GIT_WORK_TREE to the temp repo in the web test helper. Regression-tested by running the web suite under a hostile GIT_DIR against a victim repo (stays non-bare) plus unit tests for the scrubber and for gitCommand under an inherited GIT_DIR. Recorded as finding #33 in internal-doc/tooling-audit.md. Generated with Jack AI bot * fix(agent): address review findings — live-env reminders, calibration recovery, docker fatal coverage - reminder: read remote-ness from the live *tools.Env each round (switch_env mutates it in place without an agent rebuild on ACP/web); pause the env-drift / AGENTS.md / external-file sweeps while remote so local-host state is never reported as drift of the remote machine, and resume with the same baselines after switching back - token estimate: a sustained streak of below-peak counts adopts the shrunk window as the new full baseline, so calibration resumes after compaction instead of freezing on the stale peak - docker exec: route stream-copy and inspect errors through wrapDockerRunErr so a container removed mid-exec is classified Fatal like create/attach - glob: resolve a relative search path against the tool workspace instead of the process cwd; make the mtime-order test deterministic via os.Chtimes - compaction: refuse to apply an empty strategy result (counts toward the fuse instead of wiping the conversation) Generated with Jack AI bot --------- Co-authored-by: t <t@example.com>
Web Session Management Optimization
Problem
Changes
1. Deferred Session Creation (Avoid Empty Sessions)
Backend (
internal/web/server.go):handleNewSession: When creating a new conversation, no longer immediately creates a recorder; only creates one when restoring an existing sessionsubmitMessage: Retains existing lazy-loading logic — the recorder and session file are only created when the first message is sentFrontend (
web/src/stores/chat.ts):newSession(): If already on the welcome screen (no session ID and no messages), performs no action; otherwise resets the backend state and setscurrentSessionIdto emptyagentDone(): After the agent finishes running, refreshesfetchHealth()+fetchSessions()to ensure lazily-created sessions appear in the sidebar2. Simplified Deletion
Frontend (
web/src/components/Sidebar.vue):contextMenuIdstate andtoggleContextMenufunction3. Session Restore & History
Frontend (
web/src/stores/chat.ts&App.vue):restoreCurrentSession(): On page load, fetches the current session content from the backend and replays it into the UIloadSession(): Supports restoring session todo snapshots and tool call state matchingCtrl+Shift+Nkeyboard shortcut bound tonewSession()Frontend (
web/src/composables/api.ts):newSessionAPI now supports passing asessionIdparameter for restoring an existing sessionSummary by CodeRabbit
New Features
Improvements