-
Notifications
You must be signed in to change notification settings - Fork 0
Preview proposal changes on saved board objects across experiences #2872
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Chris0Jeky
merged 2 commits into
codex/2808-overhaul-integration
from
codex/2808-board-proposal-overlays
Sep 10, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
frontend/taskdeck-web/src/components/board/BoardProposalPreview.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| <script setup lang="ts"> | ||
| import { onScopeDispose, ref, watch } from 'vue' | ||
| import { RouterLink } from 'vue-router' | ||
| import { automationApi } from '../../api/automationApi' | ||
| import { useSessionStore } from '../../store/sessionStore' | ||
| import { getErrorDisplay } from '../../composables/useErrorMapper' | ||
| import type { BoardProposalMarkers } from '../../composables/useBoardProposalMarker' | ||
| import { normalizeProposalStatus } from '../../utils/automation' | ||
| import type { BoardDetail, Card } from '../../types/board' | ||
| import type { Proposal, ProposalPreview } from '../../types/automation' | ||
|
|
||
| const props = withDefaults(defineProps<{ proposalId: string; board: BoardDetail; cards: Card[]; available?: boolean }>(), { available: true }) | ||
| const emit = defineEmits<{ markers: [value: BoardProposalMarkers]; close: [] }>() | ||
| const session = useSessionStore() | ||
| const preview = ref<ProposalPreview | null>(null) | ||
| const proposal = ref<Proposal | null>(null) | ||
| const loading = ref(false) | ||
| const error = ref('') | ||
| let generation = 0 | ||
| let timer: ReturnType<typeof setTimeout> | undefined | ||
| const sameId = (a: string | null, b: string | null) => a?.toLowerCase() === b?.toLowerCase() | ||
| function clear() { | ||
| generation++; clearTimeout(timer); preview.value = null; proposal.value = null | ||
| loading.value = false; error.value = ''; emit('markers', {}) | ||
| } | ||
| function invalidate() { | ||
| clear(); error.value = 'The board or session changed. Refresh to check this proposal again.' | ||
| } | ||
| watch([() => props.proposalId, () => props.available, () => session.userId, () => !!session.token], invalidate, { flush: 'sync' }) | ||
| watch([() => props.board, () => props.cards], invalidate, { deep: true, flush: 'sync' }) | ||
|
|
||
| async function load() { | ||
| clear() | ||
| if (!props.available) return | ||
| const request = generation | ||
| const startedAt = performance.now() | ||
| loading.value = true | ||
| try { | ||
| const [receipt, detail] = await Promise.all([ | ||
| automationApi.getProposalPreview(props.proposalId), automationApi.getProposal(props.proposalId), | ||
| ]) | ||
| if (request !== generation) return | ||
| const status = normalizeProposalStatus(detail.status) | ||
| const effectiveId = status === 'Approved' ? detail.approvedRevisionId : detail.latestRevisionId | ||
| if (!sameId(receipt.proposalId, props.proposalId) || !sameId(detail.id, props.proposalId) | ||
| || !sameId(receipt.boardId, props.board.id) || !sameId(detail.boardId, props.board.id) | ||
| || !sameId(receipt.effectiveRevisionId, effectiveId) | ||
| || Date.parse(receipt.proposalUpdatedAt) !== Date.parse(detail.updatedAt) | ||
| || normalizeProposalStatus(receipt.status) !== status | ||
| || !['PendingReview', 'Approved'].includes(status)) | ||
| throw new Error('The proposal changed while loading. Refresh to check its latest revision.') | ||
| const lifetime = Math.min(30000, Date.parse(receipt.expiresAt) - Date.parse(receipt.checkedAt)) - (performance.now() - startedAt) | ||
| if (!Number.isFinite(lifetime) || lifetime <= 0) throw new Error('This proposal preview has expired. Open Review for its history.') | ||
| const existing = new Set([ | ||
| ...props.cards.filter(card => sameId(card.boardId, props.board.id)).map(card => `card:${card.id.toLowerCase()}`), | ||
| ...props.board.columns.map(column => `column:${column.id.toLowerCase()}`), | ||
| ]) | ||
| const markers: Record<string, string> = {} | ||
| for (const operation of detail.operations) { | ||
| const kind = operation.targetType.toLowerCase() | ||
| let parameters: Record<string, unknown> = {} | ||
| try { const parsed: unknown = JSON.parse(operation.parameters); if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) parameters = parsed as Record<string, unknown> } catch { /* The checked diff remains available if a target cannot be projected. */ } | ||
| // Execution uses parameter IDs. A display targetId must never override them. | ||
| const parameterId = Object.entries(parameters).find(([name]) => name.toLowerCase() === `${kind}id`)?.[1] | ||
| const id = typeof parameterId === 'string' ? parameterId : operation.targetId | ||
| const key = `${kind}:${id?.toLowerCase()}` | ||
| if (operation.actionType.toLowerCase() !== 'create' && existing.has(key)) markers[key] = 'Proposed change' | ||
| if (kind === 'card' && ['create', 'move'].includes(operation.actionType.toLowerCase()) && typeof parameters.columnId === 'string') { | ||
| const destination = `column:${parameters.columnId.toLowerCase()}` | ||
| if (existing.has(destination)) markers[destination] = 'Proposed change' | ||
| } | ||
| } | ||
| proposal.value = detail; preview.value = receipt; emit('markers', markers) | ||
| timer = setTimeout(() => { clear(); error.value = 'Refresh the preview to check the latest changes.' }, lifetime) | ||
| } catch (cause) { | ||
| if (request === generation) error.value = getErrorDisplay(cause, 'Preview unavailable. Open Review to inspect this proposal.').message | ||
| } finally { if (request === generation) loading.value = false } | ||
| } | ||
| onScopeDispose(clear) | ||
| </script> | ||
|
|
||
| <template> | ||
| <section class="board-proposal-preview" aria-label="Board proposal preview"> | ||
| <div class="board-proposal-preview__actions"> | ||
| <h2>Proposed board changes</h2> | ||
| <button type="button" :disabled="loading || !available" @click="load">{{ loading ? 'Checking proposal…' : 'Refresh board preview' }}</button> | ||
| <RouterLink :to="{ path: '/workspace/review', query: { boardId: board.id }, hash: `#proposal-${proposalId}` }">Open Review</RouterLink> | ||
| <button type="button" @click="emit('close')">Close preview</button> | ||
| </div> | ||
| <p v-if="error" role="status">{{ error }}</p> | ||
| <template v-if="preview && proposal"> | ||
| <p>{{ normalizeProposalStatus(preview.status) }} · {{ preview.effectiveRevisionNumber === null ? 'Original proposal' : `Revision ${preview.effectiveRevisionNumber}` }} · checked {{ new Date(preview.checkedAt).toLocaleTimeString() }}</p> | ||
| <p>{{ proposal.presentation?.plainSummary || proposal.summary }}</p> | ||
| <details open><summary>Changes to inspect</summary><pre>{{ preview.diff }}</pre></details> | ||
| <p>Existing targets are marked “Proposed change”. New items, hidden cards and targets without a board object appear in the summary above. The board still shows its saved state. Approval and Apply remain in Review.</p> | ||
| </template> | ||
| <p v-else-if="!loading && !error">Check the proposal to reveal its diff and mark the affected board objects.</p> | ||
| </section> | ||
| </template> | ||
|
|
||
| <style scoped> | ||
| .board-proposal-preview { margin: 1rem; padding: 1rem; border: 2px dashed var(--td-border-default); border-radius: .75rem; background: var(--td-surface-primary); color: var(--td-text-primary); } | ||
| .board-proposal-preview__actions { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; } | ||
| h2 { font-size: 1rem; font-weight: 650; margin-right: auto; } | ||
| button, a { padding: .5rem; border: 1px solid var(--td-border-default); border-radius: .3rem; } | ||
| p { font-size: .85rem; margin-top: .5rem; line-height: 1.5; } | ||
| pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 16rem; overflow: auto; font-size: .8rem; } | ||
| </style> | ||
|
|
||
| <style> | ||
| [data-proposal-change] { outline: 2px dashed var(--td-text-secondary); outline-offset: -2px; } | ||
| .td-proposal-marker { display: block; padding: .3rem .6rem; font-size: .75rem; font-weight: 650; color: var(--td-text-primary); background: var(--td-surface-secondary); border-bottom: 1px dashed var(--td-border-default); } | ||
| </style> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
frontend/taskdeck-web/src/composables/useBoardProposalMarker.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import { computed, inject, type InjectionKey, type Ref } from 'vue' | ||
|
|
||
| export type BoardProposalMarkers = Readonly<Record<string, string>> | ||
| export const BOARD_PROPOSAL_MARKERS: InjectionKey<Readonly<Ref<BoardProposalMarkers>>> = Symbol('board-proposal-markers') | ||
|
|
||
| /** Presentation only: a missing provider is the ordinary, unmodified board. */ | ||
| export function useBoardProposalMarker(kind: 'card' | 'column', id: () => string) { | ||
| const markers = inject(BOARD_PROPOSAL_MARKERS, undefined) | ||
| return computed(() => markers?.value[`${kind}:${id().toLowerCase()}`]) | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When Italian or Spanish is selected, this new board panel remains entirely in English because its labels and explanatory copy are hardcoded rather than read through
vue-i18n. Board and Review are already extracted surfaces, and ADR-0054 requires future user-visible strings on them to be added to all three catalogs, so this introduces a mixed-language core flow. Add board/review catalog keys for the panel and the new Review links instead of embedding English literals.Useful? React with 👍 / 👎.