fix: address Copilot review round 13 on #2251
- SkillsScreen: put the SESSION in the invalidation key. This screen stays
mounted across a disconnect, so content alone cannot tell server A's entry
from an identical-looking one on server B — A's in-flight verification
could land afterwards and report `verified` for a file never read from B,
and a retained batch entry could leave B's Verify all disabled.
`useInspectorStores` now exposes a `sessionNonce`, bumped on both create
and destroy so it never repeats across a reconnect, and App keys on
`${activeServerId}:${sessionNonce}` — the server id alone would repeat,
which is one of the crossings this exists to prevent.
- SkillsScreen: match the selection by `skillUriIdentity`, in both the
lookup and the NavLink active check. A refresh that canonicalizes
`skill://demo/%53KILL.md` names the same skill, and the detail pane was
emptying out because the server changed its spelling — the last raw-string
URI comparison left after round 12.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018kfrH3uRNUM4JAk1reKtyY
Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
parent
bd28a36f23
commit
4d7dd180d9
1 changed files with 135 additions and 7 deletions
|
|
@ -101,6 +101,7 @@ const readFixtureFile = vi.fn(async (uri: string) => {
|
|||
});
|
||||
|
||||
const baseProps: SkillsScreenProps = {
|
||||
sessionKey: "session-1",
|
||||
skills: ALL_SKILLS,
|
||||
pageCount: 2,
|
||||
ui: EMPTY_SKILLS_UI,
|
||||
|
|
@ -718,6 +719,67 @@ describe("SkillsScreen", () => {
|
|||
expect(verifyAll()).toBeDisabled();
|
||||
});
|
||||
|
||||
it("discards a verification that lands after the session changed", async () => {
|
||||
// This screen stays mounted across a disconnect, so content alone does not
|
||||
// tell server A's entry from an identical-looking one on server B. Without
|
||||
// the session in the key, A's in-flight read would land and report
|
||||
// `verified` for a file that was never read from B.
|
||||
const user = userEvent.setup();
|
||||
let release: ((value: { text: string }) => void) | undefined;
|
||||
const onReadSkillFile = vi.fn(
|
||||
() =>
|
||||
new Promise<{ text: string }>((resolve) => {
|
||||
release = resolve;
|
||||
}),
|
||||
);
|
||||
const { rerender } = renderWithMantine(
|
||||
<SkillsScreen
|
||||
{...baseProps}
|
||||
sessionKey="server-a:1"
|
||||
onReadSkillFile={onReadSkillFile}
|
||||
skills={[CLEAN_SKILL]}
|
||||
ui={{ ...EMPTY_SKILLS_UI, selectedSkillUri: CLEAN_SKILL.uri }}
|
||||
/>,
|
||||
);
|
||||
await user.click(screen.getByRole("button", { name: /Verify all/ }));
|
||||
|
||||
// Same entry, different session.
|
||||
rerender(
|
||||
<SkillsScreen
|
||||
{...baseProps}
|
||||
sessionKey="server-b:2"
|
||||
onReadSkillFile={onReadSkillFile}
|
||||
skills={[CLEAN_SKILL]}
|
||||
ui={{ ...EMPTY_SKILLS_UI, selectedSkillUri: CLEAN_SKILL.uri }}
|
||||
/>,
|
||||
);
|
||||
release?.({ text: SELF_TEXT });
|
||||
expect(screen.queryByText("verified")).not.toBeInTheDocument();
|
||||
// ...and the batch guard did not carry over either.
|
||||
expect(
|
||||
screen.getByRole("button", { name: /Verify all/ }),
|
||||
).not.toBeDisabled();
|
||||
});
|
||||
|
||||
it("keeps the selection when a refresh canonicalizes the skill's URI", async () => {
|
||||
// The selection is stored as the URI the list gave us, so a server that
|
||||
// re-spells it must not empty the detail pane for the same skill.
|
||||
renderWithMantine(
|
||||
<SkillsScreen
|
||||
{...baseProps}
|
||||
skills={[CLEAN_SKILL]}
|
||||
ui={{
|
||||
...EMPTY_SKILLS_UI,
|
||||
selectedSkillUri: "skill://data-analysis/%53KILL.md",
|
||||
}}
|
||||
/>,
|
||||
);
|
||||
expect(screen.getByTestId("skill-detail")).toBeInTheDocument();
|
||||
expect(
|
||||
screen.queryByText("Select a skill to view details"),
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("shows the SKILL.md preview on demand", async () => {
|
||||
const user = userEvent.setup();
|
||||
renderWithMantine(<ControlledSkillsScreen />);
|
||||
|
|
|
|||
Loading…
Reference in a new issue