Skip to content

Show files written in the current session - #1219

Closed
uvforce wants to merge 1 commit into
agegr:mainfrom
uvforce:feat/session-written-files
Closed

uvforce wants to merge 1 commit into
agegr:mainfrom
uvforce:feat/session-written-files

Conversation

@uvforce

@uvforce uvforce commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Add a session-wide Files written in this session panel while keeping the project file explorer and original file viewer unchanged.

Selected session branch
  successful write / edit / apply_patch results
    complete manifest, including entries before pagination and compaction
      merge confirmed live results and deduplicate by tool-call ID + path
        Files panel: path, type filter, write count and session-written time
          original FileViewer and existing file-access checks

The panel lists successful writes on the selected branch, not every path mentioned by a message. It does not query disk modification times, display disk-status badges, or add a file-metadata endpoint. Missing or inaccessible files are handled by the original viewer when opened.

Evidence

  • Before: The project explorer and per-turn file links exist, but there is no complete session-wide write list. The new SDK-backed route test fails on the official base because the paged response has no complete write manifest.
    After: The same route test passes with successful writes before compaction and the last-50 boundary, explicit branch selection, and deduplication across loaded pages.
  • The actual panel tests verify type-filter persistence, session write facts, unchanged file-open delegation and zero disk-metadata requests. Adjacent tool-write tests exclude reads, failed writes, incomplete tool calls and deleted-only patches.
  • Standalone validation: 2,639 tests, 2,638 passed, zero failed and one skipped; lint, TypeScript and isolated production build passed.
  • Real compiled Chromium at 1280px and 390px verified filters, write counts and session times, a 306,107-byte HTML preview, and the original missing-file and access errors. Controlled HTTP/SSE scenarios verified pending branch clearing, late context replies, old settled detail replies, and manifest failure followed by explicit Retry. No model requests were made.
  • Files-only source is aligned with the corresponding local implementation. Existing project explorer, viewer and access policy are unchanged. Disk metadata is not requested.
  • Local execution evidence uses the approved Web 0.12.0 / Core 1.1.0 baseline. Main advanced to 0.12.1 / Core 1.2.0 during preparation; this patch applies cleanly to it, but its newer dependency runtime is left to upstream CI rather than claimed as locally tested.

Merge Danger

Door: Two-way

This is an additive, read-only session response and UI feature. It requires no session-file migration or destructive operation and can be reverted without changing existing conversations. The filter preference is stored locally.

Blast Radius: Sessions

The affected paths are session loading, branch/history reconciliation and the Files panel. FileExplorer, FileViewer, file-access policies and tool execution remain unchanged. No dependencies are added.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T08:48:34.150770Z 7db8077 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7db8077e43

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread hooks/useAgentSession.ts
Comment on lines +2807 to +2809
const sessionFilesReady = ((!data && isNew)
|| (data?.sessionId === sessionIdRef.current && filesContextLeafId === activeLeafId))
&& (!session || session.id === sessionIdRef.current);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep first-turn live files ready after promotion

On a fresh composer's first prompt, promoteNewSession() causes AppShell to pass a non-null session and clear newSessionCwd without remounting this hook or populating data. Both readiness branches then become false, so confirmed SSE write results are collapsed to [] for the entire first run and only reappear when agent_end calls loadSession(). Keep the new-session live state ready through that promotion so the panel reports writes as they happen.

Useful? React with 👍 / 👎.

Comment thread hooks/useAgentSession.ts
stats: cached.stats as SessionData["stats"],
});
setActiveLeafId(cached.leafId);
setFilesContextLeafId(cached.leafId);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep cached manifests in a loading state

On a session-view cache hit, the cached SessionData constructed just above contains no writtenFileManifest, yet setting this leaf marks sessionFilesReady; the hook consequently reports sessionFilesFailed until the forced detail request finishes. With a slow or large session, especially while the Files panel remains open during a switch, a routine load is shown as “Unable to load” with Retry and can launch a duplicate request. Leave the manifest not-ready while that fetch is pending, or cache its state separately.

Useful? React with 👍 / 👎.

const key = `${write.toolCallId}\0${write.filePath}`;
if (seenCalls.has(key)) continue;
seenCalls.add(key);
const current = byPath.get(write.filePath) ?? { writeCount: 0 };

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Group Windows case variants as one file

On Windows, tool calls can refer to the same file with casing variants such as C:/Repo/a.ts and c:/repo/a.ts, and resolveLocalFilePath() does not case-fold them. Using raw filePath as the map key therefore renders duplicate rows and splits write counts, even though the repository's samePath() treats them as one filesystem location. Group with Windows path equivalence while retaining one spelling for display.

Useful? React with 👍 / 👎.

for (const block of message.content ?? []) {
if (block.type !== "toolCall") continue;
const written = extractTurnWrittenFiles([block], toolResults, cwd);
const at = toolResults?.get(block.toolCallId)?.timestamp ?? message.timestamp;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use the result entry time for writes

When a successful tool result lacks its optional message timestamp, as older or extension-authored session entries can, this falls back to the assistant timestamp, which AssistantMessage defines as the model request start. A slow response can therefore label and sort a write minutes before it occurred even though the manifest caller still has the enclosing result entry's append timestamp; use that entry/result time or omit the time rather than reporting request start.

Useful? React with 👍 / 👎.

Comment on lines +113 to +115
<span style={{ minWidth: 0 }}>
<span className="name">{location.name}</span>
{location.directory && <span className="dir">{location.directory}</span>}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Separate file names from directories

For every file below the session cwd, these two spans are inline and have no whitespace or separator between them, so src/App.tsx is rendered as App.tsxsrc; the overflow and ellipsis rules on .name and .dir also do not apply to ordinary inline spans. Make them block or flex rows, or add an explicit separator, so the displayed path is intelligible.

Useful? React with 👍 / 👎.

@agegr

agegr commented Oct 14, 2026

Copy link
Copy Markdown
Owner

Thanks @uvforce for the careful work and the thorough tests. I'm going to pass on this one, though, because it runs against the UI rules in CONTRIBUTING.md:

  • Each reply already lists the files that turn wrote (the "Files changed" chips, built from the same successful write/edit/apply_patch results). In a git project, the sidebar's changes view lists what changed too. A session-wide panel shows the same fact a third time.
  • It adds a top-bar button with a count badge and a type filter remembered per browser. I want to keep the top bar to the few things that drive a decision.
  • The manifest has no upper bound and goes out with every GET /api/sessions/[id]. On a 2,000-write session the detail response went from 157 KB to 676 KB (27 KB to 50 KB gzipped) and from 27 ms to 41 ms on the server, regardless of the 50-entry page. Each branch switch also adds a second request.

In case any of this comes back, a few things I hit while testing:

  • Rows run the name and folder together ("App.tsxsrc").
  • Going back to a cached session briefly shows "Unable to load… Retry".
  • On a new session's first run, the panel stays empty until the run ends.

If a write is ever missing from the per-turn list, a fix there would be very welcome. For a feature like this, please open an issue first; it can save you the build. Closing for now.

@agegr agegr closed this Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants