Skip to content

Commit 61b483b

Browse files
committed
Merge remote-tracking branch 'origin/main' into tuistory-test
2 parents c6d8789 + 4ea59e8 commit 61b483b

File tree

4 files changed

+31
-7
lines changed

4 files changed

+31
-7
lines changed

.agents/__tests__/context-pruner.integration.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,11 @@ Do not do anything else. Just spawn context-pruner and then report the result.`,
155155
console.log('Initial message count:', initialMessages.length)
156156
console.log('Final message count:', finalMessages.length)
157157

158-
// Verify messages were pruned (should be fewer than initial)
159-
expect(finalMessages.length).toBeLessThan(initialMessages.length + 5) // Allow for new messages from the run
158+
// The context-pruner should have run and processed messages.
159+
// We can't assert on exact message count because:
160+
// 1. The agent run adds messages (prompt, tool calls, responses)
161+
// 2. Context pruning may replace messages with placeholders rather than removing them
162+
// The key assertion is that tool-call/tool-result pairs remain intact (tested below)
160163

161164
// Verify tool-call/tool-result pairs are intact
162165
// Extract all tool call IDs from assistant messages

cli/src/__tests__/e2e/logout-relogin-flow.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
getUserCredentials,
1818
logoutUser,
1919
} from '../../utils/auth'
20+
import { setProjectRoot } from '../../project-files'
2021

2122
import type * as AuthModule from '../../utils/auth'
2223

@@ -46,6 +47,8 @@ describe('Logout and Re-login helpers', () => {
4647

4748
beforeEach(() => {
4849
tempConfigDir = fs.mkdtempSync(path.join(os.tmpdir(), 'manicode-logout-'))
50+
// Set project root to avoid "Project root not set" error in logger
51+
setProjectRoot(tempConfigDir)
4952
})
5053

5154
afterEach(() => {

cli/src/__tests__/integration/credentials-storage.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818

1919
import * as authModule from '../../utils/auth'
2020
import { saveUserCredentials, getUserCredentials } from '../../utils/auth'
21+
import { setProjectRoot } from '../../project-files'
2122

2223
import type { User } from '../../utils/auth'
2324

@@ -53,6 +54,9 @@ describe('Credentials Storage Integration', () => {
5354
// Create temporary config directory for tests
5455
tempConfigDir = fs.mkdtempSync(path.join(os.tmpdir(), 'manicode-test-'))
5556

57+
// Set project root to avoid "Project root not set" error in logger
58+
setProjectRoot(tempConfigDir)
59+
5660
// Mock getConfigDir to use temp directory
5761
spyOn(authModule, 'getConfigDir').mockReturnValue(tempConfigDir)
5862
spyOn(authModule, 'getCredentialsPath').mockReturnValue(

sdk/src/__tests__/run-handle-event.test.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,28 @@ describe('CodebuffClient handleEvent / handleStreamChunk', () => {
1616

1717
spyOn(databaseModule, 'getUserInfoFromApiKey').mockResolvedValue({
1818
id: 'user-123',
19+
email: 'test@example.com',
20+
discord_id: null,
21+
referral_code: null,
1922
})
2023
spyOn(databaseModule, 'fetchAgentFromDatabase').mockResolvedValue(null)
21-
spyOn(databaseModule, 'startAgentRun').mockResolvedValue({ runId: 'run-1' })
22-
spyOn(databaseModule, 'finishAgentRun').mockResolvedValue()
23-
spyOn(databaseModule, 'addAgentStep').mockResolvedValue()
24+
spyOn(databaseModule, 'startAgentRun').mockResolvedValue('run-1')
25+
spyOn(databaseModule, 'finishAgentRun').mockResolvedValue(undefined)
26+
spyOn(databaseModule, 'addAgentStep').mockResolvedValue('step-1')
2427

2528
spyOn(mainPromptModule, 'callMainPrompt').mockImplementation(
2629
async (
2730
params: Parameters<typeof mainPromptModule.callMainPrompt>[0],
2831
) => {
29-
const { sendAction, action: promptAction } = params
32+
const { sendAction, action: promptAction, promptId } = params
3033
const sessionState = getInitialSessionState(
3134
getStubProjectFileContext(),
3235
)
3336

3437
await sendAction({
3538
action: {
3639
type: 'response-chunk',
40+
userInputId: promptId,
3741
chunk: {
3842
type: 'subagent_start',
3943
agentId: 'sub-1',
@@ -50,7 +54,7 @@ describe('CodebuffClient handleEvent / handleStreamChunk', () => {
5054
await sendAction({
5155
action: {
5256
type: 'subagent-response-chunk',
53-
userInputId: 'input-1',
57+
userInputId: promptId,
5458
agentId: 'sub-1',
5559
agentType: 'commander',
5660
chunk: 'hello from subagent',
@@ -60,6 +64,7 @@ describe('CodebuffClient handleEvent / handleStreamChunk', () => {
6064
await sendAction({
6165
action: {
6266
type: 'response-chunk',
67+
userInputId: promptId,
6368
chunk: {
6469
type: 'subagent_finish',
6570
agentId: 'sub-1',
@@ -76,13 +81,22 @@ describe('CodebuffClient handleEvent / handleStreamChunk', () => {
7681
await sendAction({
7782
action: {
7883
type: 'prompt-response',
84+
promptId,
7985
sessionState,
8086
output: {
8187
type: 'lastMessage',
8288
value: [],
8389
},
8490
},
8591
})
92+
93+
return {
94+
sessionState,
95+
output: {
96+
type: 'lastMessage' as const,
97+
value: [],
98+
},
99+
}
86100
},
87101
)
88102

0 commit comments

Comments
 (0)