# Linear Issue Creation

## Objective

Create a Linear issue from feedback or support work in the right team and project.

A server-side path from an in-app record to a Linear issue, with team, project, label, and state mapping and a link back to the source.

## Before You Begin

This feature is being added to an application that already exists and already
works. Do not scaffold a new project, and do not assume a blank slate.

Inspect the codebase first and establish:

- The existing application structure and where code of this kind already lives.
- The framework and version in use.
- The existing design system — colours, spacing, typography, and component conventions.
- Existing UI components you can reuse instead of writing new ones.
- The existing database structure, if this feature needs to persist anything.
- The existing authentication and authorization system, if this feature is user-scoped.
- Dependencies already installed, so you don't add a library that duplicates one.
- The existing test setup and conventions.

Only start writing code once you understand the above. If the application
already implements part of this feature, extend it rather than replacing it.

## Implementation Instructions

1. Let an administrator map the destination team, project, initial workflow state, labels, and default assignee, choosing from what the connected workspace exposes, and re-resolve those selections at creation time rather than trusting identifiers cached at setup.
2. Compose the issue on the server from the originating record and include a durable deep link back into the app, so anyone reading the issue can reach the customer, ticket, or error it came from.
3. Key each submission by the originating record and check for an existing issue reference before creating, so a retried job or a request that timed out after succeeding does not produce a duplicate.
4. Decide deliberately what customer context leaves the app. Include what a triager needs and exclude anything the workspace's members are not entitled to see; where a report may contain personal data, summarise it in the issue and keep the full detail behind the app link.
5. GitHub Issue Creation, GitLab Issue Creation, Jira Ticket Creation, Trello Card Creation, and Asana Task Creation are siblings. The shared half is capturing, redacting, deduplicating, and storing the external reference; this brief owns only Linear's team and workflow mapping and its error translation.

## UI and UX Requirements

Match the application's existing design system exactly. Reuse its components,
spacing, and typography. This feature should look like it was always there.

## Responsive Requirements

Works on mobile, tablet, and desktop. Touch targets are large enough to hit on a
phone, and nothing overflows horizontally at 320px.

## Accessibility Requirements

- Fully keyboard navigable.
- Correct semantic elements and ARIA roles.
- Visible focus states.
- Meets WCAG AA contrast.
- Dynamic changes are announced to screen readers.
- Respects prefers-reduced-motion.

## Edge Cases

- Teams, projects, cycles, labels, workflow states, and assignees are all workspace-specific and can be renamed or removed. Resolve each at creation time, drop an attribute that no longer exists, still create the issue, and record what was dropped.
- A retry must never produce a second issue. Persist the created reference before acknowledging the job, and check it on every attempt, because a timeout usually means the issue was created and the response was lost.
- A removed team or a workflow state that no longer exists must not silently route issues into the wrong place. Fall back to the team's default state and raise a configuration warning to an administrator.
- The link back to the originating app record must remain valid after the record is renamed or moved, so link by stable identifier rather than by a slug or a title.
- Everyone in the destination workspace can read the issue. Private customer context, support transcripts, and personal data must not be pasted in wholesale simply because it was convenient to include.
- The workspace credential will expire or be revoked. Distinguish authentication failures from transient ones, hold the submissions in the queue, and prompt an administrator to reconnect.
- Rate limits and request throttling need exponential backoff with jitter and a bounded retry count, so a burst of reports does not lock the connection out.
- If any status synchronisation back into the app is added, treat incoming events as at-least-once and possibly out of order: dedupe by event identifier and ignore anything older than the state already stored.

## Testing

Exercise the feature end to end in the running application. Cover every edge case
above, then run the existing test suite and confirm nothing regressed.

## Acceptance Criteria

- [ ] An in-app record can be sent to Linear as an issue in the configured team and project.
- [ ] Team, project, labels, state, and assignee are resolved at creation time and missing values degrade instead of failing.
- [ ] Retries and duplicate submissions reuse the existing issue.
- [ ] Every created issue links back to the originating record by a stable identifier.
- [ ] Private customer detail stays in the app and is referenced by link rather than copied into the issue.
- [ ] Authentication failures queue submissions and alert an administrator instead of discarding them.
- [ ] Rate limiting is handled with bounded backoff and no lost reports.
- [ ] The feature matches the existing design system.
- [ ] No existing functionality is broken.

## Adaptation Rules

- Match the existing design system. Do not introduce a new colour palette,
  spacing scale, or component library.
- Reuse existing components and utilities wherever they fit.
- Follow the naming, file layout, and code style already present.
- Do not upgrade, replace, or remove existing dependencies to make this
  feature fit. Adapt the feature to the app, not the app to the feature.
- Do not break existing functionality. If a change is genuinely required in
  existing code, make the smallest one that works and say so.
- If something in these instructions conflicts with how the application is
  built, follow the application and explain the deviation.

## Final Verification

Before you report the work as done:

1. Re-read the acceptance criteria above and check each one against what you
   actually built.
2. Run the application and exercise the feature end to end.
3. Run the existing test suite and confirm you have broken nothing.
4. Check the feature on mobile, tablet, and desktop widths.
5. Check keyboard navigation and focus handling.
6. Summarize what changed: files added, files modified, and anything you
   deliberately did differently because of how this application is built.

If any acceptance criterion is unmet, fix it before reporting completion.
