Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 12 additions & 0 deletions docs/architecture/deepchat-tape-baseline/plan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# DeepChat Tape Baseline Plan

## Approach

Keep the Tape implementation baseline as a goal-scoped architecture document.
Use it as the shared map for the active Tape SDD folders.

## Maintenance

- Keep references to active Tape SDD folders relative to this directory.
- Update the baseline when ownership or runtime flow changes.
- Keep compatibility notes aligned with the current Tape schema.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# DeepChat Tape System - Implementation Baseline
Comment thread
coderabbitai[bot] marked this conversation as resolved.

Status: current implementation direction. Active SDD goals are
[deepchat-tape-view-manifest](deepchat-tape-view-manifest/spec.md),
[deepchat-tape-replay-contract](deepchat-tape-replay-contract/spec.md), and
[deepchat-tape-view-assembler](deepchat-tape-view-assembler/spec.md), and
[deepchat-tape-view-policy](deepchat-tape-view-policy/spec.md), and
[deepchat-tape-policy-provenance](deepchat-tape-policy-provenance/spec.md), and
[deepchat-tape-policy-selector](deepchat-tape-policy-selector/spec.md).
[deepchat-tape-view-manifest](../deepchat-tape-view-manifest/spec.md),
[deepchat-tape-replay-contract](../deepchat-tape-replay-contract/spec.md), and
[deepchat-tape-view-assembler](../deepchat-tape-view-assembler/spec.md), and
[deepchat-tape-view-policy](../deepchat-tape-view-policy/spec.md), and
[deepchat-tape-policy-provenance](../deepchat-tape-policy-provenance/spec.md), and
[deepchat-tape-policy-selector](../deepchat-tape-policy-selector/spec.md).

This document keeps the Tape vision aligned with the current DeepChat codebase. The implementation
path is:
Expand Down
5 changes: 5 additions & 0 deletions docs/architecture/deepchat-tape-baseline/tasks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# DeepChat Tape Baseline Tasks

- [x] Move the baseline spec into a kebab-case architecture folder.
- [x] Update relative links to active Tape SDD folders.
- [x] Update references from the legacy flat architecture path.
2 changes: 1 addition & 1 deletion docs/architecture/deepchat-tape-policy-selector/plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ TapeViewAssembler.buildTapeResumeView()
| `src/main/presenter/agentRuntimePresenter/tapeViewAssembler.ts` | Resolve default policy through selector. |
| `test/main/presenter/agentRuntimePresenter/tapeViewPolicy.test.ts` | Cover registry and selector behavior. |
| `test/main/presenter/agentRuntimePresenter/tapeViewAssembler.test.ts` | Assert selection reason and injected policy behavior. |
| `docs/architecture/deepchat_tape_spec_v1.md` | Record the selector boundary. |
| `docs/architecture/deepchat-tape-baseline/spec.md` | Record the selector boundary. |

## Compatibility

Expand Down
2 changes: 1 addition & 1 deletion docs/architecture/deepchat-tape-view-assembler/plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ resumeAssistantMessage()
| `src/main/presenter/agentRuntimePresenter/tapeViewPolicy.ts` | Selection policy boundary used by the assembler. |
| `src/main/presenter/agentRuntimePresenter/index.ts` | Replace direct metadata builder calls with assembler calls. |
| `test/main/presenter/agentRuntimePresenter/tapeViewAssembler.test.ts` | Add chat/resume parity tests. |
| `docs/architecture/deepchat_tape_spec_v1.md` | Update current implementation path and owner table. |
| `docs/architecture/deepchat-tape-baseline/spec.md` | Update current implementation path and owner table. |

## Compatibility

Expand Down
2 changes: 1 addition & 1 deletion docs/architecture/deepchat-tape-view-policy/plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ TapeViewAssembler.buildTapeResumeView()
| `src/main/presenter/agentRuntimePresenter/tapeViewAssembler.ts` | Delegate selection to `TapeViewPolicy`. |
| `test/main/presenter/agentRuntimePresenter/tapeViewPolicy.test.ts` | Prove legacy policy parity. |
| `test/main/presenter/agentRuntimePresenter/tapeViewAssembler.test.ts` | Assert policy metadata and policy delegation. |
| `docs/architecture/deepchat_tape_spec_v1.md` | Record the new policy boundary. |
| `docs/architecture/deepchat-tape-baseline/spec.md` | Record the new policy boundary. |

