Repository navigation
fix(session): preserve source titles when branching #9764
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
fa1630e
7f24b47
8aac1c3
84aae48
22a7109
65ce1f1
b0651d5
3090125
1359f61
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,6 +78,7 @@ import { | |
| subagentGenerator, | ||
| redactUrlCredentials, | ||
| computeUniqueBranchTitle, | ||
| normalizeDerivedBranchTitle, | ||
| BranchPointInvalidError, | ||
| parseGoalSnapshotV2, | ||
| parseGoalStateCause, | ||
|
|
@@ -1141,19 +1142,10 @@ function getLoadReplayPageSize(params: LoadSessionRequest): number | undefined { | |
| return value as number; | ||
| } | ||
|
|
||
| function deriveForkBaseName( | ||
| name: unknown, | ||
| recording: { getCurrentCustomTitle(): string | undefined } | undefined, | ||
| sessionId: string, | ||
| ): string { | ||
| if (typeof name === 'string' && name.trim().length > 0) { | ||
| return name.trim(); | ||
| } | ||
| const existingTitle = recording?.getCurrentCustomTitle(); | ||
| const stripped = existingTitle | ||
| ?.replace(/\s*\(Branch(?:\s+\d+)?\)\s*$/, '') | ||
| .trim(); | ||
| return stripped && stripped.length > 0 ? stripped : sessionId.slice(0, 8); | ||
| function normalizeRequestedBranchName(value: unknown): string | undefined { | ||
| if (typeof value !== 'string') return undefined; | ||
| const normalized = value.trim(); | ||
| return normalized || undefined; | ||
| } | ||
| function createHiddenWorkspaceMemoryConfig(config: Config): Config { | ||
| return new Proxy(config, { | ||
|
|
@@ -11078,11 +11070,29 @@ class QwenAgent implements Agent { | |
| const recording = sourceConfig.getChatRecordingService(); | ||
| const sessionService = sourceConfig.getSessionService(); | ||
|
|
||
| const baseName = deriveForkBaseName( | ||
| name, | ||
| recording, | ||
| sessionId, | ||
| ); | ||
| const requestedName = normalizeRequestedBranchName(name); | ||
| const sourceCustomTitle = | ||
| requestedName === undefined | ||
| ? recording?.getCurrentCustomTitle() | ||
| : undefined; | ||
| const persistedDisplayName = | ||
| requestedName === undefined && | ||
| sourceCustomTitle === undefined | ||
| ? await sessionService.getSessionDisplayName(sessionId) | ||
| : undefined; | ||
| const sourceDisplayName = | ||
| sourceCustomTitle ?? persistedDisplayName; | ||
| const derivedBaseName = sourceCustomTitle | ||
| ? normalizeDerivedBranchTitle(sourceCustomTitle) | ||
| : sourceDisplayName; | ||
| // A title that normalizes to empty (it was exactly a suffix | ||
| // token) falls back to the session-id prefix here, while | ||
| // CLI /branch falls back to the first prompt. Deliberate: | ||
| // no picker name survives to anchor the family to, and one | ||
| // shared fallback would need a prompt-only display-name | ||
| // read on this route. | ||
| const baseName = | ||
| requestedName ?? derivedBaseName ?? sessionId.slice(0, 8); | ||
|
|
||
| const title = await computeUniqueBranchTitle( | ||
| baseName, | ||
|
|
@@ -11120,7 +11130,15 @@ class QwenAgent implements Agent { | |
| const recording = sourceConfig.getChatRecordingService(); | ||
| if (recording) await recording.flush(); | ||
| const sessionService = sourceConfig.getSessionService(); | ||
| const title = deriveForkBaseName(name, recording, sessionId); | ||
| const requestedName = normalizeRequestedBranchName(name); | ||
| let title = requestedName; | ||
| if (title === undefined) { | ||
| const sourceCustomTitle = recording?.getCurrentCustomTitle(); | ||
| title = sourceCustomTitle | ||
| ? (normalizeDerivedBranchTitle(sourceCustomTitle) ?? | ||
| sessionId.slice(0, 8)) | ||
| : sessionId.slice(0, 8); | ||
| } | ||
|
Comment on lines
+11137
to
+11143
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in |
||
| const newSessionId = randomUUID(); | ||
| const fork = () => | ||
| sessionService.forkSession(sessionId, newSessionId, { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for raising this. I kept the side-task persisted-display fallback intentionally unchanged in
8aac1c3abf: side tasks retain their pre-existing explicit name -> live recorder title -> UUID semantics and separatesession_source: side_taskidentity, while ordinary branch naming follows picker semantics. Both paths still share the Core derived-title normalizer, including the empty-result fix. A configurable helper spanning the two different fallback policies would add abstraction without changing the requested behavior.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Decline upheld in this round's triage. The two derivations stay separate by design: side tasks keep
explicit name → normalized recorder title → session-id prefixand their ownside_taskidentity, while ordinary branches follow picker display-name semantics. Both paths already share the Core derived-title normalizer (including the empty-result fallback fixed in8aac1c3), so the recognition grammar cannot fragment again; a helper spanning two different fallback policies would add abstraction without changing behavior. Leaving this thread open with the recorded reason.中文说明
本轮分诊维持拒绝(Decline)。两份推导有意保持分离:side task 保留
显式名称 → 归一化后的记录器标题 → session-id 前缀链及其独立的side_task身份,普通分支则遵循选择器展示名语义。两条路径已共享 Core 的派生标题归一化函数(含8aac1c3修复的空结果回退),识别语法不会再次割裂;一个横跨两种不同回退策略的辅助函数只会增加抽象而不改变行为。线程保持打开并附已记录的理由。