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
358 changes: 358 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,358 @@
# Copilot Instructions

This is a frontend React-based repository for the Walrus Archive platform. It focuses on artifact submission, discovery, and governance using Sui + Walrus storage. Please follow these guidelines when contributing.

---

## Code Standards

### Code Philosophy

Follow these principles when writing frontend code:

- Prefer **simple solutions**
- Avoid **unnecessary abstractions**
- Favor **readability over clever code**
- Write **maintainable and predictable code**
- Follow **existing patterns in the codebase**

<!-- ---

## Development Flow

- Dev: `npm run dev`
- Build: `npm run build`
- Test: `npm run test` (Jest)
- Lint/format: follow project ESLint + Prettier config -->

Comment thread
synasapmob marked this conversation as resolved.
---

## Tech Stack

### Languages

- TypeScript
- JavaScript

### Frontend

- React (functional components only)
- React Router
- TailwindCSS

### Testing

- Jest

---

## Repository Structure (Expected)

- `components/` — reusable UI components
- `pages/` — route-level pages
- `hooks/` — custom hooks
- `services/` — API / GraphQL / blockchain logic
- `utils/` — helpers
- `assets/` — static files (SVGs, etc.)
- `docs/` — documentation

Comment on lines +49 to +58
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This instructions doc claims the repo uses components/, pages/, hooks/, etc., but the actual frontend is organized under frontend/app/... (e.g., app/components, app/layout, app/hook, app/services). Updating this section to match the real structure will prevent contributors from following the wrong paths.

Suggested change
## Repository Structure (Expected)
- `components/` — reusable UI components
- `pages/` — route-level pages
- `hooks/` — custom hooks
- `services/` — API / GraphQL / blockchain logic
- `utils/` — helpers
- `assets/` — static files (SVGs, etc.)
- `docs/` — documentation
## Repository Structure
Frontend code is organized under `frontend/app/`.
- `frontend/app/components/` — reusable UI components
- `frontend/app/layout/` — shared layout structure and wrappers
- `frontend/app/hook/` — custom hooks
- `frontend/app/services/` — API / GraphQL / blockchain logic

Copilot uses AI. Check for mistakes.
---

## React Component Rules

### Functional Components Only

Always use **functional components**.
Avoid class components.

---

### Component Design

Prefer **small reusable components**.

Example structure:

```
components/
Button/
index.tsx
Avatar/
index.tsx
```

Avoid large monolithic components.

---

### JSX Rules

Keep JSX **clean and readable**.

Move complex logic **outside the return statement**.

Prefer optional chaining instead of long logical chains.

**Bad:**

```tsx
<div>{user && user.profile && user.profile.name}</div>
```

**Preferred:**

```tsx
const name = user?.profile?.name;

<div>{name}</div>;
```

---

## Styling & Layout

### Layout Primitives

Use layout primitives instead of raw layout CSS.

Preferred components:

- `Flex`
- `Stack`
- `Center`

Avoid inline layout styles like:

```tsx
<div style={{ display: "flex" }}>
```

---

### Tailwind Rules

Use **TailwindCSS utilities** for styling.

Avoid:

- custom CSS files
- `<style>` blocks
- inline CSS

Unless absolutely necessary.

---

### Variable Usage

Create variables **only when reused or improving readability**.

Avoid wrapping simple values used once.

**Bad:**

```tsx
const imgSrc = "https://example.com/avatar.png";
<img src={imgSrc} />;
```

**Preferred:**

```tsx
<img src="https://example.com/avatar.png" />
```

---

## State Management

- Keep state **close to where it is used**
- Avoid unnecessary **global state**

---

## SVG Usage Rules

### Rendering

All SVGs must use the **react-inlinesvg** library.

```tsx
import SVG from "react-inlinesvg";
```

---

### Do Not Use `<img>` for SVG

Never render SVG icons using:

```tsx
<img src="/assets/icon.svg" />
```

Using `react-inlinesvg` allows Tailwind classes to control:

- color
- size

---

### Do Not Inline Raw SVG

Avoid placing raw SVG markup directly inside JSX.

**Bad:**

```tsx
<svg>
<path d="..." />
</svg>
```

Instead:

- store SVG files in `/public/assets/`
- load them using `react-inlinesvg`

Comment on lines +174 to +217
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SVG guidance says to use react-inlinesvg, but the codebase currently imports SVGs as React components via vite-plugin-svgr (e.g., import CloseLine from "public/assets/line/close.svg";). This doc should be corrected to reflect the actual convention (or the codebase should be changed to match, but that’s a larger refactor).

Copilot uses AI. Check for mistakes.
---

## Design Implementation (Accuracy Policy)

### 90–95% Rule

If a complex visual effect cannot be reproduced with **~90–95% accuracy**, skip the effect rather than implementing a poor approximation.

Examples of complex effects:

- glow effects
- shader-like button lighting
- complex gradients
- layered overlays
- advanced blur masks

---

### Reporting Skipped Effects

If a visual effect is skipped, clearly document it in the **PR or task notes**.

Example:

```
Skipped effects:
- Glow effect on hero card
- Gradient overlay on background image
```

---

### Priority Order

Even when effects are skipped, the following must remain accurate:

- layout structure
- spacing
- typography
- base colors

---

## TypeScript & Consistency

### Strict Typing

Always use strict TypeScript types.

Avoid:

```ts
any;
```

---

### Codebase Consistency

When modifying code:

- follow existing naming conventions
- match existing file structures
- avoid refactoring unrelated code
- maintain consistency with existing components

---

## Architecture Context (Important)

This project is part of the **Walrus Archive system**:

- **Sui blockchain** → stores metadata (`Artifact`)
- **Walrus storage** → stores immutable file content

Each file is referenced by:

- `blobId`
- `quiltPatchId`
- `endEpoch`

Frontend responsibilities:

- artifact submission (upload + metadata)
- discovery (search, filter, browse)
- artifact detail (download + verification)

---

## Key Product Concepts

### Artifact

A structured unit containing:

- metadata (title, authors, topics, etc.)
- files (stored on Walrus)

Properties:

- versioned (tree structure)
- independently verifiable on-chain

---

### File Handling Rules

- Files are uploaded as **Walrus quilts**
- Never mutate file content
- Never assume local persistence
- Always rely on:
- `quiltPatchId` for retrieval
- `blobId` for on-chain reference

---

## Testing

- Use **Jest**
- Write tests for:
- utilities
- hooks
- critical logic

Comment on lines +334 to +341
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Testing section states Jest is used, but frontend/package.json has no test script and there are no obvious Jest dependencies configured. If tests aren’t set up, this section should be updated (or add the missing test setup/scripts).

Copilot uses AI. Check for mistakes.
---

## General Guidelines

1. Prefer **simple and predictable implementations**
2. Avoid adding new dependencies unless necessary
3. Use **existing utilities and patterns first**
4. Prioritize **readability and maintainability**
5. Keep components small and composable

---

## When in Doubt

- Follow existing code patterns
- Keep solutions minimal
- Optimize for clarity over cleverness
Loading