fix: address PR #504 review warnings

- workspace-context: a transiently unavailable but still-effective candidate
  keeps its cached trimmed digest in the directory's dedup slot, so an
  identical later sibling is not emitted as a duplicate set until the next
  successful reconciliation
- app-boot: --resume rejects a following token that is itself resume syntax
  instead of accepting it as a session id
- tui: the queued-steering badge tracks per-entry sources and a drain removes
  one matching entry, so loop-authored steering (no agent/queued) cannot
  consume a pending user message's slot
This commit is contained in:
Turtle
2026-07-22 16:49:50 +08:00
parent ab32d3ec98
commit 7b46e1f73c
6 changed files with 101 additions and 19 deletions

View File

@@ -448,7 +448,17 @@ export async function reconcileInstructionContext(
const { directory } = decodeScopeKey(scope)
const previous = effective.get(scope)
const probe = await probeScopeInstruction(scope, projectRoot, resolved, fileSystem, options.signal)
if (probe.kind === 'unavailable') continue
if (probe.kind === 'unavailable') {
// Last-good-state: the candidate stays effective, so its cached trimmed
// digest must keep occupying the directory's dedup slot — otherwise an
// identical later sibling would be emitted as a duplicate `set` until the
// next successful reconciliation removed it again.
const cached = versions.get(scope)
if (cached !== undefined && previous !== undefined && previous.action !== 'remove') {
registerKeptTrimmed(directory, cached.trimmedDigest)
}
continue
}
if (probe.kind === 'absent') {
if (previous === undefined || previous.action === 'remove') versions.delete(scope)
else pushRemoval(scope, previous.path)

View File

@@ -2201,6 +2201,47 @@ describe('dynamic nested workspace context injection', () => {
}
})
it('keeps deduplicating against a loaded candidate whose probe transiently fails', async () => {
const root = await tempRepo()
const home = await tempRepo()
const ctx = new Context()
try {
await ctx.plugin(SystemPrompt)
await ctx.plugin(ToolRegistry)
await ctx.plugin(RecordingFileSystem)
const fs = ctx.fs as RecordingFileSystem
fs.entries.set(join(root, '.git'), { type: 'directory' })
fs.entries.set(join(root, 'pkg/AGENTS.md'), { type: 'file', content: 'nested rule' })
fs.entries.set(join(root, 'pkg/file.txt'), { type: 'file', content: 'hello' })
await ctx.plugin(ToolFs)
await ctx.plugin(workspaceContext, { dshHome: home, maxBytes: 65536 })
const agent = stubAgent(root)
const first = await ctx.tools.execute({
signal: testToolSignal,
callId: CallId('read-before-transient-probe-failure'), name: 'read', arguments: { file_path: join('pkg', 'file.txt') }, agent,
})
appendAdditionalContexts(agent, first)
expect(first.additionalContexts).toBeDefined()
// The loaded candidate's probe fails while an identical sibling appears:
// the cached candidate stays effective (last good state), so the sibling
// must still deduplicate against it rather than land as a duplicate set.
fs.throwOnStat.add(join(root, 'pkg/AGENTS.md'))
fs.entries.set(join(root, 'pkg/CLAUDE.md'), { type: 'file', content: 'nested rule' })
const duringFailure = await ctx.tools.execute({
signal: testToolSignal,
callId: CallId('read-during-transient-probe-failure'), name: 'read', arguments: { file_path: join('pkg', 'file.txt') }, agent,
})
expect(duringFailure.additionalContexts).toBeUndefined()
} finally {
await ctx.fiber.dispose()
await rm(root, { recursive: true, force: true })
await rm(home, { recursive: true, force: true })
}
})
it('removes a previously rendered sibling once its content becomes a duplicate of an earlier candidate', async () => {
const root = await tempRepo()
const home = await tempRepo()