Skip to content

Commit 4f8c4dc

Browse files
Copilotxiaoland
andauthored
Add source detail view with collect jobs list and enhance SourceCard navigation (#12)
* Initial plan * Add source detail view and update SourceCard with running job link Co-authored-by: xiaoland <37663413+xiaoland@users.noreply.github.com> * Make SourceCard clickable to navigate to detail view and add Chinese translations Co-authored-by: xiaoland <37663413+xiaoland@users.noreply.github.com> * Fix router order to prevent route matching issues Co-authored-by: xiaoland <37663413+xiaoland@users.noreply.github.com> * Address code review feedback: use absolute imports, add i18n, improve error handling Co-authored-by: xiaoland <37663413+xiaoland@users.noreply.github.com> * Rename newCollectJob to collectJobForm, add config field, extract sourceForm component - Renamed newCollectJob component to collectJobForm - Updated collectJobForm to be a pure form component with config field support - Added config field to SourceCollectJob - Created sourceForm component extracted from createSource - Updated createSource to use sourceForm - Updated source detail view to use sourceForm with inline editing and save button - Used shallow: true for latestRunningJob in sourceCard - Added create button to new job popup Co-authored-by: xiaoland <37663413+xiaoland@users.noreply.github.com> * Fix code review issues: add config field, remove redundant handler, add error handling Co-authored-by: xiaoland <37663413+xiaoland@users.noreply.github.com> * Extract sourceCollectJobCard component and rename latestRunningJob to latestOpenJob - Created sourceCollectJobCard component for displaying job items - Renamed getLatestRunningBySource to getLatestOpenBySource - Updated method to include both PENDING and RUNNING statuses - Updated all references from latestRunningJob to latestOpenJob - Removed inline job-item styles in favor of component Co-authored-by: xiaoland <37663413+xiaoland@users.noreply.github.com> * trivias fixes on sourceForm, collectJobForm * chore(sourceCard): checkRunningJob -> checkOpenJob * upd(sourceCollectJob): add refresh-indicator * trivias * chore: update agent docs * try fix copilot-setup-steps.yml * try fix copilot-setup-steps.yml * add pnpm-lock.yaml * rm pnpm-lock * try fix * try fix * Update copilot-setup-steps.yml * Update .npmrc * Update copilot-setup-steps.yml * Update copilot-setup-steps.yml --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: xiaoland <37663413+xiaoland@users.noreply.github.com> Co-authored-by: Lanzhijiang <lanzhijiang@foxmail.com>
1 parent a74db9c commit 4f8c4dc

File tree

31 files changed

+1111
-120
lines changed

31 files changed

+1111
-120
lines changed

.github/instructions/comp-vue.instructions.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const emit = defineEmits(compNameEmits);
3737

3838
- Use `<span>` instead of `<p>` for inline text
3939
- If template is duplicated inside a component and no third one will reuse it, define a reusable template inside the component scope using [VueUse createReusableTemplate](https://vueuse.org/core/createReusableTemplate/), instead of creating a new component.
40+
- Use UnoCSS utility classes for simple styles, instead of writing custom CSS/SCSS.
4041

4142
### Naming
4243

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: "Copilot Setup Steps"
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
paths:
7+
- .github/workflows/copilot-setup-steps.yml
8+
pull_request:
9+
paths:
10+
- .github/workflows/copilot-setup-steps.yml
11+
12+
jobs:
13+
# The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
14+
copilot-setup-steps:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
packages: read
19+
20+
# These steps will run before agent starts
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v5
24+
25+
- name: Setup pnpm
26+
uses: pnpm/action-setup@v4
27+
28+
- name: Set up Node.js
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: "20"
32+
33+
- name: Install dependencies
34+
run: pnpm install
35+
env:
36+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@ yarn-debug.log*
66
yarn-error.log*
77
pnpm-debug.log*
88
lerna-debug.log*
9-
pnpm-workspace.yaml
109

10+
# Dependency directories
11+
pnpm-workspace.yaml
1112
node_modules
12-
.DS_Store
13+
pnpm-lock.yaml
14+
package-lock.json
15+
16+
# Build output
1317
dist
1418
dist-ssr
1519
coverage
@@ -31,8 +35,9 @@ coverage
3135
*.sln
3236
*.sw?
3337

38+
# others
39+
.DS_Store
3440
*.tsbuildinfo
35-
pnpm-lock.yaml
3641
.__mf__temp
3742

3843
# env files

.npmrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
@inkcre:registry=https://npm.pkg.github.com
1+
@inkcre:registry=https://npm.pkg.github.com/
2+
//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}

AGENTS.md

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,50 @@
11
# InKCre Client-Web
22

3-
This is a Vue SPA, provides an interface to interact with InKCre (an information management tool).
3+
InKCre is an information management application aims to provides automatic information collection, organization and powerful use of information.
4+
And this is the Vue implemetation of InKCre, mainly provides a GUI to manage info-base and use information.
45

56
## Tech Stacks
67

7-
- Framework: Vue3 + TypeScript + Sass(scss) + Vite
8+
- Framework: Vue3 + TypeScript + SCSS
89
- Routing: vue-router
910
- Internalization: vue-i18n
1011
- Date and time: dayjs
1112
- State management: pinia
12-
- Packagae management: pnpm
1313

1414
## Business Domains
1515

16-
- obsrv: Observability
17-
- extension
16+
- source: Data collectors, the input of info-base
1817
- info-base
19-
- block
20-
- relation
21-
- resolver
22-
- storage
23-
- source
24-
- sink
18+
- block: Content units
19+
- relation: Links between blocks
20+
- storage: Store block content somewhere else than database.
21+
- resolver: resolves block content
22+
- sink: Interface to use information base, the output of info-base
23+
- extension: extends info-base, source and sink abilities
24+
- obsrv: Observability
2525

2626
## Source Structure
2727

28-
- `components/`: split by domain
28+
- `components/`: split by business domain
2929
- `views/`
3030
- `business/`: api requests, business logic, split by domain
3131
- `stores/`: split by domain
3232
- `styles/`
3333
- `utils/`: utilities, composables
3434
- `locales/`: locale file, split by language
3535
- `static/`
36-
- router.ts
36+
- `router.ts`
37+
38+
## Coding Guidelines
39+
40+
- Do not repeat yourself:
41+
- Search across the codebase before you creating a new type or something might can be reused.
42+
- Make the code reusable if it's used in over two places.
43+
- [Write code for human](./.github/instructions/human-readable-code.instructions.md)
44+
45+
## Deployment
3746

38-
## Best Practices
47+
This project supports following deployments:
3948

40-
- Search across the codebase before you creating a new type or something might can be reused.
41-
- Common components should be stateless or avoid maintaining state as much as possible.
42-
- Read more in `.github/instructions/`
49+
- Cloudflare Worker
50+
- Build and serve

docs/todo.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@
1919
- [ ] 时区转换有问题
2020
- [x] LogsViewer 的滚动到底部实现有问题
2121
- [x] pending job 不应该 poll logs
22+
- [ ] InkPagination new type
23+
- [ ] Source 不是 info-base 的一部分

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"@codemirror/lint": "^6.9.2",
2525
"@codemirror/state": "^6.5.2",
2626
"@codemirror/view": "^6.38.8",
27-
"@inkcre/web-design": "^1.1.1",
27+
"@inkcre/web-design": "^1.1.5",
2828
"@module-federation/runtime": "^0.21.4",
2929
"@supabase/postgrest-js": "^2.84.0",
3030
"@vueuse/core": "^14.0.0",

src/business/info-base/source.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ export class SourceCollectJob extends Z.class({
170170
.enum(SourceCollectJobStatus)
171171
.default(SourceCollectJobStatus.PENDING),
172172
state: z.looseObject({}).default(() => ({})),
173+
config: z.looseObject({}).default(() => ({})),
173174
}) {
174175
static dbApi: DBAPIClient = new DBAPIClient(
175176
"sources_collect_jobs",
@@ -186,6 +187,46 @@ export class SourceCollectJob extends Z.class({
186187
);
187188
}
188189

190+
static async getBySource(
191+
sourceId: SourceRef,
192+
options?: {
193+
limit?: number;
194+
offset?: number;
195+
order?: "asc" | "desc";
196+
}
197+
): Promise<{ data: SourceCollectJob[]; count: number }> {
198+
const { limit = 10, offset = 0, order = "desc" } = options || {};
199+
const query = this.dbApi
200+
.from()
201+
.select("*", { count: "exact" })
202+
.eq("source", sourceId)
203+
.order("created_at", { ascending: order === "asc" })
204+
.range(offset, offset + limit - 1);
205+
206+
const result = await query;
207+
return {
208+
data: (result.data || []).map((d) => new SourceCollectJob(d)),
209+
count: result.count || 0,
210+
};
211+
}
212+
213+
static async getLatestOpenBySource(
214+
sourceId: SourceRef
215+
): Promise<SourceCollectJob | null> {
216+
const result = await this.dbApi
217+
.from()
218+
.select()
219+
.eq("source", sourceId)
220+
.in("status", [SourceCollectJobStatus.PENDING, SourceCollectJobStatus.RUNNING])
221+
.order("created_at", { ascending: false })
222+
.limit(1);
223+
224+
if (result.data && result.data.length > 0) {
225+
return new SourceCollectJob(result.data[0]);
226+
}
227+
return null;
228+
}
229+
189230
public async getLogs(options?: {
190231
limit?: number;
191232
cursor?: number;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# collectJobForm
2+
3+
## Rationale
4+
5+
Provides a form interface to configure a source collect job.
6+
7+
## Goals
8+
9+
Allow users to configure collect job settings including config object.
10+
11+
## Specification
12+
13+
- Pure form component with v-model support
14+
- Provides config editor (InkJsonEditor)
15+
- No create/submit buttons - just form fields
16+
- Parent component handles submission
17+
18+
## Implementation
19+
20+
### Props
21+
22+
- `modelValue` (`SourceCollectJobForm`, required): The form data object
23+
24+
### Events
25+
26+
- `update:modelValue(form: SourceCollectJobForm)`: Emitted when form data changes
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.collect-job-form {
2+
display: flex;
3+
flex-direction: column;
4+
gap: sys-var(space, md);
5+
}

0 commit comments

Comments
 (0)