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
6 changes: 6 additions & 0 deletions client/src/features/build/FinalJd.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,12 @@ export const FinalJd = ({
<BulletSection items={jd.conditionsOfEmployment} title="Conditions of Employment" />
<BulletSection items={jd.workEnvironment} title="Work Environment" />
<BulletSection items={jd.physicalRequirements} title="Physical Requirements" />

{/* Same words as server.core/Ai/AiDisclosure.cs, which labels the Word files. */}
<p className="mt-5 border-t border-base-300 pt-3 text-sm text-base-content/70" data-testid="ai-disclosure">
Portions of this document were generated and/or assisted with the use of artificial intelligence (AI)
technologies.
</p>
</Card>
</div>

Expand Down
9 changes: 9 additions & 0 deletions client/src/test/routes/(authenticated)/saved-jds.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,15 @@ describe('saved JDs', () => {
expect(screen.getByText('Supports greenhouse research.')).toBeInTheDocument();
});

it('labels the JD, on screen and in print, as written with the help of AI', async () => {
testServer.use(http.get('/api/jds/:id', () => HttpResponse.json(saved())));
renderRoute({ initialPath: '/jds/7' });

expect(await screen.findByTestId('ai-disclosure')).toHaveTextContent(
'Portions of this document were generated and/or assisted with the use of artificial intelligence (AI) technologies.'
);
});

it('shows a summary the author already rewrote as theirs', async () => {
testServer.use(http.get('/api/jds/:id', () => HttpResponse.json(saved({ summaryEdited: true }))));
renderRoute({ initialPath: '/jds/7' });
Expand Down
35 changes: 35 additions & 0 deletions server.core/Ai/AiDisclosure.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;

namespace Server.Core.Ai;

/// <summary>
/// The label every document JDWriter produces carries, saying AI helped write it. Kept small: a
/// footer on every page of a Word file, a line at the foot of the on-screen and printed JD
/// (client/src/features/build/FinalJd.tsx carries the same words).
/// </summary>
public static class AiDisclosure
{
public const string Text =
"Portions of this document were generated and/or assisted with the use of artificial intelligence (AI) technologies.";

/// <summary>
/// Put the label in the page footer. Call last, once the body is complete: the section
/// properties that point at the footer must be the body's final element.
/// </summary>
public static void AddFooter(MainDocumentPart main, Body body)
{
var footerPart = main.AddNewPart<FooterPart>();
footerPart.Footer = new Footer(new Paragraph(
new Run(
new RunProperties(new Color { Val = "595959" }, new FontSize { Val = "16" }),
new Text(Text))));

// US Letter with 1-inch margins, stated rather than left to the reader: Word assumes them,
// but a reader set up for A4 would otherwise lay the page out differently.
body.Append(new SectionProperties(
new FooterReference { Type = HeaderFooterValues.Default, Id = main.GetIdOfPart(footerPart) },
new PageSize { Width = 12240U, Height = 15840U },
new PageMargin { Top = 1440, Right = 1440U, Bottom = 1440, Left = 1440U, Header = 720U, Footer = 720U, Gutter = 0U }));
}
}
1 change: 1 addition & 0 deletions server.core/Jd/JdDocx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public static byte[] Build(SavedJd saved)
Section(body, "Work Environment", jd.WorkEnvironment);
Section(body, "Physical Requirements", jd.PhysicalRequirements);

Server.Core.Ai.AiDisclosure.AddFooter(main, body);
main.Document.Save();
}

Expand Down
1 change: 1 addition & 0 deletions server.core/Vrf/VrfDocx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public static byte[] Build(VrfForm form, DateOnly today)
body.Append(Paragraph($"{when}: {string.Join(", ", documents)}", "ListBullet"));
}

Server.Core.Ai.AiDisclosure.AddFooter(main, body);
main.Document.Save();
}

Expand Down
12 changes: 12 additions & 0 deletions tests/server.tests/Jd/JdDocxTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,18 @@ public void Relationship_targets_are_relative_as_Word_writes_them()
doc.MainDocumentPart.NumberingDefinitionsPart.Should().NotBeNull();
}

[Fact]
public void Every_page_carries_the_AI_label_in_its_footer()
{
using var doc = WordprocessingDocument.Open(new MemoryStream(JdDocx.Build(Saved())), false);
var main = doc.MainDocumentPart!;

main.FooterParts.Should().ContainSingle()
.Which.Footer!.InnerText.Should().Be(Server.Core.Ai.AiDisclosure.Text);
main.Document!.Body!.Elements<SectionProperties>().Single()
.Elements<FooterReference>().Single().Type!.Value.Should().Be(HeaderFooterValues.Default);
}

[Theory]
[InlineData("Greenhouse Tech", "009605", "Greenhouse Tech - 009605.docx")]
[InlineData("Lab / Field: Tech?", "009605", "Lab - Field- Tech- - 009605.docx")]
Expand Down
9 changes: 9 additions & 0 deletions tests/server.tests/Vrf/VrfTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ public void The_word_file_carries_every_field_in_the_campus_form_s_order_and_is_
labels.IndexOf("Department Name").Should().BeLessThan(labels.IndexOf("Payroll Title"));
}

[Fact]
public void Every_page_carries_the_AI_label_in_its_footer()
{
using var doc = WordprocessingDocument.Open(new MemoryStream(VrfDocx.Build(Form(), new DateOnly(2026, 10, 26))), false);

doc.MainDocumentPart!.FooterParts.Should().ContainSingle()
.Which.Footer!.InnerText.Should().Be(Server.Core.Ai.AiDisclosure.Text);
}

[Fact]
public void Blank_and_inapplicable_fields_say_why()
{
Expand Down
Loading