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
2 changes: 1 addition & 1 deletion .github/workflows/bun-audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Dependency Audit

on:
schedule:
- cron: '0 0 * * 0' # Weekly Sunday 00:00 UTC
- cron: '0 0 * * 0'
workflow_dispatch:

jobs:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ jobs:
- run: bun install --frozen-lockfile
- uses: j178/prek-action@v3.1.0
with:
# Branch protection applies to local commits, not CI checkouts.
extra-args: --all-files --skip no-commit-to-branch
- run: bunx tsc --noEmit -p electron/tsconfig.json

Expand Down
1 change: 0 additions & 1 deletion .github/workflows/dependabot-automerge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ jobs:
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

# Auto-merge waits for the required status checks enforced by the dev branch rules.
- name: Enable automerge for patch and minor updates
if: >-
steps.metadata.outputs.package-ecosystem == 'bun' &&
Expand Down
1 change: 0 additions & 1 deletion bunfig.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
[install]
# Only resolve new package versions published at least 3 days ago (versions already pinned in bun.lock are unaffected)
minimumReleaseAge = 259200
21 changes: 3 additions & 18 deletions containers/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,28 +1,13 @@
# Production server for the container image (copied to
# /etc/nginx/conf.d/default.conf in the Containerfile).
#
# The Content-Security-Policy here must stay in sync with the <meta> fallback
# in src/index.html (GitHub Pages cannot send custom HTTP headers, so the meta
# tag is its only enforcement). If the inline theme script in index.html
# changes, recompute its sha256 and update script-src in both places.
# The one intended difference: frame-ancestors exists only here, because
# browsers ignore it in a <meta> tag and log an error on every page load.
#
# Policy notes:
# - img-src allows blob:/data:/https: (IndexedDB posters via object URLs,
# inline SVG placeholder, TMDB/MyAnimeList/AniList CDN posters).
# - connect-src enumerates the API + image origins the app fetches from
# (poster save uses fetch() on image CDN URLs, so those need connect-src).
# - style-src 'unsafe-inline' is required: Angular injects component styles
# at runtime. No external stylesheets are used.
# style-src 'unsafe-inline' is required: Angular injects component styles
# at runtime. No external stylesheets are used.
server {
listen 80;
server_name _;

root /usr/share/nginx/html;
index index.html;

add_header Content-Security-Policy "default-src 'self'; base-uri 'self'; form-action 'self'; object-src 'none'; frame-ancestors 'none'; script-src 'self' 'sha256-Hq3FIAQiTPolQXnEfi9wb+iJcaXWvqDZulbwr3WX+IE='; style-src 'self' 'unsafe-inline'; img-src 'self' blob: data: https:; connect-src 'self' https://api.themoviedb.org https://api.jikan.moe https://graphql.anilist.co https://image.tmdb.org https://cdn.myanimelist.net https://s4.anilist.co; font-src 'self' data:; manifest-src 'self'; worker-src 'self'" always;
add_header Content-Security-Policy "default-src 'self'; base-uri 'self'; form-action 'self'; object-src 'none'; frame-ancestors 'none'; script-src 'self' 'sha256-toZFmdk2CkvU3nyUgzTVJAy/6YfDgBH8RrDVwKZXNAo='; style-src 'self' 'unsafe-inline'; img-src 'self' blob: data: https:; connect-src 'self' https://api.themoviedb.org https://api.jikan.moe https://graphql.anilist.co https://image.tmdb.org https://cdn.myanimelist.net https://s4.anilist.co; font-src 'self' data:; manifest-src 'self'; worker-src 'self'" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "DENY" always;
add_header Referrer-Policy "no-referrer" always;
Expand Down
5 changes: 0 additions & 5 deletions e2e/journey.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { expect, test } from '@playwright/test';

// The one browser test. Component and service behaviour is covered by the
// Vitest specs; this proves what they cannot: the production bundle boots under
// its Content-Security-Policy, real clicks reach the controls, and the
// collection persists in the browser's own IndexedDB.
test('add a series, watch an episode, and delete the series', async ({ page }) => {
const title = 'Browser Journey Series';
const problems: string[] = [];
Expand Down Expand Up @@ -48,7 +44,6 @@ test('add a series, watch an episode, and delete the series', async ({ page }) =
await expect(page).toHaveURL(/\/items$/);
await expect(page.getByText('No items found')).toBeVisible();
await nav.getByRole('link', { name: 'History' }).click();
// History outlives its item by design.
await expect(page.getByText(`${title} (deleted)`)).toBeVisible();

expect(problems).toEqual([]);
Expand Down
2 changes: 0 additions & 2 deletions e2e/serve.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Serves the production build for the browser tests, with the same SPA
// fallback as containers/nginx.conf.
import { join, normalize } from 'node:path';

const root = join(import.meta.dirname, '../dist/watch-list/browser');
Expand Down
2 changes: 0 additions & 2 deletions electron/preload.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { contextBridge } from 'electron';

// Expose a minimal, secure API surface. Extend here when IPC is needed.
// Keeping contextIsolation + sandbox enabled (see main.ts).
contextBridge.exposeInMainWorld('electronAPI', {
platform: process.platform,
});
3 changes: 0 additions & 3 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { defineConfig, devices } from '@playwright/test';

// Set E2E_BASE_URL to test an already running deployment (CI points it at the
// nginx container, the only place the real security headers exist). Without it
// the production build is created and served locally.
const externalBaseUrl = process.env['E2E_BASE_URL'];
const localPort = 4300;
// Playwright's downloaded Chromium cannot start on every OS (NixOS, for one).
Expand Down
1 change: 0 additions & 1 deletion scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const version = getVersion();
const hash = getHash();
const buildDate = getBuildDate();

// All args after script name are forwarded to ng build (e.g. --configuration=..., --base-href ...)
const extraArgs = process.argv.slice(2);

const defines = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Component, inject, input, output, signal } from '@angular/core';
import { StorageService } from '../../services/storage.service';

/** Refresh shared collection state without navigating away from recoverable drafts. */
@Component({
selector: 'app-conflict-recovery',
template: `
Expand Down
4 changes: 0 additions & 4 deletions src/app/components/home/home.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,14 +270,12 @@ describe('HomeComponent', () => {
});

it('shows empty states for nextSeries/nextMovie', async () => {
// No series in list
setup({ watchItems: [], inProgressSeries: [], nextSeries: null, nextMovie: null });
let fixture = TestBed.createComponent(HomeComponent);
fixture.detectChanges();
await fixture.whenStable();
expect(fixture.nativeElement.textContent).toContain('No series in your watch list');

// Has series but none in progress
const seriesNotStarted = createItem({
id: 's1',
title: 'S',
Expand All @@ -296,7 +294,6 @@ describe('HomeComponent', () => {
await fixture.whenStable();
expect(fixture.nativeElement.textContent).toContain('No series currently being watched');

// Has in-progress but not watchable (all future)
const inProg = createItem({
id: 's2',
title: 'S2',
Expand All @@ -310,7 +307,6 @@ describe('HomeComponent', () => {
await fixture.whenStable();
expect(fixture.nativeElement.textContent).toContain('No aired series episodes available');

// Movies
setup({ watchItems: [], inProgressSeries: [], nextSeries: null, nextMovie: null });
fixture = TestBed.createComponent(HomeComponent);
fixture.detectChanges();
Expand Down
2 changes: 0 additions & 2 deletions src/app/components/home/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ import { DiscussionLinkComponent } from '../discussion-link/discussion-link.comp
</h2>
@if (nextSeries()) {
<div class="w-full">
<!-- Narrow card (280px) keeps natural 2/3 poster (~420px tall) fully visible, no cropping -->
<app-item-card [item]="nextSeries()!" />
<div class="flex flex-wrap justify-center gap-2 mt-3">
<button
Expand Down Expand Up @@ -337,7 +336,6 @@ export class HomeComponent {
constructor() {
effect((onCleanup) => {
if (!this.deferringItem()) return;
// Keep the preview accurate if the duration chooser is left open.
const timer = setInterval(() => this.previewNow.set(Date.now()), 1000);
onCleanup(() => clearInterval(timer));
});
Expand Down
18 changes: 4 additions & 14 deletions src/app/components/item-card/item-card.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, input, computed, effect, inject, signal } from '@angular/core';
import { Component, input, computed, inject, linkedSignal } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterLink } from '@angular/router';
import { ReadonlyItem as Item } from '../../models/item.model';
Expand Down Expand Up @@ -83,12 +83,10 @@ export class ItemCardComponent {
readonly posterUrl = injectPosterUrl(() => this.item().posterId);
placeholderUrl = computed(() => getPlaceholderUrl());
statusColorClass = computed(() => statusLineColor(this.item().status));
revealed = signal(false);
revealed = linkedSignal({ source: () => this.item().id, computation: () => false });
shouldBlur = computed(() => {
const mode = this.providerSettings.settings().adultDisplayMode;
// 'blur' blurs everywhere; 'hide' still blurs where card remains visible (next*), since next* is not filtered
// 'show' never blurs
return this.item().isAdult && mode !== 'show' && !!this.posterUrl() && !this.revealed();
const concealsAdultPosters = this.providerSettings.settings().adultDisplayMode !== 'show';
return this.item().isAdult && concealsAdultPosters && !!this.posterUrl() && !this.revealed();
});

progressPercent = computed(() => {
Expand All @@ -98,12 +96,4 @@ export class ItemCardComponent {
lastWatchedDate = computed(() => {
return getMostRecentWatchDate(this.item());
});

constructor() {
effect(() => {
// Reset click-to-reveal when item identity changes
void this.item().id;
this.revealed.set(false);
});
}
}
13 changes: 6 additions & 7 deletions src/app/components/item-detail/item-detail.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { ConflictRecoveryComponent } from '../conflict-recovery/conflict-recover
template: `
<div>
<app-conflict-recovery [disabled]="mutation.busy()" (recovered)="mutation.error.set(null)" />
@if (item()) {
@if (itemSnapshot()) {
<div class="border border-light-border dark:border-dark-border rounded-lg p-6">
<div class="flex justify-between items-center mb-6">
<h2 class="mt-0">Edit Item</h2>
Expand Down Expand Up @@ -91,8 +91,7 @@ export class ItemDetailComponent {
readonly groups = this.groupService.groups;
readonly mutation = new MutationFeedback(itemMutationFailure);

// Capture a baseline per routed item; live collection updates must not reset an open draft.
readonly item = toSignal(
readonly itemSnapshot = toSignal(
this.route.paramMap.pipe(
map((params) => {
const id = params.get('id');
Expand All @@ -102,16 +101,16 @@ export class ItemDetailComponent {
{ initialValue: null },
);
readonly itemExists = computed(() =>
this.watchListService.items().some((item) => item.id === this.item()?.id),
this.watchListService.items().some((item) => item.id === this.itemSnapshot()?.id),
);
readonly formValue = computed(() => {
const currentItem = this.item();
const currentItem = this.itemSnapshot();
return currentItem ? createItemFormValue(currentItem) : createDefaultItemFormValue();
});
confirmDelete = signal(false);

async saveChanges(formValue: ItemFormValue): Promise<void> {
const currentItem = this.item();
const currentItem = this.itemSnapshot();
if (!currentItem) return;

const result = await this.mutation.run(
Expand All @@ -133,7 +132,7 @@ export class ItemDetailComponent {
}

async deleteItem(): Promise<void> {
const currentItem = this.item();
const currentItem = this.itemSnapshot();
if (currentItem) {
const result = await this.mutation.run(
() => this.watchListService.deleteItem(currentItem.id),
Expand Down
7 changes: 2 additions & 5 deletions src/app/components/item-form-interactions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ describe('Settled item form interactions', () => {
fixture.detectChanges();
expect(root.querySelector('img[src="blob:owned-poster"]')).not.toBeNull();
});
// A draft is previewable, but must not be persisted separately from its item.
expect(await TestBed.inject(ImageStorageService).exportImages()).toEqual([]);
const held = holdStorageWrite(0);
root.querySelector('form')!.dispatchEvent(new Event('submit', { cancelable: true }));
Expand Down Expand Up @@ -280,9 +279,7 @@ describe('Settled item form interactions', () => {
'retains an uploaded draft poster after failed %s and retries with it',
async (command) => {
vi.stubGlobal('createImageBitmap', async () => ({
close() {
/* native image decoder boundary */
},
close: () => undefined,
}));
vi.stubGlobal(
'URL',
Expand All @@ -291,7 +288,7 @@ describe('Settled item form interactions', () => {
return 'blob:draft-poster';
}
static override revokeObjectURL() {
/* native object URL boundary */
return undefined;
}
},
);
Expand Down
8 changes: 3 additions & 5 deletions src/app/components/item-form-navigation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ describe('Item form navigation with pending saves', () => {
expect(next).toBe(screen);
expect(harness.routeNativeElement).toBe(root);
expect(router.url).toBe('/items/other/edit');
expect(next.item()?.id).toBe('other');
expect(next.itemSnapshot()?.id).toBe('other');
expect(root.querySelector<HTMLInputElement>('#title')?.value).toBe('Other item');
});
});
Expand Down Expand Up @@ -180,9 +180,7 @@ async function openForm(mode: 'add' | 'edit') {
async function setup() {
Object.defineProperty(globalThis, 'indexedDB', { configurable: true, value: new IDBFactory() });
vi.stubGlobal('createImageBitmap', async () => ({
close() {
/* native image decoder boundary */
},
close: () => undefined,
}));
vi.stubGlobal(
'URL',
Expand All @@ -191,7 +189,7 @@ async function setup() {
return 'blob:uploaded-poster';
}
static override revokeObjectURL() {
/* native object URL boundary */
return undefined;
}
},
);
Expand Down
3 changes: 0 additions & 3 deletions src/app/components/item-list/item-list.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ describe('ItemListComponent', () => {
setup({ watchItems: items, sortField: 'lastWatched', sortDirection: 'asc' });
const fixture = TestBed.createComponent(ItemListComponent);
fixture.detectChanges();
// a: 2026-01-01, c: 2026-02-01, b: 2026-03-01
expect(fixture.componentInstance.filteredItems().map((i) => i.id)).toEqual(['a', 'c', 'b']);
});

Expand Down Expand Up @@ -314,7 +313,6 @@ describe('ItemListComponent', () => {
fixture.detectChanges();

const selects = fixture.nativeElement.querySelectorAll('select');
// group + sortField = 2 selects, sort direction is now a toggle button
expect(selects.length).toBe(2);

const sortBySelect = fixture.nativeElement.querySelector('select[aria-label="Sort by"]');
Expand All @@ -341,7 +339,6 @@ describe('ItemListComponent', () => {
window.localStorage.clear();
window.localStorage.setItem('itemSortField', 'invalid');
window.localStorage.setItem('itemSortDirection', 'invalid');
// Bypass setup helper to test invalid persistence directly
TestBed.resetTestingModule();
TestBed.configureTestingModule({
providers: [
Expand Down
1 change: 0 additions & 1 deletion src/app/components/item-mutation-feedback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export function itemMutationFailure(error: unknown, failureMessage: string) {
return `${failureMessage}${detail} Please try again or return to Items.`;
}

/** Keep draft posters owned by their mounted picker until the command settles. */
export const canLeaveItemForm: CanDeactivateFn<{ mutation: MutationFeedback } | null> = (
component,
) => !component?.mutation.busy();
2 changes: 0 additions & 2 deletions src/app/components/mutation-feedback.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { signal } from '@angular/core';
import type { MutationResult } from '../services/storage.service';

/** One settled command at a time; callers own wording and post-success interaction. */
export class MutationFeedback {
readonly busy = signal(false);
readonly error = signal<string | null>(null);
readonly sessionSuccess = signal(false);

constructor(private readonly describeFailure: (error: unknown, action: string) => string) {}

/** Unlocks before returning success; rejected and duplicate attempts return undefined. */
async run<T>(operation: () => Promise<MutationResult<T>>, action: string) {
if (this.busy()) return;
this.busy.set(true);
Expand Down
1 change: 0 additions & 1 deletion src/app/components/poster-drafts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ describe('Provisional poster lifecycle', () => {
const downloaded = new Response();
vi.spyOn(downloaded, 'blob').mockResolvedValue(new Blob(['download'], { type: 'image/png' }));
finish(downloaded);
// Native decoding is the final asynchronous preparation boundary before publishing a draft.
await vi.waitFor(() =>
expect(createImageBitmap).toHaveBeenCalledTimes(action === 'supersede' ? 2 : 1),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,6 @@ describe('PosterPickerComponent', () => {
expect(fixture.componentInstance.showPosterSearch()).toBe(true);
expect(fixture.componentInstance.posterSearchQuery()).toBe('');

// with no seed
const fixture2 = TestBed.createComponent(PosterPickerComponent);
fixture2.componentRef.setInput('searchSeed', '');
fixture2.detectChanges();
Expand Down Expand Up @@ -596,7 +595,6 @@ describe('PosterPickerComponent', () => {
fixture.componentRef.setInput('posterId', 'image-1');
fixture.detectChanges();

// Simulate that draftPosterIds contains image-1
(fixture.componentInstance as unknown as { draftPosterIds: Set<string> }).draftPosterIds.add(
'image-1',
);
Expand Down Expand Up @@ -687,7 +685,6 @@ describe('PosterPickerComponent', () => {
await Promise.resolve();
await new Promise((r) => setTimeout(r, 0));

// Should not throw and not set error because destroyed
expect(fixture.componentInstance.posterError()).toBe('');
});

Expand All @@ -697,7 +694,6 @@ describe('PosterPickerComponent', () => {
fixture.componentRef.setInput('posterId', 'old-id');
fixture.detectChanges();

// Simulate draft contains old-id
(fixture.componentInstance as unknown as { draftPosterIds: Set<string> }).draftPosterIds.add(
'old-id',
);
Expand Down
Loading