refactor(config): make EditorState/ConfirmDeleteState generic over the artifact type
Review feedback: string widening dropped the compile-time guard at the write/delete boundary right where the Codex panel (the next task) starts writing into this state. Threading <TType extends string = CcArtifactType> through EditorState/EditorModal and ConfirmDeleteState/ConfirmDeleteModal keeps CcConfig.tsx's write/delete calls checked against CcArtifactType by default while still letting a Codex-typed caller instantiate its own union later, removing the two `as CcArtifactType` casts.
This commit is contained in:
@@ -426,7 +426,7 @@ export function CcConfig() {
|
||||
|
||||
const handleSave = useCallback(
|
||||
async (args: {
|
||||
type: string;
|
||||
type: CcArtifactType;
|
||||
targetScope: "user" | "project" | "auto-memory";
|
||||
name: string | undefined;
|
||||
content: string;
|
||||
@@ -434,7 +434,7 @@ export function CcConfig() {
|
||||
}) => {
|
||||
const result: CcMutationResult = await api.ccConfig.write({
|
||||
scope: args.targetScope,
|
||||
type: args.type as CcArtifactType,
|
||||
type: args.type,
|
||||
name: args.name,
|
||||
content: args.content,
|
||||
project: args.project,
|
||||
@@ -456,7 +456,7 @@ export function CcConfig() {
|
||||
try {
|
||||
const result = await api.ccConfig.delete({
|
||||
scope: confirmDelete.scope,
|
||||
type: confirmDelete.type as CcArtifactType,
|
||||
type: confirmDelete.type,
|
||||
name: confirmDelete.name,
|
||||
project: confirmDelete.project,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user