Skip to content

fix(ai-vault): name Copilot sessions from the typed prompt, not its injected context - #11

Merged
nplez1 merged 3 commits into
nplez1/mainfrom
nplez1/Session-History-Naming
Sep 19, 2026
Merged

nplez1 merged 3 commits into
nplez1/mainfrom
nplez1/Session-History-Naming

Conversation

@nplez1

@nplez1 nplez1 commented Sep 19, 2026 •

Copy link
Copy Markdown
Owner

ELI5

Copilot's session log keeps two copies of everything you type: the words you actually wrote, and a
longer version Copilot builds to send to the model, which begins with a timestamp tag. The app was
reading the longer version, so the timestamp tag became the session's name.

The branch also carries two small fixes for things that were already broken on the base branch
(nplez1/main) and blocking every PR against it. They are separate commits, described at the end.

What Changed

Before: almost every Copilot session showed up in the sidebar and in Agent Session History under
a name like

<current_datetime>2026-05-27T06:21:24.000Z</current_datetime> Fix the authentication bug in s...

After: the same session is named after the prompt the user typed:

Fix the authentication bug in src/auth.ts

The mechanism: session-scanner-copilot-parser.ts read the session title, list preview and copyable
first prompt from data.transformedContent. It now reads data.content (the prompt as typed), and
falls back to transformedContent only when content is missing or blank, so a turn that carries
nothing else still previews.

Two caches that persist the parsed title are bumped, because both replay an unchanged file whose
mtime and size still match:

  • parse cache 4 → 5 — the scanner's own answer, and the previews overlaid onto an indexed row;
  • search index 6 → 7 — the session list itself.

Also in this PR (commits 2 and 3, described under Why): a refactor to bring
agent-status-event-applicator.ts back under the max-lines cap, and an update to one stale panel
test that still asserted the pre-rename settings key.

Why

Copilot CLI stores each user.message twice: content is the prompt as typed, transformedContent
is the model-facing text, which Copilot prefixes with injected context starting
<current_datetime>...</current_datetime>. Preferring transformedContent therefore put the
injected prefix at the front of every title, where the 96-character title cap then truncated it to
fit — which is why so many names started the same way.

The tag is not one the text normalizer already hides. HIDDEN_TEXT_BLOCKS covers system-reminder,
codex_internal_context and goal_context, all machinery a user never types; adding
current_datetime there would silently strip genuine user text for every agent, not just Copilot.
Choosing the right field at the parser is the narrower fix.

The search-index bump is required, not belt-and-braces. Agent Session History lists titles from the
index once a pass has completed, the index consumer keeps its own cursor and never consults the
parse cache, and sessionSearchReadDecision returns skip for a file whose stat matches its row —
so bumping only the parse cache would have left every unchanged Copilot session titled
<current_datetime>... in the panel indefinitely.

Both bumps cost one cold rebuild of each cache, once.

The two pre-existing base failures, and why they are here

nplez1/main currently fails CI on its own. Both failures reproduce with this PR's four commits
reverted, and I chose to clear them here rather than leave the PR red behind a broken base.

  1. static analysis — agent-status-event-applicator.ts sits at 301 code lines against the 300
    max-lines cap. The file was exactly at the cap upstream, and the staged routing work
    (7d2af35858) added one import to it. I verified upstream's version of that file passes oxlint
    and the fork's does not. The fix moves the three optional envelope fields (turn boundary,
    restored marker, observation provenance) into withAgentStatusEnvelopeFields beside the other
    payload shaping, which is behavior-preserving and leaves headroom rather than one import away
    from breaking again. No max-lines disable and no per-file cap bump, per AGENTS.md.

  2. test / tests node 24 7/8 — AiVaultPanel.legacy-filter.test.tsx expects
    aiVaultSearch: { enabled: true }, but the panel writes contentEnabled. The test file is
    byte-identical to upstream's; the fork's 987a8424aa renamed the panel's write and said it
    brought the tests with it, but that commit's own test run covered the ai-vault and session-search
    suites, not this renderer panel test. The fix asserts the field the panel actually writes; no
    production code moves.

