Skip to content
Closed
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
6cd7a8e
fix(session): persist listing deltas for Moonshot prefix cache on resume
ussoewwin Jul 30, 2026
9906d47
fix(session): conditional agent suppress latch + listing allowlist tests
ussoewwin Jul 30, 2026
4f38f3c
test(session): assert agent suppress latch is one-shot via empty tran…
ussoewwin Jul 30, 2026
9900083
test(session): acquire sharedMutationLock in listingAllowlist env tests
ussoewwin Jul 31, 2026
692c9e3
fix(session): resume-cache + content fingerprints for MCP/agent listings
ussoewwin Jul 31, 2026
8a0888b
fix(session): address CodeRabbit resume-cache and MCP/agent latch fee…
ussoewwin Jul 31, 2026
a3c41fe
fix(session): harden resume-cache tests and clarify listing privacy c…
ussoewwin Jul 31, 2026
6048862
fix(session): validate listing schemas and clarify skill resume comments
ussoewwin Jul 31, 2026
ee39fe3
fix(web): add 0.27.0 to site changelog for verify-dist
ussoewwin Jul 31, 2026
52f5a6f
fix(session): address CodeRabbit resume-cache path, validation, and p…
ussoewwin Jul 31, 2026
ae14a6e
test(web): assert full newest-first ordering across all releases
ussoewwin Jul 31, 2026
2c484c4
test(web): reject non-numeric semver segments in releases ordering he…
ussoewwin Jul 31, 2026
f617f07
fix(session): Option A local retain listings with egress privacy filter
ussoewwin Jul 31, 2026
2747ba2
test(session): prove local JSONL byte-stable through last pre-resume …
ussoewwin Aug 1, 2026
373ab79
fix(session): address CodeRabbit egress and recovery comments
ussoewwin Aug 1, 2026
bc12205
fix(session): reparent remote egress across omitted listing attachments
ussoewwin Aug 2, 2026
6ccb7d4
test(session): define hydrate-equivalent remote-resume listing contract
ussoewwin Aug 2, 2026
9f6fd3b
test(session): replace as never with branded UUID casts in listingAll…
ussoewwin Aug 2, 2026
275e850
merge(origin/main): sync official ahead into prefix-cache resume branch
ussoewwin Aug 4, 2026
1ae5f3a
fix(session): hold MCP listing removals until clients settle on resume
ussoewwin Aug 7, 2026
7dce8c0
fix: hold MCP removals while required server still pending
ussoewwin Aug 7, 2026
dee0c6e
fix: fail-closed string validation for listing delta entries
ussoewwin Aug 7, 2026
877c882
Merge branch 'main' into fix/moonshot-prefix-cache-on-resume
ussoewwin Aug 7, 2026
d4fcbf2
fix: close CodeRabbit findings for prefix-cache resume egress and lis…
ussoewwin Aug 7, 2026
4bec70b
test: Feedback egress strip + restore USER_TYPE/MACRO in share tests
ussoewwin Aug 7, 2026
c9b1f35
fix: adopt resumed session on print continue/resume for listing reparent
ussoewwin Aug 8, 2026
5f9fd15
test: restore USER_TYPE in print-resume helper and dedupe setup
ussoewwin Aug 8, 2026
9644d07
fix: hold deferred_tools_delta removals until tool/MCP pool settles o…
ussoewwin Aug 8, 2026
e4db0f2
test: expand [P2] deferred_tools_delta resume-race coverage
ussoewwin Aug 8, 2026
a2461f6
fix: treat MCP needs-auth as unsettled for resume removals
ussoewwin Aug 8, 2026
3fb14c4
fix: process deferred_tools removals before additions; include abortS…
ussoewwin Aug 8, 2026
e770e64
test: add alternate-angle coverage for MCP needs-auth instruction hol…
ussoewwin Aug 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/components/Feedback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
} from '../utils/model/providers.js';
import { isEssentialTrafficOnly } from '../utils/privacyLevel.js';
import { jsonRedactor, redactJsonLines, redactSensitiveInfo } from '../utils/redaction.js';
import { extractTeammateTranscriptsFromTasks, getTranscriptPath, loadAllSubagentTranscriptsFromDisk, MAX_TRANSCRIPT_READ_BYTES } from '../utils/sessionStorage.js';
import { extractTeammateTranscriptsFromTasks, filterJsonlForExternalEgress, filterMessagesForExternalEgress, filterSubagentTranscriptsForExternalEgress, getTranscriptPath, loadAllSubagentTranscriptsFromDisk, MAX_TRANSCRIPT_READ_BYTES } from '../utils/sessionStorage.js';
import { jsonStringify } from '../utils/slowOperations.js';
import { asSystemPrompt } from '../utils/systemPromptType.js';
import { ConfigurableShortcutHint } from './ConfigurableShortcutHint.js';
Expand Down Expand Up @@ -106,7 +106,7 @@ async function loadRawTranscriptJsonl(): Promise<string | null> {
});
return null;
}
return await readFile(transcriptPath, 'utf-8');
return filterJsonlForExternalEgress(await readFile(transcriptPath, 'utf-8'));
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
} catch {
return null;
}
Expand Down Expand Up @@ -161,10 +161,10 @@ export function Feedback({
const lastAssistantMessageId = lastAssistantMessage?.requestId ?? null;
const [diskTranscripts, rawTranscriptJsonl] = await Promise.all([loadAllSubagentTranscriptsFromDisk(), loadRawTranscriptJsonl()]);
const teammateTranscripts = extractTeammateTranscriptsFromTasks(backgroundTasks);
const subagentTranscripts = {
const subagentTranscripts = filterSubagentTranscriptsForExternalEgress({
...diskTranscripts,
...teammateTranscripts
};
});
const redactedTranscriptJsonl = rawTranscriptJsonl
? redactJsonLines(rawTranscriptJsonl)
: undefined;
Expand All @@ -177,7 +177,7 @@ export function Feedback({
gitRepo: envInfo.isGit,
terminal: env.terminal,
version: MACRO.VERSION,
transcript: normalizeMessagesForAPI(messages),
transcript: normalizeMessagesForAPI(filterMessagesForExternalEgress(messages)),
errors: sanitizedErrors,
lastApiRequest: getLastAPIRequest(),
...(Object.keys(subagentTranscripts).length > 0 && {
Expand Down
171 changes: 171 additions & 0 deletions src/components/FeedbackSurvey/submitTranscriptShare.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
import { afterAll, beforeAll, expect, mock, test } from 'bun:test'
import { mkdtemp, rm, writeFile } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import type { Message } from '../../types/message.js'
import {
acquireSharedMutationLock,
releaseSharedMutationLock,
} from '../../test/sharedMutationLock.js'

type AxiosModule = typeof import('axios')

let originalAxiosModule: AxiosModule | undefined
let tempDir: string | undefined
let postedBodies: Array<{ content?: string }> = []

function buildAxiosModuleStub(
post: (...args: unknown[]) => Promise<unknown>,
): AxiosModule {
const instance = {
get: async () => ({ status: 200 }),
post,
isAxiosError: () => false,
defaults: {} as Record<string, unknown>,
interceptors: {
request: { use: () => 0, eject: () => {} },
response: { use: () => 0, eject: () => {} },
},
}
return { default: instance } as unknown as AxiosModule
}

beforeAll(async () => {
await acquireSharedMutationLock('submitTranscriptShare.egress')
originalAxiosModule = await import('axios')

// MACRO is build-time; stub for the under-test import path.
;(globalThis as { MACRO?: { VERSION: string } }).MACRO = {
VERSION: 'test-version',
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

const realProviders = await import('../../utils/model/providers.js')
mock.module('../../utils/model/providers.js', () => ({
...realProviders,
isFirstPartyAnthropicProvider: () => true,
}))

const realAuth = await import('../../utils/auth.js')
mock.module('../../utils/auth.js', () => ({
...realAuth,
checkAndRefreshOAuthTokenIfNeeded: async () => {},
}))

const realHttp = await import('../../utils/http.js')
mock.module('../../utils/http.js', () => ({
...realHttp,
getAuthHeaders: () => ({
headers: { Authorization: 'Bearer test' },
error: undefined,
}),
getUserAgent: () => 'test-agent',
}))

tempDir = await mkdtemp(join(tmpdir(), 'openclaude-transcript-share-'))
const transcriptPath = join(tempDir, 'session.jsonl')
await writeFile(
transcriptPath,
`${JSON.stringify({
type: 'user',
uuid: '00000000-0000-4000-8000-00000000s001',
parentUuid: null,
timestamp: '2026-08-07T00:00:00.000Z',
message: { role: 'user', content: 'share me' },
})}\n${JSON.stringify({
type: 'attachment',
uuid: '00000000-0000-4000-8000-00000000s002',
parentUuid: '00000000-0000-4000-8000-00000000s001',
timestamp: '2026-08-07T00:00:00.000Z',
attachment: {
type: 'skill_listing',
content: 'Available skills:\n- /leak-me-please',
skillCount: 1,
isInitial: true,
},
})}\n`,
)

const realSession = await import('../../utils/sessionStorage.js')
mock.module('../../utils/sessionStorage.js', () => ({
...realSession,
getTranscriptPath: () => transcriptPath,
loadSubagentTranscripts: async () => ({
'agent-leak': [
{
type: 'attachment',
uuid: '00000000-0000-4000-8000-00000000a101',
attachment: {
type: 'agent_listing_delta',
addedTypes: ['Explore'],
addedLines: ['- Explore: /leak-agent-listing'],
removedTypes: [],
isInitial: true,
showConcurrencyNote: false,
},
},
{
type: 'user',
uuid: '00000000-0000-4000-8000-00000000a102',
message: { role: 'user', content: 'subagent turn' },
},
],
}),
}))

mock.module('axios', () =>
buildAxiosModuleStub(async (_url: unknown, body: unknown) => {
postedBodies.push(body as { content?: string })
return { status: 200, data: { transcript_id: 'shared-1' } }
}),
)
})

afterAll(async () => {
try {
if (originalAxiosModule) {
mock.module('axios', () => originalAxiosModule!)
}
if (tempDir) {
await rm(tempDir, { recursive: true, force: true })
}
} finally {
releaseSharedMutationLock()
}
})

test('submitTranscriptShare strips listing payloads from the outgoing content body', async () => {
postedBodies = []
process.env.USER_TYPE = 'external'

const { submitTranscriptShare } = await import('./submitTranscriptShare.js')

const listing = {
type: 'attachment',
uuid: '00000000-0000-4000-8000-00000000m001',
attachment: {
type: 'skill_listing',
content: 'Available skills:\n- /leak-me-please',
skillCount: 1,
isInitial: true,
},
} as unknown as Message
const user = {
type: 'user',
uuid: '00000000-0000-4000-8000-00000000m002',
message: { role: 'user', content: 'plain turn' },
} as unknown as Message

const result = await submitTranscriptShare(
[listing, user],
'bad_feedback_survey',
'appearance-test',
)

expect(result.success).toBe(true)
expect(postedBodies).toHaveLength(1)
const content = postedBodies[0]?.content ?? ''
expect(content).toContain('plain turn')
expect(content).not.toContain('leak-me-please')
expect(content).not.toContain('leak-agent-listing')
expect(content).toContain('subagent turn')
})
15 changes: 12 additions & 3 deletions src/components/FeedbackSurvey/submitTranscriptShare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import { isFirstPartyAnthropicProvider } from '../../utils/model/providers.js'
import { normalizeMessagesForAPI } from '../../utils/messages.js'
import {
extractAgentIdsFromMessages,
filterJsonlForExternalEgress,
filterMessagesForExternalEgress,
filterSubagentTranscriptsForExternalEgress,
getTranscriptPath,
loadSubagentTranscripts,
MAX_TRANSCRIPT_READ_BYTES,
Expand Down Expand Up @@ -38,19 +41,25 @@ export async function submitTranscriptShare(
try {
logForDebugging('Collecting transcript for sharing', { level: 'info' })

const transcript = normalizeMessagesForAPI(messages)
const transcript = normalizeMessagesForAPI(
filterMessagesForExternalEgress(messages),
)

// Collect subagent transcripts
const agentIds = extractAgentIdsFromMessages(messages)
const subagentTranscripts = await loadSubagentTranscripts(agentIds)
const loadedSubagents = await loadSubagentTranscripts(agentIds)
const subagentTranscripts =
filterSubagentTranscriptsForExternalEgress(loadedSubagents)

// Read raw JSONL transcript (with size guard to prevent OOM)
let rawTranscriptJsonl: string | undefined
try {
const transcriptPath = getTranscriptPath()
const { size } = await stat(transcriptPath)
if (size <= MAX_TRANSCRIPT_READ_BYTES) {
rawTranscriptJsonl = await readFile(transcriptPath, 'utf-8')
rawTranscriptJsonl = filterJsonlForExternalEgress(
await readFile(transcriptPath, 'utf-8'),
)
Comment on lines +44 to +62

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Look for tests that exercise submitTranscriptShare and the Feedback submit path end to end.
echo "=== tests referencing submitTranscriptShare ==="
rg -nP --type=ts -C3 '\bsubmitTranscriptShare\b' --glob '*.test.ts' --glob '*.test.tsx'

echo "=== tests referencing the feedback report payload ==="
rg -nP -C3 'rawTranscriptJsonl|subagentTranscripts' --glob '*.test.ts' --glob '*.test.tsx'

echo "=== all call sites of the egress filters ==="
rg -nP --type=ts --type=tsx -C2 '\bfilter(Messages|Jsonl)ForExternalEgress\s*\(' src 2>/dev/null || rg -nP -C2 '\bfilter(Messages|Jsonl)ForExternalEgress\s*\(' src

Repository: Gitlawb/openclaude

Length of output: 204


🏁 Script executed:

#!/bin/bash
set -u

echo "=== locate submitTranscriptShare files ==="
fd -a 'submitTranscriptShare' . || true

echo "=== list test files near FeedbackSurvey ==="
fd -a 'test\.(ts|tsx)$' . | rg -i 'FeedbackSurvey|feedback|survey|submitTranscriptShare|transcript' || true

echo "=== repository-level references to submitTranscriptShare ==="
rg -n -C3 '\bsubmitTranscript_share\b|\bsubmitTranscriptShare\b|\bsubmitReport\b|\brawTranscriptJsonl\b|\bsubagentTranscripts\b' . --glob '!node_modules' --glob '!dist' --glob '!build' || true

echo "=== repository-level references to external egress filters ==="
rg -n -C2 '\bfilterMessagesForExternalEgress\b|\bfilterJsonlForExternalEgress\b' . --glob '!node_modules' --glob '!dist' --glob '!build' || true

Repository: Gitlawb/openclaude

Length of output: 23332


Add a regression test for the FeedbackSurvey transcript share payload.

submitTranscriptShare is only referenced from the telemetry-plugin stub and the survey call sites. Existing tests cover the helper allowlist filters, but they do not assert that submitTranscriptShare sends listing payloads outside the transcript share endpoint. Add a focused test that exercises this path with listing messages/JSONL so future edits cannot leak them through.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/FeedbackSurvey/submitTranscriptShare.ts` around lines 43 - 63,
Add a focused regression test for submitTranscriptShare that uses listing
messages and JSONL, mocks the transcript/subagent inputs as needed, and asserts
the outgoing payload excludes listing data while still exercising the
non-transcript-share listing path. Reuse the existing allowlist filter test
setup and verify the request sent by the telemetry-plugin stub or survey call
site.

Source: Path instructions

} else {
logForDebugging(
`Skipping raw transcript read: file too large (${size} bytes)`,
Expand Down
13 changes: 7 additions & 6 deletions src/hooks/useLogMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,13 @@ export function useLogMessages(messages: Message[], ignore: boolean = false) {
// messagesToKeep whose last-actually-recorded uuid differs.
if (isIncremental || wasFirstRender || isSameHeadShrink) {
// Match EXACTLY what recordTranscript persists: cleanMessagesForLogging
// applies both the isLoggableMessage filter and (for external users) the
// REPL-strip + isVirtual-promote transform. Using the raw predicate here
// would pick a UUID that the transform drops, leaving the parent hint
// pointing at a message that never reached disk. Pass full messages as
// replId context — REPL tool_use and its tool_result land in separate
// render cycles, so the slice alone can't pair them.
// applies the isLoggableMessage filter and (for external users) the
// REPL-strip + isVirtual-promote transform. Listing attachments are
// retained locally; remote egress is gated separately. Using the raw
// predicate here would pick a UUID that the transform drops, leaving
// the parent hint pointing at a message that never reached disk. Pass
// full messages as replId context — REPL tool_use and its tool_result
// land in separate render cycles, so the slice alone can't pair them.
const last = cleanMessagesForLogging(slice, messages).findLast(
isChainParticipant,
)
Expand Down
7 changes: 6 additions & 1 deletion src/screens/REPL.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ import type { ProcessUserInputContext } from '../utils/processUserInput/processU
import type { PastedContent } from '../utils/config.js';
import { copyPlanForFork, copyPlanForResume, getPlanSlug, setPlanSlug } from '../utils/plans.js';
import { clearSessionMetadata, resetSessionFilePointer, adoptResumedSessionFile, removeTranscriptMessage, restoreSessionMetadata, getCurrentSessionTitle, isEphemeralToolProgress, isLoggableMessage, saveWorktreeState, getAgentTranscript, saveAgentSetting } from '../utils/sessionStorage.js';
import { deserializeMessages } from '../utils/conversationRecovery.js';
import { deserializeMessages, prepareInReplResumeListingState } from '../utils/conversationRecovery.js';
import { extractReadFilesFromMessages, extractBashToolsFromMessages } from '../utils/queryHelpers.js';
import { resetMicrocompactState } from '../services/compact/microCompact.js';
import { runPostCompactCleanup } from '../services/compact/postCompactCleanup.js';
Expand Down Expand Up @@ -1982,6 +1982,11 @@ export function REPL({
// This filters unresolved tool uses and adds a synthetic assistant message if needed
const messages = deserializeMessages(log.messages);

// Same listing restore as loadConversationForResume, plus clear
// process-local sentSkillNames / suppress latches that survive in-REPL
// /resume (CLI --resume starts a fresh process and skips this helper).
prepareInReplResumeListingState(messages);

// Match coordinator/normal mode to the resumed session
if (feature('COORDINATOR_MODE')) {
/* eslint-disable @typescript-eslint/no-require-imports */
Expand Down
Loading