Course menuForge Cloud

Level 1 · Lesson 2

Work from your laptop

Goal of this lesson

Rename the panel, then lay out a sample car details card with UI Kit while forge tunnel shows every save on the site, without a deploy.

About 20 min4 steps

Behind, or starting here? Download the code as it should be before this lesson, or in the course workspace run course-catch-up level-1/start in the folder above your app. It offers to bring your own app folder to this point and keeps its app id (the id: line in manifest.yml, which links the code to your app on the site), so it stays the same app. Your old files are kept in a copy next to it.

Deploying after every small change is slow. This lesson sets up the faster loop you use for the rest of the course: the site keeps calling your app, but your laptop runs the code, so a save and a reload are enough. Changes to the manifest are the exception, and the first step shows why.

Step 1: Name the card

The heading Jira draws above the panel is the module’s title in the manifest. The View app actions menu under a work item’s title uses the same name, so after this change you find the panel there as Car details.

Change the title:

Editmanifest.yml

The title Jira shows above the panel.

resolver:
function: resolver
render: native
Removed: title: Workshop helper
Added: title: Car details

The heading Jira draws above your panel. The spaces in front matter: they show this line belongs to the panel above it.

icon: https://developer.atlassian.com/platform/forge/images/icons/issue-panel-icon.svg
function:
- key: resolver

Why: Module · Deploy

The manifest is read when you deploy, not while the code runs. Any change to it needs a deploy:

RunTerminal
forge deploy

Reload the BMW 3 Series repair task. The panel is now called Car details.

Stuck?3 common problems, and their fixes
  • I changed manifest.yml

    Check it, then deploy:

    RunTerminal
    forge lint
    forge deploy

    If the change adds a scope or an outside host, forge deploy stops and asks for approval. See Deploy stops after a permission change.

    Open in the FAQ
  • After changing manifest.yml, forge lint or forge deploy reports an error in the manifest

    Most often the spaces at the start of the lines are off. In manifest.yml those spaces matter: they show what belongs inside what, the way an outline does. Every line you add must start with exactly as many spaces as the line it sits next to in the lesson’s change, and it must use spaces, not tabs. Compare your file with the change, line up the new lines, save, and run:

    RunTerminal
    forge lint

    If you are still stuck, download the code after the lesson (the link at the end of each lesson) and compare its manifest.yml with yours.

    Open in the FAQ
  • “Make sure you’re in the top-level directory of your app” or “Command failed due to validation error”

    The terminal is not in your app folder, so the command can’t find manifest.yml. This happens most often in a codespace: every new terminal, and the codespace after it restarts, opens in the workspace folder (/workspaces/forge-cloud-workspace), one level above your app. The end of the error line, manifest-file-required, says the same thing.

    Move into the app folder and run the command again:

    RunTerminal
    cd Workshop-helper
    forge deploy

    The prompt in the terminal shows where you are: it should end in Workshop-helper. If you gave your app another name, use that folder’s name instead.

    Open in the FAQ

Step 2: Start the tunnel

Lives on your laptop

forge tunnel

forge tunnel connects the deployed app to your laptop. While it runs, Forge sends the app’s function calls to your machine and runs your local code, and UI changes are served from your folder too. Save a file, reload Jira, and you see the change. It works only for code: the manifest still comes from the last deploy.

Further reading, optional: Atlassian docs on Tunneling (opens in a new tab)

See this on the home chart, in the step where forge tunnel runs the function from your laptop.

Open a second terminal (in VS Code or a codespace, select + in the terminal panel; elsewhere, open a new terminal window). A new terminal starts in the workspace folder, not in your app, so move into the app folder first, then start the tunnel:

RunTerminal
cd Workshop-helper
forge tunnel

The tunnel is ready when it prints a line starting Listening for requests. Leave that terminal alone from then on: you work in the first terminal and your editor. Each time you save a file, the tunnel prints Reloading code... and the next reload in Jira uses your new code.

VS Code may pop up messages saying an application is running on a port. A port is a numbered door on a computer that one program listens at, so several programs can receive connections on the same computer without mixing them up. The messages come with buttons to open the port in a browser. They are about the tunnel’s own connections; close them, you don’t need them. Never choose Make Public: that would let anyone with the address open what the tunnel serves. If you did, open the Ports tab next to the terminal, right-click the port, and set Port Visibility back to Private.

A sketch of VS Code, not a real screen. The + for a second terminal sits in the same place in Docker and in a codespace.
Stuck?3 common problems, and their fixes
  • The CLI says it is out of date, or forge tunnel mentions ngrok

    Older CLI versions used a separate tool called ngrok for the tunnel; current versions do not need it. Update the CLI and check the version:

    RunTerminal
    npm install -g @forge/cli@latest
    forge --version
    Open in the FAQ
  • The tunnel says Reloading code, but Jira still shows the old version

    Jira only uses the tunnel when your browser runs on the same computer as forge tunnel. When you open Jira, your browser looks for the tunnel on your own computer. If it cannot find it, Jira shows your last deploy without any error.

    • You build in a codespace in your browser. The codespace runs on GitHub’s computer, so your browser never finds the tunnel. Stop the tunnel with Ctrl+C, then after each change deploy and reload:
    RunTerminal
    forge deploy
    • You changed manifest.yml. The tunnel only runs code. Stop it, deploy, then start it again.
    • Your browser blocks it. The tunnel works in Chrome and Firefox. Ad blockers, Brave Shields and some extensions block the connection to your own computer; turn them off for your Atlassian site. If Chrome asks whether the site may reach apps and devices on your network or this device, allow it.
    Open in the FAQ
  • The tunnel is running while I deploy or upgrade

    Stop it with Ctrl+C first, then deploy or upgrade, then start it again. While the tunnel runs, Jira runs the code on your laptop instead of your last deploy, so if you deploy with it running you cannot tell which version you are testing. Changes to the manifest only reach the site through a deploy, never through the tunnel.

    Open in the FAQ

