Skip to content

Commit f3fa813

Browse files
refactor(core): fold three copies of the view-state queue call into one helper
No behaviour change. clearPersistedViewState, rebindUnboundViewStateEntry and rekeyPersistedViewStateEntry each wrote out the same enqueue call - provider: this, generation: this.viewStateGeneration, run - over five lines. One private helper now makes that identical call, reading the generation at the same point, and the three call sites are one line each. No log string, guard, ordering or assertion moved; nothing about which write is serialized behind which changed. It is also the only honest room in the file: measured with scripts/stryker-diff.mjs's own accounting against e943530, extension goes from 500 changed executable lines to 494 (ClineProvider.ts 455 -> 449) against the 500 cap. The formatting cost is real - prettier keeps the entry object multi-line, so the helper is 6 executable lines and the fold nets -6, not the -12 the raw line count suggests. Lanes: tsc exit 0, eslint --max-warnings=0 exit 0, prettier reports the file unchanged, and core/webview + core/config + extension/__tests__ pass 517 tests.
1 parent e7a09f0 commit f3fa813

1 file changed

Lines changed: 16 additions & 15 deletions

File tree

‎src/core/webview/ClineProvider.ts‎

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -927,18 +927,27 @@ export class ClineProvider
927927
* Removes the given view's entry from the registered viewStates map.
928928
* Runs through the serialized write queue to avoid racing concurrent view-state writes.
929929
*/
930+
/**
931+
* Enqueues one serialized view-state write for this view's current generation. The three callers
932+
* below pass a fresh-read/mutate/write closure and the same generation, so this is the same call
933+
* typed once rather than a new policy.
934+
*/
935+
private enqueueViewStateWrite(run: (provider: ClineProvider) => Promise<void>): Promise<void> {
936+
return ClineProvider.enqueuePersistedViewStateWrite({
937+
provider: this,
938+
generation: this.viewStateGeneration,
939+
run,
940+
})
941+
}
942+
930943
private async clearPersistedViewState(viewStateId = this.viewStateId): Promise<void> {
931944
const run = async (provider: ClineProvider): Promise<void> => {
932945
const states = provider.getPersistedViewStates({ fresh: true })
933946
delete states[viewStateId]
934947
await provider.contextProxy.setValue("viewStates", states)
935948
}
936949

937-
await ClineProvider.enqueuePersistedViewStateWrite({
938-
provider: this,
939-
generation: this.viewStateGeneration,
940-
run,
941-
})
950+
await this.enqueueViewStateWrite(run)
942951
}
943952

944953
/** Re-bind a claim-less entry with a fresh claim; unowned selections are dropped. */
@@ -957,11 +966,7 @@ export class ClineProvider
957966
rebound = true
958967
}
959968

960-
await ClineProvider.enqueuePersistedViewStateWrite({
961-
provider: this,
962-
generation: this.viewStateGeneration,
963-
run,
964-
})
969+
await this.enqueueViewStateWrite(run)
965970

966971
return rebound ? claimToken : undefined
967972
}
@@ -1110,11 +1115,7 @@ export class ClineProvider
11101115
provider.wroteUnderTemporaryViewStateId = false
11111116
}
11121117

1113-
await ClineProvider.enqueuePersistedViewStateWrite({
1114-
provider: this,
1115-
generation: this.viewStateGeneration,
1116-
run,
1117-
})
1118+
await this.enqueueViewStateWrite(run)
11181119
}
11191120

11201121
/** Register the stable view id and load its persisted selections; a claim must match. */

0 commit comments

Comments
 (0)