## Compatibility

Expand Down
5 changes: 5 additions & 0 deletions docs/issues/deepchat-tape-view-manifest-pr-review/plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ Apply the PR review fixes in place, keeping the existing Tape architecture and p
| `TraceDialog.vue` | When a request sequence is selected, only show matching trace/manifest data. |
| `routes.ts` | Replace broad route catalog annotation with `satisfies Record<string, RouteContract>`. |
| i18n `traceDialog.json` | Translate new diagnostic keys for non-English locales and convert Traditional Chinese files. |
| `contextBuilder.ts` | Preserve turn boundaries during emergency truncation. |
| `tapeService.ts` | Exclude replay export timestamps from slice hash inputs. |
| `tapeViewManifest.ts` | Copy included/excluded ref arrays into manifest snapshots. |
| SDD docs | Keep this issue SDD current and address small doc nitpicks. |

## Compatibility
Expand All @@ -40,5 +43,7 @@ pnpm run typecheck
pnpm vitest run test/main/presenter/agentRuntimePresenter/agentRuntimePresenter.test.ts
pnpm vitest run test/main/presenter/agentRuntimePresenter/tapeViewAssembler.test.ts
pnpm vitest run test/main/presenter/agentRuntimePresenter/tapeViewManifest.test.ts
pnpm vitest run test/main/presenter/agentRuntimePresenter/tapeService.test.ts
pnpm vitest run test/main/presenter/agentRuntimePresenter/contextBuilder.test.ts
pnpm vitest run test/renderer/components/trace/TraceDialog.test.ts
```
14 changes: 8 additions & 6 deletions docs/issues/deepchat-tape-view-manifest-pr-review/spec.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# Tape ViewManifest PR Review Fixes - Spec

Status: active issue-fix SDD for PR #1767 review follow-up.
Status: active issue-fix SDD for PR #1768 review follow-up.

## Problem

PR review identified correctness and localization issues in the Tape ViewManifest flow. Some diagnostics can fail hard instead of degrading gracefully, request/manifest diagnostics can show mismatched request sequences, manifest provenance can record stale summary cursors after context-pressure recovery, resume view assembly can use stale tape history after compaction, route-contract typing loses literal key precision, and newly added TraceDialog labels are not properly localized.
PR review identified correctness and localization issues in the Tape ViewManifest flow. Some diagnostics can fail hard instead of degrading gracefully, request/manifest diagnostics can show mismatched request sequences, manifest provenance can record stale summary cursors after context-pressure recovery, resume view assembly can use stale tape history after compaction, request sequence generation can repeat after resume, replay hashes can include wall-clock time, manifest snapshots can alias caller arrays, and newly added TraceDialog labels are not properly localized.

## Goals

1. Fix still-valid CodeRabbit review findings for PR #1767 with minimal changes.
1. Fix still-valid CodeRabbit review findings for PR #1768 with minimal changes.
2. Preserve Tape ViewManifest and replay-slice contracts while correcting provenance and diagnostics behavior.
3. Ensure TraceDialog diagnostic strings are localized for every supported non-English locale touched by the PR.
4. Keep route-contract literal key inference intact.
5. Commit the fixes locally without pushing.
5. Commit and push the fixes to the existing PR branch.

## Acceptance Criteria

Expand All @@ -25,11 +25,13 @@ PR review identified correctness and localization issues in the Tape ViewManifes
7. `DEEPCHAT_ROUTE_CATALOG` uses `satisfies Record<string, RouteContract>` so route names remain a literal union.
8. TraceDialog diagnostic labels are translated in supported non-English locale files, including Traditional Chinese variants.
9. Review nitpicks that are small and local are addressed without broad refactors.
10. `pnpm run format`, `pnpm run i18n`, and `pnpm run lint` pass or any blocker is documented.
10. Emergency history truncation preserves per-turn metadata associations.
11. Replay slice hashes are deterministic across exports of the same manifest.
12. Manifest included/excluded snapshots are detached from caller-owned arrays.
13. `pnpm run format`, `pnpm run i18n`, and `pnpm run lint` pass or any blocker is documented.

## Constraints

- Do not push changes.
- Do not weaken authentication, authorization, or validation.
- Avoid unrelated refactors and preserve existing presenter boundaries.
- Keep ViewManifest schema compatible.
Expand Down
6 changes: 6 additions & 0 deletions docs/issues/deepchat-tape-view-manifest-pr-review/tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@
- [x] T6: Address local documentation/nitpick comments.
- [x] T7: Run format, i18n, lint, and focused validation.
- [x] T8: Stage intentional files and create a local commit without pushing.
- [x] T9: Preserve turn metadata during emergency context truncation.
- [x] T10: Make replay slice hashes deterministic across export times.
- [x] T11: Detach manifest included/excluded snapshots from caller-owned arrays.
- [x] T12: Localize TraceDialog fallback values and Traditional Chinese model labels.
- [x] T13: Restore MCP checkbox test semantics and PascalCase component filename.
- [x] T14: Run required checks, commit, and push the PR branch.
15 changes: 15 additions & 0 deletions docs/issues/mcp-server-form-auto-approve-controls/plan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# MCP Server Form Auto Approve Controls Plan

## Approach

Restore the existing checkbox component binding for the MCP server form auto-approve options.
Keep the submitted `MCPServerConfig.autoApprove` shape unchanged.

## Implementation

- Import the shared checkbox component used by the form template.
- Verify edit-mode initial values and submit behavior for read/write permissions.

## Verification

- `pnpm vitest --config vitest.config.renderer.ts test/renderer/components/McpServerForm.test.ts`
36 changes: 36 additions & 0 deletions docs/issues/mcp-server-form-auto-approve-controls/spec.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# MCP Server Form Auto Approve Controls Spec

## Goal

Restore editable auto-approve controls in the MCP server add/edit form.

## Requirements

- The MCP add server form displays interactive controls for All, Read, and Write auto-approve options.
- The MCP edit server form displays the same controls and initializes them from `initialConfig.autoApprove`.
- Submitting the form persists the selected values through `MCPServerConfig.autoApprove`.
- Existing server fields, route contracts, and store behavior remain unchanged.

## Layout

Before:

```text
Auto Approve
All
Read
Write
```

After:

```text
Auto Approve
[ ] All
[ ] Read
[ ] Write
```

## Compatibility

MCP config keys and saved `autoApprove` values remain unchanged.
6 changes: 6 additions & 0 deletions docs/issues/mcp-server-form-auto-approve-controls/tasks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# MCP Server Form Auto Approve Controls Tasks

- [x] Restore the checkbox component import.
- [x] Add a renderer component test for editable auto-approve controls.
- [x] Assert selected read/write permissions are submitted through `autoApprove`.
- [x] Run targeted renderer test.
17 changes: 17 additions & 0 deletions docs/issues/settings-save-clone-errors/plan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Settings Save Clone Errors Plan

## Approach

Normalize renderer-owned settings payloads into plain objects before invoking config routes.
Keep route names, persisted config keys, and presenter contracts unchanged.

## Implementation

- Add a small recursive serializer in the renderer config client for arrays, objects, and dates.
- Apply the serializer to settings save paths that can receive Vue reactive proxies.
- Normalize DeepChat Agent model selections before building create/update payloads.
- Cover serialized bridge payloads with structured clone assertions.

## Verification

- `pnpm vitest --config vitest.config.renderer.ts test/renderer/api/clients.test.ts test/renderer/components/DeepChatAgentsSettings.test.ts`
19 changes: 19 additions & 0 deletions docs/issues/settings-save-clone-errors/spec.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Settings Save Clone Errors Spec

## Goal

Fix renderer IPC clone errors when settings save paths receive reactive objects.

## Requirements

- Saving an existing DeepChat Agent sends a structured-cloneable payload to the typed route bridge.
- Creating a DeepChat Agent uses the same structured-cloneable payload shape as updating.
- Adding, updating, and replacing custom prompts send structured-cloneable payloads.
- Adding, updating, and replacing system prompts send structured-cloneable payloads.
- Saving shortcut keys sends a structured-cloneable payload.
- Existing saved values and route contracts remain unchanged.
- Tests cover the renderer API client payloads with structured clone validation.

## Compatibility

Settings route names, presenter contracts, and persisted config keys remain unchanged.
8 changes: 8 additions & 0 deletions docs/issues/settings-save-clone-errors/tasks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Settings Save Clone Errors Tasks

- [x] Identify settings save routes that can receive reactive objects.
- [x] Serialize shortcut key, custom prompt, system prompt, and DeepChat Agent payloads.
- [x] Normalize DeepChat Agent advanced model selections to plain route values.
- [x] Add renderer API client structured clone coverage.
- [x] Add DeepChat Agent settings save coverage for cloneable model selections.
- [x] Run targeted renderer tests.
33 changes: 27 additions & 6 deletions src/main/presenter/agentRuntimePresenter/contextBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -923,13 +923,34 @@ function selectTurnHistoryTurns<T extends TokenizedTurn>(
}

const truncatedMessages = truncateContext(flattened, availableTokens)
return [
{
...remainingTurns[0],
messages: truncatedMessages,
tokens: estimateMessagesTokens(truncatedMessages)
if (truncatedMessages.length === 0) {
return []
}

let droppedPrefixCount = flattened.length - truncatedMessages.length
const rebuiltTurns: T[] = []

for (const turn of remainingTurns) {
if (droppedPrefixCount >= turn.messages.length) {
droppedPrefixCount -= turn.messages.length
continue
}
]

if (droppedPrefixCount > 0) {
const keptMessages = turn.messages.slice(droppedPrefixCount)
droppedPrefixCount = 0
rebuiltTurns.push({
...turn,
messages: keptMessages,
tokens: estimateMessagesTokens(keptMessages)
})
continue
}

rebuiltTurns.push(turn)
}

return rebuiltTurns
}

function filterRecordsFromCursor(
Expand Down
3 changes: 2 additions & 1 deletion src/main/presenter/agentRuntimePresenter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2419,7 +2419,8 @@ export class AgentRuntimePresenter implements IAgentImplementation {
const rateLimitMessageId = this.buildRateLimitStreamMessageId(activeGeneration.runId)
const emitRateLimitWaitingMessage = this.emitRateLimitWaitingMessage.bind(this)
const clearRateLimitWaitingMessage = this.clearRateLimitWaitingMessage.bind(this)
let requestSeq = 0
let requestSeq =
this.tapeService.listViewManifestsByMessage(sessionId, messageId)[0]?.requestSeq ?? 0

try {
this.dispatchHook('SessionStart', {
Expand Down
4 changes: 3 additions & 1 deletion src/main/presenter/agentRuntimePresenter/tapeService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,13 @@ function withReplaySliceHash(
hashes: Omit<DeepChatTapeReplaySlice['hashes'], 'sliceHash'> & { sliceHash: '' }
}
): DeepChatTapeReplaySlice {
const sliceForHash = { ...slice } as Partial<DeepChatTapeReplaySlice>
delete sliceForHash.createdAt
return {
...slice,
hashes: {
...slice.hashes,
sliceHash: hashJson(slice)
sliceHash: hashJson(sliceForHash)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/presenter/agentRuntimePresenter/tapeViewManifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ export function createTapeViewManifest(
contextBuilderVersion: TAPE_VIEW_CONTEXT_BUILDER_VERSION,
latestEntryId: input.latestEntryId,
anchorEntryIds: [...input.anchorEntryIds],
included: input.included,
excluded: input.excluded,
included: input.included.map((entry) => ({ ...entry })),
excluded: input.excluded.map((entry) => ({ ...entry })),
tokenBudget: {
...input.tokenBudget,
estimatedPromptTokens: estimateMessagesTokens(input.messages)
Expand Down
Loading