Linked Issue

No tracked issue: issues are disabled on this fork, and the Copilot naming problem was reported
directly. This is a fork PR, not upstream-bound.

Visual Proof

The entire user-visible effect is one string, so the regression test's own before/after is the
change. With the old precedence (before):

<current_datetime>2026-05-27T06:21:24.000Z</current_datetime> Fix the authentication bug in s...

With the fix (after):

Fix the authentication bug in src/auth.ts

No screenshot or video is attached: this is a parsed-string fix with no layout, styling or
interaction change, and capturing a live panel would require running the packaged app. Happy to
attach a CDP screenshot of the session list before/after if you want one for the record — say the
word and I will rebuild and capture it.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

For the Copilot naming fix: added uses Copilot's typed prompt, not its injected context, for the title to src/main/ai-vault/session-scanner.test.ts. The fixture carries both content and a
<current_datetime>-prefixed transformedContent, and asserts the title and first preview both
come from the typed prompt. Restoring the old precedence makes it fail with exactly the reported
string, so it is a real regression test rather than a restatement of the fix.

For the two base fixes: the existing suites cover both changes, and I ran the panels, hooks and
settings directories in full. No new test was needed for the refactor (it is behavior-preserving and
covered by the existing ipc-events suite); the panel test I changed is itself the regression test
for the rename.

Run locally:

  • pnpm exec oxlint --format github (the exact CI Lint command) — 0 errors, 2 pre-existing
    unicorn/prefer-array-flat-map warnings in unrelated mobile test files.
  • pnpm tc — clean.
  • pnpm test src/main/ai-vault src/main/ai-vault-search — 169 files, 1524 tests.
  • pnpm test src/renderer/src/hooks/ipc-events src/renderer/src/components/right-sidebar src/renderer/src/components/settings
    — 453 files, 3508 tests.
  • pnpm run check:code-quality:changed — 0 findings across the 7 changed files.
  • oxfmt — clean on all changed files (also enforced by the pre-commit hook).

Platforms: the parser is platform-independent text handling, and its tests drive the scanner
directly. The remote Copilot source (remote-session-scanner-copilot-source.ts) calls the same
parser, so SSH and paired-runtime sessions get the same fix. The other two fixes are renderer-side
and platform-independent. I did not run a live desktop/mobile/SSH session; only the automated suites
above. pnpm build was not run locally — CI's package and package (windows) jobs are the build
check.

AI Disclosure

Implemented by pi, an AI coding agent, at @nplez1's direction. Diagnosis (parser field precedence,
the two cache invalidations, and the root cause of both base failures), the fixes, and the
regression test were all produced by the agent; commits and PR are @nplez1's.

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Security: no new input, no wire change, no filesystem access change; the parser still reads the
    same record and picks a different string from it. The applicator refactor moves spreading code
    between modules and changes no decision.
  • Cross-platform: no platform-specific behavior. All three OS paths run the same parser.
  • Remote SSH: the naming fix rides the shared parser; both the local and remote Copilot sources
    use it. The other two fixes are local renderer code.
  • Mobile / paired clients: titles already cross the wire, so mobile picks up the corrected name
    with no protocol change.
  • Backwards compatibility: the two schema bumps discard cached rows and re-read once. No
    transcript is modified, and no persisted format other than the two caches changes.
  • Performance: unchanged in steady state — same reads, same normalization, just a different field
    for one string. The only cost is the one-time cache rebuild the bumps require.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

On that last box: pnpm tc, the exact CI oxlint command, the ai-vault/session-search suites and the
renderer hooks/sidebar/settings suites all pass locally. pnpm build was not run locally — the
Electron packaging jobs (package, package (windows)) passed on the previous run and re-run on
this one.

One caveat on scope: this PR is nominally about Copilot session names and now also carries two base
fixes. They are separate commits so they can be reviewed — or split out — on their own terms.

…njected context

