Thanks to visit codestin.com
Credit goes to github.com

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
8 changes: 8 additions & 0 deletions .claude/docs/FRONTEND_PATTERNS.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ function actually exercises the interaction. Jest/RTL tests are for pure logic
- When a component depends on the current time or date, accept it as a prop or
via context instead of reading `new Date()` or `Date.now()` internally, so
stories render deterministically without mocking globals.
- `renderHook` suites for stateful UI hooks are interaction tests, not pure
logic. Cover that behavior through the story of the component that uses the
hook.

**Incorrect (interaction test in Jest/RTL):**

Expand Down Expand Up @@ -89,6 +92,8 @@ const config: ChatModel = parseConfig(data);
of existing ones.
- Use existing wrapped primitives (Combobox, dialogs, tables) instead of
hand-assembling the underlying pieces they already wrap.
- Do not introduce a new React hook when an existing hook, a plain function,
or component state can express the logic.
- Delete dead code and unreachable branches instead of carrying them along.
- Keep the PR scoped to one change. Move unrelated cleanups, renames, and
drive-by refactors to separate PRs.
Expand Down Expand Up @@ -209,6 +214,9 @@ Decide where logic goes before reaching for `useEffect`:
is readable on its own. Share the entity fixture, not a pre-wired query
object.
- Query keys in mocks follow FE7: import the constant.
- Never replace browser globals with `Object.defineProperty` in tests or
stories. Use `vi.stubGlobal` in unit tests and `spyOn` from
`storybook/test` in stories.

## FE10: Tests assert observable behavior

Expand Down
13 changes: 10 additions & 3 deletions .claude/skills/frontend-review/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,18 @@ before they see the PR.
user-visible behavior? Then a changed or added `.stories.tsx` must exist,
and its `play` function must perform the new interaction (open the menu,
submit the form), not merely render. Interaction tests added to `.test.tsx`
files are a FAIL unless they cover pure logic.
files are a FAIL unless they cover pure logic; `renderHook` suites for
stateful UI hooks count as interaction tests and belong in the consuming
component's story.
- **FE2 (types)**: Search the diff for `any`, `as unknown as`, non-null
assertions in any form (`x!.y`, `items[0]!`, `fn()!`, `value! as T`), and
new `as` casts. Check that API data uses types from `api/typesGenerated.ts`.
- **FE3 (reuse/scope)**: For each new component, hook, or helper, search
`site/src/components/` and sibling folders for an existing equivalent.
Flag near-duplicates, hand-assembled versions of wrapped primitives, dead
branches, and unrelated changes bundled into the diff.
branches, and unrelated changes bundled into the diff. Flag new React hooks
that an existing hook, a plain function, or component state could replace;
several new single-use hooks in one diff is a FAIL.
- **FE4 (comments)**: Read every comment line the diff adds or edits. Flag
any comment that restates the identifier, assertion, or control flow.
Verify surviving comments are factually correct.
Expand All @@ -68,7 +72,10 @@ before they see the PR.
reads.
- **FE9 (fixtures)**: Flag inline entity literals that duplicate or deviate
from `Mock*` fixtures in `site/src/testHelpers/`, and shared pre-wired
query objects instead of per-story inline `{ key, data }` wiring.
query objects instead of per-story inline `{ key, data }` wiring. Flag any
`Object.defineProperty` replacement of a browser global in tests or
stories: unit tests stub with `vi.stubGlobal`, stories mock existing
globals with `spyOn` from `storybook/test`.
- **FE10 (test queries)**: Flag `querySelector`, class-name substring
matches, geometry assertions, `behavior: "smooth"` dependence, and
locale-less `toLocaleString()` in changed tests and stories.
Expand Down
4 changes: 1 addition & 3 deletions cli/exp_chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (

"github.com/coder/coder/v2/agent/agentsocket"
"github.com/coder/coder/v2/cli/cliui"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/serpent"
)

Expand Down Expand Up @@ -293,8 +292,7 @@ func (r *RootCmd) chatContextRefreshCommand(socketPath *string) *serpent.Command
if err != nil {
return err
}
exp := codersdk.NewExperimentalClient(client)
chat, err := exp.RefreshChatContext(ctx, chatID)
chat, err := client.RefreshChatContext(ctx, chatID)
if err != nil {
return xerrors.Errorf("refresh chat context: %w", err)
}
Expand Down
7 changes: 3 additions & 4 deletions cli/exp_scaletest_chat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,20 @@ func TestScaleTestChat(t *testing.T) {
require.NoError(t, err)
require.Equal(t, mockURL, provider.BaseURL)

expClient := codersdk.NewExperimentalClient(client)
defaultOrg, err := client.OrganizationByName(ctx, codersdk.DefaultOrganization)
require.NoError(t, err)
configs, err := expClient.ChatModels(ctx, defaultOrg.ID)
configs, err := client.ChatModels(ctx, defaultOrg.ID)
require.NoError(t, err)
matchingConfigs := scaletestModelConfigsForProvider(configs.Models, provider.ID)
require.Len(t, matchingConfigs, 1)
require.True(t, matchingConfigs[0].Enabled)

chats, err := expClient.ListChats(ctx, &codersdk.ListChatsOptions{Query: "archived:true"})
chats, err := client.ListChats(ctx, &codersdk.ListChatsOptions{Query: "archived:true"})
require.NoError(t, err)

var scaletestMessages []codersdk.ChatMessage
for _, chat := range chats {
resp, err := expClient.GetChatMessages(ctx, chat.ID, nil)
resp, err := client.GetChatMessages(ctx, chat.ID, nil)
require.NoError(t, err)
if userText, ok := chatMessageText(resp.Messages, codersdk.ChatMessageRoleUser); ok &&
strings.Contains(userText, scaletestChatPrompt) {
Expand Down
Loading
Loading