Skip to content

TaskView is a self-hosted project and task management platform focused on clarity, ownership, and control. TaskView is built for teams that want a transparent, self-hosted alternative to SaaS task managers.

fix: add link to integration task source

Nikolai Gimanade7c5d007c4
diff --git a/api/src/migrations/taskview/migrate.json b/api/src/migrations/taskview/migrate.json
index 51b2c71..f42e2a5 100644
--- a/api/src/migrations/taskview/migrate.json
+++ b/api/src/migrations/taskview/migrate.json
@@ -328,5 +328,16 @@
"description": [
"Added last_synced_at column to integrations for incremental sync"
]
+ },
+ "26": {
+ "version": "1.23.0",
+ "name": "Release 1.23.0",
+ "releaseDate": "20260314",
+ "scripts": [
+ "/1.23.0/0.1.23.0.sql"
+ ],
+ "description": [
+ "Added source_url column to tasks for external issue links"
+ ]
}
}
\ No newline at end of file
diff --git a/api/src/migrations/taskview/sql/1.23.0/0.1.23.0.sql b/api/src/migrations/taskview/sql/1.23.0/0.1.23.0.sql
new file mode 100644
index 0000000..8ac5d59
--- /dev/null
+++ b/api/src/migrations/taskview/sql/1.23.0/0.1.23.0.sql
@@ -0,0 +1,2 @@
+ALTER TABLE tasks.tasks
+ ADD COLUMN IF NOT EXISTS source_url VARCHAR(500);
diff --git a/api/src/tv-modules/integrations/IntegrationsController.ts b/api/src/tv-modules/integrations/IntegrationsController.ts
index 8fe9a3e..4853cc6 100644
--- a/api/src/tv-modules/integrations/IntegrationsController.ts
+++ b/api/src/tv-modules/integrations/IntegrationsController.ts
@@ -4,8 +4,8 @@ import { logError } from '../../utils/api';
import { decrypt } from '../../utils/crypto';
import AuthController from '../auth/AuthController';
import { IntegrationsRepository } from './IntegrationsRepository';
-import { verifyGitHubWebhookSignature } from './providers/github.provider';
-import { verifyGitLabWebhookToken } from './providers/gitlab.provider';
+import { verifyGitHubWebhookSignature, GITHUB_BASE_URL } from './providers/github.provider';
+import { verifyGitLabWebhookToken, GITLAB_BASE_URL } from './providers/gitlab.provider';
import { IntegrationsArkTypeAdd, IntegrationsArkTypeDelete, IntegrationsArkTypeFetch, IntegrationsArkTypeSelectRepo, IntegrationsArkTypeToggle } from './types';
export default class IntegrationsController {
@@ -174,6 +174,7 @@ export default class IntegrationsController {
if (action === 'opened') {
if (!mapping) {
+ const repoFullName = req.body?.repository?.full_name;
await repo.createTaskAndMapping(
integration.projectId,
issueTitle,
@@ -181,6 +182,8 @@ export default class IntegrationsController {
issueNumber,
'open',
issueBody,
+ false,
+ `${GITHUB_BASE_URL}/${repoFullName}/issues/${issueNumber}`,
);
}
} else if (action === 'edited') {
@@ -255,6 +258,7 @@ export default class IntegrationsController {
if (action === 'open') {
if (!mapping) {
+ const repoPath = req.body?.project?.path_with_namespace;
await repo.createTaskAndMapping(
integration.projectId,
issueTitle,
@@ -262,6 +266,8 @@ export default class IntegrationsController {
issueIid,
'open',
issueDescription,
+ false,
+ `${GITLAB_BASE_URL}/${repoPath}/-/issues/${issueIid}`,
);
}
} else if (action === 'update') {
diff --git a/api/src/tv-modules/integrations/IntegrationsManager.ts b/api/src/tv-modules/integrations/IntegrationsManager.ts
index e4d53cd..bc8201c 100644
--- a/api/src/tv-modules/integrations/IntegrationsManager.ts
+++ b/api/src/tv-modules/integrations/IntegrationsManager.ts
@@ -10,8 +10,8 @@ import { TasksRepository } from '../tasks/TasksRepository';
import type { IntegrationsSchemaTypeForSelect } from 'taskview-db-schemas';
import type { IntegrationsArgAdd, IntegrationsArgDelete, IntegrationsArgFetch, IntegrationsArgSelectRepo, IntegrationsArgToggle, OAuthStatePayload, RepoItemForClient } from './types';
import { randomBytes } from 'crypto';
-import { getGitHubOAuthUrl, exchangeGitHubCode, fetchGitHubRepos, fetchGitHubIssues, createGitHubWebhook, updateGitHubIssueState } from './providers/github.provider';
-import { getGitLabOAuthUrl, exchangeGitLabCode, fetchGitLabRepos, fetchGitLabIssues, createGitLabWebhook, updateGitLabIssueState, refreshGitLabToken } from './providers/gitlab.provider';
+import { getGitHubOAuthUrl, exchangeGitHubCode, fetchGitHubRepos, fetchGitHubIssues, createGitHubWebhook, updateGitHubIssueState, GITHUB_BASE_URL } from './providers/github.provider';
+import { getGitLabOAuthUrl, exchangeGitLabCode, fetchGitLabRepos, fetchGitLabIssues, createGitLabWebhook, updateGitLabIssueState, refreshGitLabToken, GITLAB_BASE_URL } from './providers/gitlab.provider';
export class IntegrationsManager {
public readonly repository: IntegrationsRepository;
@@ -197,7 +197,15 @@ export class IntegrationsManager {
const existingMappings = await this.repository.fetchMappingsByIntegrationId(integrationId);
const mappingsByIssueNumber = new Map(existingMappings.map((m) => [m.issueNumber, m]));
- type NewIssueItem = { goalId: number; description: string; integrationId: number; issueNumber: number; issueState: string; note: string | null; complete: boolean; kanbanOrder: number };
+ // Backfill sourceUrl for existing tasks that don't have it yet
+ if (existingMappings.length > 0) {
+ const baseUrl = integration.provider === 'github' ? GITHUB_BASE_URL : GITLAB_BASE_URL;
+ const issuePath = integration.provider === 'gitlab' ? '/-/issues/' : '/issues/';
+ const prefix = `${baseUrl}/${integration.repoFullName}${issuePath}`;
+ await this.repository.backfillSourceUrls(integrationId, prefix).catch(logError);
+ }
+
+ type NewIssueItem = { goalId: number; description: string; integrationId: number; issueNumber: number; issueState: string; note: string | null; complete: boolean; kanbanOrder: number; sourceUrl: string | null };
const newItems: NewIssueItem[] = [];
if (integration.provider === 'github') {
@@ -212,6 +220,7 @@ export class IntegrationsManager {
await this.repository.updateMappingState(existing.id, targetState).catch(logError);
}
await this.repository.updateTaskTitleAndNote(existing.taskId, issue.title, issue.body ?? null).catch(logError);
+ await this.repository.updateTaskSourceUrl(existing.taskId, `${GITHUB_BASE_URL}/${integration.repoFullName}/issues/${issue.number}`).catch(logError);
continue;
}
newItems.push({
@@ -223,6 +232,7 @@ export class IntegrationsManager {
note: issue.body ?? null,
complete: issue.state === 'closed',
kanbanOrder: 0,
+ sourceUrl: `${GITHUB_BASE_URL}/${integration.repoFullName}/issues/${issue.number}`,
});
}
} else if (integration.provider === 'gitlab' && integration.repoExternalId) {
@@ -237,6 +247,7 @@ export class IntegrationsManager {
await this.repository.updateMappingState(existing.id, targetState).catch(logError);
}
await this.repository.updateTaskTitleAndNote(existing.taskId, issue.title, issue.description ?? null).catch(logError);
+ await this.repository.updateTaskSourceUrl(existing.taskId, `${GITLAB_BASE_URL}/${integration.repoFullName}/-/issues/${issue.iid}`).catch(logError);
continue;
}
const isClosed = issue.state === 'closed';
@@ -249,6 +260,7 @@ export class IntegrationsManager {
note: issue.description ?? null,
complete: isClosed,
kanbanOrder: 0,
+ sourceUrl: `${GITLAB_BASE_URL}/${integration.repoFullName}/-/issues/${issue.iid}`,
});
}
}
diff --git a/api/src/tv-modules/integrations/IntegrationsRepository.ts b/api/src/tv-modules/integrations/IntegrationsRepository.ts
index 88842f0..55a04a0 100644
--- a/api/src/tv-modules/integrations/IntegrationsRepository.ts
+++ b/api/src/tv-modules/integrations/IntegrationsRepository.ts
@@ -1,4 +1,4 @@
-import { and, eq, ne } from 'drizzle-orm';
+import { and, eq, ne, isNull, sql } from 'drizzle-orm';
import { IntegrationsSchema, IntegrationTaskMapSchema, TasksSchema, UsersSchema, type IntegrationsSchemaTypeForSelect, type IntegrationTaskMapSchemaTypeForSelect } from 'taskview-db-schemas';
import { Database } from '../../modules/db';
import { callWithCatch } from '../../utils/helpers';
@@ -117,6 +117,7 @@ export class IntegrationsRepository {
issueState: string,
note?: string | null,
complete?: boolean,
+ sourceUrl?: string | null,
): Promise<IntegrationTaskMapSchemaTypeForSelect | false> {
const tasksRepo = new TasksRepository();
const kanbanOrder = await tasksRepo.getNextKanbanOrder(goalId);
@@ -128,6 +129,7 @@ export class IntegrationsRepository {
complete: complete ?? false,
note: note || null,
kanbanOrder,
+ sourceUrl: sourceUrl || null,
}).returning();
const [mapping] = await this.db.dbDrizzle.insert(IntegrationTaskMapSchema).values({
integrationId,
@@ -241,6 +243,29 @@ export class IntegrationsRepository {
return !!result;
}
+ async updateTaskSourceUrl(taskId: number, sourceUrl: string): Promise<boolean> {
+ const result = await callWithCatch(() =>
+ this.db.dbDrizzle.update(TasksSchema)
+ .set({ sourceUrl })
+ .where(eq(TasksSchema.id, taskId))
+ );
+ return !!result;
+ }
+
+ async backfillSourceUrls(integrationId: number, urlPrefix: string): Promise<boolean> {
+ const result = await callWithCatch(() =>
+ this.db.dbDrizzle.execute(sql`
+ UPDATE tasks.tasks t
+ SET source_url = ${urlPrefix} || m.issue_number
+ FROM tasks.integration_task_map m
+ WHERE m.task_id = t.id
+ AND m.integration_id = ${integrationId}
+ AND t.source_url IS NULL
+ `)
+ );
+ return !!result;
+ }
+
async updateMappingState(mappingId: number, issueState: string): Promise<boolean> {
const result = await callWithCatch(() =>
this.db.dbDrizzle.update(IntegrationTaskMapSchema)
@@ -251,7 +276,7 @@ export class IntegrationsRepository {
}
async createTasksAndMappingsBatch(
- items: Array<{ goalId: number; description: string; integrationId: number; issueNumber: number; issueState: string; note: string | null; complete: boolean; kanbanOrder: number }>,
+ items: Array<{ goalId: number; description: string; integrationId: number; issueNumber: number; issueState: string; note: string | null; complete: boolean; kanbanOrder: number; sourceUrl: string | null }>,
): Promise<number> {
if (items.length === 0) return 0;
let created = 0;
@@ -267,6 +292,7 @@ export class IntegrationsRepository {
complete: item.complete,
note: item.note,
kanbanOrder: item.kanbanOrder,
+ sourceUrl: item.sourceUrl,
})),
).returning({ id: TasksSchema.id });
diff --git a/api/src/tv-modules/integrations/providers/github.provider.ts b/api/src/tv-modules/integrations/providers/github.provider.ts
index db0a47f..da7509a 100644
--- a/api/src/tv-modules/integrations/providers/github.provider.ts
+++ b/api/src/tv-modules/integrations/providers/github.provider.ts
@@ -1,7 +1,7 @@
import axios from 'axios';
import { createHmac, timingSafeEqual } from 'crypto';
-const GITHUB_BASE_URL = process.env.GITHUB_BASE_URL || 'https://github.com';
+export const GITHUB_BASE_URL = process.env.GITHUB_BASE_URL || 'https://github.com';
const GITHUB_API_URL = process.env.GITHUB_API_URL || 'https://api.github.com';
const GITHUB_OAUTH_URL = `${GITHUB_BASE_URL}/login/oauth/authorize`;
const GITHUB_TOKEN_URL = `${GITHUB_BASE_URL}/login/oauth/access_token`;
diff --git a/api/src/tv-modules/integrations/providers/gitlab.provider.ts b/api/src/tv-modules/integrations/providers/gitlab.provider.ts
index f374849..29772f7 100644
--- a/api/src/tv-modules/integrations/providers/gitlab.provider.ts
+++ b/api/src/tv-modules/integrations/providers/gitlab.provider.ts
@@ -1,6 +1,6 @@
import axios from 'axios';
-const GITLAB_BASE_URL = process.env.GITLAB_BASE_URL || 'https://gitlab.com';
+export const GITLAB_BASE_URL = process.env.GITLAB_BASE_URL || 'https://gitlab.com';
const GITLAB_API_URL = process.env.GITLAB_API_URL || `${GITLAB_BASE_URL}/api/v4`;
const GITLAB_OAUTH_URL = `${GITLAB_BASE_URL}/oauth/authorize`;
const GITLAB_TOKEN_URL = `${GITLAB_BASE_URL}/oauth/token`;
diff --git a/taskview-packages/taskview-api/src/api/tasks.api.types.ts b/taskview-packages/taskview-api/src/api/tasks.api.types.ts
index cd488ad..e56be67 100644
--- a/taskview-packages/taskview-api/src/api/tasks.api.types.ts
+++ b/taskview-packages/taskview-api/src/api/tasks.api.types.ts
@@ -30,6 +30,7 @@ export interface TaskBase {
transactionType: TaskTransactionTypes;
nodeGraphPosition: Record<'x' | 'y', number> | null;
creatorId: number | null;
+ sourceUrl: string | null;
}
export interface Task extends TaskBase {
diff --git a/taskview-packages/taskview-db-schemas/src/schemas/tasks.schema.ts b/taskview-packages/taskview-db-schemas/src/schemas/tasks.schema.ts
index e51d6f8..44e8452 100644
--- a/taskview-packages/taskview-db-schemas/src/schemas/tasks.schema.ts
+++ b/taskview-packages/taskview-db-schemas/src/schemas/tasks.schema.ts
@@ -23,6 +23,7 @@ export const TasksSchema = pgSchema('tasks').table('tasks', {
amount: numeric({ precision: 10, scale: 2 }),
transactionType: integer('transaction_type').$type<1 | 0 | null>(),
nodeGraphPosition: jsonb('node_graph_position'),
+ sourceUrl: varchar('source_url', { length: 500 }),
});
export type TasksSchemaTypeForSelect = typeof TasksSchema.$inferSelect;
diff --git a/web/src/components/features/tasks/TaskDetailPanel.vue b/web/src/components/features/tasks/TaskDetailPanel.vue
index f4e89af..87f26a1 100644
--- a/web/src/components/features/tasks/TaskDetailPanel.vue
+++ b/web/src/components/features/tasks/TaskDetailPanel.vue
@@ -26,6 +26,20 @@
</UTextarea>
</div>
</div>
+ <!-- Source link (GitHub/GitLab issue) -->
+ <a
+ v-if="task.sourceUrl"
+ :href="task.sourceUrl"
+ target="_blank"
+ rel="noopener noreferrer"
+ class="inline-flex items-center gap-2 mb-2 text-sm text-muted hover:text-default transition-colors"
+ >
+ <UIcon
+ :name="task.sourceUrl.includes('github') ? 'i-lucide-github' : task.sourceUrl.includes('gitlab') ? 'i-lucide-gitlab' : 'i-lucide-external-link'"
+ class="size-4 shrink-0"
+ />
+ <span class="truncate underline underline-offset-2">{{ task.sourceUrl }}</span>
+ </a>
<!-- Subtasks -->
<TaskSubtasks