Copilot CLI records each user turn twice: `content` is the prompt as typed, and
`transformedContent` is what the model sees, which Copilot prefixes with injected
context starting `<current_datetime>...</current_datetime>`. The parser preferred
`transformedContent`, so that prefix became the session title, preview and
copyable first prompt for essentially every Copilot session — names that start
`<current_datetime>` in the sidebar and in Agent Session History.

Prefer `content`, and fall back to `transformedContent` only when the typed prompt
is absent or blank, so a turn that carries nothing else still previews.

The tag is not one the normalizer already hides: `HIDDEN_TEXT_BLOCKS` covers
`system-reminder`, `codex_internal_context` and `goal_context`, all machinery a
user never types. Adding `current_datetime` there would hide genuine user text for
every agent, so the fix stays at the field the parser chooses.

Both caches that persist the parsed title are bumped, because both replay a file
whose mtime and size still match:

- parse cache 4 -> 5, for the scanner's own answer and the previews overlaid on an
  indexed row;
- search index 6 -> 7, for the session list itself. The index consumer keeps its
  own cursor and never consults the parse cache, and `sessionSearchReadDecision`
  skips a file whose stat matches its row, so a parse-cache bump alone would leave
  the wrong title in Agent Session History indefinitely.

Costs one cold rebuild of each cache, once.

Verified with a regression test that carries both fields and asserts the typed
prompt wins; restoring the old precedence reproduces the reported
`<current_datetime>...` title. `pnpm test src/main/ai-vault src/main/ai-vault-search`
(169 files, 1524 tests), `pnpm tc`, and the changed-code quality gate all pass.
The readiness gate added to this file by the staged routing work
(`7d2af35858`) needed one more import, and upstream had left the file at
exactly the 300-line `max-lines` cap — so static analysis has been failing on
`nplez1/main` for every PR since, not just this one.

Move the three optional envelope fields (turn boundary, restored marker,
observation provenance) out of the applicator's body and into
`withAgentStatusEnvelopeFields` beside the other payload shaping in
`normalize-agent-status-event.ts`. Each field stays optional and an absent one
still leaves the payload untouched, so the fold is behavior-preserving; the
`statusPayload` those branches sat next to is unchanged, since the suppression
check and the terminal title still read the orchestration-only payload.

No `max-lines` disable and no per-file cap bump, per AGENTS.md. The applicator
now has headroom instead of sitting one import away from breaking again.
…l test

`987a8424aa` finished moving the panel's enable button onto the content consent
and said it brought the tests with it, but it missed this upstream test, which
still typed its settings mock and asserted `aiVaultSearch: { enabled: true }`.
The panel writes `contentEnabled`, so the assertion has been failing on
`nplez1/main` since — the fork's own test run for that commit covered the
ai-vault and session-search suites, where the renamed field was already in use,
and not this renderer panel test.

Assert the field the panel writes. The mock's type and the assertion are the
only changes; no production behavior moves.
@nplez1
nplez1 merged commit e197f8a into nplez1/main Sep 19, 2026
29 checks passed
nplez1 pushed a commit that referenced this pull request Oct 21, 2026
…win projections stay on their host (review-5 #2 #9 #11) (stablyai#30890)

* fix(renderer): host writes route only through the strict owner, and twin projections stay on their host (review-5 #2 #9 #11)

A selected ssh: host that two paired servers proxy now resolves ambiguous at the one
selected-host resolver, so no caller can fall back to this app's own SSH connection.
File Explorer and SSH mutation expectations derive the full {endpoint, place} pair from
resolveOwner, so a server folder's nested SSH target stays the write's host. A local
lineage write projects onto its own host's rows only. The id-only store-write ratchet
now also covers persistence repo-row lookups by id alone (review-5 #10's shape).

* fix(ratchet): the id-only lookup scan also sees optional chaining and destructured ids

* fix(renderer): an unstamped folder keeps reading its host from its repos; editor focus fallback left for a follow-up

* docs(renderer): the File Explorer owner comment names its folder fallback
@nplez1
nplez1 deleted the nplez1/Session-History-Naming branch October 24, 2026 03:23
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.

1 participant