Revert "Preserve explicit slept workspace state (#4536)"
This reverts commit 0d2abc5cb7.
This commit is contained in:
@@ -49,10 +49,6 @@ describe('remote workspace session projection', () => {
|
||||
defaultTerminalTabsAppliedByWorktreeId: {
|
||||
'repo-a::/srv/app': true as const,
|
||||
'repo-local::/tmp/local': true as const
|
||||
},
|
||||
sleptWorktreeIds: {
|
||||
'repo-a::/srv/app': true as const,
|
||||
'repo-local::/tmp/local': true as const
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +66,6 @@ describe('remote workspace session projection', () => {
|
||||
})
|
||||
expect(projected.remoteSessionIdsByTabId).toEqual({ 'tab-1': 'pty-1' })
|
||||
expect(projected.defaultTerminalTabsAppliedByWorktreePath).toEqual({ '/srv/app': true })
|
||||
expect(projected.sleptWorktreePaths).toEqual({ '/srv/app': true })
|
||||
})
|
||||
|
||||
it('imports projected terminal state into this client repo id', () => {
|
||||
@@ -96,8 +91,7 @@ describe('remote workspace session projection', () => {
|
||||
'tab-1': { root: null, activeLeafId: null, expandedLeafId: null }
|
||||
},
|
||||
remoteSessionIdsByTabId: { 'tab-1': 'pty-1' },
|
||||
defaultTerminalTabsAppliedByWorktreePath: { '/srv/app': true },
|
||||
sleptWorktreePaths: { '/srv/app': true }
|
||||
defaultTerminalTabsAppliedByWorktreePath: { '/srv/app': true }
|
||||
},
|
||||
{ resolveWorktreeId: (path) => (path === '/srv/app' ? 'repo-b::/srv/app' : null) }
|
||||
)
|
||||
@@ -112,9 +106,6 @@ describe('remote workspace session projection', () => {
|
||||
expect(session.defaultTerminalTabsAppliedByWorktreeId).toEqual({
|
||||
'repo-b::/srv/app': true
|
||||
})
|
||||
expect(session.sleptWorktreeIds).toEqual({
|
||||
'repo-b::/srv/app': true
|
||||
})
|
||||
})
|
||||
|
||||
it('imports active worktree metadata even when the worktree has no terminal tabs', () => {
|
||||
|
||||
@@ -90,17 +90,6 @@ export function exportRemoteWorkspaceSession(
|
||||
}
|
||||
}
|
||||
|
||||
const sleptWorktreePaths: Record<string, true> = {}
|
||||
for (const worktreeId of Object.keys(session.sleptWorktreeIds ?? {})) {
|
||||
if (!options.isTargetWorktree(worktreeId)) {
|
||||
continue
|
||||
}
|
||||
const worktreePath = worktreePathFromId(worktreeId)
|
||||
if (worktreePath) {
|
||||
sleptWorktreePaths[worktreePath] = true
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
activeWorktreePath,
|
||||
activeTabId,
|
||||
@@ -123,8 +112,7 @@ export function exportRemoteWorkspaceSession(
|
||||
)
|
||||
: undefined,
|
||||
lastVisitedAtByWorktreePath,
|
||||
defaultTerminalTabsAppliedByWorktreePath,
|
||||
sleptWorktreePaths
|
||||
defaultTerminalTabsAppliedByWorktreePath
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,14 +177,6 @@ export function importRemoteWorkspaceSession(
|
||||
}
|
||||
}
|
||||
|
||||
const sleptWorktreeIds: Record<string, true> = {}
|
||||
for (const worktreePath of Object.keys(remote.sleptWorktreePaths ?? {})) {
|
||||
const worktreeId = resolvePath(worktreePath)
|
||||
if (worktreeId) {
|
||||
sleptWorktreeIds[worktreeId] = true
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
...session,
|
||||
activeRepoId: activeWorktreeId ? (splitWorktreeId(activeWorktreeId)?.repoId ?? null) : null,
|
||||
@@ -220,7 +200,6 @@ export function importRemoteWorkspaceSession(
|
||||
)
|
||||
: undefined,
|
||||
lastVisitedAtByWorktreeId,
|
||||
defaultTerminalTabsAppliedByWorktreeId,
|
||||
sleptWorktreeIds
|
||||
defaultTerminalTabsAppliedByWorktreeId
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ export type RemoteWorkspaceSession = {
|
||||
remoteSessionIdsByTabId?: Record<string, string>
|
||||
lastVisitedAtByWorktreePath?: Record<string, number>
|
||||
defaultTerminalTabsAppliedByWorktreePath?: Record<string, true>
|
||||
sleptWorktreePaths?: Record<string, true>
|
||||
}
|
||||
|
||||
export type RemoteWorkspaceSnapshot = {
|
||||
|
||||
@@ -719,9 +719,6 @@ export type WorkspaceSessionState = {
|
||||
* considered. Persisted so closing all tabs and re-opening the workspace
|
||||
* does not recreate the template. */
|
||||
defaultTerminalTabsAppliedByWorktreeId?: Record<string, true>
|
||||
/** Worktrees the user explicitly slept. Inactive terminal state alone does
|
||||
* not imply sleep; a worktree only sleeps through the user sleep action. */
|
||||
sleptWorktreeIds?: Record<string, true>
|
||||
}
|
||||
|
||||
export type WorkspaceSessionPatch = Partial<WorkspaceSessionState>
|
||||
|
||||
@@ -242,26 +242,6 @@ describe('parseWorkspaceSession', () => {
|
||||
}
|
||||
})
|
||||
|
||||
it('accepts explicit slept worktree markers', () => {
|
||||
const result = parseWorkspaceSession({
|
||||
activeRepoId: null,
|
||||
activeWorktreeId: null,
|
||||
activeTabId: null,
|
||||
tabsByWorktree: {},
|
||||
terminalLayoutsByTabId: {},
|
||||
sleptWorktreeIds: {
|
||||
'repo1::/path/wt1': true
|
||||
}
|
||||
})
|
||||
|
||||
expect(result.ok).toBe(true)
|
||||
if (result.ok) {
|
||||
expect(result.value.sleptWorktreeIds).toEqual({
|
||||
'repo1::/path/wt1': true
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
it('caps oversized browser history while parsing legacy workspace sessions', () => {
|
||||
const result = parseWorkspaceSession({
|
||||
activeRepoId: null,
|
||||
|
||||
@@ -254,8 +254,7 @@ export const workspaceSessionStateSchema: z.ZodType<WorkspaceSessionState> = z.o
|
||||
z.record(z.string(), z.number().finite().nonnegative())
|
||||
)
|
||||
.optional(),
|
||||
defaultTerminalTabsAppliedByWorktreeId: z.record(z.string(), z.literal(true)).optional(),
|
||||
sleptWorktreeIds: z.record(z.string(), z.literal(true)).optional()
|
||||
defaultTerminalTabsAppliedByWorktreeId: z.record(z.string(), z.literal(true)).optional()
|
||||
})
|
||||
|
||||
export type ParsedWorkspaceSession =
|
||||
|
||||
Reference in New Issue
Block a user