Step 3: Lay out a sample card

Runs in the browser

UI Kit

UI Kit is a set of React components from @forge/react. React is a popular JavaScript library for building screens out of components, reusable pieces such as Heading, Stack, Inline, Lozenge and List. Forge draws them with Jira’s own design system, so the card looks like part of Jira and follows its light and dark themes. You arrange the components; you never write CSS (the styling language of web pages).

Further reading, optional: Atlassian docs on UI Kit overview (opens in a new tab)

Replace the template’s two lines with the shape of the finished card:

  • a heading for the make and model
  • a tag for the fuel types
  • a line where the car data goes

For now it is sample text, and the panel no longer asks the resolver for anything. Lesson 4 brings that back.

Editsrc/frontend/index.jsxChange 1 of 3
  • Import the UI Kit components the card uses.
  • Replace the template text with a sample card.
Removed: import React, { useEffect, useState } from 'react';
Removed: import ForgeReconciler, { Text } from '@forge/react';
Removed: import { invoke } from '@forge/bridge';
Added: import React from 'react';

Borrow React, the library UI Kit is built on. Every card file starts with it.

Added: import ForgeReconciler, { Heading, Inline, Lozenge, Stack, Text } from '@forge/react';

Borrow the UI Kit pieces this card uses, by name, from Forge’s @forge/react package. A piece you don’t list here can’t be used below.

const App = () => {
Editsrc/frontend/index.jsxChange 2 of 3
const App = () => {
Removed: const [data, setData] = useState(null);
Removed: useEffect(() => {
Removed: invoke('getText', { example: 'my-invoke-variable' }).then(setData);
Removed: }, []);
return (
Editsrc/frontend/index.jsxChange 3 of 3
return (
Removed: <>
Removed: <Text>Hello world!</Text>
Removed: <Text>{data ? data : 'Loading...'}</Text>
Removed: </>
Added: <Stack space="space.200">

Stack puts what is inside it one under the other, with a medium gap between them.

Added: <Inline space="space.100" alignBlock="center">

Inline puts what is inside it side by side, lined up on their middles.

Added: <Heading size="medium">BMW 3 Series</Heading>

A heading. Each piece opens with its name in angle brackets and closes with the same name after a slash.

Added: <Lozenge>Petrol · Diesel</Lozenge>

A lozenge is Jira’s small rounded tag, the same kind a status uses.

Added: </Inline>
Added: <Text>What the car data service knows goes here.</Text>

A line of plain text. Lesson 4 replaces this sample with real data.

Added: </Stack>
);
};

Why: UI Kit

Save the file. If you don’t use the tunnel, run forge deploy now. Then reload the BMW 3 Series repair task. Stack puts things under each other with a gap; Inline puts the heading and the tag side by side.

You should see, on the work itemExampleAn example: Jira draws the real components.

Car details

BMW 3 Series Petrol · Diesel

What the car data service knows goes here.

Stuck?2 common problems, and their fixes
  • I changed code in src/

    With forge tunnel running on your own computer, save the file and reload the Jira page: the tunnel serves your laptop’s code. Without the tunnel, or in a codespace in your browser, deploy:

    RunTerminal
    forge deploy

    The site picks up the new version on its own. You do not need to install again.

    Open in the FAQ
  • The tunnel says Reloading code, but Jira still shows the old version

    Jira only uses the tunnel when your browser runs on the same computer as forge tunnel. When you open Jira, your browser looks for the tunnel on your own computer. If it cannot find it, Jira shows your last deploy without any error.

    • You build in a codespace in your browser. The codespace runs on GitHub’s computer, so your browser never finds the tunnel. Stop the tunnel with Ctrl+C, then after each change deploy and reload:
    RunTerminal
    forge deploy
    • You changed manifest.yml. The tunnel only runs code. Stop it, deploy, then start it again.
    • Your browser blocks it. The tunnel works in Chrome and Firefox. Ad blockers, Brave Shields and some extensions block the connection to your own computer; turn them off for your Atlassian site. If Chrome asks whether the site may reach apps and devices on your network or this device, allow it.
    Open in the FAQ

Step 4: Stop the tunnel and deploy

If you skipped the tunnel, your last deploy already shows the new layout: tick this step.

The tunnel only works while your laptop is on. Stop it: click into its terminal and press Ctrl + C. It prints Stopping tunnel... and takes a few seconds; it has stopped when the terminal shows its prompt again, the line where you can type.

A sketch of a terminal, not a real screen. It is Ctrl + C on a Mac too, not Cmd.

Then deploy, from the app folder, so the site serves the new layout by itself:

RunTerminal
forge deploy

Do this every time: stop the tunnel before you deploy, and start it again afterwards if you want it. Then you always know what the site is running. While the tunnel runs, it is the code on your laptop; once you stop it, it is your last deploy.

Jirathe card asksYour laptopwhile forge tunnel runsYour last deployonce the tunnel stopstunnel on: your saved filestunnel off: the cloud copymanifest.ymlalways the deployed one
Stuck?One common problem, and its fix
  • The tunnel is running while I deploy or upgrade

    Stop it with Ctrl+C first, then deploy or upgrade, then start it again. While the tunnel runs, Jira runs the code on your laptop instead of your last deploy, so if you deploy with it running you cannot tell which version you are testing. Changes to the manifest only reach the site through a deploy, never through the tunnel.

    Open in the FAQ

Compare with yours: download the code after this lesson.

Type at least two letters.