fix(edit-history): remote reads get time for their size, follow CLAUDE_CONFIG_DIR, keep the conversation after /clear

Review findings on the remote edit history:

- A forward read may carry 13 MiB and "Load older" 29 MiB; the flat 30 s
  read timeout cut those off below ~1 MiB/s. The timeout now adds the
  transfer time at 256 KiB/s (remoteEditSourcesTimeoutMs). It ends a hung
  read, it does not cut a slow one.
- The transcript lookup looked only under $HOME/.claude. It now uses an
  absolute CLAUDE_CONFIG_DIR of the ssh command's environment, else
  $HOME/.claude, for both the projects and the live sessions/<pid>.json.
  A value set only in .zshrc stays invisible (the lookup is a plain sh);
  documented, and the panel's remote no-transcript note says so instead
  of promising the next prompt (a remote host sends no hooks).
- After a remote /clear claudeSessionId stays the launch id, so once the
  remote claude exited the lookup fell back to the cleared conversation
  and the panel flipped back. The sync now hands the lookup the stored
  conversation, tried right after the live one (remoteTranscriptIds).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
RandalixandClaude Opus 5.5 committed 2026-11-05 11:19:52 +01:00
1 parent c4ba14235f
commit 0a6a877415
10 files changed
+169 -36

No files matched your search

+19 -3
View File
@@ -84,8 +84,12 @@ export interface EditHistorySession {
}
export interface EditHistorySyncDeps {
/** The session's main transcript path, or null when it has none yet. */
transcriptPath(session: EditHistorySession): Promise<string | null>;
/**
* The session's main transcript path, or null when it has none yet. `storedTranscriptId` is
* the conversation the stored history holds (null before the first read); see
* {@link remoteTranscriptIds}.
*/
transcriptPath(session: EditHistorySession, storedTranscriptId: string | null): Promise<string | null>;
/** The session's transcripts (a remote session's on its host). */
readSources(
session: EditHistorySession,
@@ -108,6 +112,18 @@ export interface SyncOptions {
older?: boolean;
}
/**
* The conversation ids a REMOTE session's transcript lookup tries, in order, after the one its
* claude writes now. No hook tells Codeman of a remote `/clear`, so `claudeSessionId` stays the
* launch id; tried first, it would flip the panel back to the cleared conversation as soon as
* the remote claude exits. The stored history's conversation is the newest the panel has read.
*/
export function remoteTranscriptIds(session: EditHistorySession, storedTranscriptId: string | null): string[] {
return [...new Set([storedTranscriptId, session.claudeSessionId || session.id, session.id])].filter(
(id): id is string => !!id
);
}
/** Why a session has no edit history, or undefined when it can have one. */
export function unsupportedReason(session: EditHistorySession): string | undefined {
if (session.docker) return 'docker';
@@ -329,7 +345,7 @@ export class EditHistorySync {
try {
// This slot's store: a run still in flight after `remove()` cannot reach a later one.
const store = await this.storeOf(session.id, slot);
const path = slot.gone ? null : await this.deps.transcriptPath(session);
const path = slot.gone ? null : await this.deps.transcriptPath(session, store.getTranscriptId());
let found: boolean;
if (!path) {
found = false;