Files
crmPRO/.paul/phases/06-task-title-ai/06-01-SUMMARY.md
Codex 3b1ba1b5ed feat(06-task-title-ai): complete OpenAI task title suggestions
Phase 6 complete:

- add AI title generator service using gpt-5-nano

- add task popup button for biuro@project-pro.pl

- add AJAX endpoint returning title suggestions without auto-save
2026-05-04 23:45:54 +02:00

6.6 KiB

phase, plan, subsystem, tags, requires, provides, affects, tech-stack, key-files, key-decisions, patterns-established, duration, started, completed
phase plan subsystem tags requires provides affects tech-stack key-files key-decisions patterns-established duration started completed
06-task-title-ai 01 tasks-ai-ui
tasks
openai
popup
ajax
gpt-5-nano
AI title suggestion button in task popup for biuro@project-pro.pl
AJAX endpoint returning title suggestions without saving task name
Domain service for OpenAI task title generation
tasks
openai-integration
added patterns
domain-service-openai
ajax-suggestion-with-explicit-save
created modified
autoload/Domain/Tasks/TaskTitleGenerator.php
config.php
autoload/controls/class.Tasks.php
templates/tasks/task_popup.php
AI title button visible only for logged-in biuro@project-pro.pl
Generated title is inserted into the inline input and saved only by existing save action
Task title model defaults to gpt-5-nano
OpenAI task-title generation is isolated in Domain\Tasks\TaskTitleGenerator
Popup AI actions must return suggestions, not persist task data directly
35min 2026-05-04T23:10:00+02:00 2026-05-04T23:45:00+02:00

Phase 6 Plan 01: AI Task Title Summary

AI title suggestions now work in the task popup for biuro@project-pro.pl, inserting a short bezosobowy title proposal into the existing title input without automatic database save.

Performance

Metric Value
Duration ~35min
Started 2026-05-04T23:10:00+02:00
Completed 2026-05-04T23:45:00+02:00
Tasks 3 auto tasks + 1 human verification checkpoint
Files modified 4 source/config files + PAUL docs

Acceptance Criteria Results

Criterion Status Notes
AC-1: Przycisk widoczny tylko dla biuro Pass task_popup.php renders AI button only when logged-in user email is biuro@project-pro.pl.
AC-2: Brak przycisku dla innych uzytkownikow Pass UI condition hides button; backend endpoint checks the same email before calling OpenAI.
AC-3: AI generuje propozycje bez zapisu do bazy Pass /tasks/task_generate_title/ returns JSON with title; JS inserts it into .task-title-input; existing /tasks/task_change_title/ remains the only save path.
AC-4: Obsluga bledow OpenAI jest czytelna Pass Service returns {status:error,msg} for missing key, empty task text, cURL/API errors, and empty OpenAI content; UI shows alert and leaves title unchanged.

Accomplishments

  • Added Domain\Tasks\TaskTitleGenerator to encapsulate OpenAI title generation.
  • Added $settings['openai_task_title_model'] = 'gpt-5-nano' for task-title generation independent from email import parsing.
  • Added /tasks/task_generate_title/ AJAX endpoint with user/email gate and no write to tasks.name.
  • Added AI button in task popup, loading state, AJAX call, and insertion of the generated suggestion into the existing inline title editor.
  • Adjusted GPT-5 request for practical output by using reasoning_effort = minimal and larger max_completion_tokens.
  • Refined prompt so titles are short, bezosobowe, and rzeczownikowe, e.g. Usuniecie bloku o firmie.

Files Created/Modified

File Change Purpose
autoload/Domain/Tasks/TaskTitleGenerator.php Created OpenAI client/service for short task title suggestions.
config.php Modified Added openai_task_title_model defaulting to gpt-5-nano.
autoload/controls/class.Tasks.php Modified Added task_generate_title() endpoint with authorization and JSON response.
templates/tasks/task_popup.php Modified Added conditional AI button and client-side generation flow.
.paul/phases/06-task-title-ai/06-01-PLAN.md Created Formal PAUL plan for the phase.
.paul/phases/06-task-title-ai/06-01-SUMMARY.md Created This execution summary.

Verification Results

Check Result
C:\xampp\php\php.exe -l config.php Pass
C:\xampp\php\php.exe -l autoload/Domain/Tasks/TaskTitleGenerator.php Pass
C:\xampp\php\php.exe -l autoload/controls/class.Tasks.php Pass
C:\xampp\php\php.exe -l templates/tasks/task_popup.php Pass
Manual user verification Pass after prompt/token fix; user confirmed OK.

Decisions Made

Decision Rationale Impact
Use gpt-5-nano User asked for cheap/fast model and approved this model. Separate setting avoids changing email import behavior.
Insert suggestion only, do not auto-save User selected safer UX. Existing save path remains authoritative.
Gate by logged-in email User clarified scope. Both UI and backend enforce biuro@project-pro.pl.
Use bezosobowy prompt User requested shorter non-personal titles. AI output better matches CRM task naming convention.

Deviations from Plan

Summary

Type Count Impact
Auto-fixed 2 Necessary fixes for GPT-5 output reliability and title style.
Scope additions 0 No scope creep.
Deferred 0 None.

Auto-fixed Issues

1. GPT-5 empty content with low completion limit

  • Found during: Human verification
  • Issue: OpenAI returned HTTP 200 but no usable message.content, resulting in OpenAI nie zwrocil poprawnego tytulu.
  • Fix: Added reasoning_effort = minimal and raised max_completion_tokens to 500 for gpt-5* models.
  • Files: autoload/Domain/Tasks/TaskTitleGenerator.php
  • Verification: php -l passed; user continued testing.

2. Prompt title style too broad

  • Found during: Human verification
  • Issue: User wanted bezosobowy, shortened titles such as Usuniecie bloku o firmie.
  • Fix: Prompt now requires max 6 words, noun-like bezosobowa form, no imperative verbs.
  • Files: autoload/Domain/Tasks/TaskTitleGenerator.php
  • Verification: php -l passed; user confirmed OK.

Issues Encountered

Issue Resolution
apply_patch could not update files with legacy encoding reliably Used PowerShell with project file encoding for existing files; new PHP service was rewritten UTF-8 without BOM after php -l caught BOM before namespace.
Initial CSS insertion in popup selector block was malformed Corrected CSS selector block and reran php -l.

Next Phase Readiness

Ready:

  • Phase 6 is complete and can be used from the task popup.
  • OpenAI title generation is isolated and configurable.
  • Phase 2 critical bug fixes can resume next.

Concerns:

  • Existing OpenAI API key remains in config.php; this was pre-existing and not changed except for adding the model setting.

Blockers:

  • None.

Phase: 06-task-title-ai, Plan: 01 Completed: 2026-05-04