Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 52 additions & 36 deletions src/components/Draft/DraftTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@
return next;
});
},
[savedDraftId],

Check warning on line 508 in src/components/Draft/DraftTab.tsx

View workflow job for this annotation

GitHub Actions / quality-gates

React Hook useCallback has a missing dependency: 'setCaseIntake'. Either include it or remove the dependency array
);

const {
Expand Down Expand Up @@ -593,7 +593,7 @@
setPendingSimilarCaseOpen(null);
setWorkspaceRunbookScopeKey(createWorkspaceRunbookScopeKey());
resetGeneration();
}, [workspacePersonalization.preferred_note_audience, resetGeneration]);

Check warning on line 596 in src/components/Draft/DraftTab.tsx

View workflow job for this annotation

GitHub Actions / quality-gates

React Hook useCallback has missing dependencies: 'resetApproval', 'resetChecklist', 'resetFirstResponse', 'resetResponseActions', 'resetWorkspaceArtifacts', 'setCaseIntake', 'setGuidedRunbookNote', 'setGuidedRunbookSession', 'setPendingSimilarCaseOpen', 'setRunbookSessionSourceScopeKey', and 'setRunbookSessionTouched'. Either include them or remove the dependency array

const handleTreeComplete = useCallback((result: TreeResult) => {
setTreeResult(result);
Expand Down Expand Up @@ -670,7 +670,7 @@
setGenerating(false);
}
},
[modelLoaded, responseLength, generateStreaming, clearStreamingText],

Check warning on line 673 in src/components/Draft/DraftTab.tsx

View workflow job for this annotation

GitHub Actions / quality-gates

React Hook useCallback has a missing dependency: 'setGenerating'. Either include it or remove the dependency array
);

const buildDiagnosisJson = useCallback(() => {
Expand Down Expand Up @@ -1018,7 +1018,7 @@

void handleCopyKbDraft();
},
[

Check warning on line 1021 in src/components/Draft/DraftTab.tsx

View workflow job for this annotation

GitHub Actions / quality-gates

React Hook useCallback has missing dependencies: 'setApprovalQuery' and 'setCaseIntake'. Either include them or remove the dependency array
logEvent,
currentTicketId,
handleGenerate,
Expand Down Expand Up @@ -1293,42 +1293,58 @@

const workspacePanel = (
<TicketWorkspaceRail
intake={caseIntake}
onIntakeChange={handleIntakeFieldChange}
onAnalyzeIntake={handleAnalyzeIntake}
onApplyIntakePreset={handleApplyIntakePreset}
onNoteAudienceChange={handleNoteAudienceChange}
nextActions={nextActions}
missingQuestions={missingQuestions}
onAcceptNextAction={handleAcceptNextAction}
similarCases={similarCases}
similarCasesLoading={similarCasesLoading}
onRefreshSimilarCases={handleRefreshSimilarCases}
onOpenSimilarCase={handleOpenSimilarCase}
onCompareSimilarCase={handleCompareSimilarCase}
onCompareLastResolution={handleCompareLastResolution}
compareCase={compareCase}
onCloseCompareCase={() => setCompareCase(null)}
handoffPack={handoffPack}
evidencePack={evidencePack}
kbDraft={kbDraft}
onCopyHandoffPack={handleCopyHandoffPack}
onCopyEvidencePack={handleCopyEvidencePack}
onCopyKbDraft={handleCopyKbDraft}
resolutionKits={resolutionKits}
onSaveResolutionKit={handleSaveCurrentResolutionKit}
onApplyResolutionKit={handleApplyResolutionKit}
favorites={workspaceFavorites}
onToggleFavorite={handleToggleWorkspaceFavorite}
runbookTemplates={runbookTemplates}
guidedRunbookSession={guidedRunbookSession}
runbookNote={guidedRunbookNote}
onRunbookNoteChange={handleGuidedRunbookNoteChange}
onStartGuidedRunbook={handleStartGuidedRunbook}
onAdvanceGuidedRunbook={handleAdvanceGuidedRunbook}
onCopyRunbookProgressToNotes={handleCopyRunbookProgressToNotes}
workspacePersonalization={workspacePersonalization}
onPersonalizationChange={handleWorkspacePersonalizationChange}
intake={{
data: caseIntake,
onChange: handleIntakeFieldChange,
onAnalyze: handleAnalyzeIntake,
onApplyPreset: handleApplyIntakePreset,
onNoteAudienceChange: handleNoteAudienceChange,
missingQuestions,
}}
nextActions={{
items: nextActions,
onAccept: handleAcceptNextAction,
}}
similarCases={{
items: similarCases,
loading: similarCasesLoading,
onRefresh: handleRefreshSimilarCases,
onOpen: handleOpenSimilarCase,
onCompare: handleCompareSimilarCase,
onCompareLast: handleCompareLastResolution,
compareCase,
onCloseCompare: () => setCompareCase(null),
}}
packs={{
handoffPack,
evidencePack,
kbDraft,
onCopyHandoff: handleCopyHandoffPack,
onCopyEvidence: handleCopyEvidencePack,
onCopyKb: handleCopyKbDraft,
}}
kits={{
items: resolutionKits,
onSaveCurrent: handleSaveCurrentResolutionKit,
onApply: handleApplyResolutionKit,
}}
favorites={{
items: workspaceFavorites,
onToggle: handleToggleWorkspaceFavorite,
}}
runbooks={{
templates: runbookTemplates,
session: guidedRunbookSession,
note: guidedRunbookNote,
onNoteChange: handleGuidedRunbookNoteChange,
onStart: handleStartGuidedRunbook,
onAdvance: handleAdvanceGuidedRunbook,
onCopyProgress: handleCopyRunbookProgressToNotes,
}}
personalization={{
value: workspacePersonalization,
onChange: handleWorkspacePersonalizationChange,
}}
workspaceCatalogLoading={workspaceCatalogLoading}
currentResponse={response}
/>
Expand Down
156 changes: 87 additions & 69 deletions src/features/workspace/TicketWorkspaceRail.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,73 +97,91 @@ const basePersonalization: WorkspacePersonalization = {
default_evidence_format: "clipboard",
};

function renderRail(
overrides: Partial<ComponentProps<typeof TicketWorkspaceRail>> = {},
) {
const props: ComponentProps<typeof TicketWorkspaceRail> = {
intake: baseIntake,
onIntakeChange: vi.fn(),
onAnalyzeIntake: vi.fn(),
onApplyIntakePreset: vi.fn(),
onNoteAudienceChange: vi.fn(),
nextActions: [],
missingQuestions: [],
onAcceptNextAction: vi.fn(),
similarCases: [baseSimilarCase],
similarCasesLoading: false,
onRefreshSimilarCases: vi.fn(),
onOpenSimilarCase: vi.fn(),
onCompareSimilarCase: vi.fn(),
onCompareLastResolution: vi.fn(),
compareCase: null,
onCloseCompareCase: vi.fn(),
handoffPack: {
summary: "VPN issue under review",
actions_taken: ["Reset VPN profile"],
current_blocker: "West region still affected",
next_step: "Escalate to network engineering",
customer_safe_update: "We are actively working the VPN issue.",
escalation_note: "Escalate the remaining west region failures.",
type RailProps = ComponentProps<typeof TicketWorkspaceRail>;

function makeBundles(): RailProps {
return {
intake: {
data: baseIntake,
onChange: vi.fn(),
onAnalyze: vi.fn(),
onApplyPreset: vi.fn(),
onNoteAudienceChange: vi.fn(),
missingQuestions: [],
},
nextActions: {
items: [],
onAccept: vi.fn(),
},
similarCases: {
items: [baseSimilarCase],
loading: false,
onRefresh: vi.fn(),
onOpen: vi.fn(),
onCompare: vi.fn(),
onCompareLast: vi.fn(),
compareCase: null,
onCloseCompare: vi.fn(),
},
evidencePack: {
title: "Evidence Pack · INC-1001",
summary: "VPN issue under review",
sections: [],
packs: {
handoffPack: {
summary: "VPN issue under review",
actions_taken: ["Reset VPN profile"],
current_blocker: "West region still affected",
next_step: "Escalate to network engineering",
customer_safe_update: "We are actively working the VPN issue.",
escalation_note: "Escalate the remaining west region failures.",
},
evidencePack: {
title: "Evidence Pack · INC-1001",
summary: "VPN issue under review",
sections: [],
},
kbDraft: {
title: "VPN disconnects every morning",
summary: "Repeated VPN disconnects for remote users.",
symptoms: "Users disconnect every morning.",
environment: "Managed Windows laptops",
cause: "Likely regional gateway issue",
resolution: "Reset profile and escalate to network engineering.",
warnings: [],
prerequisites: [],
policy_links: [],
tags: ["incident"],
},
onCopyHandoff: vi.fn(),
onCopyEvidence: vi.fn(),
onCopyKb: vi.fn(),
},
kbDraft: {
title: "VPN disconnects every morning",
summary: "Repeated VPN disconnects for remote users.",
symptoms: "Users disconnect every morning.",
environment: "Managed Windows laptops",
cause: "Likely regional gateway issue",
resolution: "Reset profile and escalate to network engineering.",
warnings: [],
prerequisites: [],
policy_links: [],
tags: ["incident"],
kits: {
items: [baseResolutionKit],
onSaveCurrent: vi.fn(),
onApply: vi.fn(),
},
favorites: {
items: baseFavorites,
onToggle: vi.fn(),
},
runbooks: {
templates: [baseRunbookTemplate],
session: baseRunbookSession,
note: "",
onNoteChange: vi.fn(),
onStart: vi.fn(),
onAdvance: vi.fn(),
onCopyProgress: vi.fn(),
},
personalization: {
value: basePersonalization,
onChange: vi.fn(),
},
onCopyHandoffPack: vi.fn(),
onCopyEvidencePack: vi.fn(),
onCopyKbDraft: vi.fn(),
resolutionKits: [baseResolutionKit],
onSaveResolutionKit: vi.fn(),
onApplyResolutionKit: vi.fn(),
favorites: baseFavorites,
onToggleFavorite: vi.fn(),
runbookTemplates: [baseRunbookTemplate],
guidedRunbookSession: baseRunbookSession,
runbookNote: "",
onRunbookNoteChange: vi.fn(),
onStartGuidedRunbook: vi.fn(),
onAdvanceGuidedRunbook: vi.fn(),
onCopyRunbookProgressToNotes: vi.fn(),
workspacePersonalization: basePersonalization,
onPersonalizationChange: vi.fn(),
workspaceCatalogLoading: false,
currentResponse: "Reset the VPN profile and verify MFA enrollment.",
...overrides,
};
}

function renderRail(overrides: Partial<RailProps> = {}) {
const props: RailProps = { ...makeBundles(), ...overrides };
return {
props,
...render(<TicketWorkspaceRail {...props} />),
Expand Down Expand Up @@ -211,9 +229,9 @@ describe("TicketWorkspaceRail", () => {
}),
);

expect(props.onCompareLastResolution).toHaveBeenCalledTimes(1);
expect(props.onApplyResolutionKit).toHaveBeenCalledTimes(1);
expect(props.onCopyRunbookProgressToNotes).toHaveBeenCalledTimes(1);
expect(props.similarCases.onCompareLast).toHaveBeenCalledTimes(1);
expect(props.kits.onApply).toHaveBeenCalledTimes(1);
expect(props.runbooks.onCopyProgress).toHaveBeenCalledTimes(1);
expect(screen.getByText("Favorites")).toBeTruthy();
expect(screen.getByText("Guided runbooks")).toBeTruthy();
});
Expand Down Expand Up @@ -243,19 +261,19 @@ describe("TicketWorkspaceRail", () => {
{ target: { value: "Long" } },
);

expect(props.onPersonalizationChange).toHaveBeenCalledWith({
expect(props.personalization.onChange).toHaveBeenCalledWith({
preferred_output_length: "Long",
});
});

it("shows empty states when the catalog is unavailable and compare is not ready", () => {
const base = makeBundles();
const { container } = renderRail({
currentResponse: "",
similarCases: [],
resolutionKits: [],
favorites: [],
guidedRunbookSession: null,
runbookTemplates: [],
similarCases: { ...base.similarCases, items: [] },
kits: { ...base.kits, items: [] },
favorites: { ...base.favorites, items: [] },
runbooks: { ...base.runbooks, session: null, templates: [] },
});
const rail = getRailRoot(container);

Expand Down
Loading